blob: 52ebf25c2f0d0d1a0fce9ca213b551910e89e421 [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
joshualitt40836102016-03-11 11:45:53 -080022class GrContextFactory;
joshualitt24dd6872016-02-25 08:37:54 -080023struct MHD_Connection;
24struct MHD_PostProcessor;
25
26struct UploadContext {
27 SkDynamicMemoryWStream fStream;
28 MHD_PostProcessor* fPostProcessor;
29 MHD_Connection* connection;
30};
31
32struct Request {
joshualitt40836102016-03-11 11:45:53 -080033 Request(SkString rootUrl);
34 ~Request();
joshualitt24dd6872016-02-25 08:37:54 -080035
joshualitt46b301d2016-03-02 08:32:37 -080036 // draws to skia draw op N, highlighting the Mth batch(-1 means no highlight)
37 SkData* drawToPng(int n, int m = -1);
joshualitte0449cf2016-03-09 10:07:02 -080038 SkData* writeOutSkp();
joshualitt4dcbe432016-02-25 10:50:28 -080039 SkCanvas* getCanvas();
joshualitt4dcbe432016-02-25 10:50:28 -080040 SkBitmap* getBitmapFromCanvas(SkCanvas* canvas);
joshualittee5348b2016-02-26 08:36:25 -080041 bool enableGPU(bool enable);
joshualitt1e5884b2016-02-26 08:22:49 -080042 bool hasPicture() const { return SkToBool(fPicture.get()); }
43 int getLastOp() const { return fDebugCanvas->getSize() - 1; }
44
joshualitt6bc96792016-02-29 05:35:04 -080045 bool initPictureFromStream(SkStream*);
46
joshualitt1e5884b2016-02-26 08:22:49 -080047 // Returns the json list of ops as an SkData
48 SkData* getJsonOps(int n);
49
50 // Returns a json list of batches as an SkData
51 SkData* getJsonBatchList(int n);
joshualitt4dcbe432016-02-25 10:50:28 -080052
joshualittee5348b2016-02-26 08:36:25 -080053 // Returns json with the viewMatrix and clipRect
54 SkData* getJsonInfo(int n);
55
joshualitte0449cf2016-03-09 10:07:02 -080056 // returns the color of the pixel at (x,y) in the canvas
57 SkColor getPixel(int x, int y);
joshualitt4dcbe432016-02-25 10:50:28 -080058
joshualitt24dd6872016-02-25 08:37:54 -080059 UploadContext* fUploadContext;
joshualitt24dd6872016-02-25 08:37:54 -080060 SkAutoTUnref<SkDebugCanvas> fDebugCanvas;
joshualittee5348b2016-02-26 08:36:25 -080061 UrlDataManager fUrlDataManager;
62
63private:
joshualitt6bc96792016-02-29 05:35:04 -080064 SkData* writeCanvasToPng(SkCanvas* canvas);
joshualitt46b301d2016-03-02 08:32:37 -080065 void drawToCanvas(int n, int m = -1);
joshualittee5348b2016-02-26 08:36:25 -080066 SkSurface* createCPUSurface();
67 SkSurface* createGPUSurface();
joshualittae47aee2016-03-10 13:29:36 -080068 SkIRect getBounds();
69 GrContext* getContext();
joshualittee5348b2016-02-26 08:36:25 -080070
joshualitt6bc96792016-02-29 05:35:04 -080071 SkAutoTUnref<SkPicture> fPicture;
joshualitt40836102016-03-11 11:45:53 -080072 GrContextFactory* fContextFactory;
joshualitt24dd6872016-02-25 08:37:54 -080073 SkAutoTUnref<SkSurface> fSurface;
joshualitt24dd6872016-02-25 08:37:54 -080074 bool fGPUEnabled;
75};
76
77#endif
78