aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skiaserve/urlhandlers
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2016-02-29 11:15:06 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-29 11:15:06 -0800
commit10d8fc29bc1605c134e98f5b58c2efb73cef6073 (patch)
tree702f20b251cfa0dfb6c858269ed148ec9e0ee62c /tools/skiaserve/urlhandlers
parent790d5132620d86813380d3df251e80dd2b41a409 (diff)
Render batch bounds as stroke rects
Diffstat (limited to 'tools/skiaserve/urlhandlers')
-rw-r--r--tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp38
-rw-r--r--tools/skiaserve/urlhandlers/UrlHandler.h11
2 files changed, 49 insertions, 0 deletions
diff --git a/tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp b/tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp
new file mode 100644
index 0000000000..40449868bf
--- /dev/null
+++ b/tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp
@@ -0,0 +1,38 @@
+/*
+ * 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 BatchBoundsHandler::canHandle(const char* method, const char* url) {
+ static const char* kBasePath = "/batchBounds/";
+ return 0 == strcmp(method, MHD_HTTP_METHOD_POST) &&
+ 0 == strncmp(url, kBasePath, strlen(kBasePath));
+}
+
+int BatchBoundsHandler::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 (!request->hasPicture() || commands.count() != 2) {
+ return MHD_NO;
+ }
+
+ int enabled;
+ sscanf(commands[1].c_str(), "%d", &enabled);
+
+ request->fDebugCanvas->setDrawGpuBatchBounds(enabled);
+ return SendOK(connection);
+}
+
diff --git a/tools/skiaserve/urlhandlers/UrlHandler.h b/tools/skiaserve/urlhandlers/UrlHandler.h
index 28d378aaf9..3fe269a57f 100644
--- a/tools/skiaserve/urlhandlers/UrlHandler.h
+++ b/tools/skiaserve/urlhandlers/UrlHandler.h
@@ -112,6 +112,17 @@ public:
const char* upload_data, size_t* upload_data_size) override;
};
+/*
+ * Enables drawing of batch bounds
+ */
+class BatchBoundsHandler : 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;
+};
+
class RootHandler : public UrlHandler {
public:
bool canHandle(const char* method, const char* url) override;