| 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 "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 scoped_refptr<cc::InProcessContextProvider> context_provider, | 33 scoped_refptr<cc::InProcessContextProvider> context_provider, |
| 34 cc::mojom::MojoCompositorFrameSinkRequest request, | 34 cc::mojom::MojoCompositorFrameSinkRequest request, |
| 35 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, | 35 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, |
| 36 cc::mojom::MojoCompositorFrameSinkClientPtr client) | 36 cc::mojom::MojoCompositorFrameSinkClientPtr client) |
| 37 : frame_sink_id_(frame_sink_id), | 37 : frame_sink_id_(frame_sink_id), |
| 38 task_runner_(base::ThreadTaskRunnerHandle::Get()), | 38 task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 39 display_compositor_(display_compositor), | 39 display_compositor_(display_compositor), |
| 40 surface_factory_(frame_sink_id_, display_compositor_->manager(), this), | 40 surface_factory_(frame_sink_id_, display_compositor_->manager(), this), |
| 41 client_(std::move(client)), | 41 client_(std::move(client)), |
| 42 binding_(this, std::move(request)), | 42 binding_(this, std::move(request)), |
| 43 private_binding_(this, std::move(private_request)) { | 43 private_binding_(this, std::move(private_request)), |
| 44 weak_factory_(this) { |
| 44 display_compositor_->manager()->RegisterFrameSinkId(frame_sink_id_); | 45 display_compositor_->manager()->RegisterFrameSinkId(frame_sink_id_); |
| 45 display_compositor_->manager()->RegisterSurfaceFactoryClient(frame_sink_id_, | 46 display_compositor_->manager()->RegisterSurfaceFactoryClient(frame_sink_id_, |
| 46 this); | 47 this); |
| 47 | 48 |
| 48 if (surface_handle != gpu::kNullSurfaceHandle) { | 49 if (surface_handle != gpu::kNullSurfaceHandle) { |
| 49 InitDisplay(surface_handle, gpu_memory_buffer_manager, | 50 InitDisplay(surface_handle, gpu_memory_buffer_manager, |
| 50 std::move(context_provider)); | 51 std::move(context_provider)); |
| 51 } | 52 } |
| 52 | 53 |
| 53 binding_.set_connection_error_handler(base::Bind( | 54 binding_.set_connection_error_handler(base::Bind( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 surface_factory_.Create(local_frame_id_); | 86 surface_factory_.Create(local_frame_id_); |
| 86 if (display_ && !frame.render_pass_list.empty()) { | 87 if (display_ && !frame.render_pass_list.empty()) { |
| 87 gfx::Size frame_size = frame.render_pass_list[0]->output_rect.size(); | 88 gfx::Size frame_size = frame.render_pass_list[0]->output_rect.size(); |
| 88 display_->Resize(frame_size); | 89 display_->Resize(frame_size); |
| 89 } | 90 } |
| 90 } | 91 } |
| 91 ++ack_pending_count_; | 92 ++ack_pending_count_; |
| 92 surface_factory_.SubmitCompositorFrame( | 93 surface_factory_.SubmitCompositorFrame( |
| 93 local_frame_id_, std::move(frame), | 94 local_frame_id_, std::move(frame), |
| 94 base::Bind(&GpuCompositorFrameSink::DidReceiveCompositorFrameAck, | 95 base::Bind(&GpuCompositorFrameSink::DidReceiveCompositorFrameAck, |
| 95 base::Unretained(this))); | 96 weak_factory_.GetWeakPtr())); |
| 96 if (display_) { | 97 if (display_) { |
| 97 display_->SetLocalFrameId(local_frame_id_, | 98 display_->SetLocalFrameId(local_frame_id_, |
| 98 frame.metadata.device_scale_factor); | 99 frame.metadata.device_scale_factor); |
| 99 } | 100 } |
| 100 } | 101 } |
| 101 | 102 |
| 102 void GpuCompositorFrameSink::DidReceiveCompositorFrameAck() { | 103 void GpuCompositorFrameSink::DidReceiveCompositorFrameAck() { |
| 103 if (!client_) | 104 if (!client_) |
| 104 return; | 105 return; |
| 105 client_->DidReceiveCompositorFrameAck(); | 106 client_->DidReceiveCompositorFrameAck(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 } | 239 } |
| 239 | 240 |
| 240 void GpuCompositorFrameSink::OnPrivateConnectionLost() { | 241 void GpuCompositorFrameSink::OnPrivateConnectionLost() { |
| 241 private_connection_lost_ = true; | 242 private_connection_lost_ = true; |
| 242 // Request destruction of |this| only if both connections are lost. | 243 // Request destruction of |this| only if both connections are lost. |
| 243 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( | 244 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( |
| 244 frame_sink_id_, client_connection_lost_); | 245 frame_sink_id_, client_connection_lost_); |
| 245 } | 246 } |
| 246 | 247 |
| 247 } // namespace ui | 248 } // namespace ui |
| OLD | NEW |