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 "platform/WebTaskRunner.h" | 10 #include "platform/WebTaskRunner.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 WTF::wrapUnique(blink::Platform::current() | 53 WTF::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 | 56 // This synchronous round-trip to the main thread is the reason why |
57 // SharedGpuContext encasulates the context provider: so we only have to do | 57 // SharedGpuContext encasulates the context provider: so we only have to do |
58 // this once per thread. | 58 // this once per thread. |
59 WaitableEvent waitableEvent; | 59 WaitableEvent waitableEvent; |
60 WebTaskRunner* taskRunner = | 60 RefPtr<WebTaskRunner> taskRunner = |
61 Platform::current()->mainThread()->getWebTaskRunner(); | 61 Platform::current()->mainThread()->getWebTaskRunner(); |
62 taskRunner->postTask( | 62 taskRunner->postTask( |
63 BLINK_FROM_HERE, | 63 BLINK_FROM_HERE, |
64 crossThreadBind(&SharedGpuContext::createContextProviderOnMainThread, | 64 crossThreadBind(&SharedGpuContext::createContextProviderOnMainThread, |
65 crossThreadUnretained(this), | 65 crossThreadUnretained(this), |
66 crossThreadUnretained(&waitableEvent))); | 66 crossThreadUnretained(&waitableEvent))); |
67 waitableEvent.wait(); | 67 waitableEvent.wait(); |
68 if (m_contextProvider && !m_contextProvider->bindToCurrentThread()) | 68 if (m_contextProvider && !m_contextProvider->bindToCurrentThread()) |
69 m_contextProvider = nullptr; | 69 m_contextProvider = nullptr; |
70 } | 70 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 121 |
122 bool SharedGpuContext::isValidWithoutRestoring() { | 122 bool SharedGpuContext::isValidWithoutRestoring() { |
123 SharedGpuContext* thisPtr = getInstanceForCurrentThread(); | 123 SharedGpuContext* thisPtr = getInstanceForCurrentThread(); |
124 if (!thisPtr->m_contextProvider) | 124 if (!thisPtr->m_contextProvider) |
125 return false; | 125 return false; |
126 return thisPtr->m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() == | 126 return thisPtr->m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() == |
127 GL_NO_ERROR; | 127 GL_NO_ERROR; |
128 } | 128 } |
129 | 129 |
130 } // blink | 130 } // blink |
OLD | NEW |