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 SERVICES_UI_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | 5 #ifndef SERVICES_UI_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ |
6 #define SERVICES_UI_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | 6 #define SERVICES_UI_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
14 #include "cc/output/context_provider.h" | 14 #include "cc/output/context_provider.h" |
15 #include "services/ui/gles2/command_buffer_local_client.h" | |
16 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/gl/gl_surface.h" | 16 #include "ui/gl/gl_surface.h" |
18 | 17 |
19 namespace gpu { | 18 namespace gpu { |
20 | 19 |
21 class CommandBufferProxyImpl; | 20 class CommandBufferProxyImpl; |
22 struct GpuProcessHostedCALayerTreeParamsMac; | 21 struct GpuProcessHostedCALayerTreeParamsMac; |
23 class TransferBuffer; | 22 class TransferBuffer; |
24 | 23 |
25 namespace gles2 { | 24 namespace gles2 { |
26 class GLES2CmdHelper; | 25 class GLES2CmdHelper; |
27 class GLES2Implementation; | 26 class GLES2Implementation; |
28 } | 27 } |
29 | 28 |
30 } // namespace gpu | 29 } // namespace gpu |
31 | 30 |
32 namespace ui { | 31 namespace ui { |
33 class LatencyInfo; | 32 class LatencyInfo; |
34 } | 33 } |
35 | 34 |
36 namespace ui { | 35 namespace ui { |
37 | 36 |
38 class CommandBufferDriver; | 37 class CommandBufferDriver; |
39 class CommandBufferImpl; | 38 class CommandBufferImpl; |
40 class CommandBufferLocal; | |
41 class GpuState; | |
42 class SurfacesContextProviderDelegate; | 39 class SurfacesContextProviderDelegate; |
43 | 40 |
44 class SurfacesContextProvider : public cc::ContextProvider, | 41 class SurfacesContextProvider : public cc::ContextProvider, |
45 public CommandBufferLocalClient, | |
46 public base::NonThreadSafe { | 42 public base::NonThreadSafe { |
47 public: | 43 public: |
48 SurfacesContextProvider(gfx::AcceleratedWidget widget, | 44 explicit SurfacesContextProvider(gfx::AcceleratedWidget widget); |
49 const scoped_refptr<GpuState>& state); | |
50 | 45 |
51 void SetDelegate(SurfacesContextProviderDelegate* delegate); | 46 void SetDelegate(SurfacesContextProviderDelegate* delegate); |
52 | 47 |
53 // cc::ContextProvider implementation. | 48 // cc::ContextProvider implementation. |
54 bool BindToCurrentThread() override; | 49 bool BindToCurrentThread() override; |
55 gpu::gles2::GLES2Interface* ContextGL() override; | 50 gpu::gles2::GLES2Interface* ContextGL() override; |
56 gpu::ContextSupport* ContextSupport() override; | 51 gpu::ContextSupport* ContextSupport() override; |
57 class GrContext* GrContext() override; | 52 class GrContext* GrContext() override; |
58 void InvalidateGrContext(uint32_t state) override; | 53 void InvalidateGrContext(uint32_t state) override; |
59 gpu::Capabilities ContextCapabilities() override; | 54 gpu::Capabilities ContextCapabilities() override; |
60 void DeleteCachedResources() override {} | 55 void DeleteCachedResources() override {} |
61 void SetLostContextCallback( | 56 void SetLostContextCallback( |
62 const LostContextCallback& lost_context_callback) override; | 57 const LostContextCallback& lost_context_callback) override; |
63 base::Lock* GetLock() override; | 58 base::Lock* GetLock() override; |
64 | 59 |
65 // SurfacesContextProvider API. | 60 // SurfacesContextProvider API. |
66 void SetSwapBuffersCompletionCallback( | 61 void SetSwapBuffersCompletionCallback( |
67 gl::GLSurface::SwapCompletionCallback callback); | 62 gl::GLSurface::SwapCompletionCallback callback); |
68 | 63 |
69 protected: | 64 protected: |
70 friend class base::RefCountedThreadSafe<SurfacesContextProvider>; | 65 friend class base::RefCountedThreadSafe<SurfacesContextProvider>; |
71 ~SurfacesContextProvider() override; | 66 ~SurfacesContextProvider() override; |
72 | 67 |
73 private: | 68 private: |
74 // CommandBufferLocalClient: | |
75 void UpdateVSyncParameters(const base::TimeTicks& timebase, | |
76 const base::TimeDelta& interval) override; | |
77 void GpuCompletedSwapBuffers(gfx::SwapResult result) override; | |
78 | |
79 // Callbacks for CommandBufferProxyImpl: | 69 // Callbacks for CommandBufferProxyImpl: |
80 void OnGpuSwapBuffersCompleted( | 70 void OnGpuSwapBuffersCompleted( |
81 const std::vector<ui::LatencyInfo>& latency_info, | 71 const std::vector<ui::LatencyInfo>& latency_info, |
82 gfx::SwapResult result, | 72 gfx::SwapResult result, |
83 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac); | 73 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac); |
84 void OnUpdateVSyncParameters(base::TimeTicks timebase, | 74 void OnUpdateVSyncParameters(base::TimeTicks timebase, |
85 base::TimeDelta interval); | 75 base::TimeDelta interval); |
86 | 76 |
87 bool use_chrome_gpu_command_buffer_; | |
88 | |
89 // From GLES2Context: | 77 // From GLES2Context: |
90 // Initialized in BindToCurrentThread. | 78 // Initialized in BindToCurrentThread. |
91 std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; | 79 std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; |
92 std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; | 80 std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; |
93 std::unique_ptr<gpu::gles2::GLES2Implementation> implementation_; | 81 std::unique_ptr<gpu::gles2::GLES2Implementation> implementation_; |
94 | 82 |
95 gpu::Capabilities capabilities_; | 83 gpu::Capabilities capabilities_; |
96 LostContextCallback lost_context_callback_; | 84 LostContextCallback lost_context_callback_; |
97 | 85 |
98 SurfacesContextProviderDelegate* delegate_; | 86 SurfacesContextProviderDelegate* delegate_; |
99 gfx::AcceleratedWidget widget_; | 87 gfx::AcceleratedWidget widget_; |
100 CommandBufferLocal* command_buffer_local_; | |
101 std::unique_ptr<gpu::CommandBufferProxyImpl> command_buffer_proxy_impl_; | 88 std::unique_ptr<gpu::CommandBufferProxyImpl> command_buffer_proxy_impl_; |
102 gl::GLSurface::SwapCompletionCallback swap_buffers_completion_callback_; | 89 gl::GLSurface::SwapCompletionCallback swap_buffers_completion_callback_; |
103 | 90 |
104 DISALLOW_COPY_AND_ASSIGN(SurfacesContextProvider); | 91 DISALLOW_COPY_AND_ASSIGN(SurfacesContextProvider); |
105 }; | 92 }; |
106 | 93 |
107 } // namespace ui | 94 } // namespace ui |
108 | 95 |
109 #endif // SERVICES_UI_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ | 96 #endif // SERVICES_UI_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ |
OLD | NEW |