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 #include "PictureRenderer.h" | 8 #include "PictureRenderer.h" |
9 #include "picture_utils.h" | 9 #include "picture_utils.h" |
10 #include "SamplePipeControllers.h" | 10 #include "SamplePipeControllers.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 return SkScalarLog(x) * log2_conversion_factor; | 41 return SkScalarLog(x) * log2_conversion_factor; |
42 } | 42 } |
43 | 43 |
44 namespace sk_tools { | 44 namespace sk_tools { |
45 | 45 |
46 enum { | 46 enum { |
47 kDefaultTileWidth = 256, | 47 kDefaultTileWidth = 256, |
48 kDefaultTileHeight = 256 | 48 kDefaultTileHeight = 256 |
49 }; | 49 }; |
50 | 50 |
51 void PictureRenderer::init(const SkPicture* pict, | 51 void PictureRenderer::init(const SkPicture* pict, |
52 const SkString* writePath, | 52 const SkString* writePath, |
53 const SkString* mismatchPath, | 53 const SkString* mismatchPath, |
54 const SkString* inputFilename, | 54 const SkString* inputFilename, |
55 bool useChecksumBasedFilenames) { | 55 bool useChecksumBasedFilenames) { |
56 this->CopyString(&fWritePath, writePath); | 56 this->CopyString(&fWritePath, writePath); |
57 this->CopyString(&fMismatchPath, mismatchPath); | 57 this->CopyString(&fMismatchPath, mismatchPath); |
58 this->CopyString(&fInputFilename, inputFilename); | 58 this->CopyString(&fInputFilename, inputFilename); |
59 fUseChecksumBasedFilenames = useChecksumBasedFilenames; | 59 fUseChecksumBasedFilenames = useChecksumBasedFilenames; |
60 | 60 |
61 SkASSERT(NULL == fPicture); | 61 SkASSERT(NULL == fPicture); |
62 SkASSERT(NULL == fCanvas.get()); | 62 SkASSERT(NULL == fCanvas.get()); |
63 if (NULL != fPicture || NULL != fCanvas.get()) { | 63 if (NULL != fPicture || NULL != fCanvas.get()) { |
64 return; | 64 return; |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 } | 439 } |
440 | 440 |
441 SkString SimplePictureRenderer::getConfigNameInternal() { | 441 SkString SimplePictureRenderer::getConfigNameInternal() { |
442 return SkString("simple"); | 442 return SkString("simple"); |
443 } | 443 } |
444 | 444 |
445 ////////////////////////////////////////////////////////////////////////////////
/////////////// | 445 ////////////////////////////////////////////////////////////////////////////////
/////////////// |
446 | 446 |
447 #if SK_SUPPORT_GPU | 447 #if SK_SUPPORT_GPU |
448 TiledPictureRenderer::TiledPictureRenderer(const GrContext::Options& opts) | 448 TiledPictureRenderer::TiledPictureRenderer(const GrContext::Options& opts) |
449 : INHERITED(opts) | 449 : INHERITED(opts) |
450 , fTileWidth(kDefaultTileWidth) | 450 , fTileWidth(kDefaultTileWidth) |
451 #else | 451 #else |
452 TiledPictureRenderer::TiledPictureRenderer() | 452 TiledPictureRenderer::TiledPictureRenderer() |
453 : fTileWidth(kDefaultTileWidth) | 453 : fTileWidth(kDefaultTileWidth) |
454 #endif | 454 #endif |
455 , fTileHeight(kDefaultTileHeight) | 455 , fTileHeight(kDefaultTileHeight) |
456 , fTileWidthPercentage(0.0) | 456 , fTileWidthPercentage(0.0) |
457 , fTileHeightPercentage(0.0) | 457 , fTileHeightPercentage(0.0) |
458 , fTileMinPowerOf2Width(0) | 458 , fTileMinPowerOf2Width(0) |
459 , fCurrentTileOffset(-1) | 459 , fCurrentTileOffset(-1) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 } | 581 } |
582 } | 582 } |
583 } | 583 } |
584 | 584 |
585 /** | 585 /** |
586 * Draw the specified picture to the canvas translated to rectangle provided, so
that this mini | 586 * Draw the specified picture to the canvas translated to rectangle provided, so
that this mini |
587 * canvas represents the rectangle's portion of the overall picture. | 587 * canvas represents the rectangle's portion of the overall picture. |
588 * Saves and restores so that the initial clip and matrix return to their state
before this function | 588 * Saves and restores so that the initial clip and matrix return to their state
before this function |
589 * is called. | 589 * is called. |
590 */ | 590 */ |
591 static void draw_tile_to_canvas(SkCanvas* canvas, | 591 static void draw_tile_to_canvas(SkCanvas* canvas, |
592 const SkRect& tileRect, | 592 const SkRect& tileRect, |
593 const SkPicture* picture) { | 593 const SkPicture* picture) { |
594 int saveCount = canvas->save(); | 594 int saveCount = canvas->save(); |
595 // Translate so that we draw the correct portion of the picture. | 595 // Translate so that we draw the correct portion of the picture. |
596 // Perform a postTranslate so that the scaleFactor does not interfere with t
he positioning. | 596 // Perform a postTranslate so that the scaleFactor does not interfere with t
he positioning. |
597 SkMatrix mat(canvas->getTotalMatrix()); | 597 SkMatrix mat(canvas->getTotalMatrix()); |
598 mat.postTranslate(-tileRect.fLeft, -tileRect.fTop); | 598 mat.postTranslate(-tileRect.fLeft, -tileRect.fTop); |
599 canvas->setMatrix(mat); | 599 canvas->setMatrix(mat); |
600 canvas->drawPicture(picture); | 600 canvas->drawPicture(picture); |
601 canvas->restoreToCount(saveCount); | 601 canvas->restoreToCount(saveCount); |
602 canvas->flush(); | 602 canvas->flush(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 return SkString("playback_creation"); | 729 return SkString("playback_creation"); |
730 } | 730 } |
731 | 731 |
732 ////////////////////////////////////////////////////////////////////////////////
/////////////// | 732 ////////////////////////////////////////////////////////////////////////////////
/////////////// |
733 // SkPicture variants for each BBoxHierarchy type | 733 // SkPicture variants for each BBoxHierarchy type |
734 | 734 |
735 SkBBHFactory* PictureRenderer::getFactory() { | 735 SkBBHFactory* PictureRenderer::getFactory() { |
736 switch (fBBoxHierarchyType) { | 736 switch (fBBoxHierarchyType) { |
737 case kNone_BBoxHierarchyType: | 737 case kNone_BBoxHierarchyType: |
738 return NULL; | 738 return NULL; |
739 case kQuadTree_BBoxHierarchyType: | |
740 return SkNEW(SkQuadTreeFactory); | |
741 case kRTree_BBoxHierarchyType: | 739 case kRTree_BBoxHierarchyType: |
742 return SkNEW(SkRTreeFactory); | 740 return SkNEW(SkRTreeFactory); |
743 case kTileGrid_BBoxHierarchyType: | 741 case kTileGrid_BBoxHierarchyType: |
744 return SkNEW_ARGS(SkTileGridFactory, (fGridInfo)); | 742 return SkNEW_ARGS(SkTileGridFactory, (fGridInfo)); |
745 } | 743 } |
746 SkASSERT(0); // invalid bbhType | 744 SkASSERT(0); // invalid bbhType |
747 return NULL; | 745 return NULL; |
748 } | 746 } |
749 | 747 |
750 /////////////////////////////////////////////////////////////////////////////// | 748 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 25 matching lines...) Expand all Loading... |
776 PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options& opts) { | 774 PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options& opts) { |
777 return SkNEW_ARGS(GatherRenderer, (opts)); | 775 return SkNEW_ARGS(GatherRenderer, (opts)); |
778 } | 776 } |
779 #else | 777 #else |
780 PictureRenderer* CreateGatherPixelRefsRenderer() { | 778 PictureRenderer* CreateGatherPixelRefsRenderer() { |
781 return SkNEW(GatherRenderer); | 779 return SkNEW(GatherRenderer); |
782 } | 780 } |
783 #endif | 781 #endif |
784 | 782 |
785 } // namespace sk_tools | 783 } // namespace sk_tools |
OLD | NEW |