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