| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | 5 #ifndef COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ |
| 6 #define COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | 6 #define COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
| 11 #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h" | 11 #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h" |
| 12 #include "third_party/mojo/src/mojo/public/cpp/system/core.h" | 12 #include "third_party/mojo/src/mojo/public/cpp/system/core.h" |
| 13 | 13 |
| 14 namespace surfaces { | 14 namespace surfaces { |
| 15 | 15 |
| 16 class SurfacesContextProvider : public cc::ContextProvider { | 16 class SurfacesContextProvider : public cc::ContextProvider { |
| 17 public: | 17 public: |
| 18 explicit SurfacesContextProvider( | 18 explicit SurfacesContextProvider( |
| 19 mojo::ScopedMessagePipeHandle command_buffer_handle); | 19 mojo::ScopedMessagePipeHandle command_buffer_handle); |
| 20 | 20 |
| 21 // cc::ContextProvider implementation. | 21 // cc::ContextProvider implementation. |
| 22 bool BindToCurrentThread() override; | 22 bool BindToCurrentThread() override; |
| 23 gpu::gles2::GLES2Interface* ContextGL() override; | 23 gpu::gles2::GLES2Interface* ContextGL() override; |
| 24 gpu::ContextSupport* ContextSupport() override; | 24 gpu::ContextSupport* ContextSupport() override; |
| 25 class GrContext* GrContext() override; | 25 class GrContext* GrContext() override; |
| 26 void InvalidateGrContext(uint32_t state) override; | 26 void InvalidateGrContext(uint32_t state) override; |
| 27 Capabilities ContextCapabilities() override; | 27 Capabilities ContextCapabilities() override; |
| 28 bool IsContextLost() override; | |
| 29 void VerifyContexts() override {} | 28 void VerifyContexts() override {} |
| 30 void DeleteCachedResources() override {} | 29 void DeleteCachedResources() override {} |
| 31 bool DestroyedOnMainThread() override; | 30 bool DestroyedOnMainThread() override; |
| 32 void SetLostContextCallback( | 31 void SetLostContextCallback( |
| 33 const LostContextCallback& lost_context_callback) override; | 32 const LostContextCallback& lost_context_callback) override; |
| 34 void SetMemoryPolicyChangedCallback( | 33 void SetMemoryPolicyChangedCallback( |
| 35 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | 34 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
| 36 override {} | 35 override {} |
| 37 void SetupLock() override; | 36 void SetupLock() override; |
| 38 base::Lock* GetLock() override; | 37 base::Lock* GetLock() override; |
| 39 | 38 |
| 40 protected: | 39 protected: |
| 41 friend class base::RefCountedThreadSafe<SurfacesContextProvider>; | 40 friend class base::RefCountedThreadSafe<SurfacesContextProvider>; |
| 42 ~SurfacesContextProvider() override; | 41 ~SurfacesContextProvider() override; |
| 43 | 42 |
| 44 private: | 43 private: |
| 45 static void ContextLostThunk(void* closure) { | 44 static void ContextLostThunk(void* closure) { |
| 46 static_cast<SurfacesContextProvider*>(closure)->ContextLost(); | 45 static_cast<SurfacesContextProvider*>(closure)->ContextLost(); |
| 47 } | 46 } |
| 48 void ContextLost(); | 47 void ContextLost(); |
| 49 | 48 |
| 50 cc::ContextProvider::Capabilities capabilities_; | 49 cc::ContextProvider::Capabilities capabilities_; |
| 51 mojo::ScopedMessagePipeHandle command_buffer_handle_; | 50 mojo::ScopedMessagePipeHandle command_buffer_handle_; |
| 52 MojoGLES2Context context_; | 51 MojoGLES2Context context_; |
| 53 bool context_lost_; | |
| 54 LostContextCallback lost_context_callback_; | 52 LostContextCallback lost_context_callback_; |
| 55 | 53 |
| 56 base::Lock context_lock_; | 54 base::Lock context_lock_; |
| 57 | 55 |
| 58 DISALLOW_COPY_AND_ASSIGN(SurfacesContextProvider); | 56 DISALLOW_COPY_AND_ASSIGN(SurfacesContextProvider); |
| 59 }; | 57 }; |
| 60 | 58 |
| 61 } // namespace surfaces | 59 } // namespace surfaces |
| 62 | 60 |
| 63 #endif // COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | 61 #endif // COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ |
| OLD | NEW |