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