Moved Canvas->JSON and JSON->Canvas functionality into SkDebugCanvas.

SkJSONCanvas and SkJSONRenderer will be deleted once the debug server
has been updated.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1681643002

Committed: https://skia.googlesource.com/skia/+/32fff1ba0c759d97ab78320b7ae46dd7696a4e6e

Committed: https://skia.googlesource.com/skia/+/46cb6d6b82b0ab71033aef91419e8beae25bb8a4

Review URL: https://codereview.chromium.org/1681643002
This commit is contained in:
ethannicholas 2016-02-10 05:40:46 -08:00 committed by Commit bot
parent d116561ddc
commit 50a8dd0a00
5 changed files with 1930 additions and 7 deletions

View File

@ -157,6 +157,7 @@
'views.gyp:views',
'views_animated.gyp:views_animated',
'xml.gyp:xml',
'jsoncpp.gyp:jsoncpp',
],
'msvs_settings': {
'VCLinkerTool': {

View File

@ -136,6 +136,7 @@
'dependencies': [
'debugger_qt_mocs',
'skia_lib.gyp:skia_lib',
'jsoncpp.gyp:jsoncpp',
],
'cflags': [
# Clang gets confused by QWeakPointer, see http://llvm.org/bugs/show_bug.cgi?id=13127

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -26,11 +26,12 @@ SkString* SkObjectParser::BitmapToString(const SkBitmap& bitmap) {
mBitmap->appendS32(bitmap.width());
mBitmap->append(" H: ");
mBitmap->appendS32(bitmap.height());
const char* gColorTypeStrings[] = {
"None", "A8", "565", "4444", "RGBA", "BGRA", "Index8", "G8"
"None", "A8", "565", "4444", "RGBA", "BGRA", "Index8", "G8", "RGBAf16"
};
SkASSERT(kLastEnum_SkColorType + 1 == SK_ARRAY_COUNT(gColorTypeStrings));
static_assert(kLastEnum_SkColorType + 1 == SK_ARRAY_COUNT(gColorTypeStrings),
"colortype names do not match colortype enum");
mBitmap->append(" ColorType: ");
mBitmap->append(gColorTypeStrings[bitmap.colorType()]);