Merge "extend recordingcanvas overrides for mat4"
This commit is contained in:
committed by
Android (Google) Code Review
commit
76d97548c4
@@ -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)
|
||||
|
||||
@@ -130,6 +130,12 @@ struct SaveBehind final : Op {
|
||||
}
|
||||
};
|
||||
|
||||
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 @@ struct SetMatrix final : Op {
|
||||
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 @@ void DisplayListData::saveBehind(const SkRect* subset) {
|
||||
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 @@ bool RecordingCanvas::onDoSaveBehind(const SkRect* subset) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -82,8 +82,10 @@ private:
|
||||
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 @@ public:
|
||||
|
||||
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;
|
||||
|
||||
@@ -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 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) {
|
||||
|
||||
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 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) {
|
||||
|
||||
// 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 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) {
|
||||
// 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 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) {
|
||||
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
|
||||
|
||||
@@ -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 @@ void VkFunctorDrawHandler::draw(const GrBackendDrawableInfo& info) {
|
||||
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 @@ void VkFunctorDrawHandler::draw(const GrBackendDrawableInfo& info) {
|
||||
.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;
|
||||
|
||||
@@ -121,7 +121,7 @@ void VkInteropFunctorDrawable::onDraw(SkCanvas* canvas) {
|
||||
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 @@ void VkInteropFunctorDrawable::onDraw(SkCanvas* canvas) {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user