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 "SkRecordDraw.h" | 13 #include "SkRecordDraw.h" |
14 #include "SkRecorder.h" | 14 #include "SkRecorder.h" |
15 #include "SkStream.h" | 15 #include "SkStream.h" |
16 #include "SkString.h" | 16 #include "SkString.h" |
17 #include "SkTime.h" | 17 #include "SkTime.h" |
18 | 18 |
19 __SK_FORCE_IMAGE_DECODER_LINKING; | 19 __SK_FORCE_IMAGE_DECODER_LINKING; |
20 | 20 |
21 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record
."); | 21 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record
."); |
22 DEFINE_int32(loops, 10, "Number of times to play back each SKP."); | 22 DEFINE_int32(loops, 10, "Number of times to play back each SKP."); |
23 DEFINE_bool(skr, false, "Play via SkRecord instead of SkPicture."); | 23 DEFINE_bool(skr, false, "Play via SkRecord instead of SkPicture."); |
24 DEFINE_int32(tile, 1000000000, "Simulated tile size."); | 24 DEFINE_int32(tile, 1000000000, "Simulated tile size."); |
25 | 25 |
26 static void bench(SkPMColor* scratch, SkPicture& src, const char* name) { | 26 static void bench(SkPMColor* scratch, SkPicture& src, const char* name) { |
| 27 // We don't use the public SkRecording interface here because we need kWrite
Only_Mode. |
| 28 // (We don't want SkPicturePlayback to be able to optimize playing into our
SkRecord.) |
27 SkRecord record; | 29 SkRecord record; |
28 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, src.width(), src.h
eight()); | 30 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, src.width(), src.h
eight()); |
29 src.draw(&recorder); | 31 src.draw(&recorder); |
30 | 32 |
31 SkAutoTDelete<SkCanvas> canvas(SkCanvas::NewRasterDirectN32(src.width(), | 33 SkAutoTDelete<SkCanvas> canvas(SkCanvas::NewRasterDirectN32(src.width(), |
32 src.height(), | 34 src.height(), |
33 scratch, | 35 scratch, |
34 src.width() * si
zeof(SkPMColor))); | 36 src.width() * si
zeof(SkPMColor))); |
35 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLA
GS_tile))); | 37 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLA
GS_tile))); |
36 | 38 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 bench(scratch.get(), *src, filename.c_str()); | 88 bench(scratch.get(), *src, filename.c_str()); |
87 } | 89 } |
88 return failed ? 1 : 0; | 90 return failed ? 1 : 0; |
89 } | 91 } |
90 | 92 |
91 #if !defined SK_BUILD_FOR_IOS | 93 #if !defined SK_BUILD_FOR_IOS |
92 int main(int argc, char * const argv[]) { | 94 int main(int argc, char * const argv[]) { |
93 return tool_main(argc, (char**) argv); | 95 return tool_main(argc, (char**) argv); |
94 } | 96 } |
95 #endif | 97 #endif |
OLD | NEW |