| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/webgl/WebGLTimerQueryEXT.h" | 5 #include "modules/webgl/WebGLTimerQueryEXT.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_interface.h" |
| 7 #include "modules/webgl/WebGLRenderingContextBase.h" | 8 #include "modules/webgl/WebGLRenderingContextBase.h" |
| 8 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
| 9 | 10 |
| 10 namespace blink { | 11 namespace blink { |
| 11 | 12 |
| 12 WebGLTimerQueryEXT* WebGLTimerQueryEXT::create(WebGLRenderingContextBase* ctx) | 13 WebGLTimerQueryEXT* WebGLTimerQueryEXT::create(WebGLRenderingContextBase* ctx) |
| 13 { | 14 { |
| 14 return new WebGLTimerQueryEXT(ctx); | 15 return new WebGLTimerQueryEXT(ctx); |
| 15 } | 16 } |
| 16 | 17 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 38 { | 39 { |
| 39 m_canUpdateAvailability = false; | 40 m_canUpdateAvailability = false; |
| 40 m_queryResultAvailable = false; | 41 m_queryResultAvailable = false; |
| 41 m_queryResult = 0; | 42 m_queryResult = 0; |
| 42 // When this is called, the implication is that we should start | 43 // When this is called, the implication is that we should start |
| 43 // keeping track of whether we can update the cached availability | 44 // keeping track of whether we can update the cached availability |
| 44 // and result. | 45 // and result. |
| 45 registerTaskObserver(); | 46 registerTaskObserver(); |
| 46 } | 47 } |
| 47 | 48 |
| 48 void WebGLTimerQueryEXT::updateCachedResult(WebGraphicsContext3D* ctx) | 49 void WebGLTimerQueryEXT::updateCachedResult(gpu::gles2::GLES2Interface* gl) |
| 49 { | 50 { |
| 50 if (m_queryResultAvailable) | 51 if (m_queryResultAvailable) |
| 51 return; | 52 return; |
| 52 | 53 |
| 53 if (!m_canUpdateAvailability) | 54 if (!m_canUpdateAvailability) |
| 54 return; | 55 return; |
| 55 | 56 |
| 56 if (!hasTarget()) | 57 if (!hasTarget()) |
| 57 return; | 58 return; |
| 58 | 59 |
| 59 // We can only update the cached result when control returns to the browser. | 60 // We can only update the cached result when control returns to the browser. |
| 60 m_canUpdateAvailability = false; | 61 m_canUpdateAvailability = false; |
| 61 GLuint available = 0; | 62 GLuint available = 0; |
| 62 ctx->getQueryObjectuivEXT(object(), GL_QUERY_RESULT_AVAILABLE_EXT, &availabl
e); | 63 gl->GetQueryObjectuivEXT(object(), GL_QUERY_RESULT_AVAILABLE_EXT, &available
); |
| 63 m_queryResultAvailable = !!available; | 64 m_queryResultAvailable = !!available; |
| 64 if (m_queryResultAvailable) { | 65 if (m_queryResultAvailable) { |
| 65 GLuint64 result = 0; | 66 GLuint64 result = 0; |
| 66 ctx->getQueryObjectui64vEXT(object(), GL_QUERY_RESULT_EXT, &result); | 67 gl->GetQueryObjectui64vEXT(object(), GL_QUERY_RESULT_EXT, &result); |
| 67 m_queryResult = result; | 68 m_queryResult = result; |
| 68 unregisterTaskObserver(); | 69 unregisterTaskObserver(); |
| 69 } | 70 } |
| 70 } | 71 } |
| 71 | 72 |
| 72 bool WebGLTimerQueryEXT::isQueryResultAvailable() | 73 bool WebGLTimerQueryEXT::isQueryResultAvailable() |
| 73 { | 74 { |
| 74 return m_queryResultAvailable; | 75 return m_queryResultAvailable; |
| 75 } | 76 } |
| 76 | 77 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 100 Platform::current()->currentThread()->removeTaskObserver(this); | 101 Platform::current()->currentThread()->removeTaskObserver(this); |
| 101 } | 102 } |
| 102 } | 103 } |
| 103 | 104 |
| 104 void WebGLTimerQueryEXT::didProcessTask() | 105 void WebGLTimerQueryEXT::didProcessTask() |
| 105 { | 106 { |
| 106 m_canUpdateAvailability = true; | 107 m_canUpdateAvailability = true; |
| 107 } | 108 } |
| 108 | 109 |
| 109 } // namespace blink | 110 } // namespace blink |
| OLD | NEW |