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