Revert of Remove SkPictureFlat.h include from SkDrawCommands.h (patchset #3 id:40001 of https://codereview.chromium.org/912403004/)
Reason for revert:
Erm - Chrome.
Original issue's description:
> Remove SkPictureFlat.h include from SkDrawCommands.h
>
> This cannot land until https://codereview.chromium.org/909353004/ (Prepare SkiaBenchmarkingExtensionTest for upcoming Skia changes) lands in Chromium
>
> Committed: https://skia.googlesource.com/skia/+/5a4c233a3657d12d836de388b41e30405b4ab976
>
> Committed: https://skia.googlesource.com/skia/+/fa3a83d0fe53907e618346d3f1c17a95da1a9d22
TBR=reed@google.com,fmalita@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/923753002
diff --git a/debugger/SkDebugger.cpp b/debugger/SkDebugger.cpp
index 61fa3ec..fc61dda 100644
--- a/debugger/SkDebugger.cpp
+++ b/debugger/SkDebugger.cpp
@@ -66,8 +66,8 @@
const SkTDArray<SkDrawCommand*>& commands = this->getDrawCommands();
SkTDArray<int> counts;
- counts.setCount(SkDrawCommand::kOpTypeCount);
- for (int i = 0; i < SkDrawCommand::kOpTypeCount; ++i) {
+ counts.setCount(LAST_DRAWTYPE_ENUM+1);
+ for (int i = 0; i < LAST_DRAWTYPE_ENUM+1; ++i) {
counts[i] = 0;
}
@@ -80,14 +80,14 @@
#ifdef SK_DEBUG
double totPercent = 0, tempSum = 0;
#endif
- for (int i = 0; i < SkDrawCommand::kOpTypeCount; ++i) {
+ for (int i = 0; i < LAST_DRAWTYPE_ENUM+1; ++i) {
if (0 == counts[i]) {
// if there were no commands of this type then they should've consumed no time
SkASSERT(NULL == typeTimes || 0.0 == (*typeTimes)[i]);
continue;
}
- overview->append(SkDrawCommand::GetCommandString((SkDrawCommand::OpType) i));
+ overview->append(SkDrawCommand::GetCommandString((DrawType) i));
overview->append(": ");
overview->appendS32(counts[i]);
if (typeTimes && totTime >= 0.0) {
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index aed87cc..337c9d0 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -396,7 +396,20 @@
}
void SkDebugCanvas::didConcat(const SkMatrix& matrix) {
- this->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);
}
@@ -505,12 +518,6 @@
this->addDrawCommand(new SkDrawTextBlobCommand(blob, x, y, paint));
}
-void SkDebugCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkXfermode* xmode,
- const SkPaint& paint) {
- this->addDrawCommand(new SkDrawPatchCommand(cubics, colors, texCoords, xmode, paint));
-}
-
void SkDebugCanvas::onDrawVertices(VertexMode vmode, int vertexCount, const SkPoint vertices[],
const SkPoint texs[], const SkColor colors[],
SkXfermode*, const uint16_t indices[], int indexCount,
diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h
index 97eb734..e1ad077 100644
--- a/src/utils/debugger/SkDebugCanvas.h
+++ b/src/utils/debugger/SkDebugCanvas.h
@@ -175,30 +175,22 @@
void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
- void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
- const SkPaint&) SK_OVERRIDE;
- void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
- const SkPaint&) SK_OVERRIDE;
- void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
- SkScalar constY, const SkPaint&) SK_OVERRIDE;
- void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
- const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
- void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
- const SkPaint& paint) SK_OVERRIDE;
+ virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
+ const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
+ SkScalar constY, const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
+ const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
+ virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
+ const SkPaint& paint) SK_OVERRIDE;
- void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint);
void onDrawPaint(const SkPaint&) SK_OVERRIDE;
-
+ void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) SK_OVERRIDE;
void onDrawRect(const SkRect&, const SkPaint&) SK_OVERRIDE;
void onDrawOval(const SkRect&, const SkPaint&) SK_OVERRIDE;
void onDrawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE;
- void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) SK_OVERRIDE;
- void onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkXfermode* xmode,
- const uint16_t indices[], int indexCount,
- const SkPaint&) SK_OVERRIDE;
void onDrawPath(const SkPath&, const SkPaint&) SK_OVERRIDE;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) SK_OVERRIDE;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
@@ -209,6 +201,12 @@
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) SK_OVERRIDE;
void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) SK_OVERRIDE;
+ void onDrawVertices(VertexMode vmode, int vertexCount,
+ const SkPoint vertices[], const SkPoint texs[],
+ const SkColor colors[], SkXfermode* xmode,
+ const uint16_t indices[], int indexCount,
+ const SkPaint&) SK_OVERRIDE;
+
void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp
index 71a7344..0804797 100644
--- a/src/utils/debugger/SkDrawCommand.cpp
+++ b/src/utils/debugger/SkDrawCommand.cpp
@@ -9,16 +9,22 @@
#include "SkDrawCommand.h"
#include "SkObjectParser.h"
-#include "SkPicture.h"
+
#include "SkTextBlob.h"
// TODO(chudy): Refactor into non subclass model.
-const char* SkDrawCommand::kDrawRectString = "DrawRect";
-const char* SkDrawCommand::kClipRectString = "ClipRect";
+const char* SkDrawCommand::kDrawRectString = "Draw Rect";
+const char* SkDrawCommand::kClipRectString = "Clip Rect";
-SkDrawCommand::SkDrawCommand(OpType type)
- : fOpType(type)
+const SkDrawCommand::OpType SkDrawCommand::kSave_OpType = SAVE;
+const SkDrawCommand::OpType SkDrawCommand::kClipRect_OpType = CLIP_RECT;
+const SkDrawCommand::OpType SkDrawCommand::kDrawRect_OpType = DRAW_RECT;
+const SkDrawCommand::OpType SkDrawCommand::kRestore_OpType = RESTORE;
+const SkDrawCommand::OpType SkDrawCommand::kSetMatrix_OpType = SET_MATRIX;
+
+SkDrawCommand::SkDrawCommand(DrawType type)
+ : fDrawType(type)
, fOffset(0)
, fVisible(true) {
}
@@ -27,42 +33,49 @@
fInfo.deleteAll();
}
-const char* SkDrawCommand::GetCommandString(OpType type) {
+const char* SkDrawCommand::GetCommandString(DrawType type) {
switch (type) {
- case kBeginCommentGroup_OpType: return "BeginCommentGroup";
- case kClipPath_OpType: return "ClipPath";
- case kClipRegion_OpType: return "ClipRegion";
- case kClipRect_OpType: return "ClipRect";
- case kClipRRect_OpType: return "ClipRRect";
- case kComment_OpType: return "Comment";
- case kConcat_OpType: return "Concat";
- case kDrawBitmap_OpType: return "DrawBitmap";
- case kDrawBitmapNine_OpType: return "DrawBitmapNine";
- case kDrawBitmapRect_OpType: return "DrawBitmapRect";
- case kDrawClear_OpType: return "DrawClear";
- case kDrawDRRect_OpType: return "DrawDRRect";
- case kDrawOval_OpType: return "DrawOval";
- case kDrawPaint_OpType: return "DrawPaint";
- case kDrawPatch_OpType: return "DrawPatch";
- case kDrawPath_OpType: return "DrawPath";
- case kDrawPicture_OpType: return "DrawPicture";
- case kDrawPoints_OpType: return "DrawPoints";
- case kDrawPosText_OpType: return "DrawPosText";
- case kDrawPosTextH_OpType: return "DrawPosTextH";
- case kDrawRect_OpType: return "DrawRect";
- case kDrawRRect_OpType: return "DrawRRect";
- case kDrawSprite_OpType: return "DrawSprite";
- case kDrawText_OpType: return "DrawText";
- case kDrawTextBlob_OpType: return "DrawTextBlob";
- case kDrawTextOnPath_OpType: return "DrawTextOnPath";
- case kDrawVertices_OpType: return "DrawVertices";
- case kEndCommentGroup_OpType: return "EndCommentGroup";
- case kRestore_OpType: return "Restore";
- case kSave_OpType: return "Save";
- case kSaveLayer_OpType: return "SaveLayer";
- case kSetMatrix_OpType: return "SetMatrix";
+ case UNUSED: SkDEBUGFAIL("DrawType UNUSED\n"); break;
+ case DRAW_CLEAR: return "Clear";
+ case CLIP_PATH: return "Clip Path";
+ case CLIP_REGION: return "Clip Region";
+ case CLIP_RECT: return "Clip Rect";
+ case CLIP_RRECT: return "Clip RRect";
+ case CONCAT: return "Concat";
+ case DRAW_BITMAP: return "Draw Bitmap";
+ case DRAW_BITMAP_MATRIX: return "Draw Bitmap Matrix";
+ case DRAW_BITMAP_NINE: return "Draw Bitmap Nine";
+ case DRAW_BITMAP_RECT_TO_RECT: return "Draw Bitmap Rect";
+ case DRAW_DATA: return "Draw Data";
+ case DRAW_OVAL: return "Draw Oval";
+ case DRAW_PAINT: return "Draw Paint";
+ case DRAW_PATH: return "Draw Path";
+ case DRAW_PICTURE: return "Draw Picture";
+ case DRAW_POINTS: return "Draw Points";
+ case DRAW_POS_TEXT: return "Draw Pos Text";
+ case DRAW_POS_TEXT_H: return "Draw Pos Text H";
+ case DRAW_RECT: return "Draw Rect";
+ case DRAW_RRECT: return "Draw RRect";
+ case DRAW_SPRITE: return "Draw Sprite";
+ case DRAW_TEXT: return "Draw Text";
+ case DRAW_TEXT_BLOB: return "Draw Text Blob";
+ case DRAW_TEXT_ON_PATH: return "Draw Text On Path";
+ case DRAW_VERTICES: return "Draw Vertices";
+ case RESTORE: return "Restore";
+ case ROTATE: return "Rotate";
+ case SAVE: return "Save";
+ case SAVE_LAYER: return "Save Layer";
+ case SCALE: return "Scale";
+ case SET_MATRIX: return "SetMatrix";
+ case SKEW: return "Skew";
+ case TRANSLATE: return "Translate";
+ case NOOP: return "NoOp";
+ case BEGIN_COMMENT_GROUP: return "BeginCommentGroup";
+ case COMMENT: return "Comment";
+ case END_COMMENT_GROUP: return "EndCommentGroup";
+ case DRAW_DRRECT: return "Draw DRRect";
default:
- SkDebugf("OpType error 0x%08x\n", type);
+ SkDebugf("DrawType error 0x%08x\n", type);
SkASSERT(0);
break;
}
@@ -71,10 +84,10 @@
}
SkString SkDrawCommand::toString() const {
- return SkString(GetCommandString(fOpType));
+ return SkString(GetCommandString(fDrawType));
}
-SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kDrawClear_OpType) {
+SkClearCommand::SkClearCommand(SkColor color) : INHERITED(DRAW_CLEAR) {
fColor = color;
fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
}
@@ -186,7 +199,7 @@
SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA)
- : INHERITED(kClipPath_OpType) {
+ : INHERITED(CLIP_PATH) {
fPath = path;
fOp = op;
fDoAA = doAA;
@@ -206,7 +219,7 @@
}
SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op)
- : INHERITED(kClipRegion_OpType) {
+ : INHERITED(CLIP_REGION) {
fRegion = region;
fOp = op;
@@ -219,7 +232,7 @@
}
SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA)
- : INHERITED(kClipRect_OpType) {
+ : INHERITED(CLIP_RECT) {
fRect = rect;
fOp = op;
fDoAA = doAA;
@@ -234,7 +247,7 @@
}
SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA)
- : INHERITED(kClipRRect_OpType) {
+ : INHERITED(CLIP_RRECT) {
fRRect = rrect;
fOp = op;
fDoAA = doAA;
@@ -254,7 +267,7 @@
}
SkConcatCommand::SkConcatCommand(const SkMatrix& matrix)
- : INHERITED(kConcat_OpType) {
+ : INHERITED(CONCAT) {
fMatrix = matrix;
fInfo.push(SkObjectParser::MatrixToString(matrix));
@@ -266,7 +279,7 @@
SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
const SkPaint* paint)
- : INHERITED(kDrawBitmap_OpType) {
+ : INHERITED(DRAW_BITMAP) {
fBitmap = bitmap;
fLeft = left;
fTop = top;
@@ -296,7 +309,7 @@
SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint)
- : INHERITED(kDrawBitmapNine_OpType) {
+ : INHERITED(DRAW_BITMAP_NINE) {
fBitmap = bitmap;
fCenter = center;
fDst = dst;
@@ -327,7 +340,7 @@
SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
SkCanvas::DrawBitmapRectFlags flags)
- : INHERITED(kDrawBitmapRect_OpType) {
+ : INHERITED(DRAW_BITMAP_RECT_TO_RECT) {
fBitmap = bitmap;
if (src) {
fSrc = *src;
@@ -365,7 +378,7 @@
}
SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description)
- : INHERITED(kBeginCommentGroup_OpType)
+ : INHERITED(BEGIN_COMMENT_GROUP)
, fDescription(description) {
SkString* temp = new SkString;
temp->appendf("Description: %s", description);
@@ -373,7 +386,7 @@
}
SkCommentCommand::SkCommentCommand(const char* kywd, const char* value)
- : INHERITED(kComment_OpType)
+ : INHERITED(COMMENT)
, fKywd(kywd)
, fValue(value) {
SkString* temp = new SkString;
@@ -382,11 +395,11 @@
}
SkEndCommentGroupCommand::SkEndCommentGroupCommand()
- : INHERITED(kEndCommentGroup_OpType) {
+ : INHERITED(END_COMMENT_GROUP) {
}
SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint)
- : INHERITED(kDrawOval_OpType) {
+ : INHERITED(DRAW_OVAL) {
fOval = oval;
fPaint = paint;
@@ -415,7 +428,7 @@
}
SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint)
- : INHERITED(kDrawPaint_OpType) {
+ : INHERITED(DRAW_PAINT) {
fPaint = paint;
fInfo.push(SkObjectParser::PaintToString(paint));
@@ -432,7 +445,7 @@
}
SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint)
- : INHERITED(kDrawPath_OpType) {
+ : INHERITED(DRAW_PATH) {
fPath = path;
fPaint = paint;
@@ -452,7 +465,7 @@
SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture,
const SkMatrix* matrix,
const SkPaint* paint)
- : INHERITED(kDrawPicture_OpType)
+ : INHERITED(DRAW_PICTURE)
, fPicture(SkRef(picture))
, fMatrixPtr(NULL)
, fPaintPtr(NULL) {
@@ -498,7 +511,7 @@
SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count,
const SkPoint pts[], const SkPaint& paint)
- : INHERITED(kDrawPoints_OpType) {
+ : INHERITED(DRAW_POINTS) {
fMode = mode;
fCount = count;
fPts = new SkPoint[count];
@@ -541,7 +554,7 @@
SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength,
const SkPoint pos[], const SkPaint& paint)
- : INHERITED(kDrawPosText_OpType) {
+ : INHERITED(DRAW_POS_TEXT) {
size_t numPts = paint.countText(text, byteLength);
fText = new char[byteLength];
@@ -567,7 +580,7 @@
SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY,
const SkPaint& paint)
- : INHERITED(kDrawPosTextH_OpType) {
+ : INHERITED(DRAW_POS_TEXT_H) {
size_t numPts = paint.countText(text, byteLength);
fText = new char[byteLength];
@@ -592,7 +605,7 @@
SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint)
- : INHERITED(kDrawTextBlob_OpType)
+ : INHERITED(DRAW_TEXT_BLOB)
, fBlob(blob)
, fXPos(x)
, fYPos(y)
@@ -625,25 +638,8 @@
return true;
}
-SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkXfermode* xfermode,
- const SkPaint& paint)
- : INHERITED(kDrawPatch_OpType) {
- memcpy(fCubics, cubics, sizeof(fCubics));
- memcpy(fColors, colors, sizeof(fColors));
- memcpy(fTexCoords, texCoords, sizeof(fTexCoords));
- fXfermode.reset(xfermode);
- fPaint = paint;
-
- fInfo.push(SkObjectParser::PaintToString(paint));
-}
-
-void SkDrawPatchCommand::execute(SkCanvas* canvas) const {
- canvas->drawPatch(fCubics, fColors, fTexCoords, fXfermode, fPaint);
-}
-
SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint)
- : INHERITED(kDrawRect_OpType) {
+ : INHERITED(DRAW_RECT) {
fRect = rect;
fPaint = paint;
@@ -656,7 +652,7 @@
}
SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint)
- : INHERITED(kDrawRRect_OpType) {
+ : INHERITED(DRAW_RRECT) {
fRRect = rrect;
fPaint = paint;
@@ -676,7 +672,7 @@
SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer,
const SkRRect& inner,
const SkPaint& paint)
- : INHERITED(kDrawDRRect_OpType) {
+ : INHERITED(DRAW_DRRECT) {
fOuter = outer;
fInner = inner;
fPaint = paint;
@@ -697,7 +693,7 @@
SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top,
const SkPaint* paint)
- : INHERITED(kDrawSprite_OpType) {
+ : INHERITED(DRAW_SPRITE) {
fBitmap = bitmap;
fLeft = left;
fTop = top;
@@ -727,7 +723,7 @@
SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
const SkPaint& paint)
- : INHERITED(kDrawText_OpType) {
+ : INHERITED(DRAW_TEXT) {
fText = new char[byteLength];
memcpy(fText, text, byteLength);
fByteLength = byteLength;
@@ -748,7 +744,7 @@
SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLength,
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint)
- : INHERITED(kDrawTextOnPath_OpType) {
+ : INHERITED(DRAW_TEXT_ON_PATH) {
fText = new char[byteLength];
memcpy(fText, text, byteLength);
fByteLength = byteLength;
@@ -779,7 +775,7 @@
const SkColor colors[], SkXfermode* xfermode,
const uint16_t indices[], int indexCount,
const SkPaint& paint)
- : INHERITED(kDrawVertices_OpType) {
+ : INHERITED(DRAW_VERTICES) {
fVmode = vmode;
fVertexCount = vertexCount;
@@ -836,7 +832,7 @@
}
SkRestoreCommand::SkRestoreCommand()
- : INHERITED(kRestore_OpType) {
+ : INHERITED(RESTORE) {
fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
}
@@ -844,8 +840,19 @@
canvas->restore();
}
+SkRotateCommand::SkRotateCommand(SkScalar degrees)
+ : INHERITED(ROTATE) {
+ fDegrees = degrees;
+
+ fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: "));
+}
+
+void SkRotateCommand::execute(SkCanvas* canvas) const {
+ canvas->rotate(fDegrees);
+}
+
SkSaveCommand::SkSaveCommand()
- : INHERITED(kSave_OpType) {
+ : INHERITED(SAVE) {
}
void SkSaveCommand::execute(SkCanvas* canvas) const {
@@ -854,7 +861,7 @@
SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
SkCanvas::SaveFlags flags)
- : INHERITED(kSaveLayer_OpType) {
+ : INHERITED(SAVE_LAYER) {
if (bounds) {
fBounds = *bounds;
} else {
@@ -888,8 +895,21 @@
canvas->save();
}
+SkScaleCommand::SkScaleCommand(SkScalar sx, SkScalar sy)
+ : INHERITED(SCALE) {
+ fSx = sx;
+ fSy = sy;
+
+ fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
+ fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
+}
+
+void SkScaleCommand::execute(SkCanvas* canvas) const {
+ canvas->scale(fSx, fSy);
+}
+
SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix)
- : INHERITED(kSetMatrix_OpType) {
+ : INHERITED(SET_MATRIX) {
fUserMatrix.reset();
fMatrix = matrix;
@@ -905,3 +925,29 @@
canvas->setMatrix(temp);
}
+SkSkewCommand::SkSkewCommand(SkScalar sx, SkScalar sy)
+ : INHERITED(SKEW) {
+ fSx = sx;
+ fSy = sy;
+
+ fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
+ fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
+}
+
+void SkSkewCommand::execute(SkCanvas* canvas) const {
+ canvas->skew(fSx, fSy);
+}
+
+SkTranslateCommand::SkTranslateCommand(SkScalar dx, SkScalar dy)
+ : INHERITED(TRANSLATE) {
+ fDx = dx;
+ fDy = dy;
+
+ fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: "));
+ fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: "));
+}
+
+void SkTranslateCommand::execute(SkCanvas* canvas) const {
+ canvas->translate(fDx, fDy);
+}
+
diff --git a/src/utils/debugger/SkDrawCommand.h b/src/utils/debugger/SkDrawCommand.h
index 9ff1a9f..ab72a88 100644
--- a/src/utils/debugger/SkDrawCommand.h
+++ b/src/utils/debugger/SkDrawCommand.h
@@ -9,56 +9,29 @@
#ifndef SKDRAWCOMMAND_H_
#define SKDRAWCOMMAND_H_
+#include "SkPictureFlat.h"
#include "SkCanvas.h"
#include "SkString.h"
class SK_API SkDrawCommand {
public:
// Staging for Chromium
+ typedef DrawType OpType;
+
+ static const int kOpTypeCount = LAST_DRAWTYPE_ENUM+1;
+
static const char* kDrawRectString;
static const char* kClipRectString;
+
+ static const OpType kSave_OpType;
+ static const OpType kClipRect_OpType;
+ static const OpType kDrawRect_OpType;
+ static const OpType kRestore_OpType;
+ static const OpType kSetMatrix_OpType;
// End Staging
- enum OpType {
- kBeginCommentGroup_OpType,
- kClipPath_OpType,
- kClipRegion_OpType,
- kClipRect_OpType,
- kClipRRect_OpType,
- kComment_OpType,
- kConcat_OpType,
- kDrawBitmap_OpType,
- kDrawBitmapNine_OpType,
- kDrawBitmapRect_OpType,
- kDrawClear_OpType,
- kDrawDRRect_OpType,
- kDrawOval_OpType,
- kDrawPaint_OpType,
- kDrawPatch_OpType,
- kDrawPath_OpType,
- kDrawPicture_OpType,
- kDrawPoints_OpType,
- kDrawPosText_OpType,
- kDrawPosTextH_OpType,
- kDrawRect_OpType,
- kDrawRRect_OpType,
- kDrawSprite_OpType,
- kDrawText_OpType,
- kDrawTextBlob_OpType,
- kDrawTextOnPath_OpType,
- kDrawVertices_OpType,
- kEndCommentGroup_OpType,
- kRestore_OpType,
- kSave_OpType,
- kSaveLayer_OpType,
- kSetMatrix_OpType,
- kLast_OpType = kSetMatrix_OpType
- };
-
- static const int kOpTypeCount = kLast_OpType + 1;
-
- SkDrawCommand(OpType opType);
+ SkDrawCommand(DrawType drawType);
virtual ~SkDrawCommand();
@@ -68,7 +41,7 @@
size_t offset() const { return fOffset; }
virtual const char* toCString() const {
- return GetCommandString(fOpType);
+ return GetCommandString(fDrawType);
}
bool isVisible() const {
@@ -100,17 +73,17 @@
virtual void setActive(bool active) {}
virtual bool active() const { return false; }
- OpType getType() const { return fOpType; }
+ DrawType getType() const { return fDrawType; }
virtual bool render(SkCanvas* canvas) const { return false; }
- static const char* GetCommandString(OpType type);
+ static const char* GetCommandString(DrawType type);
protected:
SkTDArray<SkString*> fInfo;
private:
- OpType fOpType;
+ DrawType fDrawType;
size_t fOffset;
bool fVisible;
};
@@ -457,24 +430,6 @@
typedef SkDrawCommand INHERITED;
};
-class SkDrawPatchCommand : public SkDrawCommand {
-public:
- SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkXfermode* xmode,
- const SkPaint& paint);
- void execute(SkCanvas* canvas) const SK_OVERRIDE;
-
-private:
- SkPoint fCubics[12];
- SkColor fColors[4];
- SkPoint fTexCoords[4];
- SkAutoTUnref<SkXfermode> fXfermode;
- SkPaint fPaint;
-
- typedef SkDrawCommand INHERITED;
-};
-
-
class SkDrawRectCommand : public SkDrawCommand {
public:
SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
@@ -553,6 +508,16 @@
typedef SkDrawCommand INHERITED;
};
+class SkRotateCommand : public SkDrawCommand {
+public:
+ SkRotateCommand(SkScalar degrees);
+ void execute(SkCanvas* canvas) const SK_OVERRIDE;
+private:
+ SkScalar fDegrees;
+
+ typedef SkDrawCommand INHERITED;
+};
+
class SkSaveCommand : public SkDrawCommand {
public:
SkSaveCommand();
@@ -585,6 +550,21 @@
typedef SkDrawCommand INHERITED;
};
+class SkScaleCommand : public SkDrawCommand {
+public:
+ SkScaleCommand(SkScalar sx, SkScalar sy);
+ void execute(SkCanvas* canvas) const SK_OVERRIDE;
+
+ SkScalar x() const { return fSx; }
+ SkScalar y() const { return fSy; }
+
+private:
+ SkScalar fSx;
+ SkScalar fSy;
+
+ typedef SkDrawCommand INHERITED;
+};
+
class SkSetMatrixCommand : public SkDrawCommand {
public:
SkSetMatrixCommand(const SkMatrix& matrix);
@@ -597,4 +577,30 @@
typedef SkDrawCommand INHERITED;
};
+class SkSkewCommand : public SkDrawCommand {
+public:
+ SkSkewCommand(SkScalar sx, SkScalar sy);
+ void execute(SkCanvas* canvas) const SK_OVERRIDE;
+private:
+ SkScalar fSx;
+ SkScalar fSy;
+
+ typedef SkDrawCommand INHERITED;
+};
+
+class SkTranslateCommand : public SkDrawCommand {
+public:
+ SkTranslateCommand(SkScalar dx, SkScalar dy);
+ void execute(SkCanvas* canvas) const SK_OVERRIDE;
+
+ SkScalar x() const { return fDx; }
+ SkScalar y() const { return fDy; }
+
+private:
+ SkScalar fDx;
+ SkScalar fDy;
+
+ typedef SkDrawCommand INHERITED;
+};
+
#endif
diff --git a/tools/filtermain.cpp b/tools/filtermain.cpp
index 6883ff2..3b9d056 100644
--- a/tools/filtermain.cpp
+++ b/tools/filtermain.cpp
@@ -49,10 +49,10 @@
// RESTORE
// where the saveLayer's color can be moved into the drawBitmapRect
static bool check_0(SkDebugCanvas* canvas, int curCommand) {
- if (SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SAVE_LAYER != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+2 ||
- SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+2)->getType()) {
+ DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+2)->getType()) {
return false;
}
@@ -121,13 +121,13 @@
// RESTORE
// where the saveLayer's color can be moved into the drawBitmapRect
static bool check_1(SkDebugCanvas* canvas, int curCommand) {
- if (SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SAVE_LAYER != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+5 ||
- SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+3)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+4)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+5)->getType()) {
+ SAVE != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+3)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+4)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+5)->getType()) {
return false;
}
@@ -187,11 +187,11 @@
// RESTORE
// where the rect is entirely within the clip and the clip is an intersect
static bool check_2(SkDebugCanvas* canvas, int curCommand) {
- if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+4 ||
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- SkDrawCommand::kDrawRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) {
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ DRAW_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
return false;
}
@@ -222,11 +222,11 @@
// RESTORE
// where the rect entirely encloses the clip
static bool check_3(SkDebugCanvas* canvas, int curCommand) {
- if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+4 ||
- SkDrawCommand::kClipRRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- SkDrawCommand::kDrawRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) {
+ CLIP_RRECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ DRAW_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
return false;
}
@@ -270,11 +270,11 @@
// RESTORE
// where the rect and drawBitmapRect dst exactly match
static bool check_4(SkDebugCanvas* canvas, int curCommand) {
- if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+4 ||
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) {
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
return false;
}
@@ -299,6 +299,43 @@
}
// Check for:
+// TRANSLATE
+// where the translate is zero
+static bool check_5(SkDebugCanvas* canvas, int curCommand) {
+ if (TRANSLATE != canvas->getDrawCommandAt(curCommand)->getType()) {
+ return false;
+ }
+
+ SkTranslateCommand* t =
+ (SkTranslateCommand*) canvas->getDrawCommandAt(curCommand);
+
+ return 0 == t->x() && 0 == t->y();
+}
+
+// Just remove the translate
+static void apply_5(SkDebugCanvas* canvas, int curCommand) {
+ canvas->deleteDrawCommandAt(curCommand); // translate
+}
+
+// Check for:
+// SCALE
+// where the scale is 1,1
+static bool check_6(SkDebugCanvas* canvas, int curCommand) {
+ if (SCALE != canvas->getDrawCommandAt(curCommand)->getType()) {
+ return false;
+ }
+
+ SkScaleCommand* s = (SkScaleCommand*) canvas->getDrawCommandAt(curCommand);
+
+ return SK_Scalar1 == s->x() && SK_Scalar1 == s->y();
+}
+
+// Just remove the scale
+static void apply_6(SkDebugCanvas* canvas, int curCommand) {
+ canvas->deleteDrawCommandAt(curCommand); // scale
+}
+
+// Check for:
// SAVE
// CLIP_RECT
// SAVE_LAYER
@@ -320,21 +357,21 @@
// all the saveLayer's paints can be rolled into the drawBitmapRectToRect's paint
// This pattern is used by Google spreadsheet when drawing the toolbar buttons
static bool check_7(SkDebugCanvas* canvas, int curCommand) {
- if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+13 ||
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand+3)->getType() ||
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+4)->getType() ||
- SkDrawCommand::kSaveLayer_OpType != canvas->getDrawCommandAt(curCommand+5)->getType() ||
- SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand+6)->getType() ||
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+7)->getType() ||
- SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+8)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+9)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+10)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+11)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+12)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+13)->getType()) {
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ SAVE_LAYER != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ SAVE != canvas->getDrawCommandAt(curCommand+3)->getType() ||
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+4)->getType() ||
+ SAVE_LAYER != canvas->getDrawCommandAt(curCommand+5)->getType() ||
+ SAVE != canvas->getDrawCommandAt(curCommand+6)->getType() ||
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+7)->getType() ||
+ DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+8)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+9)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+10)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+11)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+12)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+13)->getType()) {
return false;
}
@@ -496,11 +533,11 @@
// the drawBitmapRectToRect is a 1-1 copy from src to dest
// the clip rect is BW and a subset of the drawBitmapRectToRect's dest rect
static bool check_8(SkDebugCanvas* canvas, int curCommand) {
- if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+4 ||
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) {
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
return false;
}
@@ -570,11 +607,11 @@
// where:
// clipRect is BW and encloses the DBMR2R's dest rect
static bool check_9(SkDebugCanvas* canvas, int curCommand) {
- if (SkDrawCommand::kSave_OpType != canvas->getDrawCommandAt(curCommand)->getType() ||
+ if (SAVE != canvas->getDrawCommandAt(curCommand)->getType() ||
canvas->getSize() <= curCommand+4 ||
- SkDrawCommand::kClipRect_OpType != canvas->getDrawCommandAt(curCommand+1)->getType() ||
- SkDrawCommand::kDrawBitmapRect_OpType != canvas->getDrawCommandAt(curCommand+2)->getType() ||
- SkDrawCommand::kRestore_OpType != canvas->getDrawCommandAt(curCommand+3)->getType()) {
+ CLIP_RECT != canvas->getDrawCommandAt(curCommand+1)->getType() ||
+ DRAW_BITMAP_RECT_TO_RECT != canvas->getDrawCommandAt(curCommand+2)->getType() ||
+ RESTORE != canvas->getDrawCommandAt(curCommand+3)->getType()) {
return false;
}
@@ -615,6 +652,8 @@
{ check_2, apply_2, 0 },
{ check_3, apply_3, 0 },
{ check_4, apply_4, 0 },
+ { check_5, apply_5, 0 },
+ { check_6, apply_6, 0 },
{ check_7, apply_7, 0 },
{ check_8, apply_8, 0 },
{ check_9, apply_9, 0 },