Chromium Code Reviews| 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 "wtf/ThreadSpecific.h" | 5 #include "wtf/ThreadSpecific.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 namespace gpu { namespace gles2 { class GLES2Interface; } } | 9 namespace gpu { namespace gles2 { class GLES2Interface; } } |
| 10 class GrContext; | 10 class GrContext; |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class WaitableEvent; | 14 class WaitableEvent; |
| 15 class WebGraphicsContext3DProvider; | 15 class WebGraphicsContext3DProvider; |
| 16 | 16 |
| 17 // SharedGpuContext provides access to a thread-specific GPU context | 17 // SharedGpuContext provides access to a thread-specific GPU context |
| 18 // that is shared by many callsites throughout the thread. | 18 // that is shared by many callsites throughout the thread. |
| 19 // When on the main thread, provides access to the same context as | 19 // When on the main thread, provides access to the same context as |
| 20 // Platform::createSharedOffscreenGraphicsContext3DProvider | 20 // Platform::createSharedOffscreenGraphicsContext3DProvider |
| 21 class SharedGpuContext { | 21 class SharedGpuContext { |
|
xidachen
2016/09/15 18:53:35
I think you need to add PLATFORM_EXPORT in here, o
| |
| 22 public: | 22 public: |
| 23 // The contextId is incremented each time a new underlying context | 23 // The contextId is incremented each time a new underlying context |
| 24 // is created. For example, when the context is lost, then restored. | 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 | 25 // User code can rely on this Id to determine whether long-lived |
| 26 // gpu resources are still alive in the current context. | 26 // gpu resources are still alive in the current context. |
| 27 static unsigned contextId(); | 27 static unsigned contextId(); |
| 28 static gpu::gles2::GLES2Interface* gl(); | 28 static gpu::gles2::GLES2Interface* gl(); // May re-create context if context was lost |
| 29 static GrContext* gr(); | 29 static GrContext* gr(); // May re-create context if context was lost |
| 30 static bool isValid(); | 30 static bool isValid(); // May re-create context if context was lost |
| 31 static bool restore(); | 31 static bool isValidWithoutRestoring(); |
|
xidachen
2016/09/15 18:53:35
Is this method suppose to be called inside unit-te
danakj
2016/09/15 19:00:58
(or ForTesting suffix will enforce that).
| |
| 32 typedef std::function<std::unique_ptr<WebGraphicsContext3DProvider>()> Conte xtProviderFactory; | |
| 33 static void setContextProviderFactoryForTesting(ContextProviderFactory); | |
| 32 | 34 |
| 33 enum { | 35 enum { |
| 34 kNoSharedContext = 0, | 36 kNoSharedContext = 0, |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 private: | 39 private: |
| 38 static SharedGpuContext* getInstanceForCurrentThread(); | 40 static SharedGpuContext* getInstanceForCurrentThread(); |
| 39 | 41 |
| 40 SharedGpuContext(); | 42 SharedGpuContext(); |
| 41 void createContextProviderOnMainThread(WaitableEvent*); | 43 void createContextProviderOnMainThread(WaitableEvent*); |
| 42 void createContextProvider(); | 44 void createContextProviderIfNeeded(); |
| 43 | 45 |
| 46 ContextProviderFactory m_contextProviderFactory = nullptr; | |
| 44 std::unique_ptr<WebGraphicsContext3DProvider> m_contextProvider; | 47 std::unique_ptr<WebGraphicsContext3DProvider> m_contextProvider; |
| 45 unsigned m_contextId; | 48 unsigned m_contextId; |
| 46 friend class WTF::ThreadSpecific<SharedGpuContext>; | 49 friend class WTF::ThreadSpecific<SharedGpuContext>; |
| 47 }; | 50 }; |
| 48 | 51 |
| 49 } // blink | 52 } // blink |
| OLD | NEW |