| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GLBench.h" | 8 #include "GLBench.h" |
| 9 | 9 |
| 10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
| 11 #include "GrTest.h" | 11 #include "GrTest.h" |
| 12 #include <stdio.h> | 12 #include <stdio.h> |
| 13 | 13 |
| 14 const GrGLContext* GLBench::getGLContext(SkCanvas* canvas) { | 14 const GrGLContext* GLBench::getGLContext(SkCanvas* canvas) { |
| 15 // This bench exclusively tests GL calls directly | 15 // This bench exclusively tests GL calls directly |
| 16 if (NULL == canvas->getGrContext()) { | 16 if (NULL == canvas->getGrContext()) { |
| 17 return NULL; | 17 return NULL; |
| 18 } | 18 } |
| 19 GrContext* context = canvas->getGrContext(); | 19 GrContext* context = canvas->getGrContext(); |
| 20 | 20 GrGpu* gpu = context->getGpu(); |
| 21 GrTestTarget tt; | 21 if (!gpu) { |
| 22 context->getTestTarget(&tt); | 22 SkDebugf("Couldn't get Gr gpu."); |
| 23 if (!tt.target()) { | |
| 24 SkDebugf("Couldn't get Gr test target."); | |
| 25 return NULL; | 23 return NULL; |
| 26 } | 24 } |
| 27 | 25 |
| 28 const GrGLContext* ctx = tt.glContext(); | 26 const GrGLContext* ctx = gpu->glContextForTesting(); |
| 29 if (!ctx) { | 27 if (!ctx) { |
| 30 SkDebugf("Couldn't get an interface\n"); | 28 SkDebugf("Couldn't get an interface\n"); |
| 31 return NULL; | 29 return NULL; |
| 32 } | 30 } |
| 33 | 31 |
| 34 return this->onGetGLContext(ctx); | 32 return this->onGetGLContext(ctx); |
| 35 } | 33 } |
| 36 | 34 |
| 37 void GLBench::onPerCanvasPreDraw(SkCanvas* canvas) { | 35 void GLBench::onPerCanvasPreDraw(SkCanvas* canvas) { |
| 38 // This bench exclusively tests GL calls directly | 36 // This bench exclusively tests GL calls directly |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 bm.setPixels(readback.get()); | 163 bm.setPixels(readback.get()); |
| 166 | 164 |
| 167 if (!SkImageEncoder::EncodeFile(filename, bm, SkImageEncoder::kPNG_Type, 100
)) { | 165 if (!SkImageEncoder::EncodeFile(filename, bm, SkImageEncoder::kPNG_Type, 100
)) { |
| 168 SkDebugf("------ failed to encode %s\n", filename); | 166 SkDebugf("------ failed to encode %s\n", filename); |
| 169 remove(filename); // remove any partial file | 167 remove(filename); // remove any partial file |
| 170 return; | 168 return; |
| 171 } | 169 } |
| 172 } | 170 } |
| 173 | 171 |
| 174 #endif | 172 #endif |
| OLD | NEW |