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 "components/view_manager/gles2/gpu_state.h" |
| 12 #include "components/view_manager/surfaces/command_buffer_local.h" |
| 13 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 14 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 15 #include "gpu/command_buffer/client/transfer_buffer.h" |
11 #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h" | 16 #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h" |
12 #include "third_party/mojo/src/mojo/public/cpp/system/core.h" | 17 #include "third_party/mojo/src/mojo/public/cpp/system/core.h" |
| 18 #include "ui/gfx/native_widget_types.h" |
| 19 |
| 20 namespace gles2 { |
| 21 class CommandBufferDriver; |
| 22 class CommandBufferImpl; |
| 23 } |
13 | 24 |
14 namespace surfaces { | 25 namespace surfaces { |
15 | 26 |
16 class SurfacesContextProvider : public cc::ContextProvider { | 27 class SurfacesContextProvider : public cc::ContextProvider, |
| 28 public CommandBufferLocal::Client { |
17 public: | 29 public: |
18 explicit SurfacesContextProvider( | 30 class Delegate { |
19 mojo::ScopedMessagePipeHandle command_buffer_handle); | 31 public: |
| 32 virtual void OnVSyncParametersUpdated(int64_t timebase, |
| 33 int64_t interval) = 0; |
| 34 protected: |
| 35 virtual ~Delegate() {} |
| 36 }; |
| 37 |
| 38 SurfacesContextProvider(Delegate* delegate, |
| 39 gfx::AcceleratedWidget widget, |
| 40 const scoped_refptr<gles2::GpuState>& state); |
20 | 41 |
21 // cc::ContextProvider implementation. | 42 // cc::ContextProvider implementation. |
22 bool BindToCurrentThread() override; | 43 bool BindToCurrentThread() override; |
23 gpu::gles2::GLES2Interface* ContextGL() override; | 44 gpu::gles2::GLES2Interface* ContextGL() override; |
24 gpu::ContextSupport* ContextSupport() override; | 45 gpu::ContextSupport* ContextSupport() override; |
25 class GrContext* GrContext() override; | 46 class GrContext* GrContext() override; |
26 void InvalidateGrContext(uint32_t state) override; | 47 void InvalidateGrContext(uint32_t state) override; |
27 Capabilities ContextCapabilities() override; | 48 Capabilities ContextCapabilities() override; |
28 void VerifyContexts() override {} | 49 void VerifyContexts() override {} |
29 void DeleteCachedResources() override {} | 50 void DeleteCachedResources() override {} |
30 bool DestroyedOnMainThread() override; | 51 bool DestroyedOnMainThread() override; |
31 void SetLostContextCallback( | 52 void SetLostContextCallback( |
32 const LostContextCallback& lost_context_callback) override; | 53 const LostContextCallback& lost_context_callback) override; |
33 void SetMemoryPolicyChangedCallback( | 54 void SetMemoryPolicyChangedCallback( |
34 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | 55 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
35 override {} | 56 override {} |
36 void SetupLock() override; | 57 void SetupLock() override; |
37 base::Lock* GetLock() override; | 58 base::Lock* GetLock() override; |
38 | 59 |
39 protected: | 60 protected: |
40 friend class base::RefCountedThreadSafe<SurfacesContextProvider>; | 61 friend class base::RefCountedThreadSafe<SurfacesContextProvider>; |
41 ~SurfacesContextProvider() override; | 62 ~SurfacesContextProvider() override; |
42 | 63 |
43 private: | 64 private: |
44 static void ContextLostThunk(void* closure) { | 65 // CommandBufferLocal::Client: |
45 static_cast<SurfacesContextProvider*>(closure)->ContextLost(); | 66 void UpdateVSyncParameters(int64_t timebase, int64_t interval) override; |
46 } | 67 void DidLoseContext() override; |
47 void ContextLost(); | 68 |
| 69 // From GLES2Context: |
| 70 // Initialized in BindToCurrentThread. |
| 71 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; |
| 72 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; |
| 73 scoped_ptr<gpu::gles2::GLES2Implementation> implementation_; |
48 | 74 |
49 cc::ContextProvider::Capabilities capabilities_; | 75 cc::ContextProvider::Capabilities capabilities_; |
50 mojo::ScopedMessagePipeHandle command_buffer_handle_; | |
51 MojoGLES2Context context_; | |
52 LostContextCallback lost_context_callback_; | 76 LostContextCallback lost_context_callback_; |
53 | 77 |
| 78 Delegate* delegate_; |
| 79 scoped_refptr<gles2::GpuState> state_; |
| 80 gfx::AcceleratedWidget widget_; |
| 81 scoped_ptr<surfaces::CommandBufferLocal> command_buffer_local_; |
| 82 |
54 base::Lock context_lock_; | 83 base::Lock context_lock_; |
55 | 84 |
56 DISALLOW_COPY_AND_ASSIGN(SurfacesContextProvider); | 85 DISALLOW_COPY_AND_ASSIGN(SurfacesContextProvider); |
57 }; | 86 }; |
58 | 87 |
59 } // namespace surfaces | 88 } // namespace surfaces |
60 | 89 |
61 #endif // COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | 90 #endif // COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ |
OLD | NEW |