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 "DumpRecord.h" | 8 #include "DumpRecord.h" |
9 #include "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
| 10 #include "SkDeferredCanvas.h" |
10 #include "SkPicture.h" | 11 #include "SkPicture.h" |
11 #include "SkPictureRecorder.h" | 12 #include "SkPictureRecorder.h" |
12 #include "SkRecordDraw.h" | 13 #include "SkRecordDraw.h" |
13 #include "SkRecordOpts.h" | 14 #include "SkRecordOpts.h" |
14 #include "SkRecorder.h" | 15 #include "SkRecorder.h" |
15 #include "SkStream.h" | 16 #include "SkStream.h" |
16 #include <stdio.h> | 17 #include <stdio.h> |
17 | 18 |
18 DEFINE_string2(skps, r, "", ".SKPs to dump."); | 19 DEFINE_string2(skps, r, "", ".SKPs to dump."); |
19 DEFINE_string(match, "", "The usual filters on file names to dump."); | 20 DEFINE_string(match, "", "The usual filters on file names to dump."); |
20 DEFINE_bool2(optimize, O, false, "Run SkRecordOptimize before dumping."); | 21 DEFINE_bool2(optimize, O, false, "Run SkRecordOptimize before dumping."); |
21 DEFINE_bool(optimize2, false, "Run SkRecordOptimize2 before dumping."); | 22 DEFINE_bool(optimize2, false, "Run SkRecordOptimize2 before dumping."); |
22 DEFINE_int32(tile, 1000000000, "Simulated tile size."); | 23 DEFINE_int32(tile, 1000000000, "Simulated tile size."); |
23 DEFINE_bool(timeWithCommand, false, "If true, print time next to command, else i
n first column."); | 24 DEFINE_bool(timeWithCommand, false, "If true, print time next to command, else i
n first column."); |
24 DEFINE_string2(write, w, "", "Write the (optimized) picture to the named file.")
; | 25 DEFINE_string2(write, w, "", "Write the (optimized) picture to the named file.")
; |
| 26 DEFINE_bool(defer, false, "Defer clips and translates"); |
25 | 27 |
26 static void dump(const char* name, int w, int h, const SkRecord& record) { | 28 static void dump(const char* name, int w, int h, const SkRecord& record) { |
27 SkBitmap bitmap; | 29 SkBitmap bitmap; |
28 bitmap.allocN32Pixels(w, h); | 30 bitmap.allocN32Pixels(w, h); |
29 SkCanvas canvas(bitmap); | 31 SkCanvas canvas(bitmap); |
30 canvas.clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), | 32 canvas.clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), |
31 SkIntToScalar(FLAGS_tile))); | 33 SkIntToScalar(FLAGS_tile))); |
32 | 34 |
33 printf("%s %s\n", FLAGS_optimize ? "optimized" : "not-optimized", name); | 35 printf("%s %s\n", FLAGS_optimize ? "optimized" : "not-optimized", name); |
34 | 36 |
(...skipping 12 matching lines...) Expand all Loading... |
47 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(FLAGS_skps[i])); | 49 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(FLAGS_skps[i])); |
48 if (!stream) { | 50 if (!stream) { |
49 SkDebugf("Could not read %s.\n", FLAGS_skps[i]); | 51 SkDebugf("Could not read %s.\n", FLAGS_skps[i]); |
50 return 1; | 52 return 1; |
51 } | 53 } |
52 sk_sp<SkPicture> src(SkPicture::MakeFromStream(stream)); | 54 sk_sp<SkPicture> src(SkPicture::MakeFromStream(stream)); |
53 if (!src) { | 55 if (!src) { |
54 SkDebugf("Could not read %s as an SkPicture.\n", FLAGS_skps[i]); | 56 SkDebugf("Could not read %s as an SkPicture.\n", FLAGS_skps[i]); |
55 return 1; | 57 return 1; |
56 } | 58 } |
| 59 if (FLAGS_defer) { |
| 60 SkPictureRecorder recorder; |
| 61 SkDeferredCanvas deferred(recorder.beginRecording(src->cullRect())); |
| 62 src->playback(&deferred); |
| 63 src = recorder.finishRecordingAsPicture(); |
| 64 } |
57 const int w = SkScalarCeilToInt(src->cullRect().width()); | 65 const int w = SkScalarCeilToInt(src->cullRect().width()); |
58 const int h = SkScalarCeilToInt(src->cullRect().height()); | 66 const int h = SkScalarCeilToInt(src->cullRect().height()); |
59 | 67 |
60 SkRecord record; | 68 SkRecord record; |
61 SkRecorder canvas(&record, w, h); | 69 SkRecorder canvas(&record, w, h); |
62 src->playback(&canvas); | 70 src->playback(&canvas); |
63 | 71 |
64 if (FLAGS_optimize) { | 72 if (FLAGS_optimize) { |
65 SkRecordOptimize(&record); | 73 SkRecordOptimize(&record); |
66 } | 74 } |
(...skipping 19 matching lines...) Expand all Loading... |
86 } | 94 } |
87 | 95 |
88 return 0; | 96 return 0; |
89 } | 97 } |
90 | 98 |
91 #if !defined SK_BUILD_FOR_IOS | 99 #if !defined SK_BUILD_FOR_IOS |
92 int main(int argc, char * const argv[]) { | 100 int main(int argc, char * const argv[]) { |
93 return tool_main(argc, (char**) argv); | 101 return tool_main(argc, (char**) argv); |
94 } | 102 } |
95 #endif | 103 #endif |
OLD | NEW |