Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: tools/PictureRenderer.cpp

Issue 212933002: Actually identify required saveLayers in SkGpuDevice::EXPERIMENTAL_drawPicture (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: cleaned up Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/PictureRenderer.h ('k') | tools/render_pictures_main.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 void TiledPictureRenderer::init(SkPicture* pict, const SkString* outputDir, 488 void TiledPictureRenderer::init(SkPicture* pict, const SkString* outputDir,
489 const SkString* inputFilename, bool useChecksumB asedFilenames) { 489 const SkString* inputFilename, bool useChecksumB asedFilenames) {
490 SkASSERT(pict != NULL); 490 SkASSERT(pict != NULL);
491 SkASSERT(0 == fTileRects.count()); 491 SkASSERT(0 == fTileRects.count());
492 if (NULL == pict || fTileRects.count() != 0) { 492 if (NULL == pict || fTileRects.count() != 0) {
493 return; 493 return;
494 } 494 }
495 495
496 // Do not call INHERITED::init(), which would create a (potentially large) c anvas which is not 496 // Do not call INHERITED::init(), which would create a (potentially large) c anvas which is not
497 // used by bench_pictures. 497 // used by bench_pictures.
498 fPicture = pict; 498 fPicture = pict;
bsalomon 2014/03/26 17:29:21 could be fPicture = SkRef(pict);
robertphillips 2014/03/28 11:48:16 Done.
499 fPicture->ref();
499 this->CopyString(&fOutputDir, outputDir); 500 this->CopyString(&fOutputDir, outputDir);
500 this->CopyString(&fInputFilename, inputFilename); 501 this->CopyString(&fInputFilename, inputFilename);
501 fUseChecksumBasedFilenames = useChecksumBasedFilenames; 502 fUseChecksumBasedFilenames = useChecksumBasedFilenames;
502 fPicture->ref();
503 this->buildBBoxHierarchy(); 503 this->buildBBoxHierarchy();
504 504
505 if (fTileWidthPercentage > 0) { 505 if (fTileWidthPercentage > 0) {
506 fTileWidth = sk_float_ceil2int(float(fTileWidthPercentage * fPicture->wi dth() / 100)); 506 fTileWidth = sk_float_ceil2int(float(fTileWidthPercentage * fPicture->wi dth() / 100));
507 } 507 }
508 if (fTileHeightPercentage > 0) { 508 if (fTileHeightPercentage > 0) {
509 fTileHeight = sk_float_ceil2int(float(fTileHeightPercentage * fPicture-> height() / 100)); 509 fTileHeight = sk_float_ceil2int(float(fTileHeightPercentage * fPicture-> height() / 100));
510 } 510 }
511 511
512 if (fTileMinPowerOf2Width > 0) { 512 if (fTileMinPowerOf2Width > 0) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 } else { 687 } else {
688 success = false; 688 success = false;
689 } 689 }
690 } 690 }
691 } 691 }
692 return success; 692 return success;
693 } 693 }
694 694
695 SkCanvas* TiledPictureRenderer::setupCanvas(int width, int height) { 695 SkCanvas* TiledPictureRenderer::setupCanvas(int width, int height) {
696 SkCanvas* canvas = this->INHERITED::setupCanvas(width, height); 696 SkCanvas* canvas = this->INHERITED::setupCanvas(width, height);
697 SkASSERT(fPicture != NULL); 697 SkASSERT(NULL != fPicture);
698 // Clip the tile to an area that is completely inside both the SkPicture and the viewport. This 698 // Clip the tile to an area that is completely inside both the SkPicture and the viewport. This
699 // is mostly important for tiles on the right and bottom edges as they may g o over this area and 699 // is mostly important for tiles on the right and bottom edges as they may g o over this area and
700 // the picture may have some commands that draw outside of this area and so should not actually 700 // the picture may have some commands that draw outside of this area and so should not actually
701 // be written. 701 // be written.
702 // Uses a clipRegion so that it will be unaffected by the scale factor, whic h may have been set 702 // Uses a clipRegion so that it will be unaffected by the scale factor, whic h may have been set
703 // by INHERITED::setupCanvas. 703 // by INHERITED::setupCanvas.
704 SkRegion clipRegion; 704 SkRegion clipRegion;
705 clipRegion.setRect(0, 0, this->getViewWidth(), this->getViewHeight()); 705 clipRegion.setRect(0, 0, this->getViewWidth(), this->getViewHeight());
706 canvas->clipRegion(clipRegion); 706 canvas->clipRegion(clipRegion);
707 return canvas; 707 return canvas;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 return name; 903 return name;
904 } 904 }
905 905
906 //////////////////////////////////////////////////////////////////////////////// /////////////// 906 //////////////////////////////////////////////////////////////////////////////// ///////////////
907 907
908 void PlaybackCreationRenderer::setup() { 908 void PlaybackCreationRenderer::setup() {
909 fReplayer.reset(this->createPicture()); 909 fReplayer.reset(this->createPicture());
910 SkCanvas* recorder = fReplayer->beginRecording(this->getViewWidth(), this->g etViewHeight(), 910 SkCanvas* recorder = fReplayer->beginRecording(this->getViewWidth(), this->g etViewHeight(),
911 this->recordFlags()); 911 this->recordFlags());
912 this->scaleToScaleFactor(recorder); 912 this->scaleToScaleFactor(recorder);
913 fPicture->draw(recorder); 913 recorder->drawPicture(*fPicture);
914 } 914 }
915 915
916 bool PlaybackCreationRenderer::render(SkBitmap** out) { 916 bool PlaybackCreationRenderer::render(SkBitmap** out) {
917 fReplayer->endRecording(); 917 fReplayer->endRecording();
918 // Since this class does not actually render, return false. 918 // Since this class does not actually render, return false.
919 return false; 919 return false;
920 } 920 }
921 921
922 SkString PlaybackCreationRenderer::getConfigNameInternal() { 922 SkString PlaybackCreationRenderer::getConfigNameInternal() {
923 return SkString("playback_creation"); 923 return SkString("playback_creation");
(...skipping 14 matching lines...) Expand all
938 aspectRatio, sortDraws); 938 aspectRatio, sortDraws);
939 } 939 }
940 }; 940 };
941 941
942 SkPicture* PictureRenderer::createPicture() { 942 SkPicture* PictureRenderer::createPicture() {
943 switch (fBBoxHierarchyType) { 943 switch (fBBoxHierarchyType) {
944 case kNone_BBoxHierarchyType: 944 case kNone_BBoxHierarchyType:
945 return SkNEW(SkPicture); 945 return SkNEW(SkPicture);
946 case kQuadTree_BBoxHierarchyType: 946 case kQuadTree_BBoxHierarchyType:
947 return SkNEW_ARGS(SkQuadTreePicture, (SkIRect::MakeWH(fPicture->widt h(), 947 return SkNEW_ARGS(SkQuadTreePicture, (SkIRect::MakeWH(fPicture->widt h(),
948 fPicture->height()))); 948 fPicture->heig ht())));
949 case kRTree_BBoxHierarchyType: 949 case kRTree_BBoxHierarchyType:
950 return SkNEW(RTreePicture); 950 return SkNEW(RTreePicture);
951 case kTileGrid_BBoxHierarchyType: 951 case kTileGrid_BBoxHierarchyType:
952 return SkNEW_ARGS(SkTileGridPicture, (fPicture->width(), 952 return SkNEW_ARGS(SkTileGridPicture, (fPicture->width(),
953 fPicture->height(), fGridInfo)); 953 fPicture->height(), fGridInfo) );
954 } 954 }
955 SkASSERT(0); // invalid bbhType 955 SkASSERT(0); // invalid bbhType
956 return NULL; 956 return NULL;
957 } 957 }
958 958
959 /////////////////////////////////////////////////////////////////////////////// 959 ///////////////////////////////////////////////////////////////////////////////
960 960
961 class GatherRenderer : public PictureRenderer { 961 class GatherRenderer : public PictureRenderer {
962 public: 962 public:
963 virtual bool render(SkBitmap** out = NULL) 963 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE {
964 SK_OVERRIDE {
965 SkRect bounds = SkRect::MakeWH(SkIntToScalar(fPicture->width()), 964 SkRect bounds = SkRect::MakeWH(SkIntToScalar(fPicture->width()),
966 SkIntToScalar(fPicture->height())); 965 SkIntToScalar(fPicture->height()));
967 SkData* data = SkPictureUtils::GatherPixelRefs(fPicture, bounds); 966 SkData* data = SkPictureUtils::GatherPixelRefs(fPicture, bounds);
968 SkSafeUnref(data); 967 SkSafeUnref(data);
969 968
970 return (fOutputDir.isEmpty()); // we don't have anything to write 969 return (fOutputDir.isEmpty()); // we don't have anything to write
971 } 970 }
972 971
973 private: 972 private:
974 virtual SkString getConfigNameInternal() SK_OVERRIDE { 973 virtual SkString getConfigNameInternal() SK_OVERRIDE {
975 return SkString("gather_pixelrefs"); 974 return SkString("gather_pixelrefs");
976 } 975 }
977 }; 976 };
978 977
979 PictureRenderer* CreateGatherPixelRefsRenderer() { 978 PictureRenderer* CreateGatherPixelRefsRenderer() {
980 return SkNEW(GatherRenderer); 979 return SkNEW(GatherRenderer);
981 } 980 }
982 981
983 /////////////////////////////////////////////////////////////////////////////// 982 ///////////////////////////////////////////////////////////////////////////////
984 983
985 class PictureCloneRenderer : public PictureRenderer { 984 class PictureCloneRenderer : public PictureRenderer {
986 public: 985 public:
987 virtual bool render(SkBitmap** out = NULL) 986 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE {
988 SK_OVERRIDE {
989 for (int i = 0; i < 100; ++i) { 987 for (int i = 0; i < 100; ++i) {
990 SkPicture* clone = fPicture->clone(); 988 SkPicture* clone = fPicture->clone();
991 SkSafeUnref(clone); 989 SkSafeUnref(clone);
992 } 990 }
993 991
994 return (fOutputDir.isEmpty()); // we don't have anything to write 992 return (fOutputDir.isEmpty()); // we don't have anything to write
995 } 993 }
996 994
997 private: 995 private:
998 virtual SkString getConfigNameInternal() SK_OVERRIDE { 996 virtual SkString getConfigNameInternal() SK_OVERRIDE {
999 return SkString("picture_clone"); 997 return SkString("picture_clone");
1000 } 998 }
1001 }; 999 };
1002 1000
1003 PictureRenderer* CreatePictureCloneRenderer() { 1001 PictureRenderer* CreatePictureCloneRenderer() {
1004 return SkNEW(PictureCloneRenderer); 1002 return SkNEW(PictureCloneRenderer);
1005 } 1003 }
1006 1004
1007 } // namespace sk_tools 1005 } // namespace sk_tools
OLDNEW
« no previous file with comments | « tools/PictureRenderer.h ('k') | tools/render_pictures_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698