blob: d19c2ba801488e916acca6c4513856130cc2c858 [file] [log] [blame]
joshualitt24dd6872016-02-25 08:37:54 -08001/*
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
8#ifndef Request_DEFINED
9#define Request_DEFINED
10
joshualitt40836102016-03-11 11:45:53 -080011#if SK_SUPPORT_GPU
joshualitt24dd6872016-02-25 08:37:54 -080012#include "GrContextFactory.h"
joshualitt40836102016-03-11 11:45:53 -080013#endif
joshualitt24dd6872016-02-25 08:37:54 -080014
15#include "SkDebugCanvas.h"
16#include "SkPicture.h"
17#include "SkStream.h"
18#include "SkSurface.h"
19
20#include "UrlDataManager.h"
21
bsalomon3724e572016-03-30 18:56:19 -070022namespace sk_gpu_test {
joshualitt40836102016-03-11 11:45:53 -080023class GrContextFactory;
bsalomon3724e572016-03-30 18:56:19 -070024}
joshualitt24dd6872016-02-25 08:37:54 -080025struct MHD_Connection;
26struct MHD_PostProcessor;
27
28struct UploadContext {
29 SkDynamicMemoryWStream fStream;
30 MHD_PostProcessor* fPostProcessor;
31 MHD_Connection* connection;
32};
33
34struct Request {
joshualitt40836102016-03-11 11:45:53 -080035 Request(SkString rootUrl);
36 ~Request();
joshualitt24dd6872016-02-25 08:37:54 -080037
joshualitt46b301d2016-03-02 08:32:37 -080038 // draws to skia draw op N, highlighting the Mth batch(-1 means no highlight)
39 SkData* drawToPng(int n, int m = -1);
joshualitte0449cf2016-03-09 10:07:02 -080040 SkData* writeOutSkp();
joshualitt4dcbe432016-02-25 10:50:28 -080041 SkCanvas* getCanvas();
joshualitt4dcbe432016-02-25 10:50:28 -080042 SkBitmap* getBitmapFromCanvas(SkCanvas* canvas);
joshualittee5348b2016-02-26 08:36:25 -080043 bool enableGPU(bool enable);
joshualitt1e5884b2016-02-26 08:22:49 -080044 bool hasPicture() const { return SkToBool(fPicture.get()); }
45 int getLastOp() const { return fDebugCanvas->getSize() - 1; }
46
joshualitt6bc96792016-02-29 05:35:04 -080047 bool initPictureFromStream(SkStream*);
48
joshualitt1e5884b2016-02-26 08:22:49 -080049 // Returns the json list of ops as an SkData
50 SkData* getJsonOps(int n);
51
52 // Returns a json list of batches as an SkData
53 SkData* getJsonBatchList(int n);
joshualitt4dcbe432016-02-25 10:50:28 -080054
joshualittee5348b2016-02-26 08:36:25 -080055 // Returns json with the viewMatrix and clipRect
56 SkData* getJsonInfo(int n);
57
joshualitte0449cf2016-03-09 10:07:02 -080058 // returns the color of the pixel at (x,y) in the canvas
59 SkColor getPixel(int x, int y);
joshualitt4dcbe432016-02-25 10:50:28 -080060
joshualitt24dd6872016-02-25 08:37:54 -080061 UploadContext* fUploadContext;
joshualitt24dd6872016-02-25 08:37:54 -080062 SkAutoTUnref<SkDebugCanvas> fDebugCanvas;
joshualittee5348b2016-02-26 08:36:25 -080063 UrlDataManager fUrlDataManager;
halcanary9d524f22016-03-29 09:03:52 -070064
joshualittee5348b2016-02-26 08:36:25 -080065private:
joshualitt6bc96792016-02-29 05:35:04 -080066 SkData* writeCanvasToPng(SkCanvas* canvas);
joshualitt46b301d2016-03-02 08:32:37 -080067 void drawToCanvas(int n, int m = -1);
joshualittee5348b2016-02-26 08:36:25 -080068 SkSurface* createCPUSurface();
69 SkSurface* createGPUSurface();
joshualittae47aee2016-03-10 13:29:36 -080070 SkIRect getBounds();
71 GrContext* getContext();
halcanary9d524f22016-03-29 09:03:52 -070072
reedca2622b2016-03-18 07:25:55 -070073 sk_sp<SkPicture> fPicture;
bsalomon3724e572016-03-30 18:56:19 -070074 sk_gpu_test::GrContextFactory* fContextFactory;
joshualitt24dd6872016-02-25 08:37:54 -080075 SkAutoTUnref<SkSurface> fSurface;
joshualitt24dd6872016-02-25 08:37:54 -080076 bool fGPUEnabled;
77};
78
79#endif