| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/SharedGpuContext.h" | 5 #include "platform/graphics/gpu/SharedGpuContext.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_interface.h" | 7 #include "gpu/command_buffer/client/gles2_interface.h" |
| 8 #include "platform/CrossThreadFunctional.h" | 8 #include "platform/CrossThreadFunctional.h" |
| 9 #include "platform/WaitableEvent.h" | 9 #include "platform/WaitableEvent.h" |
| 10 #include "public/platform/Platform.h" | 10 #include "public/platform/Platform.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 std::unique_ptr<WebGraphicsContext3DProvider> oldContextProvider = | 46 std::unique_ptr<WebGraphicsContext3DProvider> oldContextProvider = |
| 47 std::move(m_contextProvider); | 47 std::move(m_contextProvider); |
| 48 if (m_contextProviderFactory) { | 48 if (m_contextProviderFactory) { |
| 49 // This path should only be used in unit tests | 49 // This path should only be used in unit tests |
| 50 m_contextProvider = m_contextProviderFactory(); | 50 m_contextProvider = m_contextProviderFactory(); |
| 51 } else if (isMainThread()) { | 51 } else if (isMainThread()) { |
| 52 m_contextProvider = | 52 m_contextProvider = |
| 53 wrapUnique(blink::Platform::current() | 53 wrapUnique(blink::Platform::current() |
| 54 ->createSharedOffscreenGraphicsContext3DProvider()); | 54 ->createSharedOffscreenGraphicsContext3DProvider()); |
| 55 } else { | 55 } else { |
| 56 // This synchronous round-trip to the main thread is the reason why SharedGp
uContext | 56 // This synchronous round-trip to the main thread is the reason why |
| 57 // encasulates the context provider: so we only have to do this once per thr
ead. | 57 // SharedGpuContext encasulates the context provider: so we only have to do |
| 58 // this once per thread. |
| 58 WaitableEvent waitableEvent; | 59 WaitableEvent waitableEvent; |
| 59 WebTaskRunner* taskRunner = | 60 WebTaskRunner* taskRunner = |
| 60 Platform::current()->mainThread()->getWebTaskRunner(); | 61 Platform::current()->mainThread()->getWebTaskRunner(); |
| 61 taskRunner->postTask( | 62 taskRunner->postTask( |
| 62 BLINK_FROM_HERE, | 63 BLINK_FROM_HERE, |
| 63 crossThreadBind(&SharedGpuContext::createContextProviderOnMainThread, | 64 crossThreadBind(&SharedGpuContext::createContextProviderOnMainThread, |
| 64 crossThreadUnretained(this), | 65 crossThreadUnretained(this), |
| 65 crossThreadUnretained(&waitableEvent))); | 66 crossThreadUnretained(&waitableEvent))); |
| 66 waitableEvent.wait(); | 67 waitableEvent.wait(); |
| 67 if (m_contextProvider && !m_contextProvider->bindToCurrentThread()) | 68 if (m_contextProvider && !m_contextProvider->bindToCurrentThread()) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 121 |
| 121 bool SharedGpuContext::isValidWithoutRestoring() { | 122 bool SharedGpuContext::isValidWithoutRestoring() { |
| 122 SharedGpuContext* thisPtr = getInstanceForCurrentThread(); | 123 SharedGpuContext* thisPtr = getInstanceForCurrentThread(); |
| 123 if (!thisPtr->m_contextProvider) | 124 if (!thisPtr->m_contextProvider) |
| 124 return false; | 125 return false; |
| 125 return thisPtr->m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() == | 126 return thisPtr->m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() == |
| 126 GL_NO_ERROR; | 127 GL_NO_ERROR; |
| 127 } | 128 } |
| 128 | 129 |
| 129 } // blink | 130 } // blink |
| OLD | NEW |