OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | |
6 #define COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/synchronization/lock.h" | |
10 #include "base/threading/non_thread_safe.h" | |
11 #include "cc/output/context_provider.h" | |
12 #include "components/view_manager/gles2/command_buffer_local_client.h" | |
13 #include "ui/gfx/native_widget_types.h" | |
14 | |
15 namespace gpu { | |
16 | |
17 class TransferBuffer; | |
18 | |
19 namespace gles2 { | |
20 class GLES2CmdHelper; | |
21 class GLES2Implementation; | |
22 } | |
23 | |
24 } // namespace gpu | |
25 | |
26 namespace gles2 { | |
27 class CommandBufferDriver; | |
28 class CommandBufferImpl; | |
29 class CommandBufferLocal; | |
30 class GpuState; | |
31 } | |
32 | |
33 namespace surfaces { | |
34 | |
35 class SurfacesContextProviderDelegate; | |
36 | |
37 class SurfacesContextProvider : public cc::ContextProvider, | |
38 public gles2::CommandBufferLocalClient, | |
39 public base::NonThreadSafe { | |
40 public: | |
41 SurfacesContextProvider(SurfacesContextProviderDelegate* delegate, | |
42 gfx::AcceleratedWidget widget, | |
43 const scoped_refptr<gles2::GpuState>& state); | |
44 | |
45 // cc::ContextProvider implementation. | |
46 bool BindToCurrentThread() override; | |
47 gpu::gles2::GLES2Interface* ContextGL() override; | |
48 gpu::ContextSupport* ContextSupport() override; | |
49 class GrContext* GrContext() override; | |
50 void InvalidateGrContext(uint32_t state) override; | |
51 Capabilities ContextCapabilities() override; | |
52 void VerifyContexts() override {} | |
53 void DeleteCachedResources() override {} | |
54 bool DestroyedOnMainThread() override; | |
55 void SetLostContextCallback( | |
56 const LostContextCallback& lost_context_callback) override; | |
57 void SetMemoryPolicyChangedCallback( | |
58 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | |
59 override {} | |
60 void SetupLock() override; | |
61 base::Lock* GetLock() override; | |
62 | |
63 protected: | |
64 friend class base::RefCountedThreadSafe<SurfacesContextProvider>; | |
65 ~SurfacesContextProvider() override; | |
66 | |
67 private: | |
68 // CommandBufferLocalClient: | |
69 void UpdateVSyncParameters(int64_t timebase, int64_t interval) override; | |
70 void DidLoseContext() override; | |
71 | |
72 // From GLES2Context: | |
73 // Initialized in BindToCurrentThread. | |
74 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; | |
75 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; | |
76 scoped_ptr<gpu::gles2::GLES2Implementation> implementation_; | |
77 | |
78 cc::ContextProvider::Capabilities capabilities_; | |
79 LostContextCallback lost_context_callback_; | |
80 | |
81 SurfacesContextProviderDelegate* delegate_; | |
82 scoped_refptr<gles2::GpuState> state_; | |
83 gfx::AcceleratedWidget widget_; | |
84 scoped_ptr<gles2::CommandBufferLocal> command_buffer_local_; | |
85 | |
86 base::Lock context_lock_; | |
87 | |
88 DISALLOW_COPY_AND_ASSIGN(SurfacesContextProvider); | |
89 }; | |
90 | |
91 } // namespace surfaces | |
92 | |
93 #endif // COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | |
OLD | NEW |