| 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/PlatformExport.h" | 5 #include "platform/PlatformExport.h" |
| 6 #include "platform/wtf/ThreadSpecific.h" | 6 #include "platform/wtf/ThreadSpecific.h" |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 namespace gpu { | 10 namespace gpu { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 public: | 27 public: |
| 28 // The contextId is incremented each time a new underlying context | 28 // The contextId is incremented each time a new underlying context |
| 29 // is created. For example, when the context is lost, then restored. | 29 // is created. For example, when the context is lost, then restored. |
| 30 // User code can rely on this Id to determine whether long-lived | 30 // User code can rely on this Id to determine whether long-lived |
| 31 // gpu resources are still alive in the current context. | 31 // gpu resources are still alive in the current context. |
| 32 static unsigned ContextId(); | 32 static unsigned ContextId(); |
| 33 static gpu::gles2::GLES2Interface* | 33 static gpu::gles2::GLES2Interface* |
| 34 Gl(); // May re-create context if context was lost | 34 Gl(); // May re-create context if context was lost |
| 35 static GrContext* Gr(); // May re-create context if context was lost | 35 static GrContext* Gr(); // May re-create context if context was lost |
| 36 static bool IsValid(); // May re-create context if context was lost | 36 static bool IsValid(); // May re-create context if context was lost |
| 37 // May re-create context if context was lost |
| 38 static bool AllowSoftwareToAcceleratedCanvasUpgrade(); |
| 39 |
| 37 static bool IsValidWithoutRestoring(); | 40 static bool IsValidWithoutRestoring(); |
| 38 typedef std::function<std::unique_ptr<WebGraphicsContext3DProvider>()> | 41 typedef std::function<std::unique_ptr<WebGraphicsContext3DProvider>()> |
| 39 ContextProviderFactory; | 42 ContextProviderFactory; |
| 40 static void SetContextProviderFactoryForTesting(ContextProviderFactory); | 43 static void SetContextProviderFactoryForTesting(ContextProviderFactory); |
| 41 | 44 |
| 42 enum { | 45 enum { |
| 43 kNoSharedContext = 0, | 46 kNoSharedContext = 0, |
| 44 }; | 47 }; |
| 45 | 48 |
| 46 private: | 49 private: |
| 47 static SharedGpuContext* GetInstanceForCurrentThread(); | 50 static SharedGpuContext* GetInstanceForCurrentThread(); |
| 48 | 51 |
| 49 SharedGpuContext(); | 52 SharedGpuContext(); |
| 50 void CreateContextProviderOnMainThread(WaitableEvent*); | 53 void CreateContextProviderOnMainThread(WaitableEvent*); |
| 51 void CreateContextProviderIfNeeded(); | 54 void CreateContextProviderIfNeeded(); |
| 52 | 55 |
| 53 ContextProviderFactory context_provider_factory_ = nullptr; | 56 ContextProviderFactory context_provider_factory_ = nullptr; |
| 54 std::unique_ptr<WebGraphicsContext3DProvider> context_provider_; | 57 std::unique_ptr<WebGraphicsContext3DProvider> context_provider_; |
| 55 unsigned context_id_; | 58 unsigned context_id_; |
| 56 friend class WTF::ThreadSpecific<SharedGpuContext>; | 59 friend class WTF::ThreadSpecific<SharedGpuContext>; |
| 57 }; | 60 }; |
| 58 | 61 |
| 59 } // blink | 62 } // blink |
| OLD | NEW |