2016-02-25 16:37:54 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef Request_DEFINED
|
|
|
|
#define Request_DEFINED
|
|
|
|
|
2016-09-22 18:51:24 +00:00
|
|
|
#include "SkTypes.h"
|
|
|
|
|
2016-03-11 19:45:53 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-02-25 16:37:54 +00:00
|
|
|
#include "GrContextFactory.h"
|
2016-03-11 19:45:53 +00:00
|
|
|
#endif
|
2016-02-25 16:37:54 +00:00
|
|
|
|
|
|
|
#include "SkDebugCanvas.h"
|
|
|
|
#include "SkPicture.h"
|
|
|
|
#include "SkStream.h"
|
|
|
|
#include "SkSurface.h"
|
|
|
|
|
|
|
|
#include "UrlDataManager.h"
|
|
|
|
|
2016-03-31 01:56:19 +00:00
|
|
|
namespace sk_gpu_test {
|
2016-03-11 19:45:53 +00:00
|
|
|
class GrContextFactory;
|
2016-03-31 01:56:19 +00:00
|
|
|
}
|
2016-02-25 16:37:54 +00:00
|
|
|
struct MHD_Connection;
|
|
|
|
struct MHD_PostProcessor;
|
|
|
|
|
|
|
|
struct UploadContext {
|
|
|
|
SkDynamicMemoryWStream fStream;
|
|
|
|
MHD_PostProcessor* fPostProcessor;
|
|
|
|
MHD_Connection* connection;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Request {
|
2016-03-11 19:45:53 +00:00
|
|
|
Request(SkString rootUrl);
|
|
|
|
~Request();
|
2016-02-25 16:37:54 +00:00
|
|
|
|
2016-12-20 21:48:59 +00:00
|
|
|
// draws to canvas operation N, highlighting the Mth GrOp. m = -1 means no highlight.
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> drawToPng(int n, int m = -1);
|
|
|
|
sk_sp<SkData> writeOutSkp();
|
2016-02-25 18:50:28 +00:00
|
|
|
SkCanvas* getCanvas();
|
|
|
|
SkBitmap* getBitmapFromCanvas(SkCanvas* canvas);
|
2016-02-26 16:36:25 +00:00
|
|
|
bool enableGPU(bool enable);
|
2016-10-17 19:20:02 +00:00
|
|
|
bool setOverdraw(bool enable);
|
2016-04-19 17:16:53 +00:00
|
|
|
bool setColorMode(int mode);
|
2016-02-26 16:22:49 +00:00
|
|
|
bool hasPicture() const { return SkToBool(fPicture.get()); }
|
|
|
|
int getLastOp() const { return fDebugCanvas->getSize() - 1; }
|
|
|
|
|
2016-02-29 13:35:04 +00:00
|
|
|
bool initPictureFromStream(SkStream*);
|
|
|
|
|
2016-02-26 16:22:49 +00:00
|
|
|
// Returns the json list of ops as an SkData
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> getJsonOps(int n);
|
2016-02-26 16:22:49 +00:00
|
|
|
|
2016-12-20 21:48:59 +00:00
|
|
|
// Returns a json list of ops as an SkData
|
|
|
|
sk_sp<SkData> getJsonOpList(int n);
|
2016-02-25 18:50:28 +00:00
|
|
|
|
2016-02-26 16:36:25 +00:00
|
|
|
// Returns json with the viewMatrix and clipRect
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> getJsonInfo(int n);
|
2016-02-26 16:36:25 +00:00
|
|
|
|
2016-03-09 18:07:02 +00:00
|
|
|
// returns the color of the pixel at (x,y) in the canvas
|
|
|
|
SkColor getPixel(int x, int y);
|
2016-02-25 18:50:28 +00:00
|
|
|
|
2016-02-25 16:37:54 +00:00
|
|
|
UploadContext* fUploadContext;
|
2016-11-12 14:06:55 +00:00
|
|
|
std::unique_ptr<SkDebugCanvas> fDebugCanvas;
|
2016-02-26 16:36:25 +00:00
|
|
|
UrlDataManager fUrlDataManager;
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2016-02-26 16:36:25 +00:00
|
|
|
private:
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> writeCanvasToPng(SkCanvas* canvas);
|
2016-03-02 16:32:37 +00:00
|
|
|
void drawToCanvas(int n, int m = -1);
|
2016-02-26 16:36:25 +00:00
|
|
|
SkSurface* createCPUSurface();
|
|
|
|
SkSurface* createGPUSurface();
|
2016-03-10 21:29:36 +00:00
|
|
|
SkIRect getBounds();
|
|
|
|
GrContext* getContext();
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2016-03-18 14:25:55 +00:00
|
|
|
sk_sp<SkPicture> fPicture;
|
2016-03-31 01:56:19 +00:00
|
|
|
sk_gpu_test::GrContextFactory* fContextFactory;
|
2016-11-03 20:26:13 +00:00
|
|
|
sk_sp<SkSurface> fSurface;
|
2016-02-25 16:37:54 +00:00
|
|
|
bool fGPUEnabled;
|
2016-10-17 19:20:02 +00:00
|
|
|
bool fOverdraw;
|
2016-04-19 17:16:53 +00:00
|
|
|
int fColorMode;
|
2016-02-25 16:37:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|