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

Side by Side Diff: tools/PictureRenderer.cpp

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 years, 3 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
« no previous file with comments | « tools/PictureBenchmark.cpp ('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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return this->setupCanvas(width, height); 124 return this->setupCanvas(width, height);
125 } 125 }
126 126
127 SkCanvas* PictureRenderer::setupCanvas(int width, int height) { 127 SkCanvas* PictureRenderer::setupCanvas(int width, int height) {
128 SkAutoTUnref<SkCanvas> canvas; 128 SkAutoTUnref<SkCanvas> canvas;
129 129
130 switch(fDeviceType) { 130 switch(fDeviceType) {
131 case kBitmap_DeviceType: { 131 case kBitmap_DeviceType: {
132 SkBitmap bitmap; 132 SkBitmap bitmap;
133 sk_tools::setup_bitmap(&bitmap, width, height); 133 sk_tools::setup_bitmap(&bitmap, width, height);
134 canvas.reset(SkNEW_ARGS(SkCanvas, (bitmap))); 134 canvas.reset(new SkCanvas(bitmap));
135 } 135 }
136 break; 136 break;
137 #if SK_SUPPORT_GPU 137 #if SK_SUPPORT_GPU
138 #if SK_ANGLE 138 #if SK_ANGLE
139 case kAngle_DeviceType: 139 case kAngle_DeviceType:
140 // fall through 140 // fall through
141 #endif 141 #endif
142 #if SK_MESA 142 #if SK_MESA
143 case kMesa_DeviceType: 143 case kMesa_DeviceType:
144 // fall through 144 // fall through
(...skipping 13 matching lines...) Expand all
158 } 158 }
159 159
160 uint32_t flags = fUseDFText ? SkSurfaceProps::kUseDistanceFieldFonts _Flag : 0; 160 uint32_t flags = fUseDFText ? SkSurfaceProps::kUseDistanceFieldFonts _Flag : 0;
161 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType ); 161 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType );
162 SkAutoTUnref<SkGpuDevice> device( 162 SkAutoTUnref<SkGpuDevice> device(
163 SkGpuDevice::Create(target->asRenderTarget(), &props, 163 SkGpuDevice::Create(target->asRenderTarget(), &props,
164 SkGpuDevice::kUninit_InitContents)); 164 SkGpuDevice::kUninit_InitContents));
165 if (!device) { 165 if (!device) {
166 return NULL; 166 return NULL;
167 } 167 }
168 canvas.reset(SkNEW_ARGS(SkCanvas, (device))); 168 canvas.reset(new SkCanvas(device));
169 break; 169 break;
170 } 170 }
171 #endif 171 #endif
172 default: 172 default:
173 SkASSERT(0); 173 SkASSERT(0);
174 return NULL; 174 return NULL;
175 } 175 }
176 176
177 if (fHasDrawFilters) { 177 if (fHasDrawFilters) {
178 if (fDrawFilters[0] & PictureRenderer::kAAClip_DrawFilterFlag) { 178 if (fDrawFilters[0] & PictureRenderer::kAAClip_DrawFilterFlag) {
179 canvas->setAllowSoftClip(false); 179 canvas->setAllowSoftClip(false);
180 } 180 }
181 181
182 canvas.reset(SkNEW_ARGS(FlagsFilterCanvas, (canvas.get(), fDrawFilters)) ); 182 canvas.reset(new FlagsFilterCanvas(canvas.get(), fDrawFilters));
183 } 183 }
184 184
185 this->scaleToScaleFactor(canvas); 185 this->scaleToScaleFactor(canvas);
186 186
187 // Pictures often lie about their extent (i.e., claim to be 100x100 but 187 // Pictures often lie about their extent (i.e., claim to be 100x100 but
188 // only ever draw to 90x100). Clear here so the undrawn portion will have 188 // only ever draw to 90x100). Clear here so the undrawn portion will have
189 // a consistent color 189 // a consistent color
190 canvas->clear(SK_ColorTRANSPARENT); 190 canvas->clear(SK_ColorTRANSPARENT);
191 return canvas.detach(); 191 return canvas.detach();
192 } 192 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 return false; 401 return false;
402 } 402 }
403 403
404 PipeController pipeController(fCanvas.get()); 404 PipeController pipeController(fCanvas.get());
405 SkGPipeWriter writer; 405 SkGPipeWriter writer;
406 SkCanvas* pipeCanvas = writer.startRecording(&pipeController); 406 SkCanvas* pipeCanvas = writer.startRecording(&pipeController);
407 pipeCanvas->drawPicture(fPicture); 407 pipeCanvas->drawPicture(fPicture);
408 writer.endRecording(); 408 writer.endRecording();
409 fCanvas->flush(); 409 fCanvas->flush();
410 if (out) { 410 if (out) {
411 *out = SkNEW(SkBitmap); 411 *out = new SkBitmap;
412 setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()), 412 setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()),
413 SkScalarCeilToInt(fPicture->cullRect().height())); 413 SkScalarCeilToInt(fPicture->cullRect().height()));
414 fCanvas->readPixels(*out, 0, 0); 414 fCanvas->readPixels(*out, 0, 0);
415 } 415 }
416 if (fEnableWrites) { 416 if (fEnableWrites) {
417 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSu mmaryPtr, 417 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSu mmaryPtr,
418 fUseChecksumBasedFilenames); 418 fUseChecksumBasedFilenames);
419 } else { 419 } else {
420 return true; 420 return true;
421 } 421 }
(...skipping 24 matching lines...) Expand all
446 SkMultiPictureDraw mpd; 446 SkMultiPictureDraw mpd;
447 447
448 mpd.add(fCanvas, fPicture); 448 mpd.add(fCanvas, fPicture);
449 449
450 mpd.draw(); 450 mpd.draw();
451 } else { 451 } else {
452 fCanvas->drawPicture(fPicture); 452 fCanvas->drawPicture(fPicture);
453 } 453 }
454 fCanvas->flush(); 454 fCanvas->flush();
455 if (out) { 455 if (out) {
456 *out = SkNEW(SkBitmap); 456 *out = new SkBitmap;
457 setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()), 457 setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()),
458 SkScalarCeilToInt(fPicture->cullRect().height())); 458 SkScalarCeilToInt(fPicture->cullRect().height()));
459 fCanvas->readPixels(*out, 0, 0); 459 fCanvas->readPixels(*out, 0, 0);
460 } 460 }
461 if (fEnableWrites) { 461 if (fEnableWrites) {
462 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSu mmaryPtr, 462 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSu mmaryPtr,
463 fUseChecksumBasedFilenames); 463 fUseChecksumBasedFilenames);
464 } else { 464 } else {
465 return true; 465 return true;
466 } 466 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 } 687 }
688 688
689 bool TiledPictureRenderer::render(SkBitmap** out) { 689 bool TiledPictureRenderer::render(SkBitmap** out) {
690 SkASSERT(fPicture != NULL); 690 SkASSERT(fPicture != NULL);
691 if (NULL == fPicture) { 691 if (NULL == fPicture) {
692 return false; 692 return false;
693 } 693 }
694 694
695 SkBitmap bitmap; 695 SkBitmap bitmap;
696 if (out) { 696 if (out) {
697 *out = SkNEW(SkBitmap); 697 *out = new SkBitmap;
698 setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()), 698 setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()),
699 SkScalarCeilToInt(fPicture->cullRect().height())); 699 SkScalarCeilToInt(fPicture->cullRect().height()));
700 setup_bitmap(&bitmap, fTileWidth, fTileHeight); 700 setup_bitmap(&bitmap, fTileWidth, fTileHeight);
701 } 701 }
702 bool success = true; 702 bool success = true;
703 703
704 if (fUseMultiPictureDraw) { 704 if (fUseMultiPictureDraw) {
705 SkMultiPictureDraw mpd; 705 SkMultiPictureDraw mpd;
706 SkTDArray<SkSurface*> surfaces; 706 SkTDArray<SkSurface*> surfaces;
707 surfaces.setReserve(fTileRects.count()); 707 surfaces.setReserve(fTileRects.count());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 } else { 787 } else {
788 name.appendf("%i", fTileHeight); 788 name.appendf("%i", fTileHeight);
789 } 789 }
790 return name; 790 return name;
791 } 791 }
792 792
793 //////////////////////////////////////////////////////////////////////////////// /////////////// 793 //////////////////////////////////////////////////////////////////////////////// ///////////////
794 794
795 void PlaybackCreationRenderer::setup() { 795 void PlaybackCreationRenderer::setup() {
796 SkAutoTDelete<SkBBHFactory> factory(this->getFactory()); 796 SkAutoTDelete<SkBBHFactory> factory(this->getFactory());
797 fRecorder.reset(SkNEW(SkPictureRecorder)); 797 fRecorder.reset(new SkPictureRecorder);
798 SkCanvas* canvas = fRecorder->beginRecording(SkIntToScalar(this->getViewWidt h()), 798 SkCanvas* canvas = fRecorder->beginRecording(SkIntToScalar(this->getViewWidt h()),
799 SkIntToScalar(this->getViewHeig ht()), 799 SkIntToScalar(this->getViewHeig ht()),
800 factory.get(), 800 factory.get(),
801 this->recordFlags()); 801 this->recordFlags());
802 this->scaleToScaleFactor(canvas); 802 this->scaleToScaleFactor(canvas);
803 canvas->drawPicture(fPicture); 803 canvas->drawPicture(fPicture);
804 } 804 }
805 805
806 bool PlaybackCreationRenderer::render(SkBitmap** out) { 806 bool PlaybackCreationRenderer::render(SkBitmap** out) {
807 fPicture.reset(fRecorder->endRecording()); 807 fPicture.reset(fRecorder->endRecording());
808 // Since this class does not actually render, return false. 808 // Since this class does not actually render, return false.
809 return false; 809 return false;
810 } 810 }
811 811
812 SkString PlaybackCreationRenderer::getConfigNameInternal() { 812 SkString PlaybackCreationRenderer::getConfigNameInternal() {
813 return SkString("playback_creation"); 813 return SkString("playback_creation");
814 } 814 }
815 815
816 //////////////////////////////////////////////////////////////////////////////// /////////////// 816 //////////////////////////////////////////////////////////////////////////////// ///////////////
817 // SkPicture variants for each BBoxHierarchy type 817 // SkPicture variants for each BBoxHierarchy type
818 818
819 SkBBHFactory* PictureRenderer::getFactory() { 819 SkBBHFactory* PictureRenderer::getFactory() {
820 switch (fBBoxHierarchyType) { 820 switch (fBBoxHierarchyType) {
821 case kNone_BBoxHierarchyType: 821 case kNone_BBoxHierarchyType:
822 return NULL; 822 return NULL;
823 case kRTree_BBoxHierarchyType: 823 case kRTree_BBoxHierarchyType:
824 return SkNEW(SkRTreeFactory); 824 return new SkRTreeFactory;
825 } 825 }
826 SkASSERT(0); // invalid bbhType 826 SkASSERT(0); // invalid bbhType
827 return NULL; 827 return NULL;
828 } 828 }
829 829
830 } // namespace sk_tools 830 } // namespace sk_tools
OLDNEW
« no previous file with comments | « tools/PictureBenchmark.cpp ('k') | tools/PictureRenderingFlags.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698