blob: f3af6b72ee6eff6d95dbdad8421d2fc00dcc5e5f [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);
brianosman78312952016-04-19 10:16:53 -070044 bool setColorMode(int mode);
joshualitt1e5884b2016-02-26 08:22:49 -080045 bool hasPicture() const { return SkToBool(fPicture.get()); }
46 int getLastOp() const { return fDebugCanvas->getSize() - 1; }
47
joshualitt6bc96792016-02-29 05:35:04 -080048 bool initPictureFromStream(SkStream*);
49
joshualitt1e5884b2016-02-26 08:22:49 -080050 // Returns the json list of ops as an SkData
51 SkData* getJsonOps(int n);
52
53 // Returns a json list of batches as an SkData
54 SkData* getJsonBatchList(int n);
joshualitt4dcbe432016-02-25 10:50:28 -080055
joshualittee5348b2016-02-26 08:36:25 -080056 // Returns json with the viewMatrix and clipRect
57 SkData* getJsonInfo(int n);
58
joshualitte0449cf2016-03-09 10:07:02 -080059 // returns the color of the pixel at (x,y) in the canvas
60 SkColor getPixel(int x, int y);
joshualitt4dcbe432016-02-25 10:50:28 -080061
joshualitt24dd6872016-02-25 08:37:54 -080062 UploadContext* fUploadContext;
joshualitt24dd6872016-02-25 08:37:54 -080063 SkAutoTUnref<SkDebugCanvas> fDebugCanvas;
joshualittee5348b2016-02-26 08:36:25 -080064 UrlDataManager fUrlDataManager;
halcanary9d524f22016-03-29 09:03:52 -070065
joshualittee5348b2016-02-26 08:36:25 -080066private:
joshualitt6bc96792016-02-29 05:35:04 -080067 SkData* writeCanvasToPng(SkCanvas* canvas);
joshualitt46b301d2016-03-02 08:32:37 -080068 void drawToCanvas(int n, int m = -1);
joshualittee5348b2016-02-26 08:36:25 -080069 SkSurface* createCPUSurface();
70 SkSurface* createGPUSurface();
joshualittae47aee2016-03-10 13:29:36 -080071 SkIRect getBounds();
72 GrContext* getContext();
halcanary9d524f22016-03-29 09:03:52 -070073
reedca2622b2016-03-18 07:25:55 -070074 sk_sp<SkPicture> fPicture;
bsalomon3724e572016-03-30 18:56:19 -070075 sk_gpu_test::GrContextFactory* fContextFactory;
joshualitt24dd6872016-02-25 08:37:54 -080076 SkAutoTUnref<SkSurface> fSurface;
joshualitt24dd6872016-02-25 08:37:54 -080077 bool fGPUEnabled;
brianosman78312952016-04-19 10:16:53 -070078 int fColorMode;
joshualitt24dd6872016-02-25 08:37:54 -080079};
80
81#endif