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