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

Side by Side Diff: tools/bench_record.cpp

Issue 184543003: Adding flag to switch bench_record into tilegrid mode (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Name changes Created 6 years, 9 months 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 "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 "SkStream.h" 13 #include "SkStream.h"
14 #include "SkString.h" 14 #include "SkString.h"
15 #include "SkTileGridPicture.h"
15 #include "SkTime.h" 16 #include "SkTime.h"
16 17
17 __SK_FORCE_IMAGE_DECODER_LINKING; 18 __SK_FORCE_IMAGE_DECODER_LINKING;
18 19
19 // Just reading all the SKPs takes about 2 seconds for me, which is the same as about 100 loops of 20 // Just reading all the SKPs takes about 2 seconds for me, which is the same as about 100 loops of
20 // rerecording all the SKPs. So we default to --loops=900, which makes ~90% of our time spent in 21 // rerecording all the SKPs. So we default to --loops=900, which makes ~90% of our time spent in
21 // recording, and this should take ~20 seconds to run. 22 // recording, and this should take ~20 seconds to run.
22 23
23 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record ."); 24 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record .");
24 DEFINE_int32(loops, 900, "Number of times to re-record each SKP."); 25 DEFINE_int32(loops, 900, "Number of times to re-record each SKP.");
25 DEFINE_int32(flags, SkPicture::kUsePathBoundsForClip_RecordingFlag, "RecordingFl ags to use."); 26 DEFINE_int32(flags, SkPicture::kUsePathBoundsForClip_RecordingFlag, "RecordingFl ags to use.");
26 DEFINE_bool(endRecording, true, "If false, don't time SkPicture::endRecording()" ); 27 DEFINE_bool(endRecording, true, "If false, don't time SkPicture::endRecording()" );
27 DEFINE_int32(nullSize, 1000, "Pretend dimension of null source picture."); 28 DEFINE_int32(nullSize, 1000, "Pretend dimension of null source picture.");
29 DEFINE_int32(tileGridSize, 0, "Set the tile grid size, if non zero switches to t ile grid picture and enables kOptimizeForClippedPlayback_RecordingFlag.");
28 30
29 static void bench_record(SkPicture* src, const char* name) { 31 static void bench_record(SkPicture* src, const char* name) {
30 const SkMSec start = SkTime::GetMSecs(); 32 const SkMSec start = SkTime::GetMSecs();
31 const int width = src ? src->width() : FLAGS_nullSize; 33 const int width = src ? src->width() : FLAGS_nullSize;
32 const int height = src ? src->height() : FLAGS_nullSize; 34 const int height = src ? src->height() : FLAGS_nullSize;
33 35
34 for (int i = 0; i < FLAGS_loops; i++) { 36 for (int i = 0; i < FLAGS_loops; i++) {
35 SkPicture dst; 37 SkAutoTUnref<SkPicture> dst;
36 SkCanvas* canvas = dst.beginRecording(width, height, FLAGS_flags); 38 int recordingFlags = FLAGS_flags;
39 if (FLAGS_tileGridSize > 0) {
40 SkTileGridPicture::TileGridInfo info;
41 info.fTileInterval.set(FLAGS_tileGridSize, FLAGS_tileGridSize);
42 info.fMargin.setEmpty();
43 info.fOffset.setZero();
44 dst.reset(SkNEW_ARGS(SkTileGridPicture, (width, height, info)));
45 recordingFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFl ag;
46 } else {
47 dst.reset(SkNEW(SkPicture));
48 }
49 SkCanvas* canvas = dst->beginRecording(width, height, recordingFlags);
37 if (src) src->draw(canvas); 50 if (src) src->draw(canvas);
38 if (FLAGS_endRecording) dst.endRecording(); 51 if (FLAGS_endRecording) dst->endRecording();
39 } 52 }
40 53
41 const SkMSec elapsed = SkTime::GetMSecs() - start; 54 const SkMSec elapsed = SkTime::GetMSecs() - start;
42 const double msPerLoop = elapsed / (double)FLAGS_loops; 55 const double msPerLoop = elapsed / (double)FLAGS_loops;
43 printf("%.2g\t%s\n", msPerLoop, name); 56 printf("%.2g\t%s\n", msPerLoop, name);
44 } 57 }
45 58
46 int tool_main(int argc, char** argv); 59 int tool_main(int argc, char** argv);
47 int tool_main(int argc, char** argv) { 60 int tool_main(int argc, char** argv) {
48 SkCommandLineFlags::Parse(argc, argv); 61 SkCommandLineFlags::Parse(argc, argv);
(...skipping 23 matching lines...) Expand all
72 bench_record(src, filename.c_str()); 85 bench_record(src, filename.c_str());
73 } 86 }
74 return failed ? 1 : 0; 87 return failed ? 1 : 0;
75 } 88 }
76 89
77 #if !defined SK_BUILD_FOR_IOS 90 #if !defined SK_BUILD_FOR_IOS
78 int main(int argc, char * const argv[]) { 91 int main(int argc, char * const argv[]) {
79 return tool_main(argc, (char**) argv); 92 return tool_main(argc, (char**) argv);
80 } 93 }
81 #endif 94 #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