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

Side by Side Diff: tools/bench_playback.cpp

Issue 513983002: Try out scalar picture sizes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT again Created 6 years, 3 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_pictures_main.cpp ('k') | tools/bench_record.cpp » ('j') | 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkCommandLineFlags.h" 9 #include "SkCommandLineFlags.h"
10 #include "SkForceLinking.h" 10 #include "SkForceLinking.h"
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 38
39 static SkPicture* rerecord(const SkPicture& src, bool skr) { 39 static SkPicture* rerecord(const SkPicture& src, bool skr) {
40 SkTileGridFactory::TileGridInfo info; 40 SkTileGridFactory::TileGridInfo info;
41 info.fTileInterval.set(FLAGS_tile, FLAGS_tile); 41 info.fTileInterval.set(FLAGS_tile, FLAGS_tile);
42 info.fMargin.setEmpty(); 42 info.fMargin.setEmpty();
43 info.fOffset.setZero(); 43 info.fOffset.setZero();
44 SkTileGridFactory factory(info); 44 SkTileGridFactory factory(info);
45 45
46 SkPictureRecorder recorder; 46 SkPictureRecorder recorder;
47 src.draw(skr ? recorder.EXPERIMENTAL_beginRecording(src.width(), src.height( ), &factory) 47 src.draw(skr ? recorder.EXPERIMENTAL_beginRecording(src.cullRect().width(),
48 : recorder. DEPRECATED_beginRecording(src.width(), src.height( ), &factory)); 48 src.cullRect().height(),
49 &factory)
50 : recorder. DEPRECATED_beginRecording(src.cullRect().width(),
51 src.cullRect().height(),
52 &factory));
49 return recorder.endRecording(); 53 return recorder.endRecording();
50 } 54 }
51 55
52 static void bench(SkPMColor* scratch, const SkPicture& src, const char* name) { 56 static void bench(SkPMColor* scratch, const SkPicture& src, const char* name) {
53 SkAutoTUnref<const SkPicture> picture(rerecord(src, FLAGS_skr)); 57 SkAutoTUnref<const SkPicture> picture(rerecord(src, FLAGS_skr));
54 58
55 SkAutoTDelete<SkCanvas> canvas(SkCanvas::NewRasterDirectN32(src.width(), 59 SkAutoTDelete<SkCanvas> canvas(
56 src.height(), 60 SkCanvas::NewRasterDirectN32(SkScalarCeilToInt(src.cullRect().width()),
57 scratch, 61 SkScalarCeilToInt(src.cullRect().height()),
58 src.width() * si zeof(SkPMColor))); 62 scratch,
63 SkScalarCeilToInt(src.cullRect().width()) * sizeof(SkPMColor)));
59 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLA GS_tile))); 64 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLA GS_tile)));
60 65
61 // Draw once to warm any caches. The first sample otherwise can be very noi sy. 66 // Draw once to warm any caches. The first sample otherwise can be very noi sy.
62 picture->draw(canvas.get()); 67 picture->draw(canvas.get());
63 68
64 WallTimer timer; 69 WallTimer timer;
65 const double scale = timescale(); 70 const double scale = timescale();
66 SkAutoTMalloc<double> samples(FLAGS_samples); 71 SkAutoTMalloc<double> samples(FLAGS_samples);
67 for (int i = 0; i < FLAGS_samples; i++) { 72 for (int i = 0; i < FLAGS_samples; i++) {
68 // We assume timer overhead (typically, ~30ns) is insignificant 73 // We assume timer overhead (typically, ~30ns) is insignificant
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 failed = true; 119 failed = true;
115 continue; 120 continue;
116 } 121 }
117 SkAutoTUnref<const SkPicture> src(SkPicture::CreateFromStream(stream)); 122 SkAutoTUnref<const SkPicture> src(SkPicture::CreateFromStream(stream));
118 if (!src) { 123 if (!src) {
119 SkDebugf("Could not read %s as an SkPicture.\n", path.c_str()); 124 SkDebugf("Could not read %s as an SkPicture.\n", path.c_str());
120 failed = true; 125 failed = true;
121 continue; 126 continue;
122 } 127 }
123 128
124 if (src->width() * src->height() > kMaxArea) { 129 if (SkScalarCeilToInt(src->cullRect().width()) *
125 SkDebugf("%s (%dx%d) is larger than hardcoded scratch bitmap (%dpx). \n", 130 SkScalarCeilToInt(src->cullRect().height()) > kMaxArea) {
126 path.c_str(), src->width(), src->height(), kMaxArea); 131 SkDebugf("%s (%f,%f,%f,%f) is larger than hardcoded scratch bitmap ( %dpx).\n",
132 path.c_str(),
133 src->cullRect().fLeft, src->cullRect().fTop,
134 src->cullRect().fRight, src->cullRect().fBottom,
135 kMaxArea);
127 failed = true; 136 failed = true;
128 continue; 137 continue;
129 } 138 }
130 139
131 bench(scratch.get(), *src, filename.c_str()); 140 bench(scratch.get(), *src, filename.c_str());
132 } 141 }
133 return failed ? 1 : 0; 142 return failed ? 1 : 0;
134 } 143 }
135 144
136 #if !defined SK_BUILD_FOR_IOS 145 #if !defined SK_BUILD_FOR_IOS
137 int main(int argc, char * const argv[]) { 146 int main(int argc, char * const argv[]) {
138 return tool_main(argc, (char**) argv); 147 return tool_main(argc, (char**) argv);
139 } 148 }
140 #endif 149 #endif
OLDNEW
« no previous file with comments | « tools/bench_pictures_main.cpp ('k') | tools/bench_record.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698