Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
OpBoundsHandler.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
10#include "microhttpd.h"
14
15using namespace skia_private;
16using namespace Response;
17
18bool OpBoundsHandler::canHandle(const char* method, const char* url) {
19 static const char* kBasePath = "/gpuOpBounds/";
20 return 0 == strcmp(method, MHD_HTTP_METHOD_POST) &&
21 0 == strncmp(url, kBasePath, strlen(kBasePath));
22}
23
24int OpBoundsHandler::handle(Request* request, MHD_Connection* connection, const char* url,
25 const char* method, const char* upload_data, size_t* upload_data_size) {
26 TArray<SkString> commands;
27 SkStrSplit(url, "/", &commands);
28
29 if (!request->hasPicture() || commands.size() != 2) {
30 return MHD_NO;
31 }
32
33 int enabled;
34 sscanf(commands[1].c_str(), "%d", &enabled);
35
36 request->fDebugCanvas->setDrawGpuOpBounds(SkToBool(enabled));
37 return SendOK(connection);
38}
void SkStrSplit(const char *str, const char *delimiters, SkStrSplitMode splitMode, TArray< SkString > *out)
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
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
int SendOK(MHD_Connection *connection)
Definition Response.cpp:44