blob: 568518644c62711e5f4f0f59651c0e2930653960 [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);
33 void drawToCanvas(int n);
34 SkCanvas* getCanvas();
35 SkData* writeCanvasToPng(SkCanvas* canvas);
36 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
41 // 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;
55 SkAutoTUnref<SkPicture> fPicture;
56 SkAutoTUnref<SkDebugCanvas> fDebugCanvas;
joshualittee5348b2016-02-26 08:36:25 -080057 UrlDataManager fUrlDataManager;
58
59private:
60 SkSurface* createCPUSurface();
61 SkSurface* createGPUSurface();
62
joshualitt24dd6872016-02-25 08:37:54 -080063 SkAutoTDelete<GrContextFactory> fContextFactory;
64 SkAutoTUnref<SkSurface> fSurface;
joshualitt24dd6872016-02-25 08:37:54 -080065 bool fGPUEnabled;
66};
67
68#endif
69