extend recordingcanvas overrides for mat4
Note: SkCanvas now tracks a real 4x4, so android could consider using it
Test: make
Change-Id: I6e201f2feec4fb4663f5d3e62fe0ffef5ef9a33f
diff --git a/libs/hwui/DisplayListOps.in b/libs/hwui/DisplayListOps.in
index 4a252af..4981792 100644
--- a/libs/hwui/DisplayListOps.in
+++ b/libs/hwui/DisplayListOps.in
@@ -14,39 +14,41 @@
* limitations under the License.
*/
-X(Flush)
-X(Save)
-X(Restore)
+X(Flush)
+X(Save)
+X(Restore)
X(SaveLayer)
X(SaveBehind)
-X(Concat)
-X(SetMatrix)
+X(Concat44)
+X(Concat)
+X(SetMatrix)
+X(Scale)
X(Translate)
-X(ClipPath)
-X(ClipRect)
-X(ClipRRect)
+X(ClipPath)
+X(ClipRect)
+X(ClipRRect)
X(ClipRegion)
X(DrawPaint)
X(DrawBehind)
-X(DrawPath)
-X(DrawRect)
-X(DrawRegion)
-X(DrawOval)
+X(DrawPath)
+X(DrawRect)
+X(DrawRegion)
+X(DrawOval)
X(DrawArc)
-X(DrawRRect)
-X(DrawDRRect)
-X(DrawAnnotation)
-X(DrawDrawable)
+X(DrawRRect)
+X(DrawDRRect)
+X(DrawAnnotation)
+X(DrawDrawable)
X(DrawPicture)
-X(DrawImage)
-X(DrawImageNine)
-X(DrawImageRect)
+X(DrawImage)
+X(DrawImageNine)
+X(DrawImageRect)
X(DrawImageLattice)
X(DrawTextBlob)
-X(DrawPatch)
-X(DrawPoints)
-X(DrawVertices)
-X(DrawAtlas)
+X(DrawPatch)
+X(DrawPoints)
+X(DrawVertices)
+X(DrawAtlas)
X(DrawShadowRec)
X(DrawVectorDrawable)
X(DrawWebView)
diff --git a/libs/hwui/RecordingCanvas.cpp b/libs/hwui/RecordingCanvas.cpp
index c0df2fa..dc467c4 100644
--- a/libs/hwui/RecordingCanvas.cpp
+++ b/libs/hwui/RecordingCanvas.cpp
@@ -130,6 +130,12 @@
}
};
+struct Concat44 final : Op {
+ static const auto kType = Type::Concat44;
+ Concat44(const SkScalar m[16]) { memcpy(colMajor, m, sizeof(colMajor)); }
+ SkScalar colMajor[16];
+ void draw(SkCanvas* c, const SkMatrix&) const { c->experimental_concat44(colMajor); }
+};
struct Concat final : Op {
static const auto kType = Type::Concat;
Concat(const SkMatrix& matrix) : matrix(matrix) {}
@@ -144,6 +150,12 @@
c->setMatrix(SkMatrix::Concat(original, matrix));
}
};
+struct Scale final : Op {
+ static const auto kType = Type::Scale;
+ Scale(SkScalar sx, SkScalar sy) : sx(sx), sy(sy) {}
+ SkScalar sx, sy;
+ void draw(SkCanvas* c, const SkMatrix&) const { c->scale(sx, sy); }
+};
struct Translate final : Op {
static const auto kType = Type::Translate;
Translate(SkScalar dx, SkScalar dy) : dx(dx), dy(dy) {}
@@ -562,12 +574,18 @@
this->push<SaveBehind>(0, subset);
}
+void DisplayListData::concat44(const SkScalar colMajor[16]) {
+ this->push<Concat44>(0, colMajor);
+}
void DisplayListData::concat(const SkMatrix& matrix) {
this->push<Concat>(0, matrix);
}
void DisplayListData::setMatrix(const SkMatrix& matrix) {
this->push<SetMatrix>(0, matrix);
}
+void DisplayListData::scale(SkScalar sx, SkScalar sy) {
+ this->push<Scale>(0, sx, sy);
+}
void DisplayListData::translate(SkScalar dx, SkScalar dy) {
this->push<Translate>(0, dx, dy);
}
@@ -823,12 +841,18 @@
return false;
}
+void RecordingCanvas::didConcat44(const SkScalar colMajor[16]) {
+ fDL->concat44(colMajor);
+}
void RecordingCanvas::didConcat(const SkMatrix& matrix) {
fDL->concat(matrix);
}
void RecordingCanvas::didSetMatrix(const SkMatrix& matrix) {
fDL->setMatrix(matrix);
}
+void RecordingCanvas::didScale(SkScalar sx, SkScalar sy) {
+ fDL->scale(sx, sy);
+}
void RecordingCanvas::didTranslate(SkScalar dx, SkScalar dy) {
fDL->translate(dx, dy);
}
diff --git a/libs/hwui/RecordingCanvas.h b/libs/hwui/RecordingCanvas.h
index 322eff2..7eb1ce3 100644
--- a/libs/hwui/RecordingCanvas.h
+++ b/libs/hwui/RecordingCanvas.h
@@ -82,8 +82,10 @@
void saveBehind(const SkRect*);
void restore();
+ void concat44(const SkScalar colMajor[16]);
void concat(const SkMatrix&);
void setMatrix(const SkMatrix&);
+ void scale(SkScalar, SkScalar);
void translate(SkScalar, SkScalar);
void translateZ(SkScalar);
@@ -153,8 +155,10 @@
void onFlush() override;
+ void didConcat44(const SkScalar[16]) override;
void didConcat(const SkMatrix&) override;
void didSetMatrix(const SkMatrix&) override;
+ void didScale(SkScalar, SkScalar) override;
void didTranslate(SkScalar, SkScalar) override;
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
diff --git a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
index a1b2b18..aa8849b 100644
--- a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
+++ b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
@@ -26,6 +26,7 @@
#include "SkAndroidFrameworkUtils.h"
#include "SkClipStack.h"
#include "SkRect.h"
+#include "include/private/SkM44.h"
namespace android {
namespace uirenderer {
@@ -92,7 +93,7 @@
SkIRect surfaceBounds = canvas->internal_private_getTopLayerBounds();
SkIRect clipBounds = canvas->getDeviceClipBounds();
- SkMatrix44 mat4(canvas->getTotalMatrix());
+ SkM44 mat4(canvas->experimental_getLocalToDevice());
SkRegion clipRegion;
canvas->temporary_internal_getRgnClip(&clipRegion);
@@ -118,7 +119,7 @@
// update the matrix and clip that we pass to the WebView to match the coordinates of
// the offscreen layer
- mat4.preTranslate(-clipBounds.fLeft, -clipBounds.fTop, 0);
+ mat4.preTranslate(-clipBounds.fLeft, -clipBounds.fTop);
clipBounds.offsetTo(0, 0);
clipRegion.translate(-surfaceBounds.fLeft, -surfaceBounds.fTop);
@@ -126,7 +127,7 @@
// we are drawing into a (clipped) offscreen layer so we must update the clip and matrix
// from device coordinates to the layer's coordinates
clipBounds.offset(-surfaceBounds.fLeft, -surfaceBounds.fTop);
- mat4.preTranslate(-surfaceBounds.fLeft, -surfaceBounds.fTop, 0);
+ mat4.preTranslate(-surfaceBounds.fLeft, -surfaceBounds.fTop);
}
DrawGlInfo info;
@@ -137,7 +138,7 @@
info.isLayer = fboID != 0;
info.width = fboSize.width();
info.height = fboSize.height();
- mat4.asColMajorf(&info.transform[0]);
+ mat4.getColMajor(&info.transform[0]);
info.color_space_ptr = canvas->imageInfo().colorSpace();
// ensure that the framebuffer that the webview will render into is bound before we clear
diff --git a/libs/hwui/pipeline/skia/VkFunctorDrawable.cpp b/libs/hwui/pipeline/skia/VkFunctorDrawable.cpp
index 1127926..68f1117 100644
--- a/libs/hwui/pipeline/skia/VkFunctorDrawable.cpp
+++ b/libs/hwui/pipeline/skia/VkFunctorDrawable.cpp
@@ -20,6 +20,7 @@
#include <GrBackendDrawableInfo.h>
#include <SkAndroidFrameworkUtils.h>
#include <SkImage.h>
+#include "include/private/SkM44.h"
#include <utils/Color.h>
#include <utils/Trace.h>
#include <utils/TraceUtils.h>
@@ -62,7 +63,7 @@
renderthread::RenderThread::getInstance().vulkanManager();
mFunctorHandle->initVk(vk_manager.getVkFunctorInitParams());
- SkMatrix44 mat4(mMatrix);
+ SkM44 mat4(mMatrix);
VkFunctorDrawParams params{
.width = mImageInfo.width(),
.height = mImageInfo.height(),
@@ -72,7 +73,7 @@
.clip_right = mClip.fRight,
.clip_bottom = mClip.fBottom,
};
- mat4.asColMajorf(¶ms.transform[0]);
+ mat4.getColMajor(¶ms.transform[0]);
params.secondary_command_buffer = vulkan_info.fSecondaryCommandBuffer;
params.color_attachment_index = vulkan_info.fColorAttachmentIndex;
params.compatible_render_pass = vulkan_info.fCompatibleRenderPass;
diff --git a/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp b/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp
index 706325f..241d370 100644
--- a/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp
+++ b/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp
@@ -121,7 +121,7 @@
glBindTexture(GL_TEXTURE_2D, 0);
DrawGlInfo info;
- SkMatrix44 mat4(canvas->getTotalMatrix());
+ SkM44 mat4(canvas->experimental_getLocalToDevice());
SkIRect clipBounds = canvas->getDeviceClipBounds();
info.clipLeft = clipBounds.fLeft;
@@ -131,7 +131,7 @@
info.isLayer = true;
info.width = mFBInfo.width();
info.height = mFBInfo.height();
- mat4.asColMajorf(&info.transform[0]);
+ mat4.getColMajor(&info.transform[0]);
info.color_space_ptr = canvas->imageInfo().colorSpace();
glViewport(0, 0, info.width, info.height);