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 "SkCommandLineFlags.h" | 8 #include "SkCommandLineFlags.h" |
9 #include "SkForceLinking.h" | 9 #include "SkForceLinking.h" |
10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
11 #include "SkOSFile.h" | 11 #include "SkOSFile.h" |
12 #include "SkPicture.h" | 12 #include "SkPicture.h" |
13 #include "SkQuadTreePicture.h" | 13 #include "SkQuadTreePicture.h" |
14 #include "SkRecorder.h" | 14 #include "SkRecording.h" |
15 #include "SkStream.h" | 15 #include "SkStream.h" |
16 #include "SkString.h" | 16 #include "SkString.h" |
17 #include "SkTileGridPicture.h" | 17 #include "SkTileGridPicture.h" |
18 #include "SkTime.h" | 18 #include "SkTime.h" |
19 #include "LazyDecodeBitmap.h" | 19 #include "LazyDecodeBitmap.h" |
20 | 20 |
21 __SK_FORCE_IMAGE_DECODER_LINKING; | 21 __SK_FORCE_IMAGE_DECODER_LINKING; |
22 | 22 |
23 // Just reading all the SKPs takes about 2 seconds for me, which is the same as
about 100 loops of | 23 // Just reading all the SKPs takes about 2 seconds for me, which is the same as
about 100 loops of |
24 // rerecording all the SKPs. So we default to --loops=900, which makes ~90% of
our time spent in | 24 // rerecording all the SKPs. So we default to --loops=900, which makes ~90% of
our time spent in |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return NULL; | 79 return NULL; |
80 } | 80 } |
81 | 81 |
82 static void bench_record(SkPicture* src, const char* name, PictureFactory pictur
eFactory) { | 82 static void bench_record(SkPicture* src, const char* name, PictureFactory pictur
eFactory) { |
83 const SkMSec start = SkTime::GetMSecs(); | 83 const SkMSec start = SkTime::GetMSecs(); |
84 const int width = src ? src->width() : FLAGS_nullSize; | 84 const int width = src ? src->width() : FLAGS_nullSize; |
85 const int height = src ? src->height() : FLAGS_nullSize; | 85 const int height = src ? src->height() : FLAGS_nullSize; |
86 | 86 |
87 for (int i = 0; i < FLAGS_loops; i++) { | 87 for (int i = 0; i < FLAGS_loops; i++) { |
88 if (FLAGS_skr) { | 88 if (FLAGS_skr) { |
89 SkRecord record; | 89 using EXPERIMENTAL::SkRecording; |
90 SkRecorder canvas(SkRecorder::kWriteOnly_Mode, &record, width, heigh
t); | 90 SkRecording* recording = SkRecording::Create(width, height); |
91 if (NULL != src) { | 91 if (NULL != src) { |
92 src->draw(&canvas); | 92 src->draw(recording->canvas()); |
93 } | 93 } |
| 94 SkDELETE(SkRecording::Delete(recording)); // delete the SkPlayback*
. |
94 } else { | 95 } else { |
95 int recordingFlags = FLAGS_flags; | 96 int recordingFlags = FLAGS_flags; |
96 SkAutoTUnref<SkPictureFactory> factory(pictureFactory(&recordingFlag
s)); | 97 SkAutoTUnref<SkPictureFactory> factory(pictureFactory(&recordingFlag
s)); |
97 SkPictureRecorder recorder(factory); | 98 SkPictureRecorder recorder(factory); |
98 SkCanvas* canvas = recorder.beginRecording(width, height, recordingF
lags); | 99 SkCanvas* canvas = recorder.beginRecording(width, height, recordingF
lags); |
99 if (NULL != src) { | 100 if (NULL != src) { |
100 src->draw(canvas); | 101 src->draw(canvas); |
101 } | 102 } |
102 if (FLAGS_endRecording) { | 103 if (FLAGS_endRecording) { |
103 SkAutoTUnref<SkPicture> dst(recorder.endRecording()); | 104 SkAutoTUnref<SkPicture> dst(recorder.endRecording()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 bench_record(src, filename.c_str(), pictureFactory); | 147 bench_record(src, filename.c_str(), pictureFactory); |
147 } | 148 } |
148 return failed ? 1 : 0; | 149 return failed ? 1 : 0; |
149 } | 150 } |
150 | 151 |
151 #if !defined SK_BUILD_FOR_IOS | 152 #if !defined SK_BUILD_FOR_IOS |
152 int main(int argc, char * const argv[]) { | 153 int main(int argc, char * const argv[]) { |
153 return tool_main(argc, (char**) argv); | 154 return tool_main(argc, (char**) argv); |
154 } | 155 } |
155 #endif | 156 #endif |
OLD | NEW |