| 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 private_request, | 17 cc::mojom::MojoCompositorFrameSinkPrivateRequest |
| 18 cc::mojom::MojoCompositorFrameSinkClientPtr client) | 18 compositor_frame_sink_private_request, |
| 19 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
| 20 cc::mojom::DisplayPrivateRequest display_private_request) |
| 19 : display_compositor_(display_compositor), | 21 : display_compositor_(display_compositor), |
| 20 support_(this, | 22 support_(this, |
| 21 display_compositor->manager(), | 23 display_compositor->manager(), |
| 22 frame_sink_id, | 24 frame_sink_id, |
| 23 std::move(display), | 25 std::move(display), |
| 24 std::move(begin_frame_source)), | 26 std::move(begin_frame_source)), |
| 25 client_(std::move(client)), | 27 client_(std::move(client)), |
| 26 binding_(this, std::move(request)), | 28 binding_(this, std::move(request)), |
| 27 private_binding_(this, std::move(private_request)) { | 29 compositor_frame_sink_private_binding_( |
| 30 this, |
| 31 std::move(compositor_frame_sink_private_request)), |
| 32 display_private_binding_(this, std::move(display_private_request)) { |
| 28 binding_.set_connection_error_handler(base::Bind( | 33 binding_.set_connection_error_handler(base::Bind( |
| 29 &GpuCompositorFrameSink::OnClientConnectionLost, base::Unretained(this))); | 34 &GpuCompositorFrameSink::OnClientConnectionLost, base::Unretained(this))); |
| 30 | 35 |
| 31 private_binding_.set_connection_error_handler( | 36 compositor_frame_sink_private_binding_.set_connection_error_handler( |
| 32 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, | 37 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, |
| 33 base::Unretained(this))); | 38 base::Unretained(this))); |
| 34 } | 39 } |
| 35 | 40 |
| 36 GpuCompositorFrameSink::~GpuCompositorFrameSink() {} | 41 GpuCompositorFrameSink::~GpuCompositorFrameSink() {} |
| 37 | 42 |
| 38 void GpuCompositorFrameSink::EvictFrame() { | 43 void GpuCompositorFrameSink::EvictFrame() { |
| 39 support_.EvictFrame(); | 44 support_.EvictFrame(); |
| 40 } | 45 } |
| 41 | 46 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 void GpuCompositorFrameSink::AddChildFrameSink( | 81 void GpuCompositorFrameSink::AddChildFrameSink( |
| 77 const cc::FrameSinkId& child_frame_sink_id) { | 82 const cc::FrameSinkId& child_frame_sink_id) { |
| 78 support_.AddChildFrameSink(child_frame_sink_id); | 83 support_.AddChildFrameSink(child_frame_sink_id); |
| 79 } | 84 } |
| 80 | 85 |
| 81 void GpuCompositorFrameSink::RemoveChildFrameSink( | 86 void GpuCompositorFrameSink::RemoveChildFrameSink( |
| 82 const cc::FrameSinkId& child_frame_sink_id) { | 87 const cc::FrameSinkId& child_frame_sink_id) { |
| 83 support_.RemoveChildFrameSink(child_frame_sink_id); | 88 support_.RemoveChildFrameSink(child_frame_sink_id); |
| 84 } | 89 } |
| 85 | 90 |
| 91 void GpuCompositorFrameSink::SetDisplayVisible(bool visible) { |
| 92 if (support_.display()) |
| 93 support_.display()->SetVisible(visible); |
| 94 } |
| 95 |
| 96 void GpuCompositorFrameSink::ResizeDisplay(const gfx::Size& size) { |
| 97 if (support_.display()) |
| 98 support_.display()->Resize(size); |
| 99 } |
| 100 |
| 101 void GpuCompositorFrameSink::SetDisplayColorSpace( |
| 102 const gfx::ColorSpace& color_space) { |
| 103 if (support_.display()) |
| 104 support_.display()->SetColorSpace(color_space); |
| 105 } |
| 106 |
| 107 void GpuCompositorFrameSink::SetOutputIsSecure(bool secure) { |
| 108 if (support_.display()) |
| 109 support_.display()->SetOutputIsSecure(secure); |
| 110 } |
| 111 |
| 86 void GpuCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) { | 112 void GpuCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) { |
| 87 if (client_) | 113 if (client_) |
| 88 client_->OnBeginFrame(args); | 114 client_->OnBeginFrame(args); |
| 89 } | 115 } |
| 90 | 116 |
| 91 void GpuCompositorFrameSink::ReclaimResources( | 117 void GpuCompositorFrameSink::ReclaimResources( |
| 92 const cc::ReturnedResourceArray& resources) { | 118 const cc::ReturnedResourceArray& resources) { |
| 93 if (client_) | 119 if (client_) |
| 94 client_->ReclaimResources(resources); | 120 client_->ReclaimResources(resources); |
| 95 } | 121 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 107 } | 133 } |
| 108 | 134 |
| 109 void GpuCompositorFrameSink::OnPrivateConnectionLost() { | 135 void GpuCompositorFrameSink::OnPrivateConnectionLost() { |
| 110 private_connection_lost_ = true; | 136 private_connection_lost_ = true; |
| 111 // Request destruction of |this| only if both connections are lost. | 137 // Request destruction of |this| only if both connections are lost. |
| 112 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( | 138 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( |
| 113 support_.frame_sink_id(), client_connection_lost_); | 139 support_.frame_sink_id(), client_connection_lost_); |
| 114 } | 140 } |
| 115 | 141 |
| 116 } // namespace ui | 142 } // namespace ui |
| OLD | NEW |