am b9d7bba5
: am 434b577f
: am 8ac76504
: am 9613e9b7
: Merge "New setLocalMatrix() operation for HWUI" into mnc-dev
* commit 'b9d7bba5c5453f894608971fed44aed023dcd6ba': New setLocalMatrix() operation for HWUI
This commit is contained in:
@ -80,6 +80,10 @@ public:
|
||||
virtual void getMatrix(SkMatrix* outMatrix) const = 0;
|
||||
virtual void setMatrix(const SkMatrix& matrix) = 0;
|
||||
|
||||
/// Like setMatrix(), but to be translated into local / view-relative coordinates
|
||||
/// rather than executed in global / device coordinates at rendering time.
|
||||
virtual void setLocalMatrix(const SkMatrix& matrix) = 0;
|
||||
|
||||
virtual void concat(const SkMatrix& matrix) = 0;
|
||||
virtual void rotate(float degrees) = 0;
|
||||
virtual void scale(float sx, float sy) = 0;
|
||||
|
@ -176,6 +176,11 @@ void DisplayListCanvas::setMatrix(const SkMatrix& matrix) {
|
||||
mState.setMatrix(matrix);
|
||||
}
|
||||
|
||||
void DisplayListCanvas::setLocalMatrix(const SkMatrix& matrix) {
|
||||
addStateOp(new (alloc()) SetLocalMatrixOp(matrix));
|
||||
mState.setMatrix(matrix);
|
||||
}
|
||||
|
||||
void DisplayListCanvas::concat(const SkMatrix& matrix) {
|
||||
addStateOp(new (alloc()) ConcatMatrixOp(matrix));
|
||||
mState.concatMatrix(matrix);
|
||||
|
@ -165,6 +165,7 @@ public:
|
||||
// Matrix
|
||||
virtual void getMatrix(SkMatrix* outMatrix) const override { mState.getMatrix(outMatrix); }
|
||||
virtual void setMatrix(const SkMatrix& matrix) override;
|
||||
virtual void setLocalMatrix(const SkMatrix& matrix) override;
|
||||
|
||||
virtual void concat(const SkMatrix& matrix) override;
|
||||
virtual void rotate(float degrees) override;
|
||||
|
@ -489,6 +489,25 @@ private:
|
||||
const SkMatrix mMatrix;
|
||||
};
|
||||
|
||||
class SetLocalMatrixOp : public StateOp {
|
||||
public:
|
||||
SetLocalMatrixOp(const SkMatrix& matrix)
|
||||
: mMatrix(matrix) {}
|
||||
|
||||
virtual void applyState(OpenGLRenderer& renderer, int saveCount) const override {
|
||||
renderer.setLocalMatrix(mMatrix);
|
||||
}
|
||||
|
||||
virtual void output(int level, uint32_t logFlags) const override {
|
||||
OP_LOG("SetLocalMatrix " SK_MATRIX_STRING, SK_MATRIX_ARGS(&mMatrix));
|
||||
}
|
||||
|
||||
virtual const char* name() override { return "SetLocalMatrix"; }
|
||||
|
||||
private:
|
||||
const SkMatrix mMatrix;
|
||||
};
|
||||
|
||||
class ConcatMatrixOp : public StateOp {
|
||||
public:
|
||||
ConcatMatrixOp(const SkMatrix& matrix)
|
||||
|
@ -2148,6 +2148,7 @@ void OpenGLRenderer::restoreToCount(int saveCount) {
|
||||
mState.restoreToCount(saveCount);
|
||||
}
|
||||
|
||||
|
||||
void OpenGLRenderer::translate(float dx, float dy, float dz) {
|
||||
mState.translate(dx, dy, dz);
|
||||
}
|
||||
@ -2168,6 +2169,11 @@ void OpenGLRenderer::setMatrix(const Matrix4& matrix) {
|
||||
mState.setMatrix(matrix);
|
||||
}
|
||||
|
||||
void OpenGLRenderer::setLocalMatrix(const SkMatrix& matrix) {
|
||||
mState.setMatrix(mBaseTransform);
|
||||
mState.concatMatrix(matrix);
|
||||
}
|
||||
|
||||
void OpenGLRenderer::concatMatrix(const Matrix4& matrix) {
|
||||
mState.concatMatrix(matrix);
|
||||
}
|
||||
|
@ -368,6 +368,7 @@ public:
|
||||
|
||||
void getMatrix(SkMatrix* outMatrix) const { mState.getMatrix(outMatrix); }
|
||||
void setMatrix(const SkMatrix& matrix) { mState.setMatrix(matrix); }
|
||||
void setLocalMatrix(const SkMatrix& matrix);
|
||||
void concatMatrix(const SkMatrix& matrix) { mState.concatMatrix(matrix); }
|
||||
|
||||
void translate(float dx, float dy, float dz = 0.0f);
|
||||
@ -418,6 +419,8 @@ public:
|
||||
return returnPath;
|
||||
}
|
||||
|
||||
void setBaseTransform(const Matrix4& matrix) { mBaseTransform = matrix; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Perform the setup specific to a frame. This method does not
|
||||
@ -877,6 +880,16 @@ private:
|
||||
// Paths kept alive for the duration of the frame
|
||||
std::vector<std::unique_ptr<SkPath>> mTempPaths;
|
||||
|
||||
/**
|
||||
* Initial transform for a rendering pass; transform from global device
|
||||
* coordinates to the current RenderNode's drawing content coordinates,
|
||||
* with the RenderNode's RenderProperty transforms already applied.
|
||||
* Calling setMatrix(mBaseTransform) will result in drawing at the origin
|
||||
* of the DisplayList's recorded surface prior to any Canvas
|
||||
* transformation.
|
||||
*/
|
||||
Matrix4 mBaseTransform;
|
||||
|
||||
friend class Layer;
|
||||
friend class TextDrawFunctor;
|
||||
friend class DrawBitmapOp;
|
||||
|
@ -887,6 +887,7 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) {
|
||||
&& renderer.quickRejectConservative(0, 0, properties().getWidth(), properties().getHeight());
|
||||
if (!quickRejected) {
|
||||
Matrix4 initialTransform(*(renderer.currentTransform()));
|
||||
renderer.setBaseTransform(initialTransform);
|
||||
|
||||
if (drawLayer) {
|
||||
handler(new (alloc) DrawLayerOp(mLayer, 0, 0),
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
|
||||
virtual void getMatrix(SkMatrix* outMatrix) const override;
|
||||
virtual void setMatrix(const SkMatrix& matrix) override;
|
||||
virtual void setLocalMatrix(const SkMatrix& matrix) override { this->setMatrix(matrix); }
|
||||
virtual void concat(const SkMatrix& matrix) override;
|
||||
virtual void rotate(float degrees) override;
|
||||
virtual void scale(float sx, float sy) override;
|
||||
|
@ -115,7 +115,7 @@ void SkiaCanvasProxy::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& ce
|
||||
void SkiaCanvasProxy::onDrawSprite(const SkBitmap& bitmap, int left, int top,
|
||||
const SkPaint* paint) {
|
||||
mCanvas->save(SkCanvas::kMatrixClip_SaveFlag);
|
||||
mCanvas->setMatrix(SkMatrix::I());
|
||||
mCanvas->setLocalMatrix(SkMatrix::I());
|
||||
mCanvas->drawBitmap(bitmap, left, top, paint);
|
||||
mCanvas->restore();
|
||||
}
|
||||
@ -165,7 +165,9 @@ void SkiaCanvasProxy::didConcat(const SkMatrix& matrix) {
|
||||
}
|
||||
|
||||
void SkiaCanvasProxy::didSetMatrix(const SkMatrix& matrix) {
|
||||
mCanvas->setMatrix(matrix);
|
||||
// SkCanvas setMatrix() is relative to the Canvas origin, but OpenGLRenderer's
|
||||
// setMatrix() is relative to device origin; call setLocalMatrix() instead.
|
||||
mCanvas->setLocalMatrix(matrix);
|
||||
}
|
||||
|
||||
void SkiaCanvasProxy::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
|
||||
|
Reference in New Issue
Block a user