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

Unified Diff: tools/skiaserve/skiaserve.cpp

Issue 1690023004: added clip visualization to skiaserve (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixed copy-paste error 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 1db8261bd4e1017933082063692224d1af5d9cae..d8430d7853181a9e12f2dfba103ea7ed0e88662d 100644
--- a/tools/skiaserve/skiaserve.cpp
+++ b/tools/skiaserve/skiaserve.cpp
@@ -232,7 +232,7 @@ public:
if (0 == strcmp(method, MHD_HTTP_METHOD_GET)) {
int n;
if (commands.count() == 1) {
- n = request->fDebugCanvas->getSize();
+ n = request->fDebugCanvas->getSize() - 1;
} else {
sscanf(commands[1].c_str(), "%d", &n);
}
@@ -291,6 +291,36 @@ public:
}
};
+/**
+ Updates the clip visualization alpha. On all subsequent /img requests, the clip will be drawn in
+ black with the specified alpha. 0 = no visible clip, 255 = fully opaque clip.
+ */
+class ClipAlphaHandler : public UrlHandler {
+public:
+ bool canHandle(const char* method, const char* url) override {
+ static const char* kBasePath = "/clipAlpha/";
+ return 0 == strcmp(method, MHD_HTTP_METHOD_GET) &&
+ 0 == strncmp(url, kBasePath, strlen(kBasePath));
+ }
+
+ int handle(Request* request, MHD_Connection* connection,
+ const char* url, const char* method,
+ const char* upload_data, size_t* upload_data_size) override {
+ SkTArray<SkString> commands;
+ SkStrSplit(url, "/", &commands);
+
+ if (!request->fPicture.get() || commands.count() != 2) {
+ return MHD_NO;
+ }
+
+ int alpha;
+ sscanf(commands[1].c_str(), "%d", &alpha);
+
+ request->fDebugCanvas->setClipVizColor(SkColorSetARGB(alpha, 0, 0, 0));
+ return SendOK(connection);
+ }
+};
+
class PostHandler : public UrlHandler {
public:
bool canHandle(const char* method, const char* url) override {
@@ -508,6 +538,7 @@ public:
fHandlers.push_back(new RootHandler);
fHandlers.push_back(new PostHandler);
fHandlers.push_back(new ImgHandler);
+ fHandlers.push_back(new ClipAlphaHandler);
fHandlers.push_back(new CmdHandler);
fHandlers.push_back(new InfoHandler);
fHandlers.push_back(new DownloadHandler);
« 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