| 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 "LazyDecodeBitmap.h" | 9 #include "LazyDecodeBitmap.h" |
| 10 #include "SkCommandLineFlags.h" | 10 #include "SkCommandLineFlags.h" |
| 11 #include "SkPicture.h" | 11 #include "SkPicture.h" |
| 12 #include "SkPictureRecorder.h" | 12 #include "SkPictureRecorder.h" |
| 13 #include "SkRecordDraw.h" | 13 #include "SkRecordDraw.h" |
| 14 #include "SkRecordOpts.h" | 14 #include "SkRecordOpts.h" |
| 15 #include "SkRecorder.h" | 15 #include "SkRecorder.h" |
| 16 #include "SkStream.h" | 16 #include "SkStream.h" |
| 17 #include <stdio.h> | 17 #include <stdio.h> |
| 18 | 18 |
| 19 DEFINE_string2(skps, r, "", ".SKPs to dump."); | 19 DEFINE_string2(skps, r, "", ".SKPs to dump."); |
| 20 DEFINE_string(match, "", "The usual filters on file names to dump."); | 20 DEFINE_string(match, "", "The usual filters on file names to dump."); |
| 21 DEFINE_bool2(optimize, O, false, "Run SkRecordOptimize before dumping."); | 21 DEFINE_bool2(optimize, O, false, "Run SkRecordOptimize 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.")
; |
| 25 | 26 |
| 26 static void dump(const char* name, int w, int h, const SkRecord& record) { | 27 static void dump(const char* name, int w, int h, const SkRecord& record) { |
| 27 SkBitmap bitmap; | 28 SkBitmap bitmap; |
| 28 bitmap.allocN32Pixels(w, h); | 29 bitmap.allocN32Pixels(w, h); |
| 29 SkCanvas canvas(bitmap); | 30 SkCanvas canvas(bitmap); |
| 30 canvas.clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), | 31 canvas.clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), |
| 31 SkIntToScalar(FLAGS_tile))); | 32 SkIntToScalar(FLAGS_tile))); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 58 const int w = SkScalarCeilToInt(src->cullRect().width()); | 59 const int w = SkScalarCeilToInt(src->cullRect().width()); |
| 59 const int h = SkScalarCeilToInt(src->cullRect().height()); | 60 const int h = SkScalarCeilToInt(src->cullRect().height()); |
| 60 | 61 |
| 61 SkRecord record; | 62 SkRecord record; |
| 62 SkRecorder canvas(&record, w, h); | 63 SkRecorder canvas(&record, w, h); |
| 63 src->playback(&canvas); | 64 src->playback(&canvas); |
| 64 | 65 |
| 65 if (FLAGS_optimize) { | 66 if (FLAGS_optimize) { |
| 66 SkRecordOptimize(&record); | 67 SkRecordOptimize(&record); |
| 67 } | 68 } |
| 69 if (FLAGS_optimize2) { |
| 70 SkRecordOptimize2(&record); |
| 71 } |
| 68 | 72 |
| 69 dump(FLAGS_skps[i], w, h, record); | 73 dump(FLAGS_skps[i], w, h, record); |
| 70 | 74 |
| 71 if (FLAGS_write.count() > 0) { | 75 if (FLAGS_write.count() > 0) { |
| 72 SkPictureRecorder r; | 76 SkPictureRecorder r; |
| 73 SkRecordDraw(record, | 77 SkRecordDraw(record, |
| 74 r.beginRecording(SkRect::MakeIWH(w, h)), | 78 r.beginRecording(SkRect::MakeIWH(w, h)), |
| 75 nullptr, | 79 nullptr, |
| 76 nullptr, | 80 nullptr, |
| 77 0, | 81 0, |
| 78 nullptr, | 82 nullptr, |
| 79 nullptr); | 83 nullptr); |
| 80 SkAutoTUnref<SkPicture> dst(r.endRecording()); | 84 SkAutoTUnref<SkPicture> dst(r.endRecording()); |
| 81 SkFILEWStream ostream(FLAGS_write[0]); | 85 SkFILEWStream ostream(FLAGS_write[0]); |
| 82 dst->serialize(&ostream); | 86 dst->serialize(&ostream); |
| 83 } | 87 } |
| 84 } | 88 } |
| 85 | 89 |
| 86 return 0; | 90 return 0; |
| 87 } | 91 } |
| 88 | 92 |
| 89 #if !defined SK_BUILD_FOR_IOS | 93 #if !defined SK_BUILD_FOR_IOS |
| 90 int main(int argc, char * const argv[]) { | 94 int main(int argc, char * const argv[]) { |
| 91 return tool_main(argc, (char**) argv); | 95 return tool_main(argc, (char**) argv); |
| 92 } | 96 } |
| 93 #endif | 97 #endif |
| OLD | NEW |