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 "SkPicture.h" | 10 #include "SkPicture.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 for (int i = 0; i < FLAGS_skps.count(); i++) { | 42 for (int i = 0; i < FLAGS_skps.count(); i++) { |
43 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, FLAGS_skps[i])) { | 43 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, FLAGS_skps[i])) { |
44 continue; | 44 continue; |
45 } | 45 } |
46 | 46 |
47 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(FLAGS_skps[i])); | 47 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(FLAGS_skps[i])); |
48 if (!stream) { | 48 if (!stream) { |
49 SkDebugf("Could not read %s.\n", FLAGS_skps[i]); | 49 SkDebugf("Could not read %s.\n", FLAGS_skps[i]); |
50 return 1; | 50 return 1; |
51 } | 51 } |
52 SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream)); | 52 sk_sp<SkPicture> src(SkPicture::MakeFromStream(stream)); |
53 if (!src) { | 53 if (!src) { |
54 SkDebugf("Could not read %s as an SkPicture.\n", FLAGS_skps[i]); | 54 SkDebugf("Could not read %s as an SkPicture.\n", FLAGS_skps[i]); |
55 return 1; | 55 return 1; |
56 } | 56 } |
57 const int w = SkScalarCeilToInt(src->cullRect().width()); | 57 const int w = SkScalarCeilToInt(src->cullRect().width()); |
58 const int h = SkScalarCeilToInt(src->cullRect().height()); | 58 const int h = SkScalarCeilToInt(src->cullRect().height()); |
59 | 59 |
60 SkRecord record; | 60 SkRecord record; |
61 SkRecorder canvas(&record, w, h); | 61 SkRecorder canvas(&record, w, h); |
62 src->playback(&canvas); | 62 src->playback(&canvas); |
63 | 63 |
64 if (FLAGS_optimize) { | 64 if (FLAGS_optimize) { |
65 SkRecordOptimize(&record); | 65 SkRecordOptimize(&record); |
66 } | 66 } |
67 if (FLAGS_optimize2) { | 67 if (FLAGS_optimize2) { |
68 SkRecordOptimize2(&record); | 68 SkRecordOptimize2(&record); |
69 } | 69 } |
70 | 70 |
71 dump(FLAGS_skps[i], w, h, record); | 71 dump(FLAGS_skps[i], w, h, record); |
72 | 72 |
73 if (FLAGS_write.count() > 0) { | 73 if (FLAGS_write.count() > 0) { |
74 SkPictureRecorder r; | 74 SkPictureRecorder r; |
75 SkRecordDraw(record, | 75 SkRecordDraw(record, |
76 r.beginRecording(SkRect::MakeIWH(w, h)), | 76 r.beginRecording(SkRect::MakeIWH(w, h)), |
77 nullptr, | 77 nullptr, |
78 nullptr, | 78 nullptr, |
79 0, | 79 0, |
80 nullptr, | 80 nullptr, |
81 nullptr); | 81 nullptr); |
82 SkAutoTUnref<SkPicture> dst(r.endRecording()); | 82 sk_sp<SkPicture> dst(r.finishRecordingAsPicture()); |
83 SkFILEWStream ostream(FLAGS_write[0]); | 83 SkFILEWStream ostream(FLAGS_write[0]); |
84 dst->serialize(&ostream); | 84 dst->serialize(&ostream); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 return 0; | 88 return 0; |
89 } | 89 } |
90 | 90 |
91 #if !defined SK_BUILD_FOR_IOS | 91 #if !defined SK_BUILD_FOR_IOS |
92 int main(int argc, char * const argv[]) { | 92 int main(int argc, char * const argv[]) { |
93 return tool_main(argc, (char**) argv); | 93 return tool_main(argc, (char**) argv); |
94 } | 94 } |
95 #endif | 95 #endif |
OLD | NEW |