Index: src/utils/debugger/SkDrawCommand.cpp |
diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp |
index 38f02d9616b4a980b06b523146a303bca2e9cd06..47b29f731f87772671edfdee96df432352c7f9e1 100644 |
--- a/src/utils/debugger/SkDrawCommand.cpp |
+++ b/src/utils/debugger/SkDrawCommand.cpp |
@@ -9,13 +9,13 @@ |
#include "SkDrawCommand.h" |
#include "SkObjectParser.h" |
-#include "SkPicture.h" |
+ |
#include "SkTextBlob.h" |
// TODO(chudy): Refactor into non subclass model. |
-SkDrawCommand::SkDrawCommand(OpType type) |
- : fOpType(type) |
+SkDrawCommand::SkDrawCommand(DrawType type) |
+ : fDrawType(type) |
, fOffset(0) |
, fVisible(true) { |
} |
@@ -24,42 +24,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 "Set Matrix"; |
+ 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; |
} |
@@ -68,10 +75,10 @@ |
} |
SkString SkDrawCommand::toString() const { |
- return SkString(GetCommandString(fOpType)); |
-} |
- |
-SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kDrawClear_OpType) { |
+ return SkString(GetCommandString(fDrawType)); |
+} |
+ |
+SkClearCommand::SkClearCommand(SkColor color) : INHERITED(DRAW_CLEAR) { |
fColor = color; |
fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
} |
@@ -183,7 +190,7 @@ |
SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA) |
- : INHERITED(kClipPath_OpType) { |
+ : INHERITED(CLIP_PATH) { |
fPath = path; |
fOp = op; |
fDoAA = doAA; |
@@ -203,7 +210,7 @@ |
} |
SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op) |
- : INHERITED(kClipRegion_OpType) { |
+ : INHERITED(CLIP_REGION) { |
fRegion = region; |
fOp = op; |
@@ -216,7 +223,7 @@ |
} |
SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA) |
- : INHERITED(kClipRect_OpType) { |
+ : INHERITED(CLIP_RECT) { |
fRect = rect; |
fOp = op; |
fDoAA = doAA; |
@@ -231,7 +238,7 @@ |
} |
SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA) |
- : INHERITED(kClipRRect_OpType) { |
+ : INHERITED(CLIP_RRECT) { |
fRRect = rrect; |
fOp = op; |
fDoAA = doAA; |
@@ -251,7 +258,7 @@ |
} |
SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) |
- : INHERITED(kConcat_OpType) { |
+ : INHERITED(CONCAT) { |
fMatrix = matrix; |
fInfo.push(SkObjectParser::MatrixToString(matrix)); |
@@ -263,7 +270,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; |
@@ -293,7 +300,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; |
@@ -324,7 +331,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; |
@@ -362,7 +369,7 @@ |
} |
SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description) |
- : INHERITED(kBeginCommentGroup_OpType) |
+ : INHERITED(BEGIN_COMMENT_GROUP) |
, fDescription(description) { |
SkString* temp = new SkString; |
temp->appendf("Description: %s", description); |
@@ -370,7 +377,7 @@ |
} |
SkCommentCommand::SkCommentCommand(const char* kywd, const char* value) |
- : INHERITED(kComment_OpType) |
+ : INHERITED(COMMENT) |
, fKywd(kywd) |
, fValue(value) { |
SkString* temp = new SkString; |
@@ -379,11 +386,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; |
@@ -412,7 +419,7 @@ |
} |
SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) |
- : INHERITED(kDrawPaint_OpType) { |
+ : INHERITED(DRAW_PAINT) { |
fPaint = paint; |
fInfo.push(SkObjectParser::PaintToString(paint)); |
@@ -429,7 +436,7 @@ |
} |
SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) |
- : INHERITED(kDrawPath_OpType) { |
+ : INHERITED(DRAW_PATH) { |
fPath = path; |
fPaint = paint; |
@@ -449,7 +456,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) { |
@@ -495,7 +502,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]; |
@@ -538,7 +545,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]; |
@@ -564,7 +571,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]; |
@@ -589,7 +596,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) |
@@ -622,25 +629,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; |
@@ -653,7 +643,7 @@ |
} |
SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint) |
- : INHERITED(kDrawRRect_OpType) { |
+ : INHERITED(DRAW_RRECT) { |
fRRect = rrect; |
fPaint = paint; |
@@ -673,7 +663,7 @@ |
SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer, |
const SkRRect& inner, |
const SkPaint& paint) |
- : INHERITED(kDrawDRRect_OpType) { |
+ : INHERITED(DRAW_DRRECT) { |
fOuter = outer; |
fInner = inner; |
fPaint = paint; |
@@ -694,7 +684,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; |
@@ -724,7 +714,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; |
@@ -745,7 +735,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; |
@@ -776,7 +766,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; |
@@ -833,7 +823,7 @@ |
} |
SkRestoreCommand::SkRestoreCommand() |
- : INHERITED(kRestore_OpType) { |
+ : INHERITED(RESTORE) { |
fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
} |
@@ -841,8 +831,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 { |
@@ -851,7 +852,7 @@ |
SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint, |
SkCanvas::SaveFlags flags) |
- : INHERITED(kSaveLayer_OpType) { |
+ : INHERITED(SAVE_LAYER) { |
if (bounds) { |
fBounds = *bounds; |
} else { |
@@ -885,8 +886,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; |
@@ -902,3 +916,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); |
+} |
+ |