OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "BenchGpuTimer_gl.h" | 8 #include "BenchGpuTimer_gl.h" |
9 #include "gl/SkGLContext.h" | 9 #include "gl/SkGLContext.h" |
10 #include "gl/GrGLUtil.h" | 10 #include "gl/GrGLUtil.h" |
11 | 11 |
12 BenchGpuTimer::BenchGpuTimer(const SkGLContext* glctx) { | 12 BenchGpuTimer::BenchGpuTimer(const SkGLContext* glctx) { |
13 fContext = glctx; | 13 fContext = glctx; |
14 glctx->ref(); | 14 glctx->ref(); |
15 glctx->makeCurrent(); | 15 glctx->makeCurrent(); |
16 fStarted = false; | 16 fStarted = false; |
17 fSupported = GrGLGetVersion(glctx->gl()) > GR_GL_VER(3,3) || | 17 fSupported = GrGLGetVersion(glctx->gl()) > GR_GL_VER(3,3) || |
18 GrGLHasExtension(glctx->gl(), "GL_ARB_timer_query") || | 18 glctx->hasExtension("GL_ARB_timer_query") || |
19 GrGLHasExtension(glctx->gl(), "GL_EXT_timer_query"); | 19 glctx->hasExtension("GL_EXT_timer_query"); |
20 | 20 |
21 if (fSupported) { | 21 if (fSupported) { |
22 SK_GL(*glctx, GenQueries(1, &fQuery)); | 22 SK_GL(*glctx, GenQueries(1, &fQuery)); |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 BenchGpuTimer::~BenchGpuTimer() { | 26 BenchGpuTimer::~BenchGpuTimer() { |
27 if (fSupported) { | 27 if (fSupported) { |
28 fContext->makeCurrent(); | 28 fContext->makeCurrent(); |
29 SK_GL(*fContext, DeleteQueries(1, &fQuery)); | 29 SK_GL(*fContext, DeleteQueries(1, &fQuery)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 GrGLuint64 totalGPUTimeElapsed = 0; | 65 GrGLuint64 totalGPUTimeElapsed = 0; |
66 SK_GL(*fContext, GetQueryObjectui64v(fQuery, | 66 SK_GL(*fContext, GetQueryObjectui64v(fQuery, |
67 GR_GL_QUERY_RESULT, | 67 GR_GL_QUERY_RESULT, |
68 &totalGPUTimeElapsed)); | 68 &totalGPUTimeElapsed)); |
69 | 69 |
70 return totalGPUTimeElapsed / 1000000.0; | 70 return totalGPUTimeElapsed / 1000000.0; |
71 } else { | 71 } else { |
72 return 0; | 72 return 0; |
73 } | 73 } |
74 } | 74 } |
OLD | NEW |