| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 PictureRenderer_DEFINED | 8 #ifndef PictureRenderer_DEFINED |
| 9 #define PictureRenderer_DEFINED | 9 #define PictureRenderer_DEFINED |
| 10 | 10 |
| 11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 12 #include "SkCountdown.h" | 12 #include "SkCountdown.h" |
| 13 #include "SkDrawFilter.h" | 13 #include "SkDrawFilter.h" |
| 14 #include "SkJSONCPP.h" |
| 14 #include "SkMath.h" | 15 #include "SkMath.h" |
| 15 #include "SkPaint.h" | 16 #include "SkPaint.h" |
| 16 #include "SkPicture.h" | 17 #include "SkPicture.h" |
| 17 #include "SkRect.h" | 18 #include "SkRect.h" |
| 18 #include "SkRefCnt.h" | 19 #include "SkRefCnt.h" |
| 19 #include "SkRunnable.h" | 20 #include "SkRunnable.h" |
| 20 #include "SkString.h" | 21 #include "SkString.h" |
| 21 #include "SkTDArray.h" | 22 #include "SkTDArray.h" |
| 22 #include "SkThreadPool.h" | 23 #include "SkThreadPool.h" |
| 23 #include "SkTileGridPicture.h" | 24 #include "SkTileGridPicture.h" |
| 24 #include "SkTypes.h" | 25 #include "SkTypes.h" |
| 25 | 26 |
| 26 #if SK_SUPPORT_GPU | 27 #if SK_SUPPORT_GPU |
| 27 #include "GrContextFactory.h" | 28 #include "GrContextFactory.h" |
| 28 #include "GrContext.h" | 29 #include "GrContext.h" |
| 29 #endif | 30 #endif |
| 30 | 31 |
| 31 class SkBitmap; | 32 class SkBitmap; |
| 32 class SkCanvas; | 33 class SkCanvas; |
| 33 class SkGLContextHelper; | 34 class SkGLContextHelper; |
| 34 class SkThread; | 35 class SkThread; |
| 35 | 36 |
| 36 namespace sk_tools { | 37 namespace sk_tools { |
| 37 | 38 |
| 38 class TiledPictureRenderer; | 39 class TiledPictureRenderer; |
| 39 | 40 |
| 41 /** |
| 42 * Class for collecting image results (checksums) as we go. |
| 43 */ |
| 44 class ImageResultsSummary { |
| 45 public: |
| 46 /** |
| 47 * Adds this bitmap's hash to the summary of results. |
| 48 * |
| 49 * @param testName name of the test |
| 50 * @param bitmap bitmap to store the hash of |
| 51 */ |
| 52 void add(const char *testName, const SkBitmap& bitmap); |
| 53 |
| 54 /** |
| 55 * Writes the summary (as constructed so far) to a file. |
| 56 * |
| 57 * @param filename path to write the summary to |
| 58 */ |
| 59 void writeToFile(const char *filename); |
| 60 |
| 61 private: |
| 62 Json::Value fActualResultsNoComparison; |
| 63 }; |
| 64 |
| 40 class PictureRenderer : public SkRefCnt { | 65 class PictureRenderer : public SkRefCnt { |
| 41 | 66 |
| 42 public: | 67 public: |
| 43 enum SkDeviceTypes { | 68 enum SkDeviceTypes { |
| 44 #if SK_ANGLE | 69 #if SK_ANGLE |
| 45 kAngle_DeviceType, | 70 kAngle_DeviceType, |
| 46 #endif | 71 #endif |
| 47 kBitmap_DeviceType, | 72 kBitmap_DeviceType, |
| 48 #if SK_SUPPORT_GPU | 73 #if SK_SUPPORT_GPU |
| 49 kGPU_DeviceType, | 74 kGPU_DeviceType, |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 void setBBoxHierarchyType(BBoxHierarchyType bbhType) { | 201 void setBBoxHierarchyType(BBoxHierarchyType bbhType) { |
| 177 fBBoxHierarchyType = bbhType; | 202 fBBoxHierarchyType = bbhType; |
| 178 } | 203 } |
| 179 | 204 |
| 180 BBoxHierarchyType getBBoxHierarchyType() { return fBBoxHierarchyType; } | 205 BBoxHierarchyType getBBoxHierarchyType() { return fBBoxHierarchyType; } |
| 181 | 206 |
| 182 void setGridSize(int width, int height) { | 207 void setGridSize(int width, int height) { |
| 183 fGridInfo.fTileInterval.set(width, height); | 208 fGridInfo.fTileInterval.set(width, height); |
| 184 } | 209 } |
| 185 | 210 |
| 211 void setJsonSummaryPtr(ImageResultsSummary* jsonSummaryPtr) { |
| 212 fJsonSummaryPtr = jsonSummaryPtr; |
| 213 } |
| 214 |
| 186 bool isUsingBitmapDevice() { | 215 bool isUsingBitmapDevice() { |
| 187 return kBitmap_DeviceType == fDeviceType; | 216 return kBitmap_DeviceType == fDeviceType; |
| 188 } | 217 } |
| 189 | 218 |
| 190 virtual SkString getPerIterTimeFormat() { return SkString("%.2f"); } | 219 virtual SkString getPerIterTimeFormat() { return SkString("%.2f"); } |
| 191 | 220 |
| 192 virtual SkString getNormalTimeFormat() { return SkString("%6.2f"); } | 221 virtual SkString getNormalTimeFormat() { return SkString("%6.2f"); } |
| 193 | 222 |
| 194 /** | 223 /** |
| 195 * Reports the configuration of this PictureRenderer. | 224 * Reports the configuration of this PictureRenderer. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 return fGrContextFactory.getGLContext(glContextType); | 288 return fGrContextFactory.getGLContext(glContextType); |
| 260 } | 289 } |
| 261 | 290 |
| 262 GrContext* getGrContext() { | 291 GrContext* getGrContext() { |
| 263 return fGrContext; | 292 return fGrContext; |
| 264 } | 293 } |
| 265 #endif | 294 #endif |
| 266 | 295 |
| 267 PictureRenderer() | 296 PictureRenderer() |
| 268 : fPicture(NULL) | 297 : fPicture(NULL) |
| 298 , fJsonSummaryPtr(NULL) |
| 269 , fDeviceType(kBitmap_DeviceType) | 299 , fDeviceType(kBitmap_DeviceType) |
| 270 , fBBoxHierarchyType(kNone_BBoxHierarchyType) | 300 , fBBoxHierarchyType(kNone_BBoxHierarchyType) |
| 271 , fScaleFactor(SK_Scalar1) | 301 , fScaleFactor(SK_Scalar1) |
| 272 #if SK_SUPPORT_GPU | 302 #if SK_SUPPORT_GPU |
| 273 , fGrContext(NULL) | 303 , fGrContext(NULL) |
| 274 , fSampleCount(0) | 304 , fSampleCount(0) |
| 275 #endif | 305 #endif |
| 276 { | 306 { |
| 277 fGridInfo.fMargin.setEmpty(); | 307 fGridInfo.fMargin.setEmpty(); |
| 278 fGridInfo.fOffset.setZero(); | 308 fGridInfo.fOffset.setZero(); |
| 279 fGridInfo.fTileInterval.set(1, 1); | 309 fGridInfo.fTileInterval.set(1, 1); |
| 280 sk_bzero(fDrawFilters, sizeof(fDrawFilters)); | 310 sk_bzero(fDrawFilters, sizeof(fDrawFilters)); |
| 281 fViewport.set(0, 0); | 311 fViewport.set(0, 0); |
| 282 } | 312 } |
| 283 | 313 |
| 284 #if SK_SUPPORT_GPU | 314 #if SK_SUPPORT_GPU |
| 285 virtual ~PictureRenderer() { | 315 virtual ~PictureRenderer() { |
| 286 SkSafeUnref(fGrContext); | 316 SkSafeUnref(fGrContext); |
| 287 } | 317 } |
| 288 #endif | 318 #endif |
| 289 | 319 |
| 290 protected: | 320 protected: |
| 291 SkAutoTUnref<SkCanvas> fCanvas; | 321 SkAutoTUnref<SkCanvas> fCanvas; |
| 292 SkPicture* fPicture; | 322 SkPicture* fPicture; |
| 323 ImageResultsSummary* fJsonSummaryPtr; |
| 293 SkDeviceTypes fDeviceType; | 324 SkDeviceTypes fDeviceType; |
| 294 BBoxHierarchyType fBBoxHierarchyType; | 325 BBoxHierarchyType fBBoxHierarchyType; |
| 295 DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount]; | 326 DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount]; |
| 296 SkString fDrawFiltersConfig; | 327 SkString fDrawFiltersConfig; |
| 297 SkTileGridPicture::TileGridInfo fGridInfo; // used when fBBoxHierarchyType i
s TileGrid | 328 SkTileGridPicture::TileGridInfo fGridInfo; // used when fBBoxHierarchyType i
s TileGrid |
| 298 | 329 |
| 299 void buildBBoxHierarchy(); | 330 void buildBBoxHierarchy(); |
| 300 | 331 |
| 301 /** | 332 /** |
| 302 * Return the total width that should be drawn. If the viewport width has be
en set greater than | 333 * Return the total width that should be drawn. If the viewport width has be
en set greater than |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 | 577 |
| 547 typedef PictureRenderer INHERITED; | 578 typedef PictureRenderer INHERITED; |
| 548 }; | 579 }; |
| 549 | 580 |
| 550 extern PictureRenderer* CreateGatherPixelRefsRenderer(); | 581 extern PictureRenderer* CreateGatherPixelRefsRenderer(); |
| 551 extern PictureRenderer* CreatePictureCloneRenderer(); | 582 extern PictureRenderer* CreatePictureCloneRenderer(); |
| 552 | 583 |
| 553 } | 584 } |
| 554 | 585 |
| 555 #endif // PictureRenderer_DEFINED | 586 #endif // PictureRenderer_DEFINED |
| OLD | NEW |