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

Side by Side Diff: tools/bench_record.cpp

Issue 239703006: Retract SkPicture::kOptimizeForClippedPlayback_RecordingFlag from public API (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « tools/PictureRenderer.cpp ('k') | 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 "SkQuadTreePicture.h" 13 #include "SkQuadTreePicture.h"
14 #include "SkRecording.h" 14 #include "SkRecording.h"
15 #include "SkRTreePicture.h"
15 #include "SkStream.h" 16 #include "SkStream.h"
16 #include "SkString.h" 17 #include "SkString.h"
17 #include "SkTileGridPicture.h" 18 #include "SkTileGridPicture.h"
18 #include "SkTime.h" 19 #include "SkTime.h"
19 #include "LazyDecodeBitmap.h" 20 #include "LazyDecodeBitmap.h"
20 21
21 __SK_FORCE_IMAGE_DECODER_LINKING; 22 __SK_FORCE_IMAGE_DECODER_LINKING;
22 23
23 // Just reading all the SKPs takes about 2 seconds for me, which is the same as about 100 loops of 24 // Just reading all the SKPs takes about 2 seconds for me, which is the same as about 100 loops of
24 // rerecording all the SKPs. So we default to --loops=900, which makes ~90% of our time spent in 25 // rerecording all the SKPs. So we default to --loops=900, which makes ~90% of our time spent in
25 // recording, and this should take ~20 seconds to run. 26 // recording, and this should take ~20 seconds to run.
26 27
27 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record ."); 28 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record .");
28 DEFINE_int32(loops, 900, "Number of times to re-record each SKP."); 29 DEFINE_int32(loops, 900, "Number of times to re-record each SKP.");
29 DEFINE_int32(flags, SkPicture::kUsePathBoundsForClip_RecordingFlag, "RecordingFl ags to use."); 30 DEFINE_int32(flags, SkPicture::kUsePathBoundsForClip_RecordingFlag, "RecordingFl ags to use.");
30 DEFINE_bool(endRecording, true, "If false, don't time SkPicture::endRecording()" ); 31 DEFINE_bool(endRecording, true, "If false, don't time SkPicture::endRecording()" );
31 DEFINE_int32(nullSize, 1000, "Pretend dimension of null source picture."); 32 DEFINE_int32(nullSize, 1000, "Pretend dimension of null source picture.");
32 DEFINE_int32(tileGridSize, 512, "Set the tile grid size. Has no effect if bbh is not set to tilegrid."); 33 DEFINE_int32(tileGridSize, 512, "Set the tile grid size. Has no effect if bbh is not set to tilegrid.");
33 DEFINE_string(bbh, "", "Turn on the bbh and select the type, one of rtree, tileg rid, quadtree"); 34 DEFINE_string(bbh, "", "Turn on the bbh and select the type, one of rtree, tileg rid, quadtree");
34 DEFINE_bool(skr, false, "Record SKR instead of SKP."); 35 DEFINE_bool(skr, false, "Record SKR instead of SKP.");
35 36
36 typedef SkPictureFactory* (*PictureFactory)(int* recordingFlags); 37 typedef SkPictureFactory* (*PictureFactory)();
37 38
38 static SkPictureFactory* vanilla_factory(int* recordingFlags) { 39 static SkPictureFactory* vanilla_factory() {
39 return NULL; 40 return NULL;
40 } 41 }
41 42
42 static SkPictureFactory* rtree_factory(int* recordingFlags) { 43 static SkPictureFactory* rtree_factory() {
43 *recordingFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag; 44 return SkNEW(SkRTreePictureFactory);
44 return NULL;
45 } 45 }
46 46
47 static SkPictureFactory* tilegrid_factory(int* recordingFlags) { 47 static SkPictureFactory* tilegrid_factory() {
48 *recordingFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag;
49 SkTileGridPicture::TileGridInfo info; 48 SkTileGridPicture::TileGridInfo info;
50 info.fTileInterval.set(FLAGS_tileGridSize, FLAGS_tileGridSize); 49 info.fTileInterval.set(FLAGS_tileGridSize, FLAGS_tileGridSize);
51 info.fMargin.setEmpty(); 50 info.fMargin.setEmpty();
52 info.fOffset.setZero(); 51 info.fOffset.setZero();
53 return SkNEW_ARGS(SkTileGridPictureFactory, (info)); 52 return SkNEW_ARGS(SkTileGridPictureFactory, (info));
54 } 53 }
55 54
56 static SkPictureFactory* quadtree_factory(int* recordingFlags) { 55 static SkPictureFactory* quadtree_factory() {
57 *recordingFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag;
58 return SkNEW(SkQuadTreePictureFactory); 56 return SkNEW(SkQuadTreePictureFactory);
59 } 57 }
60 58
61 static PictureFactory parse_FLAGS_bbh() { 59 static PictureFactory parse_FLAGS_bbh() {
62 if (FLAGS_bbh.isEmpty()) { 60 if (FLAGS_bbh.isEmpty()) {
63 return &vanilla_factory; 61 return &vanilla_factory;
64 } 62 }
65 if (FLAGS_bbh.count() != 1) { 63 if (FLAGS_bbh.count() != 1) {
66 SkDebugf("Multiple bbh arguments supplied.\n"); 64 SkDebugf("Multiple bbh arguments supplied.\n");
67 return NULL; 65 return NULL;
(...skipping 19 matching lines...) Expand all
87 for (int i = 0; i < FLAGS_loops; i++) { 85 for (int i = 0; i < FLAGS_loops; i++) {
88 if (FLAGS_skr) { 86 if (FLAGS_skr) {
89 using EXPERIMENTAL::SkRecording; 87 using EXPERIMENTAL::SkRecording;
90 SkRecording* recording = SkRecording::Create(width, height); 88 SkRecording* recording = SkRecording::Create(width, height);
91 if (NULL != src) { 89 if (NULL != src) {
92 src->draw(recording->canvas()); 90 src->draw(recording->canvas());
93 } 91 }
94 SkDELETE(SkRecording::Delete(recording)); // delete the SkPlayback* . 92 SkDELETE(SkRecording::Delete(recording)); // delete the SkPlayback* .
95 } else { 93 } else {
96 int recordingFlags = FLAGS_flags; 94 int recordingFlags = FLAGS_flags;
97 SkAutoTUnref<SkPictureFactory> factory(pictureFactory(&recordingFlag s)); 95 SkAutoTUnref<SkPictureFactory> factory(pictureFactory());
98 SkPictureRecorder recorder(factory); 96 SkPictureRecorder recorder(factory);
99 SkCanvas* canvas = recorder.beginRecording(width, height, recordingF lags); 97 SkCanvas* canvas = recorder.beginRecording(width, height, recordingF lags);
100 if (NULL != src) { 98 if (NULL != src) {
101 src->draw(canvas); 99 src->draw(canvas);
102 } 100 }
103 if (FLAGS_endRecording) { 101 if (FLAGS_endRecording) {
104 SkAutoTUnref<SkPicture> dst(recorder.endRecording()); 102 SkAutoTUnref<SkPicture> dst(recorder.endRecording());
105 } 103 }
106 } 104 }
107 } 105 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bench_record(src, filename.c_str(), pictureFactory); 145 bench_record(src, filename.c_str(), pictureFactory);
148 } 146 }
149 return failed ? 1 : 0; 147 return failed ? 1 : 0;
150 } 148 }
151 149
152 #if !defined SK_BUILD_FOR_IOS 150 #if !defined SK_BUILD_FOR_IOS
153 int main(int argc, char * const argv[]) { 151 int main(int argc, char * const argv[]) {
154 return tool_main(argc, (char**) argv); 152 return tool_main(argc, (char**) argv);
155 } 153 }
156 #endif 154 #endif
OLDNEW
« no previous file with comments | « tools/PictureRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698