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 | 9 |
10 #include "SkBBHFactory.h" | 10 #include "SkBBHFactory.h" |
11 #include "SkPictureRecorder.h" | 11 #include "SkPictureRecorder.h" |
12 | 12 |
13 static const int kTileSize = 256; | |
14 | |
15 RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useB
BH) | 13 RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useB
BH) |
16 : fSrc(SkRef(pic)) | 14 : fSrc(SkRef(pic)) |
17 , fName(name) | 15 , fName(name) |
18 , fUseBBH(useBBH) {} | 16 , fUseBBH(useBBH) {} |
19 | 17 |
20 const char* RecordingBench::onGetName() { | 18 const char* RecordingBench::onGetName() { |
21 return fName.c_str(); | 19 return fName.c_str(); |
22 } | 20 } |
23 | 21 |
24 bool RecordingBench::isSuitableFor(Backend backend) { | 22 bool RecordingBench::isSuitableFor(Backend backend) { |
25 return backend == kNonRendering_Backend; | 23 return backend == kNonRendering_Backend; |
26 } | 24 } |
27 | 25 |
28 SkIPoint RecordingBench::onGetSize() { | 26 SkIPoint RecordingBench::onGetSize() { |
29 return SkIPoint::Make(SkScalarCeilToInt(fSrc->cullRect().width()), | 27 return SkIPoint::Make(SkScalarCeilToInt(fSrc->cullRect().width()), |
30 SkScalarCeilToInt(fSrc->cullRect().height())); | 28 SkScalarCeilToInt(fSrc->cullRect().height())); |
31 } | 29 } |
32 | 30 |
33 void RecordingBench::onDraw(const int loops, SkCanvas*) { | 31 void RecordingBench::onDraw(const int loops, SkCanvas*) { |
34 SkTileGridFactory::TileGridInfo info; | 32 SkRTreeFactory factory; |
35 info.fTileInterval.set(kTileSize, kTileSize); | |
36 info.fMargin.setEmpty(); | |
37 info.fOffset.setZero(); | |
38 SkTileGridFactory factory(info); | |
39 | |
40 const SkScalar w = fSrc->cullRect().width(), | 33 const SkScalar w = fSrc->cullRect().width(), |
41 h = fSrc->cullRect().height(); | 34 h = fSrc->cullRect().height(); |
42 | 35 |
43 for (int i = 0; i < loops; i++) { | 36 for (int i = 0; i < loops; i++) { |
44 SkPictureRecorder recorder; | 37 SkPictureRecorder recorder; |
45 fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : NULL))
; | 38 fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : NULL))
; |
46 SkDELETE(recorder.endRecording()); | 39 SkDELETE(recorder.endRecording()); |
47 } | 40 } |
48 } | 41 } |
OLD | NEW |