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

Side by Side Diff: tools/bench_record.cpp

Issue 331573004: Add EXPERIMENTAL_beginRecording() for SkRecord-based recording. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: put back Created 6 years, 6 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 | « tools/bench_playback.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 "SkPictureRecorder.h" 13 #include "SkPictureRecorder.h"
14 #include "SkRecording.h"
15 #include "SkStream.h" 14 #include "SkStream.h"
16 #include "SkString.h" 15 #include "SkString.h"
17 16
18 #include "BenchTimer.h" 17 #include "BenchTimer.h"
19 #include "LazyDecodeBitmap.h" 18 #include "LazyDecodeBitmap.h"
20 #include "Stats.h" 19 #include "Stats.h"
21 20
22 typedef WallTimer Timer; 21 typedef WallTimer Timer;
23 22
24 __SK_FORCE_IMAGE_DECODER_LINKING; 23 __SK_FORCE_IMAGE_DECODER_LINKING;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return SkNEW_ARGS(SkTileGridFactory, (info)); 57 return SkNEW_ARGS(SkTileGridFactory, (info));
59 } 58 }
60 if (FLAGS_bbh.contains("quadtree")) { 59 if (FLAGS_bbh.contains("quadtree")) {
61 return SkNEW(SkQuadTreeFactory); 60 return SkNEW(SkQuadTreeFactory);
62 } 61 }
63 SkDebugf("Invalid bbh type %s, must be one of rtree, tilegrid, quadtree.\n", FLAGS_bbh[0]); 62 SkDebugf("Invalid bbh type %s, must be one of rtree, tilegrid, quadtree.\n", FLAGS_bbh[0]);
64 return NULL; 63 return NULL;
65 } 64 }
66 65
67 static void rerecord(const SkPicture& src, SkBBHFactory* bbhFactory) { 66 static void rerecord(const SkPicture& src, SkBBHFactory* bbhFactory) {
67 SkPictureRecorder recorder;
68 if (FLAGS_skr) { 68 if (FLAGS_skr) {
69 EXPERIMENTAL::SkRecording recording(src.width(), src.height()); 69 src.draw(recorder.EXPERIMENTAL_beginRecording(src.width(), src.height(), bbhFactory));
70 src.draw(recording.canvas());
71 // Release and delete the SkPlayback so that recording optimizes its SkR ecord.
72 SkDELETE(recording.releasePlayback());
73 } else { 70 } else {
74 SkPictureRecorder recorder;
75 src.draw(recorder.beginRecording(src.width(), src.height(), bbhFactory)) ; 71 src.draw(recorder.beginRecording(src.width(), src.height(), bbhFactory)) ;
76 SkAutoTUnref<SkPicture> dst(recorder.endRecording());
77 } 72 }
73 SkAutoTUnref<SkPicture> pic(recorder.endRecording());
78 } 74 }
79 75
80 static void bench_record(const SkPicture& src, 76 static void bench_record(const SkPicture& src,
81 const double timerOverhead, 77 const double timerOverhead,
82 const char* name, 78 const char* name,
83 SkBBHFactory* bbhFactory) { 79 SkBBHFactory* bbhFactory) {
84 // Rerecord once to warm up any caches. Otherwise the first sample can be v ery noisy. 80 // Rerecord once to warm up any caches. Otherwise the first sample can be v ery noisy.
85 rerecord(src, bbhFactory); 81 rerecord(src, bbhFactory);
86 82
87 // Rerecord once to see how many times we should loop to make timer overhead insignificant. 83 // Rerecord once to see how many times we should loop to make timer overhead insignificant.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 bench_record(*src, overheadEstimate, filename.c_str(), bbhFactory.get()) ; 167 bench_record(*src, overheadEstimate, filename.c_str(), bbhFactory.get()) ;
172 } 168 }
173 return failed ? 1 : 0; 169 return failed ? 1 : 0;
174 } 170 }
175 171
176 #if !defined SK_BUILD_FOR_IOS 172 #if !defined SK_BUILD_FOR_IOS
177 int main(int argc, char * const argv[]) { 173 int main(int argc, char * const argv[]) {
178 return tool_main(argc, (char**) argv); 174 return tool_main(argc, (char**) argv);
179 } 175 }
180 #endif 176 #endif
OLDNEW
« no previous file with comments | « tools/bench_playback.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698