blob: 0a2b17a401dc3a4b0a9217ce6b50e058a9597fb6 [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
11#include "GrContextFactory.h"
12
13#include "SkDebugCanvas.h"
14#include "SkPicture.h"
15#include "SkStream.h"
16#include "SkSurface.h"
17
18#include "UrlDataManager.h"
19
20struct MHD_Connection;
21struct MHD_PostProcessor;
22
23struct UploadContext {
24 SkDynamicMemoryWStream fStream;
25 MHD_PostProcessor* fPostProcessor;
26 MHD_Connection* connection;
27};
28
29struct Request {
joshualittee5348b2016-02-26 08:36:25 -080030 Request(SkString rootUrl);
joshualitt24dd6872016-02-25 08:37:54 -080031
joshualitt46b301d2016-03-02 08:32:37 -080032 // draws to skia draw op N, highlighting the Mth batch(-1 means no highlight)
33 SkData* drawToPng(int n, int m = -1);
joshualitte0449cf2016-03-09 10:07:02 -080034 SkData* writeOutSkp();
joshualitt4dcbe432016-02-25 10:50:28 -080035 SkCanvas* getCanvas();
joshualitt4dcbe432016-02-25 10:50:28 -080036 SkBitmap* getBitmapFromCanvas(SkCanvas* canvas);
joshualittee5348b2016-02-26 08:36:25 -080037 bool enableGPU(bool enable);
joshualitt1e5884b2016-02-26 08:22:49 -080038 bool hasPicture() const { return SkToBool(fPicture.get()); }
39 int getLastOp() const { return fDebugCanvas->getSize() - 1; }
40
joshualitt6bc96792016-02-29 05:35:04 -080041 bool initPictureFromStream(SkStream*);
42
joshualitt1e5884b2016-02-26 08:22:49 -080043 // Returns the json list of ops as an SkData
44 SkData* getJsonOps(int n);
45
46 // Returns a json list of batches as an SkData
47 SkData* getJsonBatchList(int n);
joshualitt4dcbe432016-02-25 10:50:28 -080048
joshualittee5348b2016-02-26 08:36:25 -080049 // Returns json with the viewMatrix and clipRect
50 SkData* getJsonInfo(int n);
51
joshualitte0449cf2016-03-09 10:07:02 -080052 // returns the color of the pixel at (x,y) in the canvas
53 SkColor getPixel(int x, int y);
joshualitt4dcbe432016-02-25 10:50:28 -080054
joshualitt24dd6872016-02-25 08:37:54 -080055 UploadContext* fUploadContext;
joshualitt24dd6872016-02-25 08:37:54 -080056 SkAutoTUnref<SkDebugCanvas> fDebugCanvas;
joshualittee5348b2016-02-26 08:36:25 -080057 UrlDataManager fUrlDataManager;
58
59private:
joshualitt6bc96792016-02-29 05:35:04 -080060 SkData* writeCanvasToPng(SkCanvas* canvas);
joshualitt46b301d2016-03-02 08:32:37 -080061 void drawToCanvas(int n, int m = -1);
joshualittee5348b2016-02-26 08:36:25 -080062 SkSurface* createCPUSurface();
63 SkSurface* createGPUSurface();
joshualittb95c7722016-02-29 07:44:02 -080064 GrAuditTrail* getAuditTrail(SkCanvas*);
65 void cleanupAuditTrail(SkCanvas*);
joshualittee5348b2016-02-26 08:36:25 -080066
joshualitt6bc96792016-02-29 05:35:04 -080067 SkAutoTUnref<SkPicture> fPicture;
joshualitt24dd6872016-02-25 08:37:54 -080068 SkAutoTDelete<GrContextFactory> fContextFactory;
69 SkAutoTUnref<SkSurface> fSurface;
joshualitt24dd6872016-02-25 08:37:54 -080070 bool fGPUEnabled;
71};
72
73#endif
74