Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tools/dump_record.cpp

Issue 1459823003: add --write option to dump_record (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: I SO NEED to see these warnings on the mac Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
13 #include "SkRecordDraw.h"
12 #include "SkRecordOpts.h" 14 #include "SkRecordOpts.h"
13 #include "SkRecorder.h" 15 #include "SkRecorder.h"
14 #include "SkStream.h" 16 #include "SkStream.h"
15 #include <stdio.h> 17 #include <stdio.h>
16 18
17 DEFINE_string2(skps, r, "", ".SKPs to dump."); 19 DEFINE_string2(skps, r, "", ".SKPs to dump.");
18 DEFINE_string(match, "", "The usual filters on file names to dump."); 20 DEFINE_string(match, "", "The usual filters on file names to dump.");
19 DEFINE_bool2(optimize, O, false, "Run SkRecordOptimize before dumping."); 21 DEFINE_bool2(optimize, O, false, "Run SkRecordOptimize before dumping.");
20 DEFINE_int32(tile, 1000000000, "Simulated tile size."); 22 DEFINE_int32(tile, 1000000000, "Simulated tile size.");
21 DEFINE_bool(timeWithCommand, false, "If true, print time next to command, else i n first column."); 23 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.") ;
22 25
23 static void dump(const char* name, int w, int h, const SkRecord& record) { 26 static void dump(const char* name, int w, int h, const SkRecord& record) {
24 SkBitmap bitmap; 27 SkBitmap bitmap;
25 bitmap.allocN32Pixels(w, h); 28 bitmap.allocN32Pixels(w, h);
26 SkCanvas canvas(bitmap); 29 SkCanvas canvas(bitmap);
27 canvas.clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), 30 canvas.clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile),
28 SkIntToScalar(FLAGS_tile))); 31 SkIntToScalar(FLAGS_tile)));
29 32
30 printf("%s %s\n", FLAGS_optimize ? "optimized" : "not-optimized", name); 33 printf("%s %s\n", FLAGS_optimize ? "optimized" : "not-optimized", name);
31 34
32 DumpRecord(record, &canvas, FLAGS_timeWithCommand); 35 DumpRecord(record, &canvas, FLAGS_timeWithCommand);
33 } 36 }
34 37
35
36 int tool_main(int argc, char** argv); 38 int tool_main(int argc, char** argv);
37 int tool_main(int argc, char** argv) { 39 int tool_main(int argc, char** argv) {
38 SkCommandLineFlags::Parse(argc, argv); 40 SkCommandLineFlags::Parse(argc, argv);
39 41
40 for (int i = 0; i < FLAGS_skps.count(); i++) { 42 for (int i = 0; i < FLAGS_skps.count(); i++) {
41 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, FLAGS_skps[i])) { 43 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, FLAGS_skps[i])) {
42 continue; 44 continue;
43 } 45 }
44 46
45 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(FLAGS_skps[i])); 47 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(FLAGS_skps[i]));
(...skipping 12 matching lines...) Expand all
58 60
59 SkRecord record; 61 SkRecord record;
60 SkRecorder canvas(&record, w, h); 62 SkRecorder canvas(&record, w, h);
61 src->playback(&canvas); 63 src->playback(&canvas);
62 64
63 if (FLAGS_optimize) { 65 if (FLAGS_optimize) {
64 SkRecordOptimize(&record); 66 SkRecordOptimize(&record);
65 } 67 }
66 68
67 dump(FLAGS_skps[i], w, h, record); 69 dump(FLAGS_skps[i], w, h, record);
70
71 if (FLAGS_write.count() > 0) {
72 SkPictureRecorder r;
73 SkRecordDraw(record,
74 r.beginRecording(SkRect::MakeIWH(w, h)),
75 nullptr,
76 nullptr,
77 0,
78 nullptr,
79 nullptr);
80 SkAutoTUnref<SkPicture> dst(r.endRecording());
81 SkFILEWStream ostream(FLAGS_write[0]);
82 dst->serialize(&ostream);
83 }
68 } 84 }
69 85
70 return 0; 86 return 0;
71 } 87 }
72 88
73 #if !defined SK_BUILD_FOR_IOS 89 #if !defined SK_BUILD_FOR_IOS
74 int main(int argc, char * const argv[]) { 90 int main(int argc, char * const argv[]) {
75 return tool_main(argc, (char**) argv); 91 return tool_main(argc, (char**) argv);
76 } 92 }
77 #endif 93 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698