| 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/GLES2/gl2extchromium.h" | 7 #include "gpu/GLES2/gl2extchromium.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/WebGraphicsContext3DProvider.h" | 10 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 11 #include "third_party/khronos/GLES2/gl2.h" | 11 #include "third_party/khronos/GLES2/gl2.h" |
| 12 #include "wtf/PtrUtil.h" | |
| 13 #include <memory> | |
| 14 | 12 |
| 15 namespace blink { | 13 namespace blink { |
| 16 | 14 |
| 17 std::unique_ptr<SharedContextRateLimiter> SharedContextRateLimiter::create(unsig
ned maxPendingTicks) | 15 PassOwnPtr<SharedContextRateLimiter> SharedContextRateLimiter::create(unsigned m
axPendingTicks) |
| 18 { | 16 { |
| 19 return wrapUnique(new SharedContextRateLimiter(maxPendingTicks)); | 17 return adoptPtr(new SharedContextRateLimiter(maxPendingTicks)); |
| 20 } | 18 } |
| 21 | 19 |
| 22 SharedContextRateLimiter::SharedContextRateLimiter(unsigned maxPendingTicks) | 20 SharedContextRateLimiter::SharedContextRateLimiter(unsigned maxPendingTicks) |
| 23 : m_maxPendingTicks(maxPendingTicks) | 21 : m_maxPendingTicks(maxPendingTicks) |
| 24 , m_canUseSyncQueries(false) | 22 , m_canUseSyncQueries(false) |
| 25 { | 23 { |
| 26 m_contextProvider = wrapUnique(Platform::current()->createSharedOffscreenGra
phicsContext3DProvider()); | 24 m_contextProvider = adoptPtr(Platform::current()->createSharedOffscreenGraph
icsContext3DProvider()); |
| 27 if (!m_contextProvider) | 25 if (!m_contextProvider) |
| 28 return; | 26 return; |
| 29 | 27 |
| 30 gpu::gles2::GLES2Interface* gl = m_contextProvider->contextGL(); | 28 gpu::gles2::GLES2Interface* gl = m_contextProvider->contextGL(); |
| 31 if (gl && gl->GetGraphicsResetStatusKHR() == GL_NO_ERROR) { | 29 if (gl && gl->GetGraphicsResetStatusKHR() == GL_NO_ERROR) { |
| 32 std::unique_ptr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::cre
ate(gl); | 30 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(gl); |
| 33 // TODO(junov): when the GLES 3.0 command buffer is ready, we could use
fenceSync instead | 31 // TODO(junov): when the GLES 3.0 command buffer is ready, we could use
fenceSync instead |
| 34 m_canUseSyncQueries = extensionsUtil->supportsExtension("GL_CHROMIUM_syn
c_query"); | 32 m_canUseSyncQueries = extensionsUtil->supportsExtension("GL_CHROMIUM_syn
c_query"); |
| 35 } | 33 } |
| 36 } | 34 } |
| 37 | 35 |
| 38 void SharedContextRateLimiter::tick() | 36 void SharedContextRateLimiter::tick() |
| 39 { | 37 { |
| 40 if (!m_contextProvider) | 38 if (!m_contextProvider) |
| 41 return; | 39 return; |
| 42 | 40 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 while (m_queries.size() > 0) { | 72 while (m_queries.size() > 0) { |
| 75 gl->DeleteQueriesEXT(1, &m_queries.first()); | 73 gl->DeleteQueriesEXT(1, &m_queries.first()); |
| 76 m_queries.removeFirst(); | 74 m_queries.removeFirst(); |
| 77 } | 75 } |
| 78 } else { | 76 } else { |
| 79 m_queries.clear(); | 77 m_queries.clear(); |
| 80 } | 78 } |
| 81 } | 79 } |
| 82 | 80 |
| 83 } // namespace blink | 81 } // namespace blink |
| OLD | NEW |