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

Unified Diff: tools/skiaserve/skiaserve.cpp

Issue 1691773002: wire up new json code in skiaserve (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixup comment 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.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/skiaserve/skiaserve.cpp
diff --git a/tools/skiaserve/skiaserve.cpp b/tools/skiaserve/skiaserve.cpp
index 6bc7cc78466f4bd2caab25769edb8f4eba3d57a0..4b2d52b6124f392b038ad522a1ae8f3d6a511430 100644
--- a/tools/skiaserve/skiaserve.cpp
+++ b/tools/skiaserve/skiaserve.cpp
@@ -171,11 +171,11 @@ static int SendData(MHD_Connection* connection, const SkData* data, const char*
return ret;
}
-static int SendJSON(MHD_Connection* connection, SkDebugCanvas* debugCanvas, int n) {
+static int SendJSON(MHD_Connection* connection, SkDebugCanvas* debugCanvas,
+ UrlDataManager* urlDataManager, int n) {
+ Json::Value root = debugCanvas->toJSON(*urlDataManager, n);
SkDynamicMemoryWStream stream;
- SkAutoTUnref<SkJSONCanvas> jsonCanvas(new SkJSONCanvas(kImageWidth, kImageHeight, stream));
- debugCanvas->drawTo(jsonCanvas, n);
- jsonCanvas->finish();
+ stream.writeText(Json::FastWriter().write(root).c_str());
SkAutoTUnref<SkData> data(stream.copyToData());
return SendData(connection, data, "application/json");
@@ -229,10 +229,15 @@ public:
return MHD_NO;
}
- // /cmd or /cmd/N or /cmd/N/[0|1]
- if (commands.count() == 1 && 0 == strcmp(method, MHD_HTTP_METHOD_GET)) {
- int n = request->fDebugCanvas->getSize() - 1;
- return SendJSON(connection, request->fDebugCanvas, n);
+ // /cmd or /cmd/N
+ if (0 == strcmp(method, MHD_HTTP_METHOD_GET)) {
+ int n;
+ if (commands.count() == 1) {
+ n = request->fDebugCanvas->getSize() - 1;
+ } else {
+ sscanf(commands[1].c_str(), "%d", &n);
+ }
+ return SendJSON(connection, request->fDebugCanvas, &request->fUrlDataManager, n);
}
// /cmd/N, for now only delete supported
« no previous file with comments | « tools/debugger/SkDebugCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698