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

Side by Side Diff: bench/RecordingBench.cpp

Issue 2230323002: In recording benches, record to and from the same format. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « bench/RecordingBench.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 2014 Google Inc. 2 * Copyright 2014 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 "RecordingBench.h" 8 #include "RecordingBench.h"
9 #include "SkBBHFactory.h" 9 #include "SkBBHFactory.h"
10 #include "SkLiteDL.h" 10 #include "SkLiteDL.h"
11 #include "SkLiteRecorder.h" 11 #include "SkLiteRecorder.h"
12 #include "SkPictureRecorder.h" 12 #include "SkPictureRecorder.h"
13 13
14 RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useB BH, bool lite) 14 RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useB BH, bool lite)
15 : fName(name) 15 : fName(name)
16 , fUseBBH(useBBH) 16 , fUseBBH(useBBH) {
17 , fLite(lite) {
18 // Flatten the source picture in case it's trivially nested (useless for tim ing). 17 // Flatten the source picture in case it's trivially nested (useless for tim ing).
19 SkPictureRecorder rec; 18 SkPictureRecorder rec;
20 pic->playback(rec.beginRecording(pic->cullRect(), nullptr, 19 pic->playback(rec.beginRecording(pic->cullRect(), nullptr,
21 SkPictureRecorder::kPlaybackDrawPicture_Rec ordFlag)); 20 SkPictureRecorder::kPlaybackDrawPicture_Rec ordFlag));
22 fSrc = rec.finishRecordingAsPicture(); 21 fSrc = rec.finishRecordingAsPicture();
22
23 // If we're recording into an SkLiteDL, also record _from_ one.
24 if (lite) {
25 fDL = SkLiteDL::New(pic->cullRect());
26 SkLiteRecorder r;
27 r.reset(fDL.get());
28 fSrc->playback(&r);
29 }
23 } 30 }
24 31
25 const char* RecordingBench::onGetName() { 32 const char* RecordingBench::onGetName() {
26 return fName.c_str(); 33 return fName.c_str();
27 } 34 }
28 35
29 bool RecordingBench::isSuitableFor(Backend backend) { 36 bool RecordingBench::isSuitableFor(Backend backend) {
30 return backend == kNonRendering_Backend; 37 return backend == kNonRendering_Backend;
31 } 38 }
32 39
33 SkIPoint RecordingBench::onGetSize() { 40 SkIPoint RecordingBench::onGetSize() {
34 return SkIPoint::Make(SkScalarCeilToInt(fSrc->cullRect().width()), 41 return SkIPoint::Make(SkScalarCeilToInt(fSrc->cullRect().width()),
35 SkScalarCeilToInt(fSrc->cullRect().height())); 42 SkScalarCeilToInt(fSrc->cullRect().height()));
36 } 43 }
37 44
38 void RecordingBench::onDraw(int loops, SkCanvas*) { 45 void RecordingBench::onDraw(int loops, SkCanvas*) {
39 if (fLite) { 46 if (fDL) {
40 SkLiteRecorder rec; 47 SkLiteRecorder rec;
41 while (loops --> 0) { 48 while (loops --> 0) {
42 sk_sp<SkLiteDL> dl = SkLiteDL::New(fSrc->cullRect()); 49 sk_sp<SkLiteDL> dl = SkLiteDL::New(fSrc->cullRect());
43 rec.reset(dl.get()); 50 rec.reset(dl.get());
44 fSrc->playback(&rec); 51 fDL->draw(&rec);
45 dl->makeThreadsafe(); 52 dl->makeThreadsafe();
46 } 53 }
47 54
48 } else { 55 } else {
49 SkRTreeFactory factory; 56 SkRTreeFactory factory;
50 SkPictureRecorder recorder; 57 SkPictureRecorder recorder;
51 while (loops --> 0) { 58 while (loops --> 0) {
52 fSrc->playback(recorder.beginRecording(fSrc->cullRect(), fUseBBH ? & factory : nullptr)); 59 fSrc->playback(recorder.beginRecording(fSrc->cullRect(), fUseBBH ? & factory : nullptr));
53 (void)recorder.finishRecordingAsPicture(); 60 (void)recorder.finishRecordingAsPicture();
54 } 61 }
55 } 62 }
56 } 63 }
OLDNEW
« no previous file with comments | « bench/RecordingBench.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698