Consolidate SkCanvas matrix virtuals.
Remove didTranslate, didScale, didRotate & didSkew, and rely on didConcat instead. Subclasses can sniff the matrix type if they want to differentiate. (work in progress) R=reed@google.com, robertphillips@google.com Author: fmalita@chromium.org Review URL: https://codereview.chromium.org/203203004 git-svn-id: http://skia.googlecode.com/svn/trunk@13940 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
7111d463ce
commit
d9ea09e1f2
@ -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&);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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()) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user