OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_IMPL_H_ | 5 #ifndef SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_IMPL_H_ |
6 #define SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_IMPL_H_ | 6 #define SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_IMPL_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" | 9 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" |
10 #include "cc/scheduler/begin_frame_source.h" | 10 #include "cc/scheduler/begin_frame_source.h" |
11 #include "cc/surfaces/surface_factory.h" | 11 #include "cc/surfaces/surface_factory.h" |
12 #include "cc/surfaces/surface_factory_client.h" | 12 #include "cc/surfaces/surface_factory_client.h" |
13 #include "cc/surfaces/surface_id.h" | 13 #include "cc/surfaces/surface_id.h" |
14 #include "mojo/public/cpp/bindings/strong_binding.h" | 14 #include "mojo/public/cpp/bindings/strong_binding.h" |
15 #include "services/ui/surfaces/surfaces_state.h" | 15 #include "services/ui/surfaces/display_compositor.h" |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 namespace gpu { | 18 namespace gpu { |
19 | 19 |
20 class CompositorFrameSinkDelegate; | 20 class CompositorFrameSinkDelegate; |
21 | 21 |
22 // A client presents visuals to screen by submitting CompositorFrames to a | 22 // A client presents visuals to screen by submitting CompositorFrames to a |
23 // CompositorFrameSink. | 23 // CompositorFrameSink. |
24 class CompositorFrameSinkImpl : public cc::SurfaceFactoryClient, | 24 class CompositorFrameSinkImpl : public cc::SurfaceFactoryClient, |
25 public cc::mojom::MojoCompositorFrameSink, | 25 public cc::mojom::MojoCompositorFrameSink, |
26 public cc::BeginFrameObserver { | 26 public cc::BeginFrameObserver { |
27 public: | 27 public: |
28 CompositorFrameSinkImpl( | 28 CompositorFrameSinkImpl( |
29 CompositorFrameSinkDelegate* delegate, | 29 CompositorFrameSinkDelegate* delegate, |
30 int sink_id, | 30 int sink_id, |
31 const scoped_refptr<SurfacesState>& surfaces_state, | 31 const scoped_refptr<DisplayCompositor>& display_compositor, |
32 mojo::InterfaceRequest<mojom::CompositorFrameSink> request, | 32 mojo::InterfaceRequest<mojom::CompositorFrameSink> request, |
33 mojom::CompositorFrameSinkClientPtr client); | 33 mojom::CompositorFrameSinkClientPtr client); |
34 ~CompositorFrameSinkImpl() override; | 34 ~CompositorFrameSinkImpl() override; |
35 | 35 |
36 // cc::mojom::MojoCompositorFrameSink implementation. | 36 // cc::mojom::MojoCompositorFrameSink implementation. |
37 void SetNeedsBeginFrame(bool needs_begin_frame) override; | 37 void SetNeedsBeginFrame(bool needs_begin_frame) override; |
38 void SubmitCompositorFrame( | 38 void SubmitCompositorFrame( |
39 cc::CompositorFrame compositor_frame, | 39 cc::CompositorFrame compositor_frame, |
40 const SubmitCompositorFrameCallback& callback) override; | 40 const SubmitCompositorFrameCallback& callback) override; |
41 | 41 |
42 private: | 42 private: |
43 // SurfaceFactoryClient implementation. | 43 // SurfaceFactoryClient implementation. |
44 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 44 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
45 void WillDrawSurface(const cc::SurfaceId& surface_id, | 45 void WillDrawSurface(const cc::SurfaceId& surface_id, |
46 const gfx::Rect& damage_rect) override; | 46 const gfx::Rect& damage_rect) override; |
47 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | 47 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
48 | 48 |
49 // BeginFrameObserver implementation. | 49 // BeginFrameObserver implementation. |
50 void OnBeginFrame(const cc::BeginFrameArgs& args) override; | 50 void OnBeginFrame(const cc::BeginFrameArgs& args) override; |
51 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; | 51 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
52 void OnBeginFrameSourcePausedChanged(bool paused) override; | 52 void OnBeginFrameSourcePausedChanged(bool paused) override; |
53 | 53 |
54 void OnConnectionLost(); | 54 void OnConnectionLost(); |
55 | 55 |
56 CompositorFrameSinkDelegate* const delegate_; | 56 CompositorFrameSinkDelegate* const delegate_; |
57 scoped_refptr<SurfacesState> surfaces_state_; | 57 scoped_refptr<DisplayCompositor> display_compositor_; |
58 const int sink_id_; | 58 const int sink_id_; |
59 cc::BeginFrameSource* begin_frame_source_; | 59 cc::BeginFrameSource* begin_frame_source_; |
60 bool needs_begin_frame_; | 60 bool needs_begin_frame_; |
61 cc::BeginFrameArgs last_used_begin_frame_args_; | 61 cc::BeginFrameArgs last_used_begin_frame_args_; |
62 cc::SurfaceFactory factory_; | 62 cc::SurfaceFactory factory_; |
63 cc::SurfaceId surface_id_; | 63 cc::SurfaceId surface_id_; |
64 gfx::Size last_submitted_frame_size_; | 64 gfx::Size last_submitted_frame_size_; |
65 mojom::CompositorFrameSinkClientPtr client_; | 65 mojom::CompositorFrameSinkClientPtr client_; |
66 mojo::Binding<mojom::CompositorFrameSink> binding_; | 66 mojo::Binding<mojom::CompositorFrameSink> binding_; |
67 | 67 |
68 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkImpl); | 68 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkImpl); |
69 }; | 69 }; |
70 | 70 |
71 } // namespace gpu | 71 } // namespace gpu |
72 } // namespace ui | 72 } // namespace ui |
73 | 73 |
74 #endif // SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_IMPL_H_ | 74 #endif // SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_IMPL_H_ |
OLD | NEW |