diff options
-rw-r--r-- | include/core/SkCanvas.h | 4 | ||||
-rw-r--r-- | include/utils/SkDeferredCanvas.h | 4 | ||||
-rw-r--r-- | include/utils/SkDumpCanvas.h | 4 | ||||
-rw-r--r-- | include/utils/SkLuaCanvas.h | 4 | ||||
-rw-r--r-- | include/utils/SkNWayCanvas.h | 4 | ||||
-rw-r--r-- | include/utils/SkProxyCanvas.h | 4 | ||||
-rw-r--r-- | src/core/SkBBoxHierarchyRecord.cpp | 20 | ||||
-rw-r--r-- | src/core/SkBBoxHierarchyRecord.h | 4 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 52 | ||||
-rw-r--r-- | src/core/SkPictureRecord.cpp | 66 | ||||
-rw-r--r-- | src/core/SkPictureRecord.h | 6 | ||||
-rw-r--r-- | src/pipe/SkGPipeWrite.cpp | 74 | ||||
-rw-r--r-- | src/utils/SkDeferredCanvas.cpp | 24 | ||||
-rw-r--r-- | src/utils/SkDumpCanvas.cpp | 43 | ||||
-rw-r--r-- | src/utils/SkLuaCanvas.cpp | 48 | ||||
-rw-r--r-- | src/utils/SkNWayCanvas.cpp | 32 | ||||
-rw-r--r-- | src/utils/SkProxyCanvas.cpp | 20 | ||||
-rw-r--r-- | src/utils/debugger/SkDebugCanvas.cpp | 35 | ||||
-rw-r--r-- | src/utils/debugger/SkDebugCanvas.h | 4 |
19 files changed, 119 insertions, 333 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 0d8fd463fe..332cbefcb3 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -1246,10 +1246,6 @@ protected: virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags); virtual void willRestore(); - virtual void didTranslate(SkScalar, SkScalar); - virtual void didScale(SkScalar, SkScalar); - virtual void didRotate(SkScalar); - virtual void didSkew(SkScalar, SkScalar); virtual void didConcat(const SkMatrix&); virtual void didSetMatrix(const SkMatrix&); diff --git a/include/utils/SkDeferredCanvas.h b/include/utils/SkDeferredCanvas.h index 58ea2c76c3..e12cbf03cc 100644 --- a/include/utils/SkDeferredCanvas.h +++ b/include/utils/SkDeferredCanvas.h @@ -187,10 +187,6 @@ protected: virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; virtual void willRestore() SK_OVERRIDE; - virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didRotate(SkScalar) SK_OVERRIDE; - virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE; virtual void didConcat(const SkMatrix&) SK_OVERRIDE; virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; diff --git a/include/utils/SkDumpCanvas.h b/include/utils/SkDumpCanvas.h index 4508b46a8a..b0b1847dc6 100644 --- a/include/utils/SkDumpCanvas.h +++ b/include/utils/SkDumpCanvas.h @@ -116,10 +116,6 @@ protected: virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; virtual void willRestore() SK_OVERRIDE; - virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didRotate(SkScalar) SK_OVERRIDE; - virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE; virtual void didConcat(const SkMatrix&) SK_OVERRIDE; virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; diff --git a/include/utils/SkLuaCanvas.h b/include/utils/SkLuaCanvas.h index fa537bd091..38e089e684 100644 --- a/include/utils/SkLuaCanvas.h +++ b/include/utils/SkLuaCanvas.h @@ -59,10 +59,6 @@ protected: virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; virtual void willRestore() SK_OVERRIDE; - virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didRotate(SkScalar) SK_OVERRIDE; - virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE; virtual void didConcat(const SkMatrix&) SK_OVERRIDE; virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; diff --git a/include/utils/SkNWayCanvas.h b/include/utils/SkNWayCanvas.h index 435df9b750..051674b5d0 100644 --- a/include/utils/SkNWayCanvas.h +++ b/include/utils/SkNWayCanvas.h @@ -75,10 +75,6 @@ protected: virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; virtual void willRestore() SK_OVERRIDE; - virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didRotate(SkScalar) SK_OVERRIDE; - virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE; virtual void didConcat(const SkMatrix&) SK_OVERRIDE; virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; diff --git a/include/utils/SkProxyCanvas.h b/include/utils/SkProxyCanvas.h index 1ac83c72d8..76426bd58f 100644 --- a/include/utils/SkProxyCanvas.h +++ b/include/utils/SkProxyCanvas.h @@ -72,10 +72,6 @@ protected: virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; virtual void willRestore() SK_OVERRIDE; - virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didRotate(SkScalar) SK_OVERRIDE; - virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE; virtual void didConcat(const SkMatrix&) SK_OVERRIDE; virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; diff --git a/src/core/SkBBoxHierarchyRecord.cpp b/src/core/SkBBoxHierarchyRecord.cpp index eadd20613b..16ade7748c 100644 --- a/src/core/SkBBoxHierarchyRecord.cpp +++ b/src/core/SkBBoxHierarchyRecord.cpp @@ -43,26 +43,6 @@ void SkBBoxHierarchyRecord::willRestore() { this->INHERITED::willRestore(); } -void SkBBoxHierarchyRecord::didTranslate(SkScalar dx, SkScalar dy) { - fStateTree->appendTransform(getTotalMatrix()); - INHERITED::didTranslate(dx, dy); -} - -void SkBBoxHierarchyRecord::didScale(SkScalar sx, SkScalar sy) { - fStateTree->appendTransform(getTotalMatrix()); - INHERITED::didScale(sx, sy); -} - -void SkBBoxHierarchyRecord::didRotate(SkScalar degrees) { - fStateTree->appendTransform(getTotalMatrix()); - INHERITED::didRotate(degrees); -} - -void SkBBoxHierarchyRecord::didSkew(SkScalar sx, SkScalar sy) { - fStateTree->appendTransform(getTotalMatrix()); - INHERITED::didSkew(sx, sy); -} - void SkBBoxHierarchyRecord::didConcat(const SkMatrix& matrix) { fStateTree->appendTransform(getTotalMatrix()); INHERITED::didConcat(matrix); diff --git a/src/core/SkBBoxHierarchyRecord.h b/src/core/SkBBoxHierarchyRecord.h index 08de7dbd81..51fce0d8bc 100644 --- a/src/core/SkBBoxHierarchyRecord.h +++ b/src/core/SkBBoxHierarchyRecord.h @@ -31,10 +31,6 @@ protected: virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; virtual void willRestore() SK_OVERRIDE; - virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didRotate(SkScalar) SK_OVERRIDE; - virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE; virtual void didConcat(const SkMatrix&) SK_OVERRIDE; virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 787d89d184..45f5e074a9 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1325,52 +1325,28 @@ void SkCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, } ///////////////////////////////////////////////////////////////////////////// -void SkCanvas::didTranslate(SkScalar, SkScalar) { - // Do nothing. Subclasses may do something. -} - void SkCanvas::translate(SkScalar dx, SkScalar dy) { - fDeviceCMDirty = true; - fCachedLocalClipBoundsDirty = true; - fMCRec->fMatrix->preTranslate(dx, dy); - - this->didTranslate(dx, dy); -} - -void SkCanvas::didScale(SkScalar, SkScalar) { - // Do nothing. Subclasses may do something. + SkMatrix m; + m.setTranslate(dx, dy); + this->concat(m); } void SkCanvas::scale(SkScalar sx, SkScalar sy) { - fDeviceCMDirty = true; - fCachedLocalClipBoundsDirty = true; - fMCRec->fMatrix->preScale(sx, sy); - - this->didScale(sx, sy); -} - -void SkCanvas::didRotate(SkScalar) { - // Do nothing. Subclasses may do something. + SkMatrix m; + m.setScale(sx, sy); + this->concat(m); } void SkCanvas::rotate(SkScalar degrees) { - fDeviceCMDirty = true; - fCachedLocalClipBoundsDirty = true; - fMCRec->fMatrix->preRotate(degrees); - - this->didRotate(degrees); -} - -void SkCanvas::didSkew(SkScalar, SkScalar) { - // Do nothing. Subclasses may do something. + SkMatrix m; + m.setRotate(degrees); + this->concat(m); } void SkCanvas::skew(SkScalar sx, SkScalar sy) { - fDeviceCMDirty = true; - fCachedLocalClipBoundsDirty = true; - fMCRec->fMatrix->preSkew(sx, sy); - - this->didSkew(sx, sy); + SkMatrix m; + m.setSkew(sx, sy); + this->concat(m); } void SkCanvas::didConcat(const SkMatrix&) { @@ -1378,6 +1354,10 @@ void SkCanvas::didConcat(const SkMatrix&) { } void SkCanvas::concat(const SkMatrix& matrix) { + if (matrix.isIdentity()) { + return; + } + fDeviceCMDirty = true; fCachedLocalClipBoundsDirty = true; fMCRec->fMatrix->preConcat(matrix); diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index ce21d955dd..997b974802 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -664,62 +664,26 @@ void SkPictureRecord::recordRestore(bool fillInSkips) { this->validate(initialOffset, size); } -void SkPictureRecord::didTranslate(SkScalar dx, SkScalar dy) { -#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE - fMCMgr.translate(dx, dy); -#else +void SkPictureRecord::recordTranslate(const SkMatrix& m) { + SkASSERT(SkMatrix::kTranslate_Mask == m.getType()); + // op + dx + dy uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); size_t initialOffset = this->addDraw(TRANSLATE, &size); - this->addScalar(dx); - this->addScalar(dy); + this->addScalar(m.getTranslateX()); + this->addScalar(m.getTranslateY()); this->validate(initialOffset, size); -#endif - this->INHERITED::didTranslate(dx, dy); } -void SkPictureRecord::didScale(SkScalar sx, SkScalar sy) { +void SkPictureRecord::recordScale(const SkMatrix& m) { + SkASSERT(SkMatrix::kScale_Mask == m.getType()); -#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE - fMCMgr.scale(sx, sy); -#else // op + sx + sy uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); size_t initialOffset = this->addDraw(SCALE, &size); - this->addScalar(sx); - this->addScalar(sy); + this->addScalar(m.getScaleX()); + this->addScalar(m.getScaleY()); this->validate(initialOffset, size); -#endif - this->INHERITED::didScale(sx, sy); -} - -void SkPictureRecord::didRotate(SkScalar degrees) { - -#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE - fMCMgr.rotate(degrees); -#else - // op + degrees - uint32_t size = 1 * kUInt32Size + sizeof(SkScalar); - size_t initialOffset = this->addDraw(ROTATE, &size); - this->addScalar(degrees); - this->validate(initialOffset, size); -#endif - this->INHERITED::didRotate(degrees); -} - -void SkPictureRecord::didSkew(SkScalar sx, SkScalar sy) { - -#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE - fMCMgr.skew(sx, sy); -#else - // op + sx + sy - uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); - size_t initialOffset = this->addDraw(SKEW, &size); - this->addScalar(sx); - this->addScalar(sy); - this->validate(initialOffset, size); -#endif - this->INHERITED::didSkew(sx, sy); } void SkPictureRecord::didConcat(const SkMatrix& matrix) { @@ -727,7 +691,17 @@ void SkPictureRecord::didConcat(const SkMatrix& matrix) { #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE fMCMgr.concat(matrix); #else - this->recordConcat(matrix); + switch (matrix.getType()) { + case SkMatrix::kTranslate_Mask: + this->recordTranslate(matrix); + break; + case SkMatrix::kScale_Mask: + this->recordScale(matrix); + break; + default: + this->recordConcat(matrix); + break; + } #endif this->INHERITED::didConcat(matrix); } diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h index c0b0eb11de..eca42aa57a 100644 --- a/src/core/SkPictureRecord.h +++ b/src/core/SkPictureRecord.h @@ -223,10 +223,6 @@ protected: virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; virtual void willRestore() SK_OVERRIDE; - virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didRotate(SkScalar) SK_OVERRIDE; - virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE; virtual void didConcat(const SkMatrix&) SK_OVERRIDE; virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; @@ -266,6 +262,8 @@ protected: // restores to be deferred (e.g., if the MC state is being collapsed and // only written out as needed). void recordConcat(const SkMatrix& matrix); + void recordTranslate(const SkMatrix& matrix); + void recordScale(const SkMatrix& matrix); int recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA); int recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA); int recordClipPath(int pathID, SkRegion::Op op, bool doAA); diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp index 637778500a..17695ae63f 100644 --- a/src/pipe/SkGPipeWrite.cpp +++ b/src/pipe/SkGPipeWrite.cpp @@ -281,10 +281,6 @@ protected: virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; virtual void willRestore() SK_OVERRIDE; - virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didRotate(SkScalar) SK_OVERRIDE; - virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE; virtual void didConcat(const SkMatrix&) SK_OVERRIDE; virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; @@ -296,6 +292,10 @@ protected: virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; private: + void recordTranslate(const SkMatrix&); + void recordScale(const SkMatrix&); + void recordConcat(const SkMatrix&); + enum { kNoSaveLayer = -1, }; @@ -572,61 +572,45 @@ bool SkGPipeCanvas::isDrawingToLayer() const { return kNoSaveLayer != fFirstSaveLayerStackLevel; } -void SkGPipeCanvas::didTranslate(SkScalar dx, SkScalar dy) { - if (dx || dy) { - NOTIFY_SETUP(this); - if (this->needOpBytes(2 * sizeof(SkScalar))) { - this->writeOp(kTranslate_DrawOp); - fWriter.writeScalar(dx); - fWriter.writeScalar(dy); - } +void SkGPipeCanvas::recordTranslate(const SkMatrix& m) { + if (this->needOpBytes(2 * sizeof(SkScalar))) { + this->writeOp(kTranslate_DrawOp); + fWriter.writeScalar(m.getTranslateX()); + fWriter.writeScalar(m.getTranslateY()); } - this->INHERITED::didTranslate(dx, dy); } -void SkGPipeCanvas::didScale(SkScalar sx, SkScalar sy) { - if (sx || sy) { - NOTIFY_SETUP(this); - if (this->needOpBytes(2 * sizeof(SkScalar))) { - this->writeOp(kScale_DrawOp); - fWriter.writeScalar(sx); - fWriter.writeScalar(sy); - } +void SkGPipeCanvas::recordScale(const SkMatrix& m) { + if (this->needOpBytes(2 * sizeof(SkScalar))) { + this->writeOp(kScale_DrawOp); + fWriter.writeScalar(m.getScaleX()); + fWriter.writeScalar(m.getScaleY()); } - this->INHERITED::didScale(sx, sy); } -void SkGPipeCanvas::didRotate(SkScalar degrees) { - if (degrees) { - NOTIFY_SETUP(this); - if (this->needOpBytes(sizeof(SkScalar))) { - this->writeOp(kRotate_DrawOp); - fWriter.writeScalar(degrees); - } +void SkGPipeCanvas::recordConcat(const SkMatrix& m) { + if (this->needOpBytes(m.writeToMemory(NULL))) { + this->writeOp(kConcat_DrawOp); + fWriter.writeMatrix(m); } - this->INHERITED::didRotate(degrees); -} - -void SkGPipeCanvas::didSkew(SkScalar sx, SkScalar sy) { - if (sx || sy) { - NOTIFY_SETUP(this); - if (this->needOpBytes(2 * sizeof(SkScalar))) { - this->writeOp(kSkew_DrawOp); - fWriter.writeScalar(sx); - fWriter.writeScalar(sy); - } - } - this->INHERITED::didSkew(sx, sy); } void SkGPipeCanvas::didConcat(const SkMatrix& matrix) { if (!matrix.isIdentity()) { NOTIFY_SETUP(this); - if (this->needOpBytes(matrix.writeToMemory(NULL))) { - this->writeOp(kConcat_DrawOp); - fWriter.writeMatrix(matrix); + switch (matrix.getType()) { + case SkMatrix::kTranslate_Mask: + this->recordTranslate(matrix); + break; + case SkMatrix::kScale_Mask: + this->recordScale(matrix); + break; + default: + this->recordConcat(matrix); + break; } } + this->INHERITED::didConcat(matrix); } diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp index 2e3f5bb6a5..12ccb9aba2 100644 --- a/src/utils/SkDeferredCanvas.cpp +++ b/src/utils/SkDeferredCanvas.cpp @@ -735,30 +735,6 @@ bool SkDeferredCanvas::isDrawingToLayer() const { return this->drawingCanvas()->isDrawingToLayer(); } -void SkDeferredCanvas::didTranslate(SkScalar dx, SkScalar dy) { - this->drawingCanvas()->translate(dx, dy); - this->recordedDrawCommand(); - this->INHERITED::didTranslate(dx, dy); -} - -void SkDeferredCanvas::didScale(SkScalar sx, SkScalar sy) { - this->drawingCanvas()->scale(sx, sy); - this->recordedDrawCommand(); - this->INHERITED::didScale(sx, sy); -} - -void SkDeferredCanvas::didRotate(SkScalar degrees) { - this->drawingCanvas()->rotate(degrees); - this->recordedDrawCommand(); - this->INHERITED::didRotate(degrees); -} - -void SkDeferredCanvas::didSkew(SkScalar sx, SkScalar sy) { - this->drawingCanvas()->skew(sx, sy); - this->recordedDrawCommand(); - this->INHERITED::didSkew(sx, sy); -} - void SkDeferredCanvas::didConcat(const SkMatrix& matrix) { this->drawingCanvas()->concat(matrix); this->recordedDrawCommand(); diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp index 7445940f4e..3bf90da9f5 100644 --- a/src/utils/SkDumpCanvas.cpp +++ b/src/utils/SkDumpCanvas.cpp @@ -222,33 +222,26 @@ void SkDumpCanvas::willRestore() { this->INHERITED::willRestore(); } -void SkDumpCanvas::didTranslate(SkScalar dx, SkScalar dy) { - this->dump(kMatrix_Verb, NULL, "translate(%g %g)", - SkScalarToFloat(dx), SkScalarToFloat(dy)); - this->INHERITED::didTranslate(dx, dy); -} - -void SkDumpCanvas::didScale(SkScalar sx, SkScalar sy) { - this->dump(kMatrix_Verb, NULL, "scale(%g %g)", - SkScalarToFloat(sx), SkScalarToFloat(sy)); - this->INHERITED::didScale(sx, sy); -} - -void SkDumpCanvas::didRotate(SkScalar degrees) { - this->dump(kMatrix_Verb, NULL, "rotate(%g)", SkScalarToFloat(degrees)); - this->INHERITED::didRotate(degrees); -} - -void SkDumpCanvas::didSkew(SkScalar sx, SkScalar sy) { - this->dump(kMatrix_Verb, NULL, "skew(%g %g)", - SkScalarToFloat(sx), SkScalarToFloat(sy)); - this->INHERITED::didSkew(sx, sy); -} - void SkDumpCanvas::didConcat(const SkMatrix& matrix) { SkString str; - matrix.toString(&str); - this->dump(kMatrix_Verb, NULL, "concat(%s)", str.c_str()); + + switch (matrix.getType()) { + case SkMatrix::kTranslate_Mask: + this->dump(kMatrix_Verb, NULL, "translate(%g %g)", + SkScalarToFloat(matrix.getTranslateX()), + SkScalarToFloat(matrix.getTranslateY())); + break; + case SkMatrix::kScale_Mask: + this->dump(kMatrix_Verb, NULL, "scale(%g %g)", + SkScalarToFloat(matrix.getScaleX()), + SkScalarToFloat(matrix.getScaleY())); + break; + default: + matrix.toString(&str); + this->dump(kMatrix_Verb, NULL, "concat(%s)", str.c_str()); + break; + } + this->INHERITED::didConcat(matrix); } diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp index b5789e058b..7e1d5a8fe2 100644 --- a/src/utils/SkLuaCanvas.cpp +++ b/src/utils/SkLuaCanvas.cpp @@ -106,35 +106,27 @@ void SkLuaCanvas::willRestore() { this->INHERITED::willRestore(); } -void SkLuaCanvas::didTranslate(SkScalar dx, SkScalar dy) { - AUTO_LUA("translate"); - lua.pushScalar(dx, "dx"); - lua.pushScalar(dy, "dy"); - this->INHERITED::didTranslate(dx, dy); -} - -void SkLuaCanvas::didScale(SkScalar sx, SkScalar sy) { - AUTO_LUA("scale"); - lua.pushScalar(sx, "sx"); - lua.pushScalar(sy, "sy"); - this->INHERITED::didScale(sx, sy); -} - -void SkLuaCanvas::didRotate(SkScalar degrees) { - AUTO_LUA("rotate"); - lua.pushScalar(degrees, "degrees"); - this->INHERITED::didRotate(degrees); -} - -void SkLuaCanvas::didSkew(SkScalar kx, SkScalar ky) { - AUTO_LUA("skew"); - lua.pushScalar(kx, "kx"); - lua.pushScalar(ky, "ky"); - this->INHERITED::didSkew(kx, ky); -} - void SkLuaCanvas::didConcat(const SkMatrix& matrix) { - AUTO_LUA("concat"); + switch (matrix.getType()) { + case SkMatrix::kTranslate_Mask: { + AUTO_LUA("translate"); + lua.pushScalar(matrix.getTranslateX(), "dx"); + lua.pushScalar(matrix.getTranslateY(), "dy"); + break; + } + case SkMatrix::kScale_Mask: { + AUTO_LUA("scale"); + lua.pushScalar(matrix.getScaleX(), "sx"); + lua.pushScalar(matrix.getScaleY(), "sy"); + break; + } + default: { + AUTO_LUA("concat"); + lua.pushMatrix(matrix); + break; + } + } + this->INHERITED::didConcat(matrix); } diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp index b127f21e8a..4e580c2ea1 100644 --- a/src/utils/SkNWayCanvas.cpp +++ b/src/utils/SkNWayCanvas.cpp @@ -86,38 +86,6 @@ void SkNWayCanvas::willRestore() { this->INHERITED::willRestore(); } -void SkNWayCanvas::didTranslate(SkScalar dx, SkScalar dy) { - Iter iter(fList); - while (iter.next()) { - iter->translate(dx, dy); - } - this->INHERITED::didTranslate(dx, dy); -} - -void SkNWayCanvas::didScale(SkScalar sx, SkScalar sy) { - Iter iter(fList); - while (iter.next()) { - iter->scale(sx, sy); - } - this->INHERITED::didScale(sx, sy); -} - -void SkNWayCanvas::didRotate(SkScalar degrees) { - Iter iter(fList); - while (iter.next()) { - iter->rotate(degrees); - } - this->INHERITED::didRotate(degrees); -} - -void SkNWayCanvas::didSkew(SkScalar sx, SkScalar sy) { - Iter iter(fList); - while (iter.next()) { - iter->skew(sx, sy); - } - this->INHERITED::didSkew(sx, sy); -} - void SkNWayCanvas::didConcat(const SkMatrix& matrix) { Iter iter(fList); while (iter.next()) { diff --git a/src/utils/SkProxyCanvas.cpp b/src/utils/SkProxyCanvas.cpp index 037ddd0df6..26f2c73d18 100644 --- a/src/utils/SkProxyCanvas.cpp +++ b/src/utils/SkProxyCanvas.cpp @@ -39,26 +39,6 @@ void SkProxyCanvas::willRestore() { this->INHERITED::willRestore(); } -void SkProxyCanvas::didTranslate(SkScalar dx, SkScalar dy) { - fProxy->translate(dx, dy); - this->INHERITED::didTranslate(dx, dy); -} - -void SkProxyCanvas::didScale(SkScalar sx, SkScalar sy) { - fProxy->scale(sx, sy); - this->INHERITED::didScale(sx, sy); -} - -void SkProxyCanvas::didRotate(SkScalar degrees) { - fProxy->rotate(degrees); - this->INHERITED::didRotate(degrees); -} - -void SkProxyCanvas::didSkew(SkScalar sx, SkScalar sy) { - fProxy->skew(sx, sy); - this->INHERITED::didSkew(sx, sy); -} - void SkProxyCanvas::didConcat(const SkMatrix& matrix) { fProxy->concat(matrix); this->INHERITED::didConcat(matrix); diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp index 88bee505d8..b4813e4103 100644 --- a/src/utils/debugger/SkDebugCanvas.cpp +++ b/src/utils/debugger/SkDebugCanvas.cpp @@ -410,7 +410,20 @@ void SkDebugCanvas::onClipRegion(const SkRegion& region, SkRegion::Op op) { } void SkDebugCanvas::didConcat(const SkMatrix& matrix) { - addDrawCommand(new SkConcatCommand(matrix)); + switch (matrix.getType()) { + case SkMatrix::kTranslate_Mask: + this->addDrawCommand(new SkTranslateCommand(matrix.getTranslateX(), + matrix.getTranslateY())); + break; + case SkMatrix::kScale_Mask: + this->addDrawCommand(new SkScaleCommand(matrix.getScaleX(), + matrix.getScaleY())); + break; + default: + this->addDrawCommand(new SkConcatCommand(matrix)); + break; + } + this->INHERITED::didConcat(matrix); } @@ -535,11 +548,6 @@ void SkDebugCanvas::willRestore() { this->INHERITED::willRestore(); } -void SkDebugCanvas::didRotate(SkScalar degrees) { - addDrawCommand(new SkRotateCommand(degrees)); - this->INHERITED::didRotate(degrees); -} - void SkDebugCanvas::willSave(SaveFlags flags) { this->addDrawCommand(new SkSaveCommand(flags)); this->INHERITED::willSave(flags); @@ -553,26 +561,11 @@ SkCanvas::SaveLayerStrategy SkDebugCanvas::willSaveLayer(const SkRect* bounds, c return kNoLayer_SaveLayerStrategy; } -void SkDebugCanvas::didScale(SkScalar sx, SkScalar sy) { - addDrawCommand(new SkScaleCommand(sx, sy)); - this->INHERITED::didScale(sx, sy); -} - void SkDebugCanvas::didSetMatrix(const SkMatrix& matrix) { addDrawCommand(new SkSetMatrixCommand(matrix)); this->INHERITED::didSetMatrix(matrix); } -void SkDebugCanvas::didSkew(SkScalar sx, SkScalar sy) { - addDrawCommand(new SkSkewCommand(sx, sy)); - this->INHERITED::didSkew(sx, sy); -} - -void SkDebugCanvas::didTranslate(SkScalar dx, SkScalar dy) { - addDrawCommand(new SkTranslateCommand(dx, dy)); - this->INHERITED::didTranslate(dx, dy); -} - void SkDebugCanvas::toggleCommand(int index, bool toggle) { SkASSERT(index < fCommandVector.count()); fCommandVector[index]->setVisible(toggle); diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h index 1191a76110..ac3083e49b 100644 --- a/src/utils/debugger/SkDebugCanvas.h +++ b/src/utils/debugger/SkDebugCanvas.h @@ -234,10 +234,6 @@ protected: virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; virtual void willRestore() SK_OVERRIDE; - virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE; - virtual void didRotate(SkScalar) SK_OVERRIDE; - virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE; virtual void didConcat(const SkMatrix&) SK_OVERRIDE; virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; |