OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "services/ui/surfaces/gpu_compositor_frame_sink.h" | 5 #include "services/ui/surfaces/gpu_compositor_frame_sink.h" |
6 | 6 |
7 #include "services/ui/surfaces/display_compositor.h" | 7 #include "services/ui/surfaces/display_compositor.h" |
8 | 8 |
9 namespace ui { | 9 namespace ui { |
10 | 10 |
11 GpuCompositorFrameSink::GpuCompositorFrameSink( | 11 GpuCompositorFrameSink::GpuCompositorFrameSink( |
12 DisplayCompositor* display_compositor, | 12 DisplayCompositor* display_compositor, |
13 const cc::FrameSinkId& frame_sink_id, | 13 const cc::FrameSinkId& frame_sink_id, |
14 std::unique_ptr<cc::Display> display, | 14 std::unique_ptr<cc::Display> display, |
15 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, | 15 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, |
16 cc::mojom::MojoCompositorFrameSinkRequest request, | 16 cc::mojom::MojoCompositorFrameSinkRequest request, |
17 cc::mojom::MojoCompositorFrameSinkPrivateRequest | 17 cc::mojom::MojoCompositorFrameSinkPrivateRequest |
18 compositor_frame_sink_private_request, | 18 compositor_frame_sink_private_request, |
19 cc::mojom::MojoCompositorFrameSinkClientPtr client, | 19 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
20 cc::mojom::DisplayPrivateRequest display_private_request) | 20 cc::mojom::DisplayPrivateRequest display_private_request) |
21 : display_compositor_(display_compositor), | 21 : display_compositor_(display_compositor), |
| 22 display_(std::move(display)), |
22 support_(this, | 23 support_(this, |
23 display_compositor->manager(), | 24 display_compositor->manager(), |
24 frame_sink_id, | 25 frame_sink_id, |
25 std::move(display), | 26 display_.get(), |
26 std::move(begin_frame_source)), | 27 std::move(begin_frame_source)), |
27 client_(std::move(client)), | 28 client_(std::move(client)), |
28 binding_(this, std::move(request)), | 29 binding_(this, std::move(request)), |
29 compositor_frame_sink_private_binding_( | 30 compositor_frame_sink_private_binding_( |
30 this, | 31 this, |
31 std::move(compositor_frame_sink_private_request)), | 32 std::move(compositor_frame_sink_private_request)), |
32 display_private_binding_(this, std::move(display_private_request)) { | 33 display_private_binding_(this, std::move(display_private_request)) { |
| 34 support_.BindToClient(); |
| 35 support_.RegisterFrameSinkId(); |
| 36 support_.SetDisplayVisible(true); |
33 binding_.set_connection_error_handler(base::Bind( | 37 binding_.set_connection_error_handler(base::Bind( |
34 &GpuCompositorFrameSink::OnClientConnectionLost, base::Unretained(this))); | 38 &GpuCompositorFrameSink::OnClientConnectionLost, base::Unretained(this))); |
35 | 39 |
36 compositor_frame_sink_private_binding_.set_connection_error_handler( | 40 compositor_frame_sink_private_binding_.set_connection_error_handler( |
37 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, | 41 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, |
38 base::Unretained(this))); | 42 base::Unretained(this))); |
39 } | 43 } |
40 | 44 |
41 GpuCompositorFrameSink::~GpuCompositorFrameSink() {} | 45 GpuCompositorFrameSink::~GpuCompositorFrameSink() { |
| 46 support_.DetachFromClient(); |
| 47 support_.InvalidateFrameSinkId(); |
| 48 } |
42 | 49 |
43 void GpuCompositorFrameSink::EvictFrame() { | 50 void GpuCompositorFrameSink::EvictFrame() { |
44 support_.EvictFrame(); | 51 support_.EvictFrame(); |
45 } | 52 } |
46 | 53 |
47 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { | 54 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { |
48 support_.SetNeedsBeginFrame(needs_begin_frame); | 55 support_.SetNeedsBeginFrame(needs_begin_frame); |
49 } | 56 } |
50 | 57 |
51 void GpuCompositorFrameSink::SubmitCompositorFrame( | 58 void GpuCompositorFrameSink::SubmitCompositorFrame( |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 140 } |
134 | 141 |
135 void GpuCompositorFrameSink::OnPrivateConnectionLost() { | 142 void GpuCompositorFrameSink::OnPrivateConnectionLost() { |
136 private_connection_lost_ = true; | 143 private_connection_lost_ = true; |
137 // Request destruction of |this| only if both connections are lost. | 144 // Request destruction of |this| only if both connections are lost. |
138 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( | 145 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( |
139 support_.frame_sink_id(), client_connection_lost_); | 146 support_.frame_sink_id(), client_connection_lost_); |
140 } | 147 } |
141 | 148 |
142 } // namespace ui | 149 } // namespace ui |
OLD | NEW |