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

Unified Diff: tools/skiaserve/Request.cpp

Issue 1737323002: Wire up /batches in skiaserve (Closed) Base URL: https://skia.googlesource.com/skia@skiaserve-1
Patch Set: minor tweak 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/skiaserve/Request.h ('k') | tools/skiaserve/Response.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/skiaserve/Request.cpp
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index 33e94fdc40637c082c77fad68841d907ef028d7f..3d9e9d37b3fbb4d344dff3224404a1ec2f7152a4 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -111,3 +111,41 @@ SkSurface* Request::createGPUSurface() {
return surface;
}
+SkData* Request::getJsonOps(int n) {
+ SkCanvas* canvas = this->getCanvas();
+ Json::Value root = fDebugCanvas->toJSON(fUrlDataManager, n, canvas);
+ root["mode"] = Json::Value(fGPUEnabled ? "gpu" : "cpu");
+ SkDynamicMemoryWStream stream;
+ stream.writeText(Json::FastWriter().write(root).c_str());
+
+ return stream.copyToData();
+}
+
+SkData* Request::getJsonBatchList(int n) {
+ SkCanvas* canvas = this->getCanvas();
+ SkASSERT(fGPUEnabled);
+
+ // TODO if this is inefficient we could add a method to GrAuditTrail which takes
+ // a Json::Value and is only compiled in this file
+ Json::Value parsedFromString;
+#if SK_SUPPORT_GPU
+ GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget();
+ SkASSERT(rt);
+ GrContext* ctx = rt->getContext();
+ SkASSERT(ctx);
+ GrAuditTrail* at = ctx->getAuditTrail();
+ GrAuditTrail::AutoManageBatchList enable(at);
+
+ fDebugCanvas->drawTo(canvas, n);
+
+ Json::Reader reader;
+ SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson(true).c_str(),
+ parsedFromString);
+ SkASSERT(parsingSuccessful);
+#endif
+
+ SkDynamicMemoryWStream stream;
+ stream.writeText(Json::FastWriter().write(parsedFromString).c_str());
+
+ return stream.copyToData();
+}
« no previous file with comments | « tools/skiaserve/Request.h ('k') | tools/skiaserve/Response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698