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 | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 32 | SkData* drawToPng(int n); |
joshualitt | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 33 | SkCanvas* getCanvas(); |
joshualitt | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 34 | SkBitmap* getBitmapFromCanvas(SkCanvas* canvas); |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 35 | bool enableGPU(bool enable); |
joshualitt | 1e5884b | 2016-02-26 08:22:49 -0800 | [diff] [blame] | 36 | bool hasPicture() const { return SkToBool(fPicture.get()); } |
| 37 | int getLastOp() const { return fDebugCanvas->getSize() - 1; } |
| 38 | |
joshualitt | 6bc9679 | 2016-02-29 05:35:04 -0800 | [diff] [blame^] | 39 | bool initPictureFromStream(SkStream*); |
| 40 | |
joshualitt | 1e5884b | 2016-02-26 08:22:49 -0800 | [diff] [blame] | 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); |
joshualitt | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 46 | |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 47 | // Returns json with the viewMatrix and clipRect |
| 48 | SkData* getJsonInfo(int n); |
| 49 | |
joshualitt | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 50 | // TODO probably want to make this configurable |
| 51 | static const int kImageWidth; |
| 52 | static const int kImageHeight; |
| 53 | |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 54 | UploadContext* fUploadContext; |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 55 | SkAutoTUnref<SkDebugCanvas> fDebugCanvas; |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 56 | UrlDataManager fUrlDataManager; |
| 57 | |
| 58 | private: |
joshualitt | 6bc9679 | 2016-02-29 05:35:04 -0800 | [diff] [blame^] | 59 | SkData* writeCanvasToPng(SkCanvas* canvas); |
| 60 | void drawToCanvas(int n); |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 61 | SkSurface* createCPUSurface(); |
| 62 | SkSurface* createGPUSurface(); |
joshualitt | 9b48a6e | 2016-02-29 05:20:38 -0800 | [diff] [blame] | 63 | GrAuditTrail* getAuditTrail(SkCanvas*); |
| 64 | void cleanupAuditTrail(SkCanvas*); |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 65 | |
joshualitt | 6bc9679 | 2016-02-29 05:35:04 -0800 | [diff] [blame^] | 66 | SkAutoTUnref<SkPicture> fPicture; |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 67 | SkAutoTDelete<GrContextFactory> fContextFactory; |
| 68 | SkAutoTUnref<SkSurface> fSurface; |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 69 | bool fGPUEnabled; |
| 70 | }; |
| 71 | |
| 72 | #endif |
| 73 | |