Chromium Code Reviews| 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 "cc/surfaces/surface_reference.h" | 7 #include "cc/surfaces/surface_reference.h" |
| 8 #include "services/ui/surfaces/display_compositor.h" | 8 #include "services/ui/surfaces/display_compositor.h" |
| 9 | 9 |
| 10 namespace ui { | 10 namespace ui { |
| 11 | 11 |
| 12 GpuCompositorFrameSink::GpuCompositorFrameSink( | 12 GpuCompositorFrameSink::GpuCompositorFrameSink( |
| 13 DisplayCompositor* display_compositor, | 13 DisplayCompositor* display_compositor, |
| 14 const cc::FrameSinkId& frame_sink_id, | 14 const cc::FrameSinkId& frame_sink_id, |
| 15 std::unique_ptr<cc::Display> display, | 15 std::unique_ptr<cc::Display> display, |
| 16 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, | 16 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, |
| 17 cc::mojom::MojoCompositorFrameSinkRequest request, | 17 cc::mojom::MojoCompositorFrameSinkRequest request, |
| 18 cc::mojom::MojoCompositorFrameSinkPrivateRequest | 18 cc::mojom::MojoCompositorFrameSinkPrivateRequest |
| 19 compositor_frame_sink_private_request, | 19 compositor_frame_sink_private_request, |
| 20 cc::mojom::MojoCompositorFrameSinkClientPtr client, | 20 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
| 21 cc::mojom::DisplayPrivateRequest display_private_request) | 21 cc::mojom::DisplayPrivateRequest display_private_request) |
| 22 : display_compositor_(display_compositor), | 22 : display_compositor_(display_compositor), |
| 23 display_(std::move(display)), | |
| 24 display_begin_frame_source_(std::move(begin_frame_source)), | |
| 23 support_(this, | 25 support_(this, |
| 24 display_compositor->manager(), | 26 display_compositor->manager(), |
| 25 frame_sink_id, | 27 frame_sink_id, |
| 26 std::move(display), | 28 display_.get()), |
| 27 std::move(begin_frame_source)), | |
| 28 surface_tracker_(frame_sink_id), | 29 surface_tracker_(frame_sink_id), |
| 29 client_(std::move(client)), | 30 client_(std::move(client)), |
| 30 binding_(this, std::move(request)), | 31 binding_(this, std::move(request)), |
| 31 compositor_frame_sink_private_binding_( | 32 compositor_frame_sink_private_binding_( |
| 32 this, | 33 this, |
| 33 std::move(compositor_frame_sink_private_request)), | 34 std::move(compositor_frame_sink_private_request)), |
| 34 display_private_binding_(this, std::move(display_private_request)) { | 35 display_private_binding_(this, std::move(display_private_request)) { |
| 36 if (display_.get()) | |
| 37 display_->SetVisible(true); | |
| 35 binding_.set_connection_error_handler(base::Bind( | 38 binding_.set_connection_error_handler(base::Bind( |
| 36 &GpuCompositorFrameSink::OnClientConnectionLost, base::Unretained(this))); | 39 &GpuCompositorFrameSink::OnClientConnectionLost, base::Unretained(this))); |
| 37 | 40 |
| 38 compositor_frame_sink_private_binding_.set_connection_error_handler( | 41 compositor_frame_sink_private_binding_.set_connection_error_handler( |
| 39 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, | 42 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, |
| 40 base::Unretained(this))); | 43 base::Unretained(this))); |
| 41 } | 44 } |
| 42 | 45 |
| 43 GpuCompositorFrameSink::~GpuCompositorFrameSink() { | 46 GpuCompositorFrameSink::~GpuCompositorFrameSink() { |
| 44 // For display root surfaces, remove the reference from top level root to | 47 // For display root surfaces, remove the reference from top level root to |
| 45 // indicate the display root surface is no longer visible. | 48 // indicate the display root surface is no longer visible. |
| 46 if (support_.display() && surface_tracker_.current_surface_id().is_valid()) { | 49 if (support_.display() && surface_tracker_.current_surface_id().is_valid()) { |
| 47 const cc::SurfaceId top_level_root_surface_id = | 50 const cc::SurfaceId top_level_root_surface_id = |
| 48 display_compositor_->manager()->GetRootSurfaceId(); | 51 display_compositor_->manager()->GetRootSurfaceId(); |
| 49 std::vector<cc::SurfaceReference> references_to_remove{cc::SurfaceReference( | 52 std::vector<cc::SurfaceReference> references_to_remove{cc::SurfaceReference( |
| 50 top_level_root_surface_id, surface_tracker_.current_surface_id())}; | 53 top_level_root_surface_id, surface_tracker_.current_surface_id())}; |
| 51 display_compositor_->RemoveSurfaceReferences(references_to_remove); | 54 display_compositor_->RemoveSurfaceReferences(references_to_remove); |
| 52 } | 55 } |
| 56 support_.InvalidateFrameSinkId(); | |
|
Fady Samuel
2017/01/23 21:56:12
Why?
| |
| 53 } | 57 } |
| 54 | 58 |
| 55 void GpuCompositorFrameSink::EvictFrame() { | 59 void GpuCompositorFrameSink::EvictFrame() { |
| 56 support_.EvictFrame(); | 60 support_.EvictFrame(); |
| 57 } | 61 } |
| 58 | 62 |
| 59 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { | 63 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { |
| 60 support_.SetNeedsBeginFrame(needs_begin_frame); | 64 support_.SetNeedsBeginFrame(needs_begin_frame); |
| 61 } | 65 } |
| 62 | 66 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 } | 173 } |
| 170 | 174 |
| 171 void GpuCompositorFrameSink::OnPrivateConnectionLost() { | 175 void GpuCompositorFrameSink::OnPrivateConnectionLost() { |
| 172 private_connection_lost_ = true; | 176 private_connection_lost_ = true; |
| 173 // Request destruction of |this| only if both connections are lost. | 177 // Request destruction of |this| only if both connections are lost. |
| 174 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( | 178 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( |
| 175 support_.frame_sink_id(), client_connection_lost_); | 179 support_.frame_sink_id(), client_connection_lost_); |
| 176 } | 180 } |
| 177 | 181 |
| 178 } // namespace ui | 182 } // namespace ui |
| OLD | NEW |