diff options
author | ethannicholas <ethannicholas@google.com> | 2016-02-12 12:06:53 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-12 12:06:53 -0800 |
commit | 0a0520afccb9dcad9db2258c936456e69012fa34 (patch) | |
tree | 2ec83a3ec40290885b17822cf83d6528dc51b238 /tools/skiaserve/skiaserve.cpp | |
parent | bbfe47bd0fd328a387722e233304f35f4f9d27a2 (diff) |
added clip visualization to skiaserve
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1690023004
Review URL: https://codereview.chromium.org/1690023004
Diffstat (limited to 'tools/skiaserve/skiaserve.cpp')
-rw-r--r-- | tools/skiaserve/skiaserve.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/tools/skiaserve/skiaserve.cpp b/tools/skiaserve/skiaserve.cpp index 1db8261bd4..d8430d7853 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); |