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

Unified Diff: tools/skiaserve/skiaserve.cpp

Issue 1719973002: added mode=cpu|gpu to skiaserve JSON (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « no previous file | 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 18a522a4c1b9170523f97741f5411356a2bdc77d..427ce4b8f31f8a9cb3b002884f0e68c575794f15 100644
--- a/tools/skiaserve/skiaserve.cpp
+++ b/tools/skiaserve/skiaserve.cpp
@@ -67,13 +67,18 @@ struct UploadContext {
};
struct Request {
- Request(SkString rootUrl) : fUploadContext(nullptr), fUrlDataManager(rootUrl) {}
+ Request(SkString rootUrl)
+ : fUploadContext(nullptr)
+ , fUrlDataManager(rootUrl)
+ , fGPUEnabled(false) {}
+
UploadContext* fUploadContext;
SkAutoTUnref<SkPicture> fPicture;
SkAutoTUnref<SkDebugCanvas> fDebugCanvas;
SkAutoTDelete<GrContextFactory> fContextFactory;
SkAutoTUnref<SkSurface> fSurface;
UrlDataManager fUrlDataManager;
+ bool fGPUEnabled;
};
static void write_png_callback(png_structp png_ptr, png_bytep data, png_size_t length) {
@@ -226,9 +231,12 @@ static int SendData(MHD_Connection* connection, const SkData* data, const char*
return ret;
}
-static int SendJSON(MHD_Connection* connection, SkCanvas* canvas, SkDebugCanvas* debugCanvas,
- UrlDataManager* urlDataManager, int n) {
+static int SendJSON(MHD_Connection* connection, Request* request, int n) {
+ SkCanvas* canvas = getCanvasFromRequest(request);
+ SkDebugCanvas* debugCanvas = request->fDebugCanvas;
+ UrlDataManager* urlDataManager = &request->fUrlDataManager;
Json::Value root = debugCanvas->toJSON(*urlDataManager, n, canvas);
+ root["mode"] = Json::Value(request->fGPUEnabled ? "gpu" : "cpu");
SkDynamicMemoryWStream stream;
stream.writeText(Json::FastWriter().write(root).c_str());
@@ -292,8 +300,7 @@ public:
} else {
sscanf(commands[1].c_str(), "%d", &n);
}
- return SendJSON(connection, getCanvasFromRequest(request), request->fDebugCanvas,
- &request->fUrlDataManager, n);
+ return SendJSON(connection, request, n);
}
// /cmd/N, for now only delete supported
@@ -493,11 +500,13 @@ public:
SkSurface* surface = createGPUSurface(request);
if (surface) {
request->fSurface.reset(surface);
+ request->fGPUEnabled = true;
return SendOK(connection);
}
return SendError(connection, "Unable to create GPU surface");
}
request->fSurface.reset(createCPUSurface());
+ request->fGPUEnabled = false;
return SendOK(connection);
}
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698