From 144a5c518ae921f210bdd9647c061e57d18f440c Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Tue, 20 Dec 2016 16:48:59 -0500 Subject: Rename batch->op in skiaserve Change-Id: Ib831b9a6bcf4f37c0f077b26f68b1cefef81bb73 Reviewed-on: https://skia-review.googlesource.com/6351 Reviewed-by: Brian Osman Commit-Queue: Brian Salomon --- tools/skiaserve/Request.cpp | 6 ++-- tools/skiaserve/Request.h | 6 ++-- tools/skiaserve/skiaserve.cpp | 4 +-- tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp | 37 -------------------- tools/skiaserve/urlhandlers/BatchesHandler.cpp | 40 ---------------------- tools/skiaserve/urlhandlers/OpBoundsHandler.cpp | 36 +++++++++++++++++++ tools/skiaserve/urlhandlers/OpsHandler.cpp | 39 +++++++++++++++++++++ tools/skiaserve/urlhandlers/UrlHandler.h | 8 ++--- 8 files changed, 87 insertions(+), 89 deletions(-) delete mode 100644 tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp delete mode 100644 tools/skiaserve/urlhandlers/BatchesHandler.cpp create mode 100644 tools/skiaserve/urlhandlers/OpBoundsHandler.cpp create mode 100644 tools/skiaserve/urlhandlers/OpsHandler.cpp (limited to 'tools/skiaserve') diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp index 2064a464f0..0e55d926aa 100644 --- a/tools/skiaserve/Request.cpp +++ b/tools/skiaserve/Request.cpp @@ -259,7 +259,7 @@ sk_sp Request::getJsonOps(int n) { SkCanvas* canvas = this->getCanvas(); Json::Value root = fDebugCanvas->toJSON(fUrlDataManager, n, canvas); root["mode"] = Json::Value(fGPUEnabled ? "gpu" : "cpu"); - root["drawGpuBatchBounds"] = Json::Value(fDebugCanvas->getDrawGpuBatchBounds()); + root["drawGpuBatchBounds"] = Json::Value(fDebugCanvas->getDrawGpuOpBounds()); root["colorMode"] = Json::Value(fColorMode); SkDynamicMemoryWStream stream; stream.writeText(Json::FastWriter().write(root).c_str()); @@ -267,11 +267,11 @@ sk_sp Request::getJsonOps(int n) { return stream.detachAsData(); } -sk_sp Request::getJsonBatchList(int n) { +sk_sp Request::getJsonOpList(int n) { SkCanvas* canvas = this->getCanvas(); SkASSERT(fGPUEnabled); - Json::Value result = fDebugCanvas->toJSONBatchList(n, canvas); + Json::Value result = fDebugCanvas->toJSONOpList(n, canvas); SkDynamicMemoryWStream stream; stream.writeText(Json::FastWriter().write(result).c_str()); diff --git a/tools/skiaserve/Request.h b/tools/skiaserve/Request.h index 4058d7ce7e..7f41748c02 100644 --- a/tools/skiaserve/Request.h +++ b/tools/skiaserve/Request.h @@ -37,7 +37,7 @@ struct Request { Request(SkString rootUrl); ~Request(); - // draws to skia draw op N, highlighting the Mth batch(-1 means no highlight) + // draws to canvas operation N, highlighting the Mth GrOp. m = -1 means no highlight. sk_sp drawToPng(int n, int m = -1); sk_sp writeOutSkp(); SkCanvas* getCanvas(); @@ -53,8 +53,8 @@ struct Request { // Returns the json list of ops as an SkData sk_sp getJsonOps(int n); - // Returns a json list of batches as an SkData - sk_sp getJsonBatchList(int n); + // Returns a json list of ops as an SkData + sk_sp getJsonOpList(int n); // Returns json with the viewMatrix and clipRect sk_sp getJsonInfo(int n); diff --git a/tools/skiaserve/skiaserve.cpp b/tools/skiaserve/skiaserve.cpp index 3e547a8d70..29dd1b4996 100644 --- a/tools/skiaserve/skiaserve.cpp +++ b/tools/skiaserve/skiaserve.cpp @@ -42,8 +42,8 @@ public: fHandlers.push_back(new DownloadHandler); fHandlers.push_back(new DataHandler); fHandlers.push_back(new BreakHandler); - fHandlers.push_back(new BatchesHandler); - fHandlers.push_back(new BatchBoundsHandler); + fHandlers.push_back(new OpsHandler); + fHandlers.push_back(new OpBoundsHandler); fHandlers.push_back(new ColorModeHandler); fHandlers.push_back(new QuitHandler); } diff --git a/tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp b/tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp deleted file mode 100644 index 3eb51d2f68..0000000000 --- a/tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 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(SkToBool(enabled)); - return SendOK(connection); -} diff --git a/tools/skiaserve/urlhandlers/BatchesHandler.cpp b/tools/skiaserve/urlhandlers/BatchesHandler.cpp deleted file mode 100644 index 81457acca4..0000000000 --- a/tools/skiaserve/urlhandlers/BatchesHandler.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 BatchesHandler::canHandle(const char* method, const char* url) { - const char* kBasePath = "/batches"; - return 0 == strncmp(url, kBasePath, strlen(kBasePath)); -} - -int BatchesHandler::handle(Request* request, MHD_Connection* connection, - const char* url, const char* method, - const char* upload_data, size_t* upload_data_size) { - SkTArray commands; - SkStrSplit(url, "/", &commands); - - if (!request->hasPicture() || commands.count() > 1) { - return MHD_NO; - } - - // /batches - if (0 == strcmp(method, MHD_HTTP_METHOD_GET)) { - int n = request->getLastOp(); - - sk_sp data(request->getJsonBatchList(n)); - return SendData(connection, data.get(), "application/json"); - } - - return MHD_NO; -} diff --git a/tools/skiaserve/urlhandlers/OpBoundsHandler.cpp b/tools/skiaserve/urlhandlers/OpBoundsHandler.cpp new file mode 100644 index 0000000000..f0e9758b63 --- /dev/null +++ b/tools/skiaserve/urlhandlers/OpBoundsHandler.cpp @@ -0,0 +1,36 @@ +/* + * 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 "../Request.h" +#include "../Response.h" +#include "microhttpd.h" + +using namespace Response; + +bool OpBoundsHandler::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 OpBoundsHandler::handle(Request* request, MHD_Connection* connection, const char* url, + const char* method, const char* upload_data, size_t* upload_data_size) { + SkTArray commands; + SkStrSplit(url, "/", &commands); + + if (!request->hasPicture() || commands.count() != 2) { + return MHD_NO; + } + + int enabled; + sscanf(commands[1].c_str(), "%d", &enabled); + + request->fDebugCanvas->setDrawGpuOpBounds(SkToBool(enabled)); + return SendOK(connection); +} diff --git a/tools/skiaserve/urlhandlers/OpsHandler.cpp b/tools/skiaserve/urlhandlers/OpsHandler.cpp new file mode 100644 index 0000000000..a44e594c6b --- /dev/null +++ b/tools/skiaserve/urlhandlers/OpsHandler.cpp @@ -0,0 +1,39 @@ +/* + * 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 "../Request.h" +#include "../Response.h" +#include "microhttpd.h" + +using namespace Response; + +bool OpsHandler::canHandle(const char* method, const char* url) { + const char* kBasePath = "/batches"; + return 0 == strncmp(url, kBasePath, strlen(kBasePath)); +} + +int OpsHandler::handle(Request* request, MHD_Connection* connection, const char* url, + const char* method, const char* upload_data, size_t* upload_data_size) { + SkTArray commands; + SkStrSplit(url, "/", &commands); + + if (!request->hasPicture() || commands.count() > 1) { + return MHD_NO; + } + + // /batches + if (0 == strcmp(method, MHD_HTTP_METHOD_GET)) { + int n = request->getLastOp(); + + sk_sp data(request->getJsonOpList(n)); + return SendData(connection, data.get(), "application/json"); + } + + return MHD_NO; +} diff --git a/tools/skiaserve/urlhandlers/UrlHandler.h b/tools/skiaserve/urlhandlers/UrlHandler.h index 1536ef33c7..e86e7fca90 100644 --- a/tools/skiaserve/urlhandlers/UrlHandler.h +++ b/tools/skiaserve/urlhandlers/UrlHandler.h @@ -112,9 +112,9 @@ public: }; /* - * Returns a json descripton of all the batches in the image + * Returns a json descripton of all the GPU ops in the image */ -class BatchesHandler : public UrlHandler { +class OpsHandler : public UrlHandler { public: bool canHandle(const char* method, const char* url) override; int handle(Request* request, MHD_Connection* connection, @@ -123,9 +123,9 @@ public: }; /* - * Enables drawing of batch bounds + * Enables drawing of gpu op bounds */ -class BatchBoundsHandler : public UrlHandler { +class OpBoundsHandler : public UrlHandler { public: bool canHandle(const char* method, const char* url) override; int handle(Request* request, MHD_Connection* connection, -- cgit v1.2.3