| 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 "platform/graphics/gpu/SharedContextRateLimiter.h" | 5 #include "platform/graphics/gpu/SharedContextRateLimiter.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_interface.h" | 7 #include "gpu/command_buffer/client/gles2_interface.h" |
| 8 #include "platform/graphics/gpu/Extensions3DUtil.h" | 8 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 9 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
| 10 #include "public/platform/WebGraphicsContext3D.h" | 10 #include "public/platform/WebGraphicsContext3D.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 m_canUseSyncQueries = extensionsUtil->supportsExtension("GL_CHROMIUM_syn
c_query"); | 36 m_canUseSyncQueries = extensionsUtil->supportsExtension("GL_CHROMIUM_syn
c_query"); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 void SharedContextRateLimiter::tick() | 40 void SharedContextRateLimiter::tick() |
| 41 { | 41 { |
| 42 if (!m_contextProvider) | 42 if (!m_contextProvider) |
| 43 return; | 43 return; |
| 44 | 44 |
| 45 gpu::gles2::GLES2Interface* gl = m_contextProvider->contextGL(); | 45 gpu::gles2::GLES2Interface* gl = m_contextProvider->contextGL(); |
| 46 |
| 46 if (!gl || gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) | 47 if (!gl || gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) |
| 47 return; | 48 return; |
| 48 | 49 |
| 49 m_queries.append(0); | 50 WebGraphicsContext3D* context = m_contextProvider->context3d(); |
| 50 if (m_canUseSyncQueries) | 51 m_queries.append(m_canUseSyncQueries ? context->createQueryEXT() : 0); |
| 51 gl->GenQueriesEXT(1, &m_queries.last()); | |
| 52 if (m_canUseSyncQueries) { | 52 if (m_canUseSyncQueries) { |
| 53 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, m_queries.last()); | 53 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, m_queries.last()); |
| 54 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); | 54 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); |
| 55 } | 55 } |
| 56 if (m_queries.size() > m_maxPendingTicks) { | 56 if (m_queries.size() > m_maxPendingTicks) { |
| 57 if (m_canUseSyncQueries) { | 57 if (m_canUseSyncQueries) { |
| 58 WGC3Duint result; | 58 WGC3Duint result; |
| 59 gl->GetQueryObjectuivEXT(m_queries.first(), GL_QUERY_RESULT_EXT, &re
sult); | 59 gl->GetQueryObjectuivEXT(m_queries.first(), GL_QUERY_RESULT_EXT, &re
sult); |
| 60 gl->DeleteQueriesEXT(1, &m_queries.first()); | 60 context->deleteQueryEXT(m_queries.first()); |
| 61 m_queries.removeFirst(); | 61 m_queries.removeFirst(); |
| 62 } else { | 62 } else { |
| 63 gl->Finish(); | 63 gl->Finish(); |
| 64 reset(); | 64 reset(); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 void SharedContextRateLimiter::reset() | 69 void SharedContextRateLimiter::reset() |
| 70 { | 70 { |
| 71 if (!m_contextProvider) | 71 if (!m_contextProvider) |
| 72 return; | 72 return; |
| 73 | 73 |
| 74 gpu::gles2::GLES2Interface* gl = m_contextProvider->contextGL(); | 74 gpu::gles2::GLES2Interface* gl = m_contextProvider->contextGL(); |
| 75 if (gl && gl->GetGraphicsResetStatusKHR() == GL_NO_ERROR) { | 75 if (gl && gl->GetGraphicsResetStatusKHR() == GL_NO_ERROR) { |
| 76 WebGraphicsContext3D* context = m_contextProvider->context3d(); |
| 76 while (m_queries.size() > 0) { | 77 while (m_queries.size() > 0) { |
| 77 gl->DeleteQueriesEXT(1, &m_queries.first()); | 78 context->deleteQueryEXT(m_queries.first()); |
| 78 m_queries.removeFirst(); | 79 m_queries.removeFirst(); |
| 79 } | 80 } |
| 80 } else { | 81 } else { |
| 81 m_queries.clear(); | 82 m_queries.clear(); |
| 82 } | 83 } |
| 83 } | 84 } |
| 84 | 85 |
| 85 } // namespace blink | 86 } // namespace blink |
| OLD | NEW |