blob: 60a59a7b1cd82a9b935f9a064d106f6a13ddf1bd [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
joshualitt4dcbe432016-02-25 10:50:28 -080032 SkData* drawToPng(int n);
joshualitt4dcbe432016-02-25 10:50:28 -080033 SkCanvas* getCanvas();
joshualitt4dcbe432016-02-25 10:50:28 -080034 SkBitmap* getBitmapFromCanvas(SkCanvas* canvas);
joshualittee5348b2016-02-26 08:36:25 -080035 bool enableGPU(bool enable);
joshualitt1e5884b2016-02-26 08:22:49 -080036 bool hasPicture() const { return SkToBool(fPicture.get()); }
37 int getLastOp() const { return fDebugCanvas->getSize() - 1; }
38
joshualitt6bc96792016-02-29 05:35:04 -080039 bool initPictureFromStream(SkStream*);
40
joshualitt1e5884b2016-02-26 08:22:49 -080041 // Returns the json list of ops as an SkData
42 SkData* getJsonOps(int n);
43
44 // Returns a json list of batches as an SkData
45 SkData* getJsonBatchList(int n);
joshualitt4dcbe432016-02-25 10:50:28 -080046
joshualittee5348b2016-02-26 08:36:25 -080047 // Returns json with the viewMatrix and clipRect
48 SkData* getJsonInfo(int n);
49
joshualitt4dcbe432016-02-25 10:50:28 -080050 // TODO probably want to make this configurable
51 static const int kImageWidth;
52 static const int kImageHeight;
53
joshualitt24dd6872016-02-25 08:37:54 -080054 UploadContext* fUploadContext;
joshualitt24dd6872016-02-25 08:37:54 -080055 SkAutoTUnref<SkDebugCanvas> fDebugCanvas;
joshualittee5348b2016-02-26 08:36:25 -080056 UrlDataManager fUrlDataManager;
57
58private:
joshualitt6bc96792016-02-29 05:35:04 -080059 SkData* writeCanvasToPng(SkCanvas* canvas);
60 void drawToCanvas(int n);
joshualittee5348b2016-02-26 08:36:25 -080061 SkSurface* createCPUSurface();
62 SkSurface* createGPUSurface();
joshualitt9b48a6e2016-02-29 05:20:38 -080063 GrAuditTrail* getAuditTrail(SkCanvas*);
64 void cleanupAuditTrail(SkCanvas*);
joshualittee5348b2016-02-26 08:36:25 -080065
joshualitt6bc96792016-02-29 05:35:04 -080066 SkAutoTUnref<SkPicture> fPicture;
joshualitt24dd6872016-02-25 08:37:54 -080067 SkAutoTDelete<GrContextFactory> fContextFactory;
68 SkAutoTUnref<SkSurface> fSurface;
joshualitt24dd6872016-02-25 08:37:54 -080069 bool fGPUEnabled;
70};
71
72#endif
73