| 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_.display()->SetVisible(true); |
| 35 support_.RegisterFrameSinkId(); |
| 33 binding_.set_connection_error_handler(base::Bind( | 36 binding_.set_connection_error_handler(base::Bind( |
| 34 &GpuCompositorFrameSink::OnClientConnectionLost, base::Unretained(this))); | 37 &GpuCompositorFrameSink::OnClientConnectionLost, base::Unretained(this))); |
| 35 | 38 |
| 36 compositor_frame_sink_private_binding_.set_connection_error_handler( | 39 compositor_frame_sink_private_binding_.set_connection_error_handler( |
| 37 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, | 40 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, |
| 38 base::Unretained(this))); | 41 base::Unretained(this))); |
| 39 } | 42 } |
| 40 | 43 |
| 41 GpuCompositorFrameSink::~GpuCompositorFrameSink() {} | 44 GpuCompositorFrameSink::~GpuCompositorFrameSink() { |
| 45 support_.InvalidateFrameSinkId(); |
| 46 } |
| 42 | 47 |
| 43 void GpuCompositorFrameSink::EvictFrame() { | 48 void GpuCompositorFrameSink::EvictFrame() { |
| 44 support_.EvictFrame(); | 49 support_.EvictFrame(); |
| 45 } | 50 } |
| 46 | 51 |
| 47 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { | 52 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { |
| 48 support_.SetNeedsBeginFrame(needs_begin_frame); | 53 support_.SetNeedsBeginFrame(needs_begin_frame); |
| 49 } | 54 } |
| 50 | 55 |
| 51 void GpuCompositorFrameSink::SubmitCompositorFrame( | 56 void GpuCompositorFrameSink::SubmitCompositorFrame( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 138 } |
| 134 | 139 |
| 135 void GpuCompositorFrameSink::OnPrivateConnectionLost() { | 140 void GpuCompositorFrameSink::OnPrivateConnectionLost() { |
| 136 private_connection_lost_ = true; | 141 private_connection_lost_ = true; |
| 137 // Request destruction of |this| only if both connections are lost. | 142 // Request destruction of |this| only if both connections are lost. |
| 138 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( | 143 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( |
| 139 support_.frame_sink_id(), client_connection_lost_); | 144 support_.frame_sink_id(), client_connection_lost_); |
| 140 } | 145 } |
| 141 | 146 |
| 142 } // namespace ui | 147 } // namespace ui |
| OLD | NEW |