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