| OLD | NEW | 
|   1 /* |   1 /* | 
|   2  * Copyright 2016 Google Inc. |   2  * Copyright 2016 Google Inc. | 
|   3  * |   3  * | 
|   4  * Use of this source code is governed by a BSD-style license that can be |   4  * Use of this source code is governed by a BSD-style license that can be | 
|   5  * found in the LICENSE file. |   5  * found in the LICENSE file. | 
|   6  */ |   6  */ | 
|   7  |   7  | 
|   8 #ifndef Request_DEFINED |   8 #ifndef Request_DEFINED | 
|   9 #define Request_DEFINED |   9 #define Request_DEFINED | 
|  10  |  10  | 
|  11 #include "GrContextFactory.h" |  11 #include "GrContextFactory.h" | 
|  12  |  12  | 
|  13 #include "SkDebugCanvas.h" |  13 #include "SkDebugCanvas.h" | 
|  14 #include "SkPicture.h" |  14 #include "SkPicture.h" | 
|  15 #include "SkStream.h" |  15 #include "SkStream.h" | 
|  16 #include "SkSurface.h" |  16 #include "SkSurface.h" | 
|  17  |  17  | 
|  18 #include "UrlDataManager.h" |  18 #include "UrlDataManager.h" | 
|  19  |  19  | 
|  20 struct MHD_Connection; |  20 struct MHD_Connection; | 
|  21 struct MHD_PostProcessor; |  21 struct MHD_PostProcessor; | 
|  22  |  22  | 
|  23 struct UploadContext { |  23 struct UploadContext { | 
|  24     SkDynamicMemoryWStream fStream; |  24     SkDynamicMemoryWStream fStream; | 
|  25     MHD_PostProcessor* fPostProcessor; |  25     MHD_PostProcessor* fPostProcessor; | 
|  26     MHD_Connection* connection; |  26     MHD_Connection* connection; | 
|  27 }; |  27 }; | 
|  28  |  28  | 
|  29 struct Request { |  29 struct Request { | 
|  30     Request(SkString rootUrl)  |  30     Request(SkString rootUrl);  | 
|  31     : fUploadContext(nullptr) |  | 
|  32     , fUrlDataManager(rootUrl) |  | 
|  33     , fGPUEnabled(false) {} |  | 
|  34  |  31  | 
|  35     SkSurface* createCPUSurface(); |  | 
|  36     SkSurface* createGPUSurface(); |  | 
|  37     SkData* drawToPng(int n); |  32     SkData* drawToPng(int n); | 
|  38     void drawToCanvas(int n); |  33     void drawToCanvas(int n); | 
|  39     SkCanvas* getCanvas(); |  34     SkCanvas* getCanvas(); | 
|  40     SkData* writeCanvasToPng(SkCanvas* canvas); |  35     SkData* writeCanvasToPng(SkCanvas* canvas); | 
|  41     SkBitmap* getBitmapFromCanvas(SkCanvas* canvas); |  36     SkBitmap* getBitmapFromCanvas(SkCanvas* canvas); | 
 |  37     bool enableGPU(bool enable); | 
|  42     bool hasPicture() const { return SkToBool(fPicture.get()); } |  38     bool hasPicture() const { return SkToBool(fPicture.get()); } | 
|  43     int getLastOp() const { return fDebugCanvas->getSize() - 1; } |  39     int getLastOp() const { return fDebugCanvas->getSize() - 1; } | 
|  44  |  40  | 
|  45     // Returns the json list of ops as an SkData |  41     // Returns the json list of ops as an SkData | 
|  46     SkData* getJsonOps(int n); |  42     SkData* getJsonOps(int n); | 
|  47  |  43  | 
|  48     // Returns a json list of batches as an SkData |  44     // Returns a json list of batches as an SkData | 
|  49     SkData* getJsonBatchList(int n); |  45     SkData* getJsonBatchList(int n); | 
|  50  |  46  | 
 |  47     // Returns json with the viewMatrix and clipRect | 
 |  48     SkData* getJsonInfo(int n); | 
 |  49  | 
|  51     // TODO probably want to make this configurable |  50     // TODO probably want to make this configurable | 
|  52     static const int kImageWidth; |  51     static const int kImageWidth; | 
|  53     static const int kImageHeight; |  52     static const int kImageHeight; | 
|  54  |  53  | 
|  55     UploadContext* fUploadContext; |  54     UploadContext* fUploadContext; | 
|  56     SkAutoTUnref<SkPicture> fPicture; |  55     SkAutoTUnref<SkPicture> fPicture; | 
|  57     SkAutoTUnref<SkDebugCanvas> fDebugCanvas; |  56     SkAutoTUnref<SkDebugCanvas> fDebugCanvas; | 
 |  57     UrlDataManager fUrlDataManager; | 
 |  58      | 
 |  59 private: | 
 |  60     SkSurface* createCPUSurface(); | 
 |  61     SkSurface* createGPUSurface(); | 
 |  62      | 
|  58     SkAutoTDelete<GrContextFactory> fContextFactory; |  63     SkAutoTDelete<GrContextFactory> fContextFactory; | 
|  59     SkAutoTUnref<SkSurface> fSurface; |  64     SkAutoTUnref<SkSurface> fSurface; | 
|  60     UrlDataManager fUrlDataManager; |  | 
|  61     bool fGPUEnabled; |  65     bool fGPUEnabled; | 
|  62 }; |  66 }; | 
|  63  |  67  | 
|  64 #endif |  68 #endif | 
|  65  |  69  | 
| OLD | NEW |