diff options
author | ethannicholas <ethannicholas@google.com> | 2016-02-10 12:57:30 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-10 12:57:30 -0800 |
commit | 402cd91f60bcf1a2f86f769bd02d79ace73770c9 (patch) | |
tree | 8ea697052b927abed3c7026df59dce0ab917ca2a /tools/debugger | |
parent | d31588523c531353a5139739cc81ec6cf91eaa96 (diff) |
added SkDebugCanvas::toJSON
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1684233002
Review URL: https://codereview.chromium.org/1684233002
Diffstat (limited to 'tools/debugger')
-rw-r--r-- | tools/debugger/SkDebugCanvas.cpp | 15 | ||||
-rw-r--r-- | tools/debugger/SkDebugCanvas.h | 7 |
2 files changed, 22 insertions, 0 deletions
diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp index c2dd8f8a19..d8d51fe0ac 100644 --- a/tools/debugger/SkDebugCanvas.cpp +++ b/tools/debugger/SkDebugCanvas.cpp @@ -12,6 +12,10 @@ #include "SkPaintFilterCanvas.h" #include "SkOverdrawMode.h" +#define SKDEBUGCANVAS_VERSION 1 +#define SKDEBUGCANVAS_ATTRIBUTE_VERSION "version" +#define SKDEBUGCANVAS_ATTRIBUTE_COMMANDS "commands" + class DebugPaintFilterCanvas : public SkPaintFilterCanvas { public: DebugPaintFilterCanvas(int width, @@ -314,6 +318,17 @@ SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() { return fCommandVector; } +Json::Value SkDebugCanvas::toJSON(UrlDataManager& urlDataManager) { + Json::Value result = Json::Value(Json::objectValue); + result[SKDEBUGCANVAS_ATTRIBUTE_VERSION] = Json::Value(SKDEBUGCANVAS_VERSION); + Json::Value commands = Json::Value(Json::arrayValue); + for (int i = 0; i < this->getSize(); i++) { + commands[i] = this->getDrawCommandAt(i)->toJSON(); + } + result[SKDEBUGCANVAS_ATTRIBUTE_COMMANDS] = commands; + return result; +} + void SkDebugCanvas::updatePaintFilterCanvas() { if (!fOverdrawViz && !fOverrideFilterQuality) { fPaintFilterCanvas.reset(nullptr); diff --git a/tools/debugger/SkDebugCanvas.h b/tools/debugger/SkDebugCanvas.h index 217b52e3ce..505b5c79fa 100644 --- a/tools/debugger/SkDebugCanvas.h +++ b/tools/debugger/SkDebugCanvas.h @@ -17,6 +17,7 @@ #include "SkPicture.h" #include "SkString.h" #include "SkTArray.h" +#include "UrlDataManager.h" class SkNWayCanvas; @@ -139,6 +140,12 @@ public: SkString clipStackData() const { return fClipStackData; } + /** + Returns a JSON object representing all of the draws. The encoder may use the UrlDataManager + to store binary data such as images, referring to them via URLs embedded in the JSON. + */ + Json::Value toJSON(UrlDataManager& urlDataManager); + //////////////////////////////////////////////////////////////////////////////// // Inherited from SkCanvas //////////////////////////////////////////////////////////////////////////////// |