blob: 0b974e74237460e385a36f10126f8c6b6bfc208a [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);
joshualitt4dcbe432016-02-25 10:50:28 -080034 SkCanvas* getCanvas();
joshualitt4dcbe432016-02-25 10:50:28 -080035 SkBitmap* getBitmapFromCanvas(SkCanvas* canvas);
joshualittee5348b2016-02-26 08:36:25 -080036 bool enableGPU(bool enable);
joshualitt1e5884b2016-02-26 08:22:49 -080037 bool hasPicture() const { return SkToBool(fPicture.get()); }
38 int getLastOp() const { return fDebugCanvas->getSize() - 1; }
39
joshualitt6bc96792016-02-29 05:35:04 -080040 bool initPictureFromStream(SkStream*);
41
joshualitt1e5884b2016-02-26 08:22:49 -080042 // Returns the json list of ops as an SkData
43 SkData* getJsonOps(int n);
44
45 // Returns a json list of batches as an SkData
46 SkData* getJsonBatchList(int n);
joshualitt4dcbe432016-02-25 10:50:28 -080047
joshualittee5348b2016-02-26 08:36:25 -080048 // Returns json with the viewMatrix and clipRect
49 SkData* getJsonInfo(int n);
50
joshualitt4dcbe432016-02-25 10:50:28 -080051 // TODO probably want to make this configurable
52 static const int kImageWidth;
53 static const int kImageHeight;
54
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