OLD | NEW |
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 | |
10 #include "SkBBHFactory.h" | 9 #include "SkBBHFactory.h" |
| 10 #include "SkLiteDL.h" |
| 11 #include "SkLiteRecorder.h" |
11 #include "SkPictureRecorder.h" | 12 #include "SkPictureRecorder.h" |
12 | 13 |
13 RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useB
BH) | 14 RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useB
BH, bool lite) |
14 : fSrc(SkRef(pic)) | 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). |
| 19 SkPictureRecorder rec; |
| 20 pic->playback(rec.beginRecording(pic->cullRect(), nullptr, |
| 21 SkPictureRecorder::kPlaybackDrawPicture_Rec
ordFlag)); |
| 22 fSrc = rec.finishRecordingAsPicture(); |
| 23 } |
17 | 24 |
18 const char* RecordingBench::onGetName() { | 25 const char* RecordingBench::onGetName() { |
19 return fName.c_str(); | 26 return fName.c_str(); |
20 } | 27 } |
21 | 28 |
22 bool RecordingBench::isSuitableFor(Backend backend) { | 29 bool RecordingBench::isSuitableFor(Backend backend) { |
23 return backend == kNonRendering_Backend; | 30 return backend == kNonRendering_Backend; |
24 } | 31 } |
25 | 32 |
26 SkIPoint RecordingBench::onGetSize() { | 33 SkIPoint RecordingBench::onGetSize() { |
27 return SkIPoint::Make(SkScalarCeilToInt(fSrc->cullRect().width()), | 34 return SkIPoint::Make(SkScalarCeilToInt(fSrc->cullRect().width()), |
28 SkScalarCeilToInt(fSrc->cullRect().height())); | 35 SkScalarCeilToInt(fSrc->cullRect().height())); |
29 } | 36 } |
30 | 37 |
31 void RecordingBench::onDraw(int loops, SkCanvas*) { | 38 void RecordingBench::onDraw(int loops, SkCanvas*) { |
32 SkRTreeFactory factory; | 39 if (fLite) { |
33 const SkScalar w = fSrc->cullRect().width(), | 40 SkLiteRecorder rec; |
34 h = fSrc->cullRect().height(); | 41 while (loops --> 0) { |
| 42 sk_sp<SkLiteDL> dl = SkLiteDL::New(fSrc->cullRect()); |
| 43 rec.reset(dl.get()); |
| 44 fSrc->playback(&rec); |
| 45 dl->makeThreadsafe(); |
| 46 } |
35 | 47 |
36 uint32_t flags = SkPictureRecorder::kPlaybackDrawPicture_RecordFlag; | 48 } else { |
37 for (int i = 0; i < loops; i++) { | 49 SkRTreeFactory factory; |
38 SkPictureRecorder recorder; | 50 SkPictureRecorder recorder; |
39 fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : nullpt
r, flags)); | 51 while (loops --> 0) { |
40 (void)recorder.finishRecordingAsPicture(); | 52 fSrc->playback(recorder.beginRecording(fSrc->cullRect(), fUseBBH ? &
factory : nullptr)); |
| 53 (void)recorder.finishRecordingAsPicture(); |
| 54 } |
41 } | 55 } |
42 } | 56 } |
OLD | NEW |