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

Side by Side Diff: bench/nanobench.cpp

Issue 1817383002: switch surface to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 | « bench/nanobench.h ('k') | cmake/example.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 <ctype.h> 8 #include <ctype.h>
9 9
10 #include "nanobench.h" 10 #include "nanobench.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } 125 static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
126 126
127 static SkString humanize(double ms) { 127 static SkString humanize(double ms) {
128 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); 128 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6));
129 return HumanizeMs(ms); 129 return HumanizeMs(ms);
130 } 130 }
131 #define HUMANIZE(ms) humanize(ms).c_str() 131 #define HUMANIZE(ms) humanize(ms).c_str()
132 132
133 bool Target::init(SkImageInfo info, Benchmark* bench) { 133 bool Target::init(SkImageInfo info, Benchmark* bench) {
134 if (Benchmark::kRaster_Backend == config.backend) { 134 if (Benchmark::kRaster_Backend == config.backend) {
135 this->surface.reset(SkSurface::NewRaster(info)); 135 this->surface = SkSurface::MakeRaster(info);
136 if (!this->surface.get()) { 136 if (!this->surface) {
137 return false; 137 return false;
138 } 138 }
139 } 139 }
140 return true; 140 return true;
141 } 141 }
142 bool Target::capturePixels(SkBitmap* bmp) { 142 bool Target::capturePixels(SkBitmap* bmp) {
143 SkCanvas* canvas = this->getCanvas(); 143 SkCanvas* canvas = this->getCanvas();
144 if (!canvas) { 144 if (!canvas) {
145 return false; 145 return false;
146 } 146 }
(...skipping 29 matching lines...) Expand all
176 if (!this->gl->getMaxGpuFrameLag(maxFrameLag)) { 176 if (!this->gl->getMaxGpuFrameLag(maxFrameLag)) {
177 // Frame lag is unknown. 177 // Frame lag is unknown.
178 *maxFrameLag = FLAGS_gpuFrameLag; 178 *maxFrameLag = FLAGS_gpuFrameLag;
179 } 179 }
180 return true; 180 return true;
181 } 181 }
182 bool init(SkImageInfo info, Benchmark* bench) override { 182 bool init(SkImageInfo info, Benchmark* bench) override {
183 uint32_t flags = this->config.useDFText ? SkSurfaceProps::kUseDeviceInde pendentFonts_Flag : 183 uint32_t flags = this->config.useDFText ? SkSurfaceProps::kUseDeviceInde pendentFonts_Flag :
184 0; 184 0;
185 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); 185 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
186 this->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(this->con fig.ctxType, 186 this->surface = SkSurface::MakeRenderTarget(gGrFactory->get(this->config .ctxType,
187 this->con fig.ctxOptions), 187 this->config .ctxOptions),
188 SkBudgeted::kNo, info, 188 SkBudgeted::kNo, info,
189 this->config.samples, & props)); 189 this->config.samples, & props);
190 this->gl = gGrFactory->getContextInfo(this->config.ctxType, 190 this->gl = gGrFactory->getContextInfo(this->config.ctxType,
191 this->config.ctxOptions).fGLContex t; 191 this->config.ctxOptions).fGLContex t;
192 if (!this->surface.get()) { 192 if (!this->surface.get()) {
193 return false; 193 return false;
194 } 194 }
195 if (!this->gl->fenceSyncSupport()) { 195 if (!this->gl->fenceSyncSupport()) {
196 SkDebugf("WARNING: GL context for config \"%s\" does not support fen ce sync. " 196 SkDebugf("WARNING: GL context for config \"%s\" does not support fen ce sync. "
197 "Timings might not be accurate.\n", this->config.name.c_str ()); 197 "Timings might not be accurate.\n", this->config.name.c_str ());
198 } 198 }
199 return true; 199 return true;
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 1280
1281 return 0; 1281 return 0;
1282 } 1282 }
1283 1283
1284 #if !defined SK_BUILD_FOR_IOS 1284 #if !defined SK_BUILD_FOR_IOS
1285 int main(int argc, char** argv) { 1285 int main(int argc, char** argv) {
1286 SkCommandLineFlags::Parse(argc, argv); 1286 SkCommandLineFlags::Parse(argc, argv);
1287 return nanobench_main(); 1287 return nanobench_main();
1288 } 1288 }
1289 #endif 1289 #endif
OLDNEW
« no previous file with comments | « bench/nanobench.h ('k') | cmake/example.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698