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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1129693003: Do we still need this DOUBLE_LOOP feature? (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 | « dm/DMSrcSink.h ('k') | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 "DMSrcSink.h" 8 #include "DMSrcSink.h"
9 #include "SamplePipeControllers.h" 9 #include "SamplePipeControllers.h"
10 #include "SkCodec.h" 10 #include "SkCodec.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (!stream) { 281 if (!stream) {
282 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); 282 return SkStringPrintf("Couldn't read %s.", fPath.c_str());
283 } 283 }
284 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream, &lazy_decode _bitmap)); 284 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream, &lazy_decode _bitmap));
285 if (!pic) { 285 if (!pic) {
286 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ; 286 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ;
287 } 287 }
288 stream.reset((SkStream*)NULL); // Might as well drop this when we're done w ith it. 288 stream.reset((SkStream*)NULL); // Might as well drop this when we're done w ith it.
289 289
290 canvas->clipRect(kSKPViewport); 290 canvas->clipRect(kSKPViewport);
291 // Testing TextBlob batching requires that we see individual text blobs more than once
292 // TODO remove this and add a flag to DM so we can run skps multiple times
293 //#define DOUBLE_LOOP
294 #ifdef DOUBLE_LOOP
295 {
296 SkAutoCanvasRestore acr(canvas, true);
297 #endif
298 canvas->drawPicture(pic);
299 #ifdef DOUBLE_LOOP
300 }
301 canvas->clear(0);
302 canvas->drawPicture(pic); 291 canvas->drawPicture(pic);
303 #endif
304 return ""; 292 return "";
305 } 293 }
306 294
307 SkISize SKPSrc::size() const { 295 SkISize SKPSrc::size() const {
308 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str())); 296 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str()));
309 if (!stream) { 297 if (!stream) {
310 return SkISize::Make(0,0); 298 return SkISize::Make(0,0);
311 } 299 }
312 SkPictInfo info; 300 SkPictInfo info;
313 if (!SkPicture::InternalOnly_StreamIsSKP(stream, &info)) { 301 if (!SkPicture::InternalOnly_StreamIsSKP(stream, &info)) {
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 701 }
714 pic.reset(recorder.endRecordingAsPicture()); 702 pic.reset(recorder.endRecordingAsPicture());
715 } 703 }
716 canvas->drawPicture(pic); 704 canvas->drawPicture(pic);
717 return ""; 705 return "";
718 }); 706 });
719 } 707 }
720 708
721 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 709 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
722 710
711 // Draw the Src twice. This can help exercise caching.
712 Error ViaTwice::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri ng* log) const {
713 return draw_to_canvas(fSink, bitmap, stream, log, src.size(), [&](SkCanvas* canvas) -> Error {
714 for (int i = 0; i < 2; i++) {
715 SkAutoCanvasRestore acr(canvas, true/*save now*/);
716 canvas->clear(SK_ColorTRANSPARENT);
717 Error err = src.draw(canvas);
718 if (err.isEmpty()) {
719 return err;
720 }
721 }
722 return "";
723 });
724 }
725
726 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
727
723 // This is like SkRecords::Draw, in that it plays back SkRecords ops into a Canv as. 728 // This is like SkRecords::Draw, in that it plays back SkRecords ops into a Canv as.
724 // Unlike SkRecords::Draw, it builds a single-op sub-picture out of each Draw-ty pe op. 729 // Unlike SkRecords::Draw, it builds a single-op sub-picture out of each Draw-ty pe op.
725 // This is an only-slightly-exaggerated simluation of Blink's Slimming Paint pic tures. 730 // This is an only-slightly-exaggerated simluation of Blink's Slimming Paint pic tures.
726 struct DrawsAsSingletonPictures { 731 struct DrawsAsSingletonPictures {
727 SkCanvas* fCanvas; 732 SkCanvas* fCanvas;
728 733
729 SK_CREATE_MEMBER_DETECTOR(paint); 734 SK_CREATE_MEMBER_DETECTOR(paint);
730 735
731 template <typename T> 736 template <typename T>
732 void draw(const T& op, SkCanvas* canvas) { 737 void draw(const T& op, SkCanvas* canvas) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 skr.visit<void>(i, drawsAsSingletonPictures); 780 skr.visit<void>(i, drawsAsSingletonPictures);
776 } 781 }
777 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 782 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
778 783
779 canvas->drawPicture(macroPic); 784 canvas->drawPicture(macroPic);
780 return ""; 785 return "";
781 }); 786 });
782 } 787 }
783 788
784 } // namespace DM 789 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMSrcSink.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698