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-03-02 16:32:37 +00:00
|
|
|
// draws to skia draw op N, highlighting the Mth batch(-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
|
|
|
|
|
|
|
// Returns a json list of batches as an SkData
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> getJsonBatchList(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;
|
|
|
|
SkAutoTUnref<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-02-25 16:37:54 +00:00
|
|
|
SkAutoTUnref<SkSurface> fSurface;
|
|
|
|
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
|