OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "wtf/ThreadSpecific.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 namespace gpu { namespace gles2 { class GLES2Interface; } } |
| 10 class GrContext; |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 class WaitableEvent; |
| 15 class WebGraphicsContext3DProvider; |
| 16 |
| 17 // SharedGpuContext provides access to a thread-specific GPU context |
| 18 // that is shared by many callsites throughout the thread. |
| 19 // When on the main thread, provides access to the same context as |
| 20 // Platform::createSharedOffscreenGraphicsContext3DProvider |
| 21 class SharedGpuContext { |
| 22 public: |
| 23 // The contextId is incremented each time a new underlying context |
| 24 // is created. For example, when the context is lost, then restored. |
| 25 // User code can rely on this Id to determine whether long-lived |
| 26 // gpu resources are still alive in the current context. |
| 27 static unsigned contextId(); |
| 28 static gpu::gles2::GLES2Interface* gl(); |
| 29 static GrContext* gr(); |
| 30 static bool isValid(); |
| 31 static bool restore(); |
| 32 |
| 33 enum { |
| 34 kNoSharedContext = 0, |
| 35 }; |
| 36 |
| 37 private: |
| 38 static SharedGpuContext* getInstanceForCurrentThread(); |
| 39 |
| 40 SharedGpuContext(); |
| 41 void createContextProviderOnMainThread(WaitableEvent*); |
| 42 void createContextProvider(); |
| 43 |
| 44 std::unique_ptr<WebGraphicsContext3DProvider> m_contextProvider; |
| 45 unsigned m_contextId; |
| 46 friend class WTF::ThreadSpecific<SharedGpuContext>; |
| 47 }; |
| 48 |
| 49 } // blink |
OLD | NEW |