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 "GpuTimer.h" | 8 #include "GpuTimer.h" |
9 #include "gl/SkGLContext.h" | 9 #include "gl/SkGLContextHelper.h" |
10 #include "gl/GrGLUtil.h" | 10 #include "gl/GrGLUtil.h" |
11 | 11 |
12 GpuTimer::GpuTimer(const SkGLContext* glctx) : fContext(glctx) { | 12 GpuTimer::GpuTimer(const SkGLContextHelper* glctx) : fContext(glctx) { |
13 if (fContext) { | 13 if (fContext) { |
14 fContext->ref(); | 14 fContext->ref(); |
15 fContext->makeCurrent(); | 15 fContext->makeCurrent(); |
16 fStarted = false; | 16 fStarted = false; |
17 fSupported = GrGLGetVersion(fContext->gl()) > GR_GL_VER(3,3) || | 17 fSupported = GrGLGetVersion(fContext->gl()) > GR_GL_VER(3,3) || |
18 fContext->hasExtension("GL_ARB_timer_query") || | 18 fContext->hasExtension("GL_ARB_timer_query") || |
19 fContext->hasExtension("GL_EXT_timer_query"); | 19 fContext->hasExtension("GL_EXT_timer_query"); |
20 | 20 |
21 if (fSupported) { | 21 if (fSupported) { |
22 SK_GL(*fContext, GenQueries(1, &fQuery)); | 22 SK_GL(*fContext, GenQueries(1, &fQuery)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 GrGLuint64 totalGPUTimeElapsed = 0; | 68 GrGLuint64 totalGPUTimeElapsed = 0; |
69 SK_GL(*fContext, GetQueryObjectui64v(fQuery, | 69 SK_GL(*fContext, GetQueryObjectui64v(fQuery, |
70 GR_GL_QUERY_RESULT, | 70 GR_GL_QUERY_RESULT, |
71 &totalGPUTimeElapsed)); | 71 &totalGPUTimeElapsed)); |
72 | 72 |
73 return totalGPUTimeElapsed / 1000000.0; | 73 return totalGPUTimeElapsed / 1000000.0; |
74 } else { | 74 } else { |
75 return 0; | 75 return 0; |
76 } | 76 } |
77 } | 77 } |
OLD | NEW |