joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | struct MHD_Connection; |
| 21 | struct MHD_PostProcessor; |
| 22 | |
| 23 | struct UploadContext { |
| 24 | SkDynamicMemoryWStream fStream; |
| 25 | MHD_PostProcessor* fPostProcessor; |
| 26 | MHD_Connection* connection; |
| 27 | }; |
| 28 | |
| 29 | struct Request { |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 30 | Request(SkString rootUrl); |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 31 | |
joshualitt | 46b301d | 2016-03-02 08:32:37 -0800 | [diff] [blame^] | 32 | // draws to skia draw op N, highlighting the Mth batch(-1 means no highlight) |
| 33 | SkData* drawToPng(int n, int m = -1); |
joshualitt | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 34 | SkCanvas* getCanvas(); |
joshualitt | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 35 | SkBitmap* getBitmapFromCanvas(SkCanvas* canvas); |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 36 | bool enableGPU(bool enable); |
joshualitt | 1e5884b | 2016-02-26 08:22:49 -0800 | [diff] [blame] | 37 | bool hasPicture() const { return SkToBool(fPicture.get()); } |
| 38 | int getLastOp() const { return fDebugCanvas->getSize() - 1; } |
| 39 | |
joshualitt | 6bc9679 | 2016-02-29 05:35:04 -0800 | [diff] [blame] | 40 | bool initPictureFromStream(SkStream*); |
| 41 | |
joshualitt | 1e5884b | 2016-02-26 08:22:49 -0800 | [diff] [blame] | 42 | // 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); |
joshualitt | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 47 | |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 48 | // Returns json with the viewMatrix and clipRect |
| 49 | SkData* getJsonInfo(int n); |
| 50 | |
joshualitt | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 51 | // TODO probably want to make this configurable |
| 52 | static const int kImageWidth; |
| 53 | static const int kImageHeight; |
| 54 | |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 55 | UploadContext* fUploadContext; |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 56 | SkAutoTUnref<SkDebugCanvas> fDebugCanvas; |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 57 | UrlDataManager fUrlDataManager; |
| 58 | |
| 59 | private: |
joshualitt | 6bc9679 | 2016-02-29 05:35:04 -0800 | [diff] [blame] | 60 | SkData* writeCanvasToPng(SkCanvas* canvas); |
joshualitt | 46b301d | 2016-03-02 08:32:37 -0800 | [diff] [blame^] | 61 | void drawToCanvas(int n, int m = -1); |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 62 | SkSurface* createCPUSurface(); |
| 63 | SkSurface* createGPUSurface(); |
joshualitt | b95c772 | 2016-02-29 07:44:02 -0800 | [diff] [blame] | 64 | GrAuditTrail* getAuditTrail(SkCanvas*); |
| 65 | void cleanupAuditTrail(SkCanvas*); |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 66 | |
joshualitt | 6bc9679 | 2016-02-29 05:35:04 -0800 | [diff] [blame] | 67 | SkAutoTUnref<SkPicture> fPicture; |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 68 | SkAutoTDelete<GrContextFactory> fContextFactory; |
| 69 | SkAutoTUnref<SkSurface> fSurface; |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 70 | bool fGPUEnabled; |
| 71 | }; |
| 72 | |
| 73 | #endif |
| 74 | |