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 "SkPictureRecorder.h" | 18 #include "SkPictureRecorder.h" |
18 #include "SkRect.h" | 19 #include "SkRect.h" |
19 #include "SkRefCnt.h" | 20 #include "SkRefCnt.h" |
20 #include "SkRunnable.h" | 21 #include "SkRunnable.h" |
21 #include "SkString.h" | 22 #include "SkString.h" |
22 #include "SkTDArray.h" | 23 #include "SkTDArray.h" |
23 #include "SkThreadPool.h" | 24 #include "SkThreadPool.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 #endif | 290 #endif |
290 default: | 291 default: |
291 // Assume that no extra info means bitmap. | 292 // Assume that no extra info means bitmap. |
292 break; | 293 break; |
293 } | 294 } |
294 #endif | 295 #endif |
295 config.append(fDrawFiltersConfig.c_str()); | 296 config.append(fDrawFiltersConfig.c_str()); |
296 return config; | 297 return config; |
297 } | 298 } |
298 | 299 |
| 300 Json::Value getJSONConfig() { |
| 301 Json::Value result; |
| 302 |
| 303 result["mode"] = this->getConfigNameInternal().c_str(); |
| 304 result["scale"] = 1.0f; |
| 305 if (SK_Scalar1 != fScaleFactor) { |
| 306 result["scale"] = SkScalarToFloat(fScaleFactor); |
| 307 } |
| 308 if (kRTree_BBoxHierarchyType == fBBoxHierarchyType) { |
| 309 result["bbh"] = "rtree"; |
| 310 } else if (kQuadTree_BBoxHierarchyType == fBBoxHierarchyType) { |
| 311 result["bbh"] = "quadtree"; |
| 312 } else if (kTileGrid_BBoxHierarchyType == fBBoxHierarchyType) { |
| 313 SkString tmp("grid_"); |
| 314 tmp.appendS32(fGridInfo.fTileInterval.width()); |
| 315 tmp.append("x"); |
| 316 tmp.appendS32(fGridInfo.fTileInterval.height()); |
| 317 result["bbh"] = tmp.c_str(); |
| 318 } |
| 319 #if SK_SUPPORT_GPU |
| 320 SkString tmp; |
| 321 switch (fDeviceType) { |
| 322 case kGPU_DeviceType: |
| 323 if (0 != fSampleCount) { |
| 324 tmp = "msaa"; |
| 325 tmp.appendS32(fSampleCount); |
| 326 result["config"] = tmp.c_str(); |
| 327 } else { |
| 328 result["config"] = "gpu"; |
| 329 } |
| 330 break; |
| 331 case kNVPR_DeviceType: |
| 332 tmp = "nvprmsaa"; |
| 333 tmp.appendS32(fSampleCount); |
| 334 result["config"] = tmp.c_str(); |
| 335 break; |
| 336 #if SK_ANGLE |
| 337 case kAngle_DeviceType: |
| 338 result["config"] = "angle"; |
| 339 break; |
| 340 #endif |
| 341 #if SK_MESA |
| 342 case kMesa_DeviceType: |
| 343 result["config"] = "mesa"; |
| 344 break; |
| 345 #endif |
| 346 default: |
| 347 // Assume that no extra info means bitmap. |
| 348 break; |
| 349 } |
| 350 #endif |
| 351 return result; |
| 352 } |
| 353 |
299 #if SK_SUPPORT_GPU | 354 #if SK_SUPPORT_GPU |
300 bool isUsingGpuDevice() { | 355 bool isUsingGpuDevice() { |
301 switch (fDeviceType) { | 356 switch (fDeviceType) { |
302 case kGPU_DeviceType: | 357 case kGPU_DeviceType: |
303 case kNVPR_DeviceType: | 358 case kNVPR_DeviceType: |
304 // fall through | 359 // fall through |
305 #if SK_ANGLE | 360 #if SK_ANGLE |
306 case kAngle_DeviceType: | 361 case kAngle_DeviceType: |
307 // fall through | 362 // fall through |
308 #endif | 363 #endif |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 | 707 |
653 typedef PictureRenderer INHERITED; | 708 typedef PictureRenderer INHERITED; |
654 }; | 709 }; |
655 | 710 |
656 extern PictureRenderer* CreateGatherPixelRefsRenderer(); | 711 extern PictureRenderer* CreateGatherPixelRefsRenderer(); |
657 extern PictureRenderer* CreatePictureCloneRenderer(); | 712 extern PictureRenderer* CreatePictureCloneRenderer(); |
658 | 713 |
659 } | 714 } |
660 | 715 |
661 #endif // PictureRenderer_DEFINED | 716 #endif // PictureRenderer_DEFINED |
OLD | NEW |