2016-02-25 19:28:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2017-02-10 14:06:38 +00:00
|
|
|
#ifndef UrlHandler_DEFINED
|
|
|
|
#define UrlHandler_DEFINED
|
2016-02-25 19:28:18 +00:00
|
|
|
|
|
|
|
#include "SkColor.h"
|
|
|
|
|
|
|
|
struct MHD_Connection;
|
|
|
|
struct Request;
|
|
|
|
|
|
|
|
class UrlHandler {
|
|
|
|
public:
|
|
|
|
virtual ~UrlHandler() {}
|
|
|
|
virtual bool canHandle(const char* method, const char* url) = 0;
|
|
|
|
virtual int handle(Request* request, MHD_Connection* connection,
|
|
|
|
const char* url, const char* method,
|
|
|
|
const char* upload_data, size_t* upload_data_size) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CmdHandler : 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 ImgHandler : 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 BreakHandler : 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;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
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;
|
|
|
|
int handle(Request* request, MHD_Connection* connection,
|
|
|
|
const char* url, const char* method,
|
|
|
|
const char* upload_data, size_t* upload_data_size) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2016-03-29 16:03:52 +00:00
|
|
|
Controls whether GPU rendering is enabled. Posting to /enableGPU/1 turns GPU on, /enableGPU/0
|
2016-02-25 19:28:18 +00:00
|
|
|
disables it.
|
|
|
|
*/
|
|
|
|
class EnableGPUHandler : 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;
|
2016-10-17 19:20:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Controls whether overdraw rendering is enabled. Posting to /overdraw/1 turns overdraw on,
|
|
|
|
/overdraw/0 disables it.
|
|
|
|
*/
|
|
|
|
class OverdrawHandler : 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;
|
2016-02-25 19:28:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PostHandler : 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 DownloadHandler : 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 InfoHandler : 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 DataHandler : 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;
|
|
|
|
};
|
|
|
|
|
2016-02-26 16:22:49 +00:00
|
|
|
/*
|
2016-12-20 21:48:59 +00:00
|
|
|
* Returns a json descripton of all the GPU ops in the image
|
2016-02-26 16:22:49 +00:00
|
|
|
*/
|
2016-12-20 21:48:59 +00:00
|
|
|
class OpsHandler : public UrlHandler {
|
2016-02-26 16:22:49 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2016-02-29 19:15:06 +00:00
|
|
|
/*
|
2016-12-20 21:48:59 +00:00
|
|
|
* Enables drawing of gpu op bounds
|
2016-02-29 19:15:06 +00:00
|
|
|
*/
|
2016-12-20 21:48:59 +00:00
|
|
|
class OpBoundsHandler : public UrlHandler {
|
2016-02-29 19:15:06 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2016-02-25 19:28:18 +00:00
|
|
|
class RootHandler : 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;
|
|
|
|
};
|
2016-04-19 17:16:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
};
|
2016-04-19 19:47:54 +00:00
|
|
|
|
2016-05-31 19:51:31 +00:00
|
|
|
class QuitHandler : 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;
|
|
|
|
};
|
|
|
|
|
2017-02-10 14:06:38 +00:00
|
|
|
#endif // UrlHandler_DEFINED
|