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

Side by Side Diff: tools/PictureRenderer.cpp

Issue 238273012: Staged removal of SkPicture-derived classes (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: have SkPicture only friend SkPictureRecorder once Created 6 years, 8 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/PictureRenderingFlags.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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 return height; 267 return height;
268 } 268 }
269 269
270 /** Converts fPicture to a picture that uses a BBoxHierarchy. 270 /** Converts fPicture to a picture that uses a BBoxHierarchy.
271 * PictureRenderer subclasses that are used to test picture playback 271 * PictureRenderer subclasses that are used to test picture playback
272 * should call this method during init. 272 * should call this method during init.
273 */ 273 */
274 void PictureRenderer::buildBBoxHierarchy() { 274 void PictureRenderer::buildBBoxHierarchy() {
275 SkASSERT(NULL != fPicture); 275 SkASSERT(NULL != fPicture);
276 if (kNone_BBoxHierarchyType != fBBoxHierarchyType && NULL != fPicture) { 276 if (kNone_BBoxHierarchyType != fBBoxHierarchyType && NULL != fPicture) {
277 SkAutoTUnref<SkPictureFactory> factory(this->getFactory()); 277 SkAutoTDelete<SkBBHFactory> factory(this->getFactory());
278 SkPictureRecorder recorder(factory); 278 SkPictureRecorder recorder;
279 SkCanvas* canvas = recorder.beginRecording(fPicture->width(), fPicture-> height(), 279 SkCanvas* canvas = recorder.beginRecording(fPicture->width(), fPicture-> height(),
280 factory.get(),
280 this->recordFlags()); 281 this->recordFlags());
281 fPicture->draw(canvas); 282 fPicture->draw(canvas);
282 fPicture.reset(recorder.endRecording()); 283 fPicture.reset(recorder.endRecording());
283 } 284 }
284 } 285 }
285 286
286 void PictureRenderer::resetState(bool callFinish) { 287 void PictureRenderer::resetState(bool callFinish) {
287 #if SK_SUPPORT_GPU 288 #if SK_SUPPORT_GPU
288 SkGLContextHelper* glContext = this->getGLContext(); 289 SkGLContextHelper* glContext = this->getGLContext();
289 if (NULL == glContext) { 290 if (NULL == glContext) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 // defer the canvas setup until the render step 429 // defer the canvas setup until the render step
429 return NULL; 430 return NULL;
430 } 431 }
431 432
432 // the size_t* parameter is deprecated, so we ignore it 433 // the size_t* parameter is deprecated, so we ignore it
433 static SkData* encode_bitmap_to_data(size_t*, const SkBitmap& bm) { 434 static SkData* encode_bitmap_to_data(size_t*, const SkBitmap& bm) {
434 return SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, 100); 435 return SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, 100);
435 } 436 }
436 437
437 bool RecordPictureRenderer::render(SkBitmap** out) { 438 bool RecordPictureRenderer::render(SkBitmap** out) {
438 SkAutoTUnref<SkPictureFactory> factory(this->getFactory()); 439 SkAutoTDelete<SkBBHFactory> factory(this->getFactory());
439 SkPictureRecorder recorder(factory); 440 SkPictureRecorder recorder;
440 SkCanvas* canvas = recorder.beginRecording(this->getViewWidth(), this->getVi ewHeight(), 441 SkCanvas* canvas = recorder.beginRecording(this->getViewWidth(), this->getVi ewHeight(),
442 factory.get(),
441 this->recordFlags()); 443 this->recordFlags());
442 this->scaleToScaleFactor(canvas); 444 this->scaleToScaleFactor(canvas);
443 fPicture->draw(canvas); 445 fPicture->draw(canvas);
444 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 446 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
445 if (!fOutputDir.isEmpty()) { 447 if (!fOutputDir.isEmpty()) {
446 // Record the new picture as a new SKP with PNG encoded bitmaps. 448 // Record the new picture as a new SKP with PNG encoded bitmaps.
447 SkString skpPath = SkOSPath::SkPathJoin(fOutputDir.c_str(), fInputFilena me.c_str()); 449 SkString skpPath = SkOSPath::SkPathJoin(fOutputDir.c_str(), fInputFilena me.c_str());
448 SkFILEWStream stream(skpPath.c_str()); 450 SkFILEWStream stream(skpPath.c_str());
449 picture->serialize(&stream, &encode_bitmap_to_data); 451 picture->serialize(&stream, &encode_bitmap_to_data);
450 return true; 452 return true;
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 949
948 SkString MultiCorePictureRenderer::getConfigNameInternal() { 950 SkString MultiCorePictureRenderer::getConfigNameInternal() {
949 SkString name = this->INHERITED::getConfigNameInternal(); 951 SkString name = this->INHERITED::getConfigNameInternal();
950 name.appendf("_multi_%i_threads", fNumThreads); 952 name.appendf("_multi_%i_threads", fNumThreads);
951 return name; 953 return name;
952 } 954 }
953 955
954 //////////////////////////////////////////////////////////////////////////////// /////////////// 956 //////////////////////////////////////////////////////////////////////////////// ///////////////
955 957
956 void PlaybackCreationRenderer::setup() { 958 void PlaybackCreationRenderer::setup() {
957 SkAutoTUnref<SkPictureFactory> factory(this->getFactory()); 959 SkAutoTDelete<SkBBHFactory> factory(this->getFactory());
958 fRecorder.reset(SkNEW_ARGS(SkPictureRecorder, (factory))); 960 fRecorder.reset(SkNEW(SkPictureRecorder));
959 SkCanvas* canvas = fRecorder->beginRecording(this->getViewWidth(), this->get ViewHeight(), 961 SkCanvas* canvas = fRecorder->beginRecording(this->getViewWidth(), this->get ViewHeight(),
962 factory.get(),
960 this->recordFlags()); 963 this->recordFlags());
961 this->scaleToScaleFactor(canvas); 964 this->scaleToScaleFactor(canvas);
962 canvas->drawPicture(*fPicture); 965 canvas->drawPicture(*fPicture);
963 } 966 }
964 967
965 bool PlaybackCreationRenderer::render(SkBitmap** out) { 968 bool PlaybackCreationRenderer::render(SkBitmap** out) {
966 fPicture.reset(fRecorder->endRecording()); 969 fPicture.reset(fRecorder->endRecording());
967 // Since this class does not actually render, return false. 970 // Since this class does not actually render, return false.
968 return false; 971 return false;
969 } 972 }
970 973
971 SkString PlaybackCreationRenderer::getConfigNameInternal() { 974 SkString PlaybackCreationRenderer::getConfigNameInternal() {
972 return SkString("playback_creation"); 975 return SkString("playback_creation");
973 } 976 }
974 977
975 //////////////////////////////////////////////////////////////////////////////// /////////////// 978 //////////////////////////////////////////////////////////////////////////////// ///////////////
976 // SkPicture variants for each BBoxHierarchy type 979 // SkPicture variants for each BBoxHierarchy type
977 980
978 SkPictureFactory* PictureRenderer::getFactory() { 981 SkBBHFactory* PictureRenderer::getFactory() {
979 switch (fBBoxHierarchyType) { 982 switch (fBBoxHierarchyType) {
980 case kNone_BBoxHierarchyType: 983 case kNone_BBoxHierarchyType:
981 return NULL; 984 return NULL;
982 case kQuadTree_BBoxHierarchyType: 985 case kQuadTree_BBoxHierarchyType:
983 return SkNEW(SkQuadTreePictureFactory); 986 return SkNEW(SkQuadTreeFactory);
984 case kRTree_BBoxHierarchyType: 987 case kRTree_BBoxHierarchyType:
985 return SkNEW(SkRTreePictureFactory); 988 return SkNEW(SkRTreeFactory);
986 case kTileGrid_BBoxHierarchyType: 989 case kTileGrid_BBoxHierarchyType:
987 return new SkTileGridPictureFactory(fGridInfo); 990 return SkNEW_ARGS(SkTileGridFactory, (fGridInfo));
988 } 991 }
989 SkASSERT(0); // invalid bbhType 992 SkASSERT(0); // invalid bbhType
990 return NULL; 993 return NULL;
991 } 994 }
992 995
993 /////////////////////////////////////////////////////////////////////////////// 996 ///////////////////////////////////////////////////////////////////////////////
994 997
995 class GatherRenderer : public PictureRenderer { 998 class GatherRenderer : public PictureRenderer {
996 public: 999 public:
997 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE { 1000 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 virtual SkString getConfigNameInternal() SK_OVERRIDE { 1033 virtual SkString getConfigNameInternal() SK_OVERRIDE {
1031 return SkString("picture_clone"); 1034 return SkString("picture_clone");
1032 } 1035 }
1033 }; 1036 };
1034 1037
1035 PictureRenderer* CreatePictureCloneRenderer() { 1038 PictureRenderer* CreatePictureCloneRenderer() {
1036 return SkNEW(PictureCloneRenderer); 1039 return SkNEW(PictureCloneRenderer);
1037 } 1040 }
1038 1041
1039 } // namespace sk_tools 1042 } // namespace sk_tools
OLDNEW
« no previous file with comments | « tools/PictureRenderer.h ('k') | tools/PictureRenderingFlags.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698