Index: tools/debugger/SkDrawCommand.h |
diff --git a/tools/debugger/SkDrawCommand.h b/tools/debugger/SkDrawCommand.h |
index f67df92de7d37babbf40f1fdb1e8f745ce797492..a93461ab26a4d5a80adaa60e7884ed52551f3f20 100644 |
--- a/tools/debugger/SkDrawCommand.h |
+++ b/tools/debugger/SkDrawCommand.h |
@@ -15,6 +15,7 @@ |
#include "SkRRect.h" |
#include "SkString.h" |
#include "SkTDArray.h" |
+#include "SkJSONCPP.h" |
class SK_API SkDrawCommand { |
public: |
@@ -99,6 +100,14 @@ public: |
virtual bool render(SkCanvas* canvas) const { return false; } |
+ virtual Json::Value toJSON() const; |
+ |
+ /* Converts a JSON representation of a command into a newly-allocated SkDrawCommand object. It |
+ * is the caller's responsibility to delete this object. This method may return null if an error |
+ * occurs. |
+ */ |
+ static SkDrawCommand* fromJSON(Json::Value& command); |
+ |
static const char* GetCommandString(OpType type); |
protected: |
@@ -114,6 +123,7 @@ public: |
SkRestoreCommand(); |
void execute(SkCanvas* canvas) const override; |
Action action() const override { return kPopLayer_Action; } |
+ static SkRestoreCommand* fromJSON(Json::Value& command); |
private: |
typedef SkDrawCommand INHERITED; |
@@ -123,6 +133,9 @@ class SkClearCommand : public SkDrawCommand { |
public: |
SkClearCommand(SkColor color); |
void execute(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkClearCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkColor fColor; |
@@ -134,6 +147,9 @@ public: |
SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA); |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkClipPathCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkPath fPath; |
SkRegion::Op fOp; |
@@ -146,6 +162,9 @@ class SkClipRegionCommand : public SkDrawCommand { |
public: |
SkClipRegionCommand(const SkRegion& region, SkRegion::Op op); |
void execute(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkClipRegionCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkRegion fRegion; |
SkRegion::Op fOp; |
@@ -157,6 +176,8 @@ class SkClipRectCommand : public SkDrawCommand { |
public: |
SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA); |
void execute(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkClipRectCommand* fromJSON(Json::Value& command); |
const SkRect& rect() const { return fRect; } |
SkRegion::Op op() const { return fOp; } |
@@ -175,6 +196,8 @@ public: |
SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA); |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkClipRRectCommand* fromJSON(Json::Value& command); |
const SkRRect& rrect() const { return fRRect; } |
SkRegion::Op op() const { return fOp; } |
@@ -192,6 +215,9 @@ class SkConcatCommand : public SkDrawCommand { |
public: |
SkConcatCommand(const SkMatrix& matrix); |
void execute(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkConcatCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkMatrix fMatrix; |
@@ -204,6 +230,9 @@ public: |
const SkPaint* paint); |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawBitmapCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkBitmap fBitmap; |
SkScalar fLeft; |
@@ -220,6 +249,9 @@ public: |
const SkRect& dst, const SkPaint* paint); |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawBitmapNineCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkBitmap fBitmap; |
SkIRect fCenter; |
@@ -237,6 +269,8 @@ public: |
SkCanvas::SrcRectConstraint); |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawBitmapRectCommand* fromJSON(Json::Value& command); |
const SkBitmap& bitmap() const { return fBitmap; } |
@@ -274,6 +308,9 @@ public: |
SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint); |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawImageCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkAutoTUnref<const SkImage> fImage; |
SkScalar fLeft; |
@@ -289,6 +326,9 @@ public: |
const SkPaint* paint, SkCanvas::SrcRectConstraint constraint); |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawImageRectCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkAutoTUnref<const SkImage> fImage; |
SkTLazy<SkRect> fSrc; |
@@ -304,6 +344,9 @@ public: |
SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint); |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawOvalCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkRect fOval; |
SkPaint fPaint; |
@@ -316,6 +359,9 @@ public: |
SkDrawPaintCommand(const SkPaint& paint); |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawPaintCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkPaint fPaint; |
@@ -327,6 +373,8 @@ public: |
SkDrawPathCommand(const SkPath& path, const SkPaint& paint); |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawPathCommand* fromJSON(Json::Value& command); |
private: |
SkPath fPath; |
@@ -371,6 +419,9 @@ public: |
virtual ~SkDrawPointsCommand() { delete [] fPts; } |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawPointsCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkCanvas::PointMode fMode; |
size_t fCount; |
@@ -386,6 +437,9 @@ public: |
const SkPaint& paint); |
virtual ~SkDrawTextCommand() { delete [] fText; } |
void execute(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawTextCommand* fromJSON(Json::Value& command); |
+ |
private: |
char* fText; |
size_t fByteLength; |
@@ -402,6 +456,9 @@ public: |
const SkPaint& paint); |
virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; } |
void execute(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawPosTextCommand* fromJSON(Json::Value& command); |
+ |
private: |
char* fText; |
size_t fByteLength; |
@@ -417,6 +474,9 @@ public: |
const SkMatrix* matrix, const SkPaint& paint); |
virtual ~SkDrawTextOnPathCommand() { delete [] fText; } |
void execute(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawTextOnPathCommand* fromJSON(Json::Value& command); |
+ |
private: |
char* fText; |
size_t fByteLength; |
@@ -433,6 +493,7 @@ public: |
SkScalar constY, const SkPaint& paint); |
virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; } |
void execute(SkCanvas* canvas) const override; |
+ |
private: |
SkScalar* fXpos; |
char* fText; |
@@ -449,6 +510,8 @@ public: |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawTextBlobCommand* fromJSON(Json::Value& command); |
private: |
SkAutoTUnref<const SkTextBlob> fBlob; |
@@ -481,6 +544,8 @@ class SkDrawRectCommand : public SkDrawCommand { |
public: |
SkDrawRectCommand(const SkRect& rect, const SkPaint& paint); |
void execute(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawRectCommand* fromJSON(Json::Value& command); |
const SkRect& rect() const { return fRect; } |
const SkPaint& paint() const { return fPaint; } |
@@ -496,6 +561,9 @@ public: |
SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint); |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawRRectCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkRRect fRRect; |
SkPaint fPaint; |
@@ -509,6 +577,9 @@ public: |
const SkPaint& paint); |
void execute(SkCanvas* canvas) const override; |
bool render(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkDrawDRRectCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkRRect fOuter; |
SkRRect fInner; |
@@ -526,6 +597,7 @@ public: |
const SkPaint& paint); |
virtual ~SkDrawVerticesCommand(); |
void execute(SkCanvas* canvas) const override; |
+ |
private: |
SkCanvas::VertexMode fVmode; |
int fVertexCount; |
@@ -545,6 +617,8 @@ public: |
SkSaveCommand(); |
void execute(SkCanvas* canvas) const override; |
Action action() const override { return kPushLayer_Action; } |
+ static SkSaveCommand* fromJSON(Json::Value& command); |
+ |
private: |
typedef SkDrawCommand INHERITED; |
}; |
@@ -552,7 +626,10 @@ private: |
class SkSaveLayerCommand : public SkDrawCommand { |
public: |
SkSaveLayerCommand(const SkCanvas::SaveLayerRec&); |
+ virtual ~SkSaveLayerCommand(); |
void execute(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkSaveLayerCommand* fromJSON(Json::Value& command); |
void vizExecute(SkCanvas* canvas) const override; |
Action action() const override{ return kPushLayer_Action; } |
void setActive(bool active) override { fActive = active; } |
@@ -561,10 +638,11 @@ public: |
const SkPaint* paint() const { return fPaintPtr; } |
private: |
- SkRect fBounds; |
- SkPaint fPaint; |
- SkPaint* fPaintPtr; |
- uint32_t fSaveLayerFlags; |
+ SkRect fBounds; |
+ SkPaint fPaint; |
+ SkPaint* fPaintPtr; |
+ const SkImageFilter* fBackdrop; |
+ uint32_t fSaveLayerFlags; |
bool fActive; |
@@ -576,6 +654,9 @@ public: |
SkSetMatrixCommand(const SkMatrix& matrix); |
void setUserMatrix(const SkMatrix&) override; |
void execute(SkCanvas* canvas) const override; |
+ Json::Value toJSON() const override; |
+ static SkSetMatrixCommand* fromJSON(Json::Value& command); |
+ |
private: |
SkMatrix fUserMatrix; |
SkMatrix fMatrix; |