Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: tools/debugger/SkDebugCanvas.cpp

Issue 1684233002: added SkDebugCanvas::toJSON (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: constantified everything Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/debugger/SkDebugCanvas.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/debugger/SkDebugCanvas.cpp
diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp
index c2dd8f8a1915376cffcd47e6ccd64d935a14dc27..d8d51fe0ace3b260bf360d27bd62f49cd9af0fb1 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);
« no previous file with comments | « tools/debugger/SkDebugCanvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698