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

Review URL: https://codereview.chromium.org/912403004
diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp
index 0804797..71a7344 100644
--- a/src/utils/debugger/SkDrawCommand.cpp
+++ b/src/utils/debugger/SkDrawCommand.cpp
@@ -9,22 +9,16 @@
 
 #include "SkDrawCommand.h"
 #include "SkObjectParser.h"
-
+#include "SkPicture.h"
 #include "SkTextBlob.h"
 
 // TODO(chudy): Refactor into non subclass model.
 
-const char* SkDrawCommand::kDrawRectString = "Draw Rect";
-const char* SkDrawCommand::kClipRectString = "Clip Rect";
+const char* SkDrawCommand::kDrawRectString = "DrawRect";
+const char* SkDrawCommand::kClipRectString = "ClipRect";
 
-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)
+SkDrawCommand::SkDrawCommand(OpType type)
+    : fOpType(type)
     , fOffset(0)
     , fVisible(true) {
 }
@@ -33,49 +27,42 @@
     fInfo.deleteAll();
 }
 
-const char* SkDrawCommand::GetCommandString(DrawType type) {
+const char* SkDrawCommand::GetCommandString(OpType type) {
     switch (type) {
-        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";
+        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";
         default:
-            SkDebugf("DrawType error 0x%08x\n", type);
+            SkDebugf("OpType error 0x%08x\n", type);
             SkASSERT(0);
             break;
     }
@@ -84,10 +71,10 @@
 }
 
 SkString SkDrawCommand::toString() const {
-    return SkString(GetCommandString(fDrawType));
+    return SkString(GetCommandString(fOpType));
 }
 
-SkClearCommand::SkClearCommand(SkColor color) : INHERITED(DRAW_CLEAR) {
+SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kDrawClear_OpType) {
     fColor = color;
     fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
 }
@@ -199,7 +186,7 @@
 
 
 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA)
-    : INHERITED(CLIP_PATH) {
+    : INHERITED(kClipPath_OpType) {
     fPath = path;
     fOp = op;
     fDoAA = doAA;
@@ -219,7 +206,7 @@
 }
 
 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op)
-    : INHERITED(CLIP_REGION) {
+    : INHERITED(kClipRegion_OpType) {
     fRegion = region;
     fOp = op;
 
@@ -232,7 +219,7 @@
 }
 
 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA)
-    : INHERITED(CLIP_RECT) {
+    : INHERITED(kClipRect_OpType) {
     fRect = rect;
     fOp = op;
     fDoAA = doAA;
@@ -247,7 +234,7 @@
 }
 
 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA)
-    : INHERITED(CLIP_RRECT) {
+    : INHERITED(kClipRRect_OpType) {
     fRRect = rrect;
     fOp = op;
     fDoAA = doAA;
@@ -267,7 +254,7 @@
 }
 
 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix)
-    : INHERITED(CONCAT) {
+    : INHERITED(kConcat_OpType) {
     fMatrix = matrix;
 
     fInfo.push(SkObjectParser::MatrixToString(matrix));
@@ -279,7 +266,7 @@
 
 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                                          const SkPaint* paint)
-    : INHERITED(DRAW_BITMAP) {
+    : INHERITED(kDrawBitmap_OpType) {
     fBitmap = bitmap;
     fLeft = left;
     fTop = top;
@@ -309,7 +296,7 @@
 
 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
                                                  const SkRect& dst, const SkPaint* paint)
-    : INHERITED(DRAW_BITMAP_NINE) {
+    : INHERITED(kDrawBitmapNine_OpType) {
     fBitmap = bitmap;
     fCenter = center;
     fDst = dst;
@@ -340,7 +327,7 @@
 SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
                                                  const SkRect& dst, const SkPaint* paint,
                                                  SkCanvas::DrawBitmapRectFlags flags)
-    : INHERITED(DRAW_BITMAP_RECT_TO_RECT) {
+    : INHERITED(kDrawBitmapRect_OpType) {
     fBitmap = bitmap;
     if (src) {
         fSrc = *src;
@@ -378,7 +365,7 @@
 }
 
 SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description)
-    : INHERITED(BEGIN_COMMENT_GROUP)
+    : INHERITED(kBeginCommentGroup_OpType)
     , fDescription(description) {
     SkString* temp = new SkString;
     temp->appendf("Description: %s", description);
@@ -386,7 +373,7 @@
 }
 
 SkCommentCommand::SkCommentCommand(const char* kywd, const char* value)
-    : INHERITED(COMMENT)
+    : INHERITED(kComment_OpType)
     , fKywd(kywd)
     , fValue(value) {
     SkString* temp = new SkString;
@@ -395,11 +382,11 @@
 }
 
 SkEndCommentGroupCommand::SkEndCommentGroupCommand()
-    : INHERITED(END_COMMENT_GROUP) {
+    : INHERITED(kEndCommentGroup_OpType) {
 }
 
 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint)
-    : INHERITED(DRAW_OVAL) {
+    : INHERITED(kDrawOval_OpType) {
     fOval = oval;
     fPaint = paint;
 
@@ -428,7 +415,7 @@
 }
 
 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint)
-    : INHERITED(DRAW_PAINT) {
+    : INHERITED(kDrawPaint_OpType) {
     fPaint = paint;
 
     fInfo.push(SkObjectParser::PaintToString(paint));
@@ -445,7 +432,7 @@
 }
 
 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint)
-    : INHERITED(DRAW_PATH) {
+    : INHERITED(kDrawPath_OpType) {
     fPath = path;
     fPaint = paint;
 
@@ -465,7 +452,7 @@
 SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture,
                                            const SkMatrix* matrix,
                                            const SkPaint* paint)
-    : INHERITED(DRAW_PICTURE)
+    : INHERITED(kDrawPicture_OpType)
     , fPicture(SkRef(picture))
     , fMatrixPtr(NULL)
     , fPaintPtr(NULL) {
@@ -511,7 +498,7 @@
 
 SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count,
                                          const SkPoint pts[], const SkPaint& paint)
-    : INHERITED(DRAW_POINTS) {
+    : INHERITED(kDrawPoints_OpType) {
     fMode = mode;
     fCount = count;
     fPts = new SkPoint[count];
@@ -554,7 +541,7 @@
 
 SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength,
                                            const SkPoint pos[], const SkPaint& paint)
-    : INHERITED(DRAW_POS_TEXT) {
+    : INHERITED(kDrawPosText_OpType) {
     size_t numPts = paint.countText(text, byteLength);
 
     fText = new char[byteLength];
@@ -580,7 +567,7 @@
 SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength,
                                              const SkScalar xpos[], SkScalar constY,
                                              const SkPaint& paint)
-    : INHERITED(DRAW_POS_TEXT_H) {
+    : INHERITED(kDrawPosTextH_OpType) {
     size_t numPts = paint.countText(text, byteLength);
 
     fText = new char[byteLength];
@@ -605,7 +592,7 @@
 
 SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y,
                                              const SkPaint& paint)
-    : INHERITED(DRAW_TEXT_BLOB)
+    : INHERITED(kDrawTextBlob_OpType)
     , fBlob(blob)
     , fXPos(x)
     , fYPos(y)
@@ -638,8 +625,25 @@
     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(DRAW_RECT) {
+    : INHERITED(kDrawRect_OpType) {
     fRect = rect;
     fPaint = paint;
 
@@ -652,7 +656,7 @@
 }
 
 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint)
-    : INHERITED(DRAW_RRECT) {
+    : INHERITED(kDrawRRect_OpType) {
     fRRect = rrect;
     fPaint = paint;
 
@@ -672,7 +676,7 @@
 SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer,
                                          const SkRRect& inner,
                                          const SkPaint& paint)
-    : INHERITED(DRAW_DRRECT) {
+    : INHERITED(kDrawDRRect_OpType) {
     fOuter = outer;
     fInner = inner;
     fPaint = paint;
@@ -693,7 +697,7 @@
 
 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top,
                                          const SkPaint* paint)
-    : INHERITED(DRAW_SPRITE) {
+    : INHERITED(kDrawSprite_OpType) {
     fBitmap = bitmap;
     fLeft = left;
     fTop = top;
@@ -723,7 +727,7 @@
 
 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
                                      const SkPaint& paint)
-    : INHERITED(DRAW_TEXT) {
+    : INHERITED(kDrawText_OpType) {
     fText = new char[byteLength];
     memcpy(fText, text, byteLength);
     fByteLength = byteLength;
@@ -744,7 +748,7 @@
 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLength,
                                                  const SkPath& path, const SkMatrix* matrix,
                                                  const SkPaint& paint)
-    : INHERITED(DRAW_TEXT_ON_PATH) {
+    : INHERITED(kDrawTextOnPath_OpType) {
     fText = new char[byteLength];
     memcpy(fText, text, byteLength);
     fByteLength = byteLength;
@@ -775,7 +779,7 @@
                                              const SkColor colors[], SkXfermode* xfermode,
                                              const uint16_t indices[], int indexCount,
                                              const SkPaint& paint)
-    : INHERITED(DRAW_VERTICES) {
+    : INHERITED(kDrawVertices_OpType) {
     fVmode = vmode;
 
     fVertexCount = vertexCount;
@@ -832,7 +836,7 @@
 }
 
 SkRestoreCommand::SkRestoreCommand()
-    : INHERITED(RESTORE) {
+    : INHERITED(kRestore_OpType) {
     fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
 }
 
@@ -840,19 +844,8 @@
     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(SAVE) {
+    : INHERITED(kSave_OpType) {
 }
 
 void SkSaveCommand::execute(SkCanvas* canvas) const {
@@ -861,7 +854,7 @@
 
 SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
                                        SkCanvas::SaveFlags flags)
-    : INHERITED(SAVE_LAYER) {
+    : INHERITED(kSaveLayer_OpType) {
     if (bounds) {
         fBounds = *bounds;
     } else {
@@ -895,21 +888,8 @@
     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(SET_MATRIX) {
+    : INHERITED(kSetMatrix_OpType) {
     fUserMatrix.reset();
     fMatrix = matrix;
 
@@ -925,29 +905,3 @@
     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);
-}
-