| 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/WebGLQuery.h" | 5 #include "modules/webgl/WebGLQuery.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_interface.h" |
| 7 #include "modules/webgl/WebGL2RenderingContextBase.h" | 8 #include "modules/webgl/WebGL2RenderingContextBase.h" |
| 8 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
| 9 | 10 |
| 10 namespace blink { | 11 namespace blink { |
| 11 | 12 |
| 12 WebGLQuery* WebGLQuery::create(WebGL2RenderingContextBase* ctx) | 13 WebGLQuery* WebGLQuery::create(WebGL2RenderingContextBase* ctx) |
| 13 { | 14 { |
| 14 return new WebGLQuery(ctx); | 15 return new WebGLQuery(ctx); |
| 15 } | 16 } |
| 16 | 17 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 { | 51 { |
| 51 m_canUpdateAvailability = false; | 52 m_canUpdateAvailability = false; |
| 52 m_queryResultAvailable = false; | 53 m_queryResultAvailable = false; |
| 53 m_queryResult = 0; | 54 m_queryResult = 0; |
| 54 // When this is called, the implication is that we should start | 55 // When this is called, the implication is that we should start |
| 55 // keeping track of whether we can update the cached availability | 56 // keeping track of whether we can update the cached availability |
| 56 // and result. | 57 // and result. |
| 57 registerTaskObserver(); | 58 registerTaskObserver(); |
| 58 } | 59 } |
| 59 | 60 |
| 60 void WebGLQuery::updateCachedResult(WebGraphicsContext3D* ctx) | 61 void WebGLQuery::updateCachedResult(gpu::gles2::GLES2Interface* gl) |
| 61 { | 62 { |
| 62 if (m_queryResultAvailable) | 63 if (m_queryResultAvailable) |
| 63 return; | 64 return; |
| 64 | 65 |
| 65 if (!m_canUpdateAvailability) | 66 if (!m_canUpdateAvailability) |
| 66 return; | 67 return; |
| 67 | 68 |
| 68 if (!hasTarget()) | 69 if (!hasTarget()) |
| 69 return; | 70 return; |
| 70 | 71 |
| 71 // We can only update the cached result when control returns to the browser. | 72 // We can only update the cached result when control returns to the browser. |
| 72 m_canUpdateAvailability = false; | 73 m_canUpdateAvailability = false; |
| 73 GLuint available = 0; | 74 GLuint available = 0; |
| 74 ctx->getQueryObjectuivEXT(object(), GL_QUERY_RESULT_AVAILABLE_EXT, &availabl
e); | 75 gl->GetQueryObjectuivEXT(object(), GL_QUERY_RESULT_AVAILABLE_EXT, &available
); |
| 75 m_queryResultAvailable = !!available; | 76 m_queryResultAvailable = !!available; |
| 76 if (m_queryResultAvailable) { | 77 if (m_queryResultAvailable) { |
| 77 GLuint result = 0; | 78 GLuint result = 0; |
| 78 ctx->getQueryObjectuivEXT(object(), GL_QUERY_RESULT_EXT, &result); | 79 gl->GetQueryObjectuivEXT(object(), GL_QUERY_RESULT_EXT, &result); |
| 79 m_queryResult = result; | 80 m_queryResult = result; |
| 80 unregisterTaskObserver(); | 81 unregisterTaskObserver(); |
| 81 } | 82 } |
| 82 } | 83 } |
| 83 | 84 |
| 84 bool WebGLQuery::isQueryResultAvailable() | 85 bool WebGLQuery::isQueryResultAvailable() |
| 85 { | 86 { |
| 86 return m_queryResultAvailable; | 87 return m_queryResultAvailable; |
| 87 } | 88 } |
| 88 | 89 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 106 Platform::current()->currentThread()->removeTaskObserver(this); | 107 Platform::current()->currentThread()->removeTaskObserver(this); |
| 107 } | 108 } |
| 108 } | 109 } |
| 109 | 110 |
| 110 void WebGLQuery::didProcessTask() | 111 void WebGLQuery::didProcessTask() |
| 111 { | 112 { |
| 112 m_canUpdateAvailability = true; | 113 m_canUpdateAvailability = true; |
| 113 } | 114 } |
| 114 | 115 |
| 115 } // namespace blink | 116 } // namespace blink |
| OLD | NEW |