| caryclark@google.com | 411bb72 | 2012-11-06 21:29:16 +0000 | [diff] [blame] | 1 | /* |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 2 | * Copyright 2012 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 PictureRenderer_DEFINED |
| 9 | #define PictureRenderer_DEFINED |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 10 | |
| scroggo@google.com | 161e1ba | 2013-03-04 16:41:06 +0000 | [diff] [blame] | 11 | #include "SkCanvas.h" |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 12 | #include "SkCountdown.h" |
| caryclark@google.com | a362237 | 2012-11-06 21:26:13 +0000 | [diff] [blame] | 13 | #include "SkDrawFilter.h" |
| keyar@chromium.org | f4959ab | 2012-08-23 20:53:25 +0000 | [diff] [blame] | 14 | #include "SkMath.h" |
| reed@google.com | ea6a306 | 2012-11-06 22:14:54 +0000 | [diff] [blame] | 15 | #include "SkPaint.h" |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 16 | #include "SkPicture.h" |
| robertphillips@google.com | 770963f | 2014-04-18 18:04:41 +0000 | [diff] [blame] | 17 | #include "SkPictureRecorder.h" |
| scroggo@google.com | acfb30e | 2012-09-18 14:32:35 +0000 | [diff] [blame] | 18 | #include "SkRect.h" |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 19 | #include "SkRefCnt.h" |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 20 | #include "SkRunnable.h" |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 21 | #include "SkString.h" |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 22 | #include "SkTDArray.h" |
| 23 | #include "SkThreadPool.h" |
| 24 | #include "SkTypes.h" |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 25 | |
| keyar@chromium.org | 0612564 | 2012-08-20 15:03:33 +0000 | [diff] [blame] | 26 | #if SK_SUPPORT_GPU |
| 27 | #include "GrContextFactory.h" |
| 28 | #include "GrContext.h" |
| 29 | #endif |
| 30 | |
| commit-bot@chromium.org | 90c0fbd | 2014-05-09 03:18:41 +0000 | [diff] [blame] | 31 | #include "image_expectations.h" |
| 32 | |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 33 | class SkBitmap; |
| 34 | class SkCanvas; |
| robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 35 | class SkGLContextHelper; |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 36 | class SkThread; |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 37 | |
| 38 | namespace sk_tools { |
| 39 | |
| scroggo@google.com | cbcef70 | 2012-12-13 22:09:28 +0000 | [diff] [blame] | 40 | class TiledPictureRenderer; |
| 41 | |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 42 | class PictureRenderer : public SkRefCnt { |
| scroggo@google.com | cbcef70 | 2012-12-13 22:09:28 +0000 | [diff] [blame] | 43 | |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 44 | public: |
| keyar@chromium.org | c81686c | 2012-08-20 15:04:04 +0000 | [diff] [blame] | 45 | enum SkDeviceTypes { |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 46 | #if SK_ANGLE |
| 47 | kAngle_DeviceType, |
| 48 | #endif |
| rmistry@google.com | 6ab9673 | 2014-01-06 18:37:24 +0000 | [diff] [blame] | 49 | #if SK_MESA |
| 50 | kMesa_DeviceType, |
| 51 | #endif |
| keyar@chromium.org | c81686c | 2012-08-20 15:04:04 +0000 | [diff] [blame] | 52 | kBitmap_DeviceType, |
| 53 | #if SK_SUPPORT_GPU |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 54 | kGPU_DeviceType, |
| commit-bot@chromium.org | 0fd5270 | 2014-03-07 18:41:14 +0000 | [diff] [blame] | 55 | kNVPR_DeviceType, |
| keyar@chromium.org | c81686c | 2012-08-20 15:04:04 +0000 | [diff] [blame] | 56 | #endif |
| 57 | }; |
| 58 | |
| junov@chromium.org | 9313ca4 | 2012-11-02 18:11:49 +0000 | [diff] [blame] | 59 | enum BBoxHierarchyType { |
| 60 | kNone_BBoxHierarchyType = 0, |
| commit-bot@chromium.org | c22d139 | 2014-02-03 18:08:33 +0000 | [diff] [blame] | 61 | kQuadTree_BBoxHierarchyType, |
| junov@chromium.org | 9313ca4 | 2012-11-02 18:11:49 +0000 | [diff] [blame] | 62 | kRTree_BBoxHierarchyType, |
| junov@chromium.org | 7b53706 | 2012-11-06 18:58:43 +0000 | [diff] [blame] | 63 | kTileGrid_BBoxHierarchyType, |
| commit-bot@chromium.org | cdd0f92 | 2014-03-11 17:27:07 +0000 | [diff] [blame] | 64 | |
| 65 | kLast_BBoxHierarchyType = kTileGrid_BBoxHierarchyType, |
| junov@chromium.org | 9313ca4 | 2012-11-02 18:11:49 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| caryclark@google.com | a362237 | 2012-11-06 21:26:13 +0000 | [diff] [blame] | 68 | // this uses SkPaint::Flags as a base and adds additional flags |
| 69 | enum DrawFilterFlags { |
| 70 | kNone_DrawFilterFlag = 0, |
| reed@google.com | 881b10b | 2013-05-22 14:03:45 +0000 | [diff] [blame] | 71 | kHinting_DrawFilterFlag = 0x10000, // toggles between no hinting and normal hinting |
| 72 | kSlightHinting_DrawFilterFlag = 0x20000, // toggles between slight and normal hinting |
| 73 | kAAClip_DrawFilterFlag = 0x40000, // toggles between soft and hard clip |
| humper@google.com | 387db0a | 2013-07-09 14:13:04 +0000 | [diff] [blame] | 74 | kMaskFilter_DrawFilterFlag = 0x80000, // toggles on/off mask filters (e.g., blurs) |
| caryclark@google.com | a362237 | 2012-11-06 21:26:13 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| robertphillips@google.com | 4914931 | 2013-07-03 15:34:35 +0000 | [diff] [blame] | 77 | SK_COMPILE_ASSERT(!(kMaskFilter_DrawFilterFlag & SkPaint::kAllFlags), maskfilter_flag_must_be_greater); |
| caryclark@google.com | a362237 | 2012-11-06 21:26:13 +0000 | [diff] [blame] | 78 | SK_COMPILE_ASSERT(!(kHinting_DrawFilterFlag & SkPaint::kAllFlags), |
| 79 | hinting_flag_must_be_greater); |
| 80 | SK_COMPILE_ASSERT(!(kSlightHinting_DrawFilterFlag & SkPaint::kAllFlags), |
| 81 | slight_hinting_flag_must_be_greater); |
| 82 | |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 83 | /** |
| 84 | * Called with each new SkPicture to render. |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 85 | * |
| 86 | * @param pict The SkPicture to render. |
| 87 | * @param outputDir The output directory within which this renderer should write files, |
| 88 | * or NULL if this renderer should not write files at all. |
| 89 | * @param inputFilename The name of the input file we are rendering. |
| 90 | * @param useChecksumBasedFilenames Whether to use checksum-based filenames when writing |
| 91 | * bitmap images to disk. |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 92 | */ |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 93 | virtual void init(SkPicture* pict, const SkString* outputDir, |
| 94 | const SkString* inputFilename, bool useChecksumBasedFilenames); |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 95 | |
| 96 | /** |
| scroggo@google.com | c0d5e54 | 2012-12-13 21:40:48 +0000 | [diff] [blame] | 97 | * Set the viewport so that only the portion listed gets drawn. |
| 98 | */ |
| 99 | void setViewport(SkISize size) { fViewport = size; } |
| 100 | |
| 101 | /** |
| scroggo@google.com | 82ec0b0 | 2012-12-17 19:25:54 +0000 | [diff] [blame] | 102 | * Set the scale factor at which draw the picture. |
| 103 | */ |
| 104 | void setScaleFactor(SkScalar scale) { fScaleFactor = scale; } |
| 105 | |
| 106 | /** |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 107 | * Perform any setup that should done prior to each iteration of render() which should not be |
| 108 | * timed. |
| 109 | */ |
| 110 | virtual void setup() {} |
| 111 | |
| 112 | /** |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 113 | * Perform the work. If this is being called within the context of bench_pictures, |
| 114 | * this is the step that will be timed. |
| 115 | * |
| 116 | * Typically "the work" is rendering an SkPicture into a bitmap, but in some subclasses |
| 117 | * it is recording the source SkPicture into another SkPicture. |
| 118 | * |
| 119 | * If fOutputDir has been specified, the result of the work will be written to that dir. |
| 120 | * |
| 121 | * @param out If non-null, the implementing subclass MAY allocate an SkBitmap, copy the |
| 122 | * output image into it, and return it here. (Some subclasses ignore this parameter) |
| 123 | * @return bool True if rendering succeeded and, if fOutputDir had been specified, the output |
| 124 | * was successfully written to a file. |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 125 | */ |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 126 | virtual bool render(SkBitmap** out = NULL) = 0; |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 127 | |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 128 | /** |
| 129 | * Called once finished with a particular SkPicture, before calling init again, and before |
| 130 | * being done with this Renderer. |
| 131 | */ |
| keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 132 | virtual void end(); |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 133 | |
| scroggo@google.com | cbcef70 | 2012-12-13 22:09:28 +0000 | [diff] [blame] | 134 | /** |
| 135 | * If this PictureRenderer is actually a TiledPictureRender, return a pointer to this as a |
| 136 | * TiledPictureRender so its methods can be called. |
| 137 | */ |
| 138 | virtual TiledPictureRenderer* getTiledRenderer() { return NULL; } |
| 139 | |
| scroggo@google.com | 08085f8 | 2013-01-28 20:40:24 +0000 | [diff] [blame] | 140 | /** |
| 141 | * Resets the GPU's state. Does nothing if the backing is raster. For a GPU renderer, calls |
| commit-bot@chromium.org | 51c040e | 2014-03-11 22:58:00 +0000 | [diff] [blame] | 142 | * flush, swapBuffers and, if callFinish is true, finish. |
| scroggo@google.com | 08085f8 | 2013-01-28 20:40:24 +0000 | [diff] [blame] | 143 | * @param callFinish Whether to call finish. |
| 144 | */ |
| 145 | void resetState(bool callFinish); |
| keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 146 | |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 147 | /** |
| robertphillips@google.com | 94d8f1e | 2013-12-18 17:25:33 +0000 | [diff] [blame] | 148 | * Remove all decoded textures from the CPU caches and all uploaded textures |
| 149 | * from the GPU. |
| 150 | */ |
| 151 | void purgeTextures(); |
| 152 | |
| 153 | /** |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 154 | * Set the backend type. Returns true on success and false on failure. |
| 155 | */ |
| 156 | bool setDeviceType(SkDeviceTypes deviceType) { |
| keyar@chromium.org | c81686c | 2012-08-20 15:04:04 +0000 | [diff] [blame] | 157 | fDeviceType = deviceType; |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 158 | #if SK_SUPPORT_GPU |
| 159 | // In case this function is called more than once |
| 160 | SkSafeUnref(fGrContext); |
| 161 | fGrContext = NULL; |
| 162 | // Set to Native so it will have an initial value. |
| 163 | GrContextFactory::GLContextType glContextType = GrContextFactory::kNative_GLContextType; |
| 164 | #endif |
| 165 | switch(deviceType) { |
| 166 | case kBitmap_DeviceType: |
| 167 | return true; |
| 168 | #if SK_SUPPORT_GPU |
| 169 | case kGPU_DeviceType: |
| 170 | // Already set to GrContextFactory::kNative_GLContextType, above. |
| 171 | break; |
| commit-bot@chromium.org | 0fd5270 | 2014-03-07 18:41:14 +0000 | [diff] [blame] | 172 | case kNVPR_DeviceType: |
| 173 | glContextType = GrContextFactory::kNVPR_GLContextType; |
| 174 | break; |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 175 | #if SK_ANGLE |
| 176 | case kAngle_DeviceType: |
| 177 | glContextType = GrContextFactory::kANGLE_GLContextType; |
| 178 | break; |
| 179 | #endif |
| rmistry@google.com | 6ab9673 | 2014-01-06 18:37:24 +0000 | [diff] [blame] | 180 | #if SK_MESA |
| 181 | case kMesa_DeviceType: |
| 182 | glContextType = GrContextFactory::kMESA_GLContextType; |
| 183 | break; |
| 184 | #endif |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 185 | #endif |
| 186 | default: |
| 187 | // Invalid device type. |
| 188 | return false; |
| 189 | } |
| 190 | #if SK_SUPPORT_GPU |
| 191 | fGrContext = fGrContextFactory.get(glContextType); |
| 192 | if (NULL == fGrContext) { |
| 193 | return false; |
| 194 | } else { |
| 195 | fGrContext->ref(); |
| 196 | return true; |
| 197 | } |
| 198 | #endif |
| keyar@chromium.org | fe6391a | 2012-08-20 15:03:41 +0000 | [diff] [blame] | 199 | } |
| 200 | |
| jvanverth@google.com | f6a9033 | 2013-05-02 12:39:37 +0000 | [diff] [blame] | 201 | #if SK_SUPPORT_GPU |
| 202 | void setSampleCount(int sampleCount) { |
| 203 | fSampleCount = sampleCount; |
| 204 | } |
| 205 | #endif |
| 206 | |
| caryclark@google.com | e3e940c | 2012-11-07 16:42:17 +0000 | [diff] [blame] | 207 | void setDrawFilters(DrawFilterFlags const * const filters, const SkString& configName) { |
| 208 | memcpy(fDrawFilters, filters, sizeof(fDrawFilters)); |
| caryclark@google.com | a362237 | 2012-11-06 21:26:13 +0000 | [diff] [blame] | 209 | fDrawFiltersConfig = configName; |
| 210 | } |
| 211 | |
| junov@chromium.org | 9313ca4 | 2012-11-02 18:11:49 +0000 | [diff] [blame] | 212 | void setBBoxHierarchyType(BBoxHierarchyType bbhType) { |
| 213 | fBBoxHierarchyType = bbhType; |
| 214 | } |
| 215 | |
| junov@chromium.org | e286e84 | 2013-03-13 17:27:16 +0000 | [diff] [blame] | 216 | BBoxHierarchyType getBBoxHierarchyType() { return fBBoxHierarchyType; } |
| 217 | |
| junov@chromium.org | 7b53706 | 2012-11-06 18:58:43 +0000 | [diff] [blame] | 218 | void setGridSize(int width, int height) { |
| junov@chromium.org | 29b19e5 | 2013-02-27 18:35:16 +0000 | [diff] [blame] | 219 | fGridInfo.fTileInterval.set(width, height); |
| junov@chromium.org | 7b53706 | 2012-11-06 18:58:43 +0000 | [diff] [blame] | 220 | } |
| 221 | |
| commit-bot@chromium.org | 205ce48 | 2014-05-12 15:37:20 +0000 | [diff] [blame^] | 222 | void setJsonSummaryPtr(ImageResultsAndExpectations* jsonSummaryPtr) { |
| commit-bot@chromium.org | a3f882c | 2013-12-13 20:52:36 +0000 | [diff] [blame] | 223 | fJsonSummaryPtr = jsonSummaryPtr; |
| 224 | } |
| 225 | |
| keyar@chromium.org | fe6391a | 2012-08-20 15:03:41 +0000 | [diff] [blame] | 226 | bool isUsingBitmapDevice() { |
| keyar@chromium.org | 78a35c5 | 2012-08-20 15:03:44 +0000 | [diff] [blame] | 227 | return kBitmap_DeviceType == fDeviceType; |
| keyar@chromium.org | 4ea96c5 | 2012-08-20 15:03:29 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 230 | virtual SkString getPerIterTimeFormat() { return SkString("%.2f"); } |
| 231 | |
| 232 | virtual SkString getNormalTimeFormat() { return SkString("%6.2f"); } |
| 233 | |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 234 | /** |
| 235 | * Reports the configuration of this PictureRenderer. |
| 236 | */ |
| 237 | SkString getConfigName() { |
| 238 | SkString config = this->getConfigNameInternal(); |
| scroggo@google.com | c4013c1 | 2012-12-13 22:07:08 +0000 | [diff] [blame] | 239 | if (!fViewport.isEmpty()) { |
| 240 | config.appendf("_viewport_%ix%i", fViewport.width(), fViewport.height()); |
| 241 | } |
| commit-bot@chromium.org | 9de35eb | 2013-12-20 21:49:33 +0000 | [diff] [blame] | 242 | if (fScaleFactor != SK_Scalar1) { |
| 243 | config.appendf("_scalar_%f", SkScalarToFloat(fScaleFactor)); |
| 244 | } |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 245 | if (kRTree_BBoxHierarchyType == fBBoxHierarchyType) { |
| 246 | config.append("_rtree"); |
| commit-bot@chromium.org | c22d139 | 2014-02-03 18:08:33 +0000 | [diff] [blame] | 247 | } else if (kQuadTree_BBoxHierarchyType == fBBoxHierarchyType) { |
| 248 | config.append("_quadtree"); |
| junov@chromium.org | 7b53706 | 2012-11-06 18:58:43 +0000 | [diff] [blame] | 249 | } else if (kTileGrid_BBoxHierarchyType == fBBoxHierarchyType) { |
| 250 | config.append("_grid"); |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 251 | } |
| 252 | #if SK_SUPPORT_GPU |
| robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 253 | switch (fDeviceType) { |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 254 | case kGPU_DeviceType: |
| jvanverth@google.com | f6a9033 | 2013-05-02 12:39:37 +0000 | [diff] [blame] | 255 | if (fSampleCount) { |
| 256 | config.appendf("_msaa%d", fSampleCount); |
| 257 | } else { |
| 258 | config.append("_gpu"); |
| 259 | } |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 260 | break; |
| commit-bot@chromium.org | 0fd5270 | 2014-03-07 18:41:14 +0000 | [diff] [blame] | 261 | case kNVPR_DeviceType: |
| 262 | config.appendf("_nvprmsaa%d", fSampleCount); |
| 263 | break; |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 264 | #if SK_ANGLE |
| 265 | case kAngle_DeviceType: |
| 266 | config.append("_angle"); |
| 267 | break; |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 268 | #endif |
| rmistry@google.com | 6ab9673 | 2014-01-06 18:37:24 +0000 | [diff] [blame] | 269 | #if SK_MESA |
| 270 | case kMesa_DeviceType: |
| 271 | config.append("_mesa"); |
| 272 | break; |
| 273 | #endif |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 274 | default: |
| 275 | // Assume that no extra info means bitmap. |
| 276 | break; |
| 277 | } |
| robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 278 | #endif |
| caryclark@google.com | a362237 | 2012-11-06 21:26:13 +0000 | [diff] [blame] | 279 | config.append(fDrawFiltersConfig.c_str()); |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 280 | return config; |
| 281 | } |
| 282 | |
| keyar@chromium.org | 4ea96c5 | 2012-08-20 15:03:29 +0000 | [diff] [blame] | 283 | #if SK_SUPPORT_GPU |
| keyar@chromium.org | fe6391a | 2012-08-20 15:03:41 +0000 | [diff] [blame] | 284 | bool isUsingGpuDevice() { |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 285 | switch (fDeviceType) { |
| 286 | case kGPU_DeviceType: |
| commit-bot@chromium.org | 0fd5270 | 2014-03-07 18:41:14 +0000 | [diff] [blame] | 287 | case kNVPR_DeviceType: |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 288 | // fall through |
| 289 | #if SK_ANGLE |
| 290 | case kAngle_DeviceType: |
| rmistry@google.com | 6ab9673 | 2014-01-06 18:37:24 +0000 | [diff] [blame] | 291 | // fall through |
| 292 | #endif |
| 293 | #if SK_MESA |
| 294 | case kMesa_DeviceType: |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 295 | #endif |
| 296 | return true; |
| 297 | default: |
| 298 | return false; |
| 299 | } |
| keyar@chromium.org | fe6391a | 2012-08-20 15:03:41 +0000 | [diff] [blame] | 300 | } |
| keyar@chromium.org | 77a5522 | 2012-08-20 15:03:47 +0000 | [diff] [blame] | 301 | |
| robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 302 | SkGLContextHelper* getGLContext() { |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 303 | GrContextFactory::GLContextType glContextType |
| 304 | = GrContextFactory::kNull_GLContextType; |
| 305 | switch(fDeviceType) { |
| 306 | case kGPU_DeviceType: |
| 307 | glContextType = GrContextFactory::kNative_GLContextType; |
| 308 | break; |
| commit-bot@chromium.org | 0fd5270 | 2014-03-07 18:41:14 +0000 | [diff] [blame] | 309 | case kNVPR_DeviceType: |
| 310 | glContextType = GrContextFactory::kNVPR_GLContextType; |
| 311 | break; |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 312 | #if SK_ANGLE |
| 313 | case kAngle_DeviceType: |
| 314 | glContextType = GrContextFactory::kANGLE_GLContextType; |
| 315 | break; |
| 316 | #endif |
| rmistry@google.com | 6ab9673 | 2014-01-06 18:37:24 +0000 | [diff] [blame] | 317 | #if SK_MESA |
| 318 | case kMesa_DeviceType: |
| 319 | glContextType = GrContextFactory::kMESA_GLContextType; |
| 320 | break; |
| 321 | #endif |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 322 | default: |
| 323 | return NULL; |
| keyar@chromium.org | 77a5522 | 2012-08-20 15:03:47 +0000 | [diff] [blame] | 324 | } |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 325 | return fGrContextFactory.getGLContext(glContextType); |
| keyar@chromium.org | 77a5522 | 2012-08-20 15:03:47 +0000 | [diff] [blame] | 326 | } |
| robertphillips@google.com | 163c84b | 2012-09-13 15:40:37 +0000 | [diff] [blame] | 327 | |
| 328 | GrContext* getGrContext() { |
| 329 | return fGrContext; |
| 330 | } |
| keyar@chromium.org | 4ea96c5 | 2012-08-20 15:03:29 +0000 | [diff] [blame] | 331 | #endif |
| 332 | |
| commit-bot@chromium.org | 145d1c0 | 2014-03-16 19:46:36 +0000 | [diff] [blame] | 333 | SkCanvas* getCanvas() { |
| 334 | return fCanvas; |
| 335 | } |
| 336 | |
| commit-bot@chromium.org | 8ddc26b | 2014-03-31 17:55:12 +0000 | [diff] [blame] | 337 | SkPicture* getPicture() { |
| 338 | return fPicture; |
| 339 | } |
| 340 | |
| keyar@chromium.org | 02dfb12 | 2012-08-20 15:03:36 +0000 | [diff] [blame] | 341 | PictureRenderer() |
| robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 342 | : fJsonSummaryPtr(NULL) |
| keyar@chromium.org | 0612564 | 2012-08-20 15:03:33 +0000 | [diff] [blame] | 343 | , fDeviceType(kBitmap_DeviceType) |
| junov@chromium.org | 50ff9bd | 2012-11-02 19:16:22 +0000 | [diff] [blame] | 344 | , fBBoxHierarchyType(kNone_BBoxHierarchyType) |
| scroggo@google.com | 06d6ac6 | 2013-02-08 21:16:19 +0000 | [diff] [blame] | 345 | , fScaleFactor(SK_Scalar1) |
| keyar@chromium.org | 0612564 | 2012-08-20 15:03:33 +0000 | [diff] [blame] | 346 | #if SK_SUPPORT_GPU |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 347 | , fGrContext(NULL) |
| jvanverth@google.com | f6a9033 | 2013-05-02 12:39:37 +0000 | [diff] [blame] | 348 | , fSampleCount(0) |
| keyar@chromium.org | 0612564 | 2012-08-20 15:03:33 +0000 | [diff] [blame] | 349 | #endif |
| caryclark@google.com | e3e940c | 2012-11-07 16:42:17 +0000 | [diff] [blame] | 350 | { |
| robertphillips@google.com | 7ae918e | 2013-03-02 17:45:27 +0000 | [diff] [blame] | 351 | fGridInfo.fMargin.setEmpty(); |
| 352 | fGridInfo.fOffset.setZero(); |
| 353 | fGridInfo.fTileInterval.set(1, 1); |
| caryclark@google.com | e3e940c | 2012-11-07 16:42:17 +0000 | [diff] [blame] | 354 | sk_bzero(fDrawFilters, sizeof(fDrawFilters)); |
| scroggo@google.com | c0d5e54 | 2012-12-13 21:40:48 +0000 | [diff] [blame] | 355 | fViewport.set(0, 0); |
| caryclark@google.com | e3e940c | 2012-11-07 16:42:17 +0000 | [diff] [blame] | 356 | } |
| keyar@chromium.org | 0612564 | 2012-08-20 15:03:33 +0000 | [diff] [blame] | 357 | |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 358 | #if SK_SUPPORT_GPU |
| 359 | virtual ~PictureRenderer() { |
| 360 | SkSafeUnref(fGrContext); |
| 361 | } |
| 362 | #endif |
| 363 | |
| keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 364 | protected: |
| 365 | SkAutoTUnref<SkCanvas> fCanvas; |
| robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 366 | SkAutoTUnref<SkPicture> fPicture; |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 367 | bool fUseChecksumBasedFilenames; |
| commit-bot@chromium.org | 205ce48 | 2014-05-12 15:37:20 +0000 | [diff] [blame^] | 368 | ImageResultsAndExpectations* fJsonSummaryPtr; |
| scroggo@google.com | c0d5e54 | 2012-12-13 21:40:48 +0000 | [diff] [blame] | 369 | SkDeviceTypes fDeviceType; |
| 370 | BBoxHierarchyType fBBoxHierarchyType; |
| 371 | DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount]; |
| 372 | SkString fDrawFiltersConfig; |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 373 | SkString fOutputDir; |
| 374 | SkString fInputFilename; |
| commit-bot@chromium.org | 5fb2ce3 | 2014-04-17 23:35:06 +0000 | [diff] [blame] | 375 | SkTileGridFactory::TileGridInfo fGridInfo; // used when fBBoxHierarchyType is TileGrid |
| keyar@chromium.org | 0612564 | 2012-08-20 15:03:33 +0000 | [diff] [blame] | 376 | |
| scroggo@google.com | c0d5e54 | 2012-12-13 21:40:48 +0000 | [diff] [blame] | 377 | void buildBBoxHierarchy(); |
| 378 | |
| 379 | /** |
| 380 | * Return the total width that should be drawn. If the viewport width has been set greater than |
| 381 | * 0, this will be the minimum of the current SkPicture's width and the viewport's width. |
| 382 | */ |
| 383 | int getViewWidth(); |
| 384 | |
| 385 | /** |
| 386 | * Return the total height that should be drawn. If the viewport height has been set greater |
| 387 | * than 0, this will be the minimum of the current SkPicture's height and the viewport's height. |
| 388 | */ |
| 389 | int getViewHeight(); |
| 390 | |
| scroggo@google.com | 82ec0b0 | 2012-12-17 19:25:54 +0000 | [diff] [blame] | 391 | /** |
| 392 | * Scales the provided canvas to the scale factor set by setScaleFactor. |
| 393 | */ |
| 394 | void scaleToScaleFactor(SkCanvas*); |
| 395 | |
| commit-bot@chromium.org | 5fb2ce3 | 2014-04-17 23:35:06 +0000 | [diff] [blame] | 396 | SkBBHFactory* getFactory(); |
| scroggo@google.com | c0d5e54 | 2012-12-13 21:40:48 +0000 | [diff] [blame] | 397 | uint32_t recordFlags(); |
| 398 | SkCanvas* setupCanvas(); |
| 399 | virtual SkCanvas* setupCanvas(int width, int height); |
| 400 | |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 401 | /** |
| 402 | * Copy src to dest; if src==NULL, set dest to empty string. |
| 403 | */ |
| 404 | static void CopyString(SkString* dest, const SkString* src); |
| 405 | |
| keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 406 | private: |
| scroggo@google.com | c0d5e54 | 2012-12-13 21:40:48 +0000 | [diff] [blame] | 407 | SkISize fViewport; |
| scroggo@google.com | 82ec0b0 | 2012-12-17 19:25:54 +0000 | [diff] [blame] | 408 | SkScalar fScaleFactor; |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 409 | #if SK_SUPPORT_GPU |
| 410 | GrContextFactory fGrContextFactory; |
| 411 | GrContext* fGrContext; |
| jvanverth@google.com | f6a9033 | 2013-05-02 12:39:37 +0000 | [diff] [blame] | 412 | int fSampleCount; |
| scroggo@google.com | 0556ea0 | 2013-02-08 19:38:21 +0000 | [diff] [blame] | 413 | #endif |
| scroggo@google.com | c0d5e54 | 2012-12-13 21:40:48 +0000 | [diff] [blame] | 414 | |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 415 | virtual SkString getConfigNameInternal() = 0; |
| 416 | |
| keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 417 | typedef SkRefCnt INHERITED; |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 418 | }; |
| 419 | |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 420 | /** |
| 421 | * This class does not do any rendering, but its render function executes recording, which we want |
| 422 | * to time. |
| 423 | */ |
| 424 | class RecordPictureRenderer : public PictureRenderer { |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 425 | virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 426 | |
| 427 | virtual SkString getPerIterTimeFormat() SK_OVERRIDE { return SkString("%.4f"); } |
| 428 | |
| 429 | virtual SkString getNormalTimeFormat() SK_OVERRIDE { return SkString("%6.4f"); } |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 430 | |
| djsollen@google.com | fd9720c | 2012-11-06 16:54:40 +0000 | [diff] [blame] | 431 | protected: |
| 432 | virtual SkCanvas* setupCanvas(int width, int height) SK_OVERRIDE; |
| 433 | |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 434 | private: |
| 435 | virtual SkString getConfigNameInternal() SK_OVERRIDE; |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 436 | }; |
| 437 | |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 438 | class PipePictureRenderer : public PictureRenderer { |
| keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 439 | public: |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 440 | virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
| keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 441 | |
| 442 | private: |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 443 | virtual SkString getConfigNameInternal() SK_OVERRIDE; |
| 444 | |
| keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 445 | typedef PictureRenderer INHERITED; |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 446 | }; |
| 447 | |
| 448 | class SimplePictureRenderer : public PictureRenderer { |
| keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 449 | public: |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 450 | virtual void init(SkPicture* pict, const SkString* outputDir, |
| 451 | const SkString* inputFilename, bool useChecksumBasedFilenames) SK_OVERRIDE; |
| junov@chromium.org | 9313ca4 | 2012-11-02 18:11:49 +0000 | [diff] [blame] | 452 | |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 453 | virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
| keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 454 | |
| 455 | private: |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 456 | virtual SkString getConfigNameInternal() SK_OVERRIDE; |
| 457 | |
| keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 458 | typedef PictureRenderer INHERITED; |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 459 | }; |
| 460 | |
| 461 | class TiledPictureRenderer : public PictureRenderer { |
| 462 | public: |
| 463 | TiledPictureRenderer(); |
| 464 | |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 465 | virtual void init(SkPicture* pict, const SkString* outputDir, |
| 466 | const SkString* inputFilename, bool useChecksumBasedFilenames) SK_OVERRIDE; |
| scroggo@google.com | 81f9d2e | 2012-09-20 14:54:21 +0000 | [diff] [blame] | 467 | |
| scroggo@google.com | 81f9d2e | 2012-09-20 14:54:21 +0000 | [diff] [blame] | 468 | /** |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 469 | * Renders to tiles, rather than a single canvas. |
| 470 | * If fOutputDir was provided, a separate file is |
| scroggo@google.com | 81f9d2e | 2012-09-20 14:54:21 +0000 | [diff] [blame] | 471 | * created for each tile, named "path0.png", "path1.png", etc. |
| 472 | * Multithreaded mode currently does not support writing to a file. |
| 473 | */ |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 474 | virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
| scroggo@google.com | 81f9d2e | 2012-09-20 14:54:21 +0000 | [diff] [blame] | 475 | |
| keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 476 | virtual void end() SK_OVERRIDE; |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 477 | |
| keyar@chromium.org | cc6e5ef | 2012-07-27 20:09:26 +0000 | [diff] [blame] | 478 | void setTileWidth(int width) { |
| 479 | fTileWidth = width; |
| 480 | } |
| 481 | |
| 482 | int getTileWidth() const { |
| 483 | return fTileWidth; |
| 484 | } |
| 485 | |
| 486 | void setTileHeight(int height) { |
| 487 | fTileHeight = height; |
| 488 | } |
| 489 | |
| 490 | int getTileHeight() const { |
| 491 | return fTileHeight; |
| 492 | } |
| 493 | |
| 494 | void setTileWidthPercentage(double percentage) { |
| 495 | fTileWidthPercentage = percentage; |
| 496 | } |
| 497 | |
| keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 498 | double getTileWidthPercentage() const { |
| keyar@chromium.org | cc6e5ef | 2012-07-27 20:09:26 +0000 | [diff] [blame] | 499 | return fTileWidthPercentage; |
| 500 | } |
| 501 | |
| 502 | void setTileHeightPercentage(double percentage) { |
| 503 | fTileHeightPercentage = percentage; |
| 504 | } |
| 505 | |
| keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 506 | double getTileHeightPercentage() const { |
| keyar@chromium.org | cc6e5ef | 2012-07-27 20:09:26 +0000 | [diff] [blame] | 507 | return fTileHeightPercentage; |
| 508 | } |
| 509 | |
| keyar@chromium.org | f4959ab | 2012-08-23 20:53:25 +0000 | [diff] [blame] | 510 | void setTileMinPowerOf2Width(int width) { |
| 511 | SkASSERT(SkIsPow2(width) && width > 0); |
| 512 | if (!SkIsPow2(width) || width <= 0) { |
| 513 | return; |
| 514 | } |
| 515 | |
| 516 | fTileMinPowerOf2Width = width; |
| 517 | } |
| 518 | |
| 519 | int getTileMinPowerOf2Width() const { |
| 520 | return fTileMinPowerOf2Width; |
| 521 | } |
| 522 | |
| scroggo@google.com | cbcef70 | 2012-12-13 22:09:28 +0000 | [diff] [blame] | 523 | virtual TiledPictureRenderer* getTiledRenderer() SK_OVERRIDE { return this; } |
| 524 | |
| scroggo@google.com | 161e1ba | 2013-03-04 16:41:06 +0000 | [diff] [blame] | 525 | virtual bool supportsTimingIndividualTiles() { return true; } |
| 526 | |
| scroggo@google.com | cbcef70 | 2012-12-13 22:09:28 +0000 | [diff] [blame] | 527 | /** |
| 528 | * Report the number of tiles in the x and y directions. Must not be called before init. |
| 529 | * @param x Output parameter identifying the number of tiles in the x direction. |
| 530 | * @param y Output parameter identifying the number of tiles in the y direction. |
| 531 | * @return True if the tiles have been set up, and x and y are meaningful. If false, x and y are |
| 532 | * unmodified. |
| 533 | */ |
| 534 | bool tileDimensions(int& x, int&y); |
| 535 | |
| 536 | /** |
| 537 | * Move to the next tile and return its indices. Must be called before calling drawCurrentTile |
| 538 | * for the first time. |
| 539 | * @param i Output parameter identifying the column of the next tile to be drawn on the next |
| 540 | * call to drawNextTile. |
| 541 | * @param j Output parameter identifying the row of the next tile to be drawn on the next call |
| 542 | * to drawNextTile. |
| 543 | * @param True if the tiles have been created and the next tile to be drawn by drawCurrentTile |
| 544 | * is within the range of tiles. If false, i and j are unmodified. |
| 545 | */ |
| 546 | bool nextTile(int& i, int& j); |
| 547 | |
| 548 | /** |
| 549 | * Render one tile. This will draw the same tile each time it is called until nextTile is |
| 550 | * called. The tile rendered will depend on how many calls have been made to nextTile. |
| 551 | * It is an error to call this without first calling nextTile, or if nextTile returns false. |
| 552 | */ |
| 553 | void drawCurrentTile(); |
| 554 | |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 555 | protected: |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 556 | SkTDArray<SkRect> fTileRects; |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 557 | |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 558 | virtual SkCanvas* setupCanvas(int width, int height) SK_OVERRIDE; |
| 559 | virtual SkString getConfigNameInternal() SK_OVERRIDE; |
| 560 | |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 561 | private: |
| scroggo@google.com | cbcef70 | 2012-12-13 22:09:28 +0000 | [diff] [blame] | 562 | int fTileWidth; |
| 563 | int fTileHeight; |
| 564 | double fTileWidthPercentage; |
| 565 | double fTileHeightPercentage; |
| 566 | int fTileMinPowerOf2Width; |
| 567 | |
| 568 | // These variables are only used for timing individual tiles. |
| 569 | // Next tile to draw in fTileRects. |
| 570 | int fCurrentTileOffset; |
| 571 | // Number of tiles in the x direction. |
| 572 | int fTilesX; |
| 573 | // Number of tiles in the y direction. |
| 574 | int fTilesY; |
| scroggo@google.com | bcdf2ec | 2012-09-20 14:42:33 +0000 | [diff] [blame] | 575 | |
| keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 576 | void setupTiles(); |
| keyar@chromium.org | f4959ab | 2012-08-23 20:53:25 +0000 | [diff] [blame] | 577 | void setupPowerOf2Tiles(); |
| keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 578 | |
| 579 | typedef PictureRenderer INHERITED; |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 580 | }; |
| 581 | |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 582 | class CloneData; |
| 583 | |
| 584 | class MultiCorePictureRenderer : public TiledPictureRenderer { |
| 585 | public: |
| 586 | explicit MultiCorePictureRenderer(int threadCount); |
| 587 | |
| 588 | ~MultiCorePictureRenderer(); |
| 589 | |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 590 | virtual void init(SkPicture* pict, const SkString* outputDir, |
| 591 | const SkString* inputFilename, bool useChecksumBasedFilenames) SK_OVERRIDE; |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 592 | |
| 593 | /** |
| 594 | * Behaves like TiledPictureRenderer::render(), only using multiple threads. |
| 595 | */ |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 596 | virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 597 | |
| 598 | virtual void end() SK_OVERRIDE; |
| 599 | |
| scroggo@google.com | 161e1ba | 2013-03-04 16:41:06 +0000 | [diff] [blame] | 600 | virtual bool supportsTimingIndividualTiles() SK_OVERRIDE { return false; } |
| 601 | |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 602 | private: |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 603 | virtual SkString getConfigNameInternal() SK_OVERRIDE; |
| 604 | |
| scroggo@google.com | a62da2f | 2012-11-02 21:28:12 +0000 | [diff] [blame] | 605 | const int fNumThreads; |
| 606 | SkTDArray<SkCanvas*> fCanvasPool; |
| 607 | SkThreadPool fThreadPool; |
| 608 | SkPicture* fPictureClones; |
| 609 | CloneData** fCloneData; |
| 610 | SkCountdown fCountdown; |
| 611 | |
| 612 | typedef TiledPictureRenderer INHERITED; |
| 613 | }; |
| 614 | |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 615 | /** |
| 616 | * This class does not do any rendering, but its render function executes turning an SkPictureRecord |
| 617 | * into an SkPicturePlayback, which we want to time. |
| 618 | */ |
| 619 | class PlaybackCreationRenderer : public PictureRenderer { |
| 620 | public: |
| 621 | virtual void setup() SK_OVERRIDE; |
| 622 | |
| commit-bot@chromium.org | f5e315c | 2014-03-19 17:26:07 +0000 | [diff] [blame] | 623 | virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 624 | |
| 625 | virtual SkString getPerIterTimeFormat() SK_OVERRIDE { return SkString("%.4f"); } |
| 626 | |
| 627 | virtual SkString getNormalTimeFormat() SK_OVERRIDE { return SkString("%6.4f"); } |
| 628 | |
| 629 | private: |
| robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 630 | SkAutoTDelete<SkPictureRecorder> fRecorder; |
| scroggo@google.com | 0a049b8 | 2012-11-02 22:01:26 +0000 | [diff] [blame] | 631 | |
| 632 | virtual SkString getConfigNameInternal() SK_OVERRIDE; |
| 633 | |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 634 | typedef PictureRenderer INHERITED; |
| 635 | }; |
| 636 | |
| reed@google.com | fe7b1ed | 2012-11-29 21:00:39 +0000 | [diff] [blame] | 637 | extern PictureRenderer* CreateGatherPixelRefsRenderer(); |
| reed@google.com | 5a34fd3 | 2012-12-10 16:05:09 +0000 | [diff] [blame] | 638 | extern PictureRenderer* CreatePictureCloneRenderer(); |
| reed@google.com | fe7b1ed | 2012-11-29 21:00:39 +0000 | [diff] [blame] | 639 | |
| keyar@chromium.org | 451bb9f | 2012-07-26 17:27:57 +0000 | [diff] [blame] | 640 | } |
| 641 | |
| 642 | #endif // PictureRenderer_DEFINED |