aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/debugger
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-02-12 13:29:15 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-12 13:29:15 -0800
commit3a092042bce0a8b7c43bf621cacdb2c644febeb2 (patch)
tree3ac5095fc9dca4fa97459850737abfc7384c235f /src/utils/debugger
parent7cd3f64385ab161a69c39be41fd1827e49da3170 (diff)
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
Diffstat (limited to 'src/utils/debugger')
-rw-r--r--src/utils/debugger/SkDebugCanvas.cpp21
-rw-r--r--src/utils/debugger/SkDebugCanvas.h38
-rw-r--r--src/utils/debugger/SkDrawCommand.cpp222
-rw-r--r--src/utils/debugger/SkDrawCommand.h128
4 files changed, 233 insertions, 176 deletions
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index aed87cc221..337c9d0d65 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -396,7 +396,20 @@ void SkDebugCanvas::onClipRegion(const SkRegion& region, SkRegion::Op op) {
}
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 @@ void SkDebugCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar
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 97eb73449c..e1ad077f83 100644
--- a/src/utils/debugger/SkDebugCanvas.h
+++ b/src/utils/debugger/SkDebugCanvas.h
@@ -175,30 +175,22 @@ protected:
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;
-
- 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;
+ 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 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 @@ protected:
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 71a7344046..0804797692 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";
+
+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(OpType type)
- : fOpType(type)
+SkDrawCommand::SkDrawCommand(DrawType type)
+ : fDrawType(type)
, fOffset(0)
, fVisible(true) {
}
@@ -27,42 +33,49 @@ SkDrawCommand::~SkDrawCommand() {
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 @@ const char* SkDrawCommand::GetCommandString(OpType type) {
}
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 @@ void render_drrect(SkCanvas* canvas, const SkRRect& outer, const SkRRect& inner)
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 @@ bool SkClipPathCommand::render(SkCanvas* canvas) const {
}
SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op)
- : INHERITED(kClipRegion_OpType) {
+ : INHERITED(CLIP_REGION) {
fRegion = region;
fOp = op;
@@ -219,7 +232,7 @@ void SkClipRegionCommand::execute(SkCanvas* canvas) const {
}
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 @@ void SkClipRectCommand::execute(SkCanvas* canvas) const {
}
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 @@ bool SkClipRRectCommand::render(SkCanvas* canvas) const {
}
SkConcatCommand::SkConcatCommand(const SkMatrix& matrix)
- : INHERITED(kConcat_OpType) {
+ : INHERITED(CONCAT) {
fMatrix = matrix;
fInfo.push(SkObjectParser::MatrixToString(matrix));
@@ -266,7 +279,7 @@ void SkConcatCommand::execute(SkCanvas* canvas) const {
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 @@ bool SkDrawBitmapCommand::render(SkCanvas* canvas) const {
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 @@ bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const {
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 @@ bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const {
}
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 @@ SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description)
}
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 @@ SkCommentCommand::SkCommentCommand(const char* kywd, const char* value)
}
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 @@ bool SkDrawOvalCommand::render(SkCanvas* canvas) const {
}
SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint)
- : INHERITED(kDrawPaint_OpType) {
+ : INHERITED(DRAW_PAINT) {
fPaint = paint;
fInfo.push(SkObjectParser::PaintToString(paint));
@@ -432,7 +445,7 @@ bool SkDrawPaintCommand::render(SkCanvas* canvas) const {
}
SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint)
- : INHERITED(kDrawPath_OpType) {
+ : INHERITED(DRAW_PATH) {
fPath = path;
fPaint = paint;
@@ -452,7 +465,7 @@ bool SkDrawPathCommand::render(SkCanvas* canvas) const {
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 @@ bool SkDrawPictureCommand::render(SkCanvas* canvas) const {
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 @@ bool SkDrawPointsCommand::render(SkCanvas* canvas) const {
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 @@ void SkDrawPosTextCommand::execute(SkCanvas* canvas) const {
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 @@ void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const {
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 @@ bool SkDrawTextBlobCommand::render(SkCanvas* canvas) const {
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 @@ void SkDrawRectCommand::execute(SkCanvas* canvas) const {
}
SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint)
- : INHERITED(kDrawRRect_OpType) {
+ : INHERITED(DRAW_RRECT) {
fRRect = rrect;
fPaint = paint;
@@ -676,7 +672,7 @@ bool SkDrawRRectCommand::render(SkCanvas* canvas) const {
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 @@ bool SkDrawDRRectCommand::render(SkCanvas* canvas) const {
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 @@ bool SkDrawSpriteCommand::render(SkCanvas* canvas) const {
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 @@ void SkDrawTextCommand::execute(SkCanvas* canvas) const {
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 @@ SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int ver
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 @@ void SkDrawVerticesCommand::execute(SkCanvas* canvas) const {
}
SkRestoreCommand::SkRestoreCommand()
- : INHERITED(kRestore_OpType) {
+ : INHERITED(RESTORE) {
fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
}
@@ -844,8 +840,19 @@ void SkRestoreCommand::execute(SkCanvas* canvas) const {
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 @@ void SkSaveCommand::execute(SkCanvas* canvas) const {
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 @@ void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const {
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 @@ void SkSetMatrixCommand::execute(SkCanvas* canvas) const {
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 9ff1a9f65c..ab72a88d71 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;
- // 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 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
- static const int kOpTypeCount = kLast_OpType + 1;
- SkDrawCommand(OpType opType);
+ SkDrawCommand(DrawType drawType);
virtual ~SkDrawCommand();
@@ -68,7 +41,7 @@ public:
size_t offset() const { return fOffset; }
virtual const char* toCString() const {
- return GetCommandString(fOpType);
+ return GetCommandString(fDrawType);
}
bool isVisible() const {
@@ -100,17 +73,17 @@ public:
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 @@ private:
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 @@ private:
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 @@ private:
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 @@ private:
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