OLD | NEW |
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #endif | 49 #endif |
50 | 50 |
51 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 51 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
52 #include "nanobenchAndroid.h" | 52 #include "nanobenchAndroid.h" |
53 #endif | 53 #endif |
54 | 54 |
55 #if SK_SUPPORT_GPU | 55 #if SK_SUPPORT_GPU |
56 #include "gl/GrGLDefines.h" | 56 #include "gl/GrGLDefines.h" |
57 #include "GrCaps.h" | 57 #include "GrCaps.h" |
58 #include "GrContextFactory.h" | 58 #include "GrContextFactory.h" |
| 59 #include "gl/GrGLUtil.h" |
| 60 using sk_gpu_test::GrContextFactory; |
| 61 using sk_gpu_test::GLContext; |
59 SkAutoTDelete<GrContextFactory> gGrFactory; | 62 SkAutoTDelete<GrContextFactory> gGrFactory; |
60 #endif | 63 #endif |
61 | 64 |
62 struct GrContextOptions; | 65 struct GrContextOptions; |
63 | 66 |
64 __SK_FORCE_IMAGE_DECODER_LINKING; | 67 __SK_FORCE_IMAGE_DECODER_LINKING; |
65 | 68 |
66 static const int kAutoTuneLoops = 0; | 69 static const int kAutoTuneLoops = 0; |
67 | 70 |
68 static const int kDefaultLoops = | 71 static const int kDefaultLoops = |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 if (!canvas->readPixels(bmp, 0, 0)) { | 151 if (!canvas->readPixels(bmp, 0, 0)) { |
149 SkDebugf("Can't read canvas pixels.\n"); | 152 SkDebugf("Can't read canvas pixels.\n"); |
150 return false; | 153 return false; |
151 } | 154 } |
152 return true; | 155 return true; |
153 } | 156 } |
154 | 157 |
155 #if SK_SUPPORT_GPU | 158 #if SK_SUPPORT_GPU |
156 struct GPUTarget : public Target { | 159 struct GPUTarget : public Target { |
157 explicit GPUTarget(const Config& c) : Target(c), gl(nullptr) { } | 160 explicit GPUTarget(const Config& c) : Target(c), gl(nullptr) { } |
158 SkGLContext* gl; | 161 GLContext* gl; |
159 | 162 |
160 void setup() override { | 163 void setup() override { |
161 this->gl->makeCurrent(); | 164 this->gl->makeCurrent(); |
162 // Make sure we're done with whatever came before. | 165 // Make sure we're done with whatever came before. |
163 SK_GL(*this->gl, Finish()); | 166 GR_GL_CALL(this->gl->gl(), Finish()); |
164 } | 167 } |
165 void endTiming() override { | 168 void endTiming() override { |
166 if (this->gl) { | 169 if (this->gl) { |
167 SK_GL(*this->gl, Flush()); | 170 GR_GL_CALL(this->gl->gl(), Flush()); |
168 this->gl->waitOnSyncOrSwap(); | 171 this->gl->waitOnSyncOrSwap(); |
169 } | 172 } |
170 } | 173 } |
171 void fence() override { | 174 void fence() override { |
172 SK_GL(*this->gl, Finish()); | 175 GR_GL_CALL(this->gl->gl(), Finish()); |
173 } | 176 } |
174 | 177 |
175 bool needsFrameTiming(int* maxFrameLag) const override { | 178 bool needsFrameTiming(int* maxFrameLag) const override { |
176 if (!this->gl->getMaxGpuFrameLag(maxFrameLag)) { | 179 if (!this->gl->getMaxGpuFrameLag(maxFrameLag)) { |
177 // Frame lag is unknown. | 180 // Frame lag is unknown. |
178 *maxFrameLag = FLAGS_gpuFrameLag; | 181 *maxFrameLag = FLAGS_gpuFrameLag; |
179 } | 182 } |
180 return true; | 183 return true; |
181 } | 184 } |
182 bool init(SkImageInfo info, Benchmark* bench) override { | 185 bool init(SkImageInfo info, Benchmark* bench) override { |
(...skipping 10 matching lines...) Expand all Loading... |
193 return false; | 196 return false; |
194 } | 197 } |
195 if (!this->gl->fenceSyncSupport()) { | 198 if (!this->gl->fenceSyncSupport()) { |
196 SkDebugf("WARNING: GL context for config \"%s\" does not support fen
ce sync. " | 199 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
()); | 200 "Timings might not be accurate.\n", this->config.name.c_str
()); |
198 } | 201 } |
199 return true; | 202 return true; |
200 } | 203 } |
201 void fillOptions(ResultsWriter* log) override { | 204 void fillOptions(ResultsWriter* log) override { |
202 const GrGLubyte* version; | 205 const GrGLubyte* version; |
203 SK_GL_RET(*this->gl, version, GetString(GR_GL_VERSION)); | 206 GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_VERSION)); |
204 log->configOption("GL_VERSION", (const char*)(version)); | 207 log->configOption("GL_VERSION", (const char*)(version)); |
205 | 208 |
206 SK_GL_RET(*this->gl, version, GetString(GR_GL_RENDERER)); | 209 GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_RENDERER)); |
207 log->configOption("GL_RENDERER", (const char*) version); | 210 log->configOption("GL_RENDERER", (const char*) version); |
208 | 211 |
209 SK_GL_RET(*this->gl, version, GetString(GR_GL_VENDOR)); | 212 GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_VENDOR)); |
210 log->configOption("GL_VENDOR", (const char*) version); | 213 log->configOption("GL_VENDOR", (const char*) version); |
211 | 214 |
212 SK_GL_RET(*this->gl, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION))
; | 215 GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_SHADING_LANGUAGE
_VERSION)); |
213 log->configOption("GL_SHADING_LANGUAGE_VERSION", (const char*) version); | 216 log->configOption("GL_SHADING_LANGUAGE_VERSION", (const char*) version); |
214 } | 217 } |
215 }; | 218 }; |
216 | 219 |
217 #endif | 220 #endif |
218 | 221 |
219 static double time(int loops, Benchmark* bench, Target* target) { | 222 static double time(int loops, Benchmark* bench, Target* target) { |
220 SkCanvas* canvas = target->getCanvas(); | 223 SkCanvas* canvas = target->getCanvas(); |
221 if (canvas) { | 224 if (canvas) { |
222 canvas->clear(SK_ColorWHITE); | 225 canvas->clear(SK_ColorWHITE); |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 | 1283 |
1281 return 0; | 1284 return 0; |
1282 } | 1285 } |
1283 | 1286 |
1284 #if !defined SK_BUILD_FOR_IOS | 1287 #if !defined SK_BUILD_FOR_IOS |
1285 int main(int argc, char** argv) { | 1288 int main(int argc, char** argv) { |
1286 SkCommandLineFlags::Parse(argc, argv); | 1289 SkCommandLineFlags::Parse(argc, argv); |
1287 return nanobench_main(); | 1290 return nanobench_main(); |
1288 } | 1291 } |
1289 #endif | 1292 #endif |
OLD | NEW |