diff options
author | brianosman <brianosman@google.com> | 2016-04-19 10:16:53 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-19 10:16:53 -0700 |
commit | 7831295c63b57efca6e4331b9d66df66985ca805 (patch) | |
tree | 8d73be4e52023b5898a3334e4e432103a4615734 /tools/skiaserve/urlhandlers | |
parent | 1bf3e71ad06a318613ccc09e1cf47d3c2465b23c (diff) |
Adding support for playback to L32/S32/F16 canvas.
Playback of my test GM works correctly on both raster and GPU, in all three modes.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1893393002
Review URL: https://codereview.chromium.org/1893393002
Diffstat (limited to 'tools/skiaserve/urlhandlers')
-rw-r--r-- | tools/skiaserve/urlhandlers/ColorModeHandler.cpp | 42 | ||||
-rw-r--r-- | tools/skiaserve/urlhandlers/UrlHandler.h | 13 |
2 files changed, 55 insertions, 0 deletions
diff --git a/tools/skiaserve/urlhandlers/ColorModeHandler.cpp b/tools/skiaserve/urlhandlers/ColorModeHandler.cpp new file mode 100644 index 0000000000..25cdf7dce9 --- /dev/null +++ b/tools/skiaserve/urlhandlers/ColorModeHandler.cpp @@ -0,0 +1,42 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "UrlHandler.h" + +#include "microhttpd.h" +#include "../Request.h" +#include "../Response.h" + +using namespace Response; + +bool ColorModeHandler::canHandle(const char* method, const char* url) { + static const char* kBasePath = "/colorMode/"; + return 0 == strcmp(method, MHD_HTTP_METHOD_POST) && + 0 == strncmp(url, kBasePath, strlen(kBasePath)); +} + +int ColorModeHandler::handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) { + SkTArray<SkString> commands; + SkStrSplit(url, "/", &commands); + + if (commands.count() != 2) { + return MHD_NO; + } + + int mode; + if (1 != sscanf(commands[1].c_str(), "%d", &mode)) { + return MHD_NO; + } + + bool success = request->setColorMode(mode); + if (!success) { + return SendError(connection, "Unable to create requested surface"); + } + return SendOK(connection); +} diff --git a/tools/skiaserve/urlhandlers/UrlHandler.h b/tools/skiaserve/urlhandlers/UrlHandler.h index 02a07b0d14..adbdcb9aa2 100644 --- a/tools/skiaserve/urlhandlers/UrlHandler.h +++ b/tools/skiaserve/urlhandlers/UrlHandler.h @@ -128,3 +128,16 @@ public: const char* url, const char* method, const char* upload_data, size_t* upload_data_size) override; }; + +/** + * Controls how rendering is performed (L32, S32, F16). + * Posting to /colorMode/0 turns on L32, /colorMode/1 turns on sRGB, + * /colorMode/2 turns on FP16. + */ +class ColorModeHandler : public UrlHandler { +public: + bool canHandle(const char* method, const char* url) override; + int handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) override; +}; |