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 | |
joshualitt | 4083610 | 2016-03-11 11:45:53 -0800 | [diff] [blame^] | 11 | #if SK_SUPPORT_GPU |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 12 | #include "GrContextFactory.h" |
joshualitt | 4083610 | 2016-03-11 11:45:53 -0800 | [diff] [blame^] | 13 | #endif |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 14 | |
| 15 | #include "SkDebugCanvas.h" |
| 16 | #include "SkPicture.h" |
| 17 | #include "SkStream.h" |
| 18 | #include "SkSurface.h" |
| 19 | |
| 20 | #include "UrlDataManager.h" |
| 21 | |
joshualitt | 4083610 | 2016-03-11 11:45:53 -0800 | [diff] [blame^] | 22 | class GrContextFactory; |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 23 | struct MHD_Connection; |
| 24 | struct MHD_PostProcessor; |
| 25 | |
| 26 | struct UploadContext { |
| 27 | SkDynamicMemoryWStream fStream; |
| 28 | MHD_PostProcessor* fPostProcessor; |
| 29 | MHD_Connection* connection; |
| 30 | }; |
| 31 | |
| 32 | struct Request { |
joshualitt | 4083610 | 2016-03-11 11:45:53 -0800 | [diff] [blame^] | 33 | Request(SkString rootUrl); |
| 34 | ~Request(); |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 35 | |
joshualitt | 46b301d | 2016-03-02 08:32:37 -0800 | [diff] [blame] | 36 | // draws to skia draw op N, highlighting the Mth batch(-1 means no highlight) |
| 37 | SkData* drawToPng(int n, int m = -1); |
joshualitt | e0449cf | 2016-03-09 10:07:02 -0800 | [diff] [blame] | 38 | SkData* writeOutSkp(); |
joshualitt | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 39 | SkCanvas* getCanvas(); |
joshualitt | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 40 | SkBitmap* getBitmapFromCanvas(SkCanvas* canvas); |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 41 | bool enableGPU(bool enable); |
joshualitt | 1e5884b | 2016-02-26 08:22:49 -0800 | [diff] [blame] | 42 | bool hasPicture() const { return SkToBool(fPicture.get()); } |
| 43 | int getLastOp() const { return fDebugCanvas->getSize() - 1; } |
| 44 | |
joshualitt | 6bc9679 | 2016-02-29 05:35:04 -0800 | [diff] [blame] | 45 | bool initPictureFromStream(SkStream*); |
| 46 | |
joshualitt | 1e5884b | 2016-02-26 08:22:49 -0800 | [diff] [blame] | 47 | // Returns the json list of ops as an SkData |
| 48 | SkData* getJsonOps(int n); |
| 49 | |
| 50 | // Returns a json list of batches as an SkData |
| 51 | SkData* getJsonBatchList(int n); |
joshualitt | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 52 | |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 53 | // Returns json with the viewMatrix and clipRect |
| 54 | SkData* getJsonInfo(int n); |
| 55 | |
joshualitt | e0449cf | 2016-03-09 10:07:02 -0800 | [diff] [blame] | 56 | // returns the color of the pixel at (x,y) in the canvas |
| 57 | SkColor getPixel(int x, int y); |
joshualitt | 4dcbe43 | 2016-02-25 10:50:28 -0800 | [diff] [blame] | 58 | |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 59 | UploadContext* fUploadContext; |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 60 | SkAutoTUnref<SkDebugCanvas> fDebugCanvas; |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 61 | UrlDataManager fUrlDataManager; |
| 62 | |
| 63 | private: |
joshualitt | 6bc9679 | 2016-02-29 05:35:04 -0800 | [diff] [blame] | 64 | SkData* writeCanvasToPng(SkCanvas* canvas); |
joshualitt | 46b301d | 2016-03-02 08:32:37 -0800 | [diff] [blame] | 65 | void drawToCanvas(int n, int m = -1); |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 66 | SkSurface* createCPUSurface(); |
| 67 | SkSurface* createGPUSurface(); |
joshualitt | ae47aee | 2016-03-10 13:29:36 -0800 | [diff] [blame] | 68 | SkIRect getBounds(); |
| 69 | GrContext* getContext(); |
joshualitt | ee5348b | 2016-02-26 08:36:25 -0800 | [diff] [blame] | 70 | |
joshualitt | 6bc9679 | 2016-02-29 05:35:04 -0800 | [diff] [blame] | 71 | SkAutoTUnref<SkPicture> fPicture; |
joshualitt | 4083610 | 2016-03-11 11:45:53 -0800 | [diff] [blame^] | 72 | GrContextFactory* fContextFactory; |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 73 | SkAutoTUnref<SkSurface> fSurface; |
joshualitt | 24dd687 | 2016-02-25 08:37:54 -0800 | [diff] [blame] | 74 | bool fGPUEnabled; |
| 75 | }; |
| 76 | |
| 77 | #endif |
| 78 | |