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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 private_binding_.set_connection_error_handler( | 57 private_binding_.set_connection_error_handler( |
58 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, | 58 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, |
59 base::Unretained(this))); | 59 base::Unretained(this))); |
60 } | 60 } |
61 | 61 |
62 GpuCompositorFrameSink::~GpuCompositorFrameSink() { | 62 GpuCompositorFrameSink::~GpuCompositorFrameSink() { |
63 // SurfaceFactory's destructor will attempt to return resources which will | 63 // SurfaceFactory's destructor will attempt to return resources which will |
64 // call back into here and access |client_| so we should destroy | 64 // call back into here and access |client_| so we should destroy |
65 // |surface_factory_|'s resources early on. | 65 // |surface_factory_|'s resources early on. |
66 surface_factory_.DestroyAll(); | 66 surface_factory_.EvictSurface(); |
67 display_compositor_->manager()->UnregisterSurfaceFactoryClient( | 67 display_compositor_->manager()->UnregisterSurfaceFactoryClient( |
68 frame_sink_id_); | 68 frame_sink_id_); |
69 display_compositor_->manager()->InvalidateFrameSinkId(frame_sink_id_); | 69 display_compositor_->manager()->InvalidateFrameSinkId(frame_sink_id_); |
70 } | 70 } |
71 | 71 |
72 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { | 72 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { |
73 needs_begin_frame_ = needs_begin_frame; | 73 needs_begin_frame_ = needs_begin_frame; |
74 UpdateNeedsBeginFramesInternal(); | 74 UpdateNeedsBeginFramesInternal(); |
75 } | 75 } |
76 | 76 |
77 void GpuCompositorFrameSink::SubmitCompositorFrame( | 77 void GpuCompositorFrameSink::SubmitCompositorFrame( |
78 const cc::LocalFrameId& local_frame_id, | 78 const cc::LocalFrameId& local_frame_id, |
79 cc::CompositorFrame frame) { | 79 cc::CompositorFrame frame) { |
80 // If the size of the CompostiorFrame has changed then destroy the existing | 80 // If the size of the CompostiorFrame has changed then destroy the existing |
81 // Surface and create a new one of the appropriate size. | 81 // Surface and create a new one of the appropriate size. |
82 if (local_frame_id_ != local_frame_id) { | 82 if (local_frame_id_ != local_frame_id) { |
83 if (local_frame_id_.is_valid()) | |
84 surface_factory_.Destroy(local_frame_id_); | |
85 local_frame_id_ = local_frame_id; | 83 local_frame_id_ = local_frame_id; |
86 surface_factory_.Create(local_frame_id_); | |
87 if (display_ && !frame.render_pass_list.empty()) { | 84 if (display_ && !frame.render_pass_list.empty()) { |
88 gfx::Size frame_size = frame.render_pass_list[0]->output_rect.size(); | 85 gfx::Size frame_size = frame.render_pass_list[0]->output_rect.size(); |
89 display_->Resize(frame_size); | 86 display_->Resize(frame_size); |
90 } | 87 } |
91 } | 88 } |
92 ++ack_pending_count_; | 89 ++ack_pending_count_; |
93 surface_factory_.SubmitCompositorFrame( | 90 surface_factory_.SubmitCompositorFrame( |
94 local_frame_id_, std::move(frame), | 91 local_frame_id_, std::move(frame), |
95 base::Bind(&GpuCompositorFrameSink::DidReceiveCompositorFrameAck, | 92 base::Bind(&GpuCompositorFrameSink::DidReceiveCompositorFrameAck, |
96 weak_factory_.GetWeakPtr())); | 93 weak_factory_.GetWeakPtr())); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 236 } |
240 | 237 |
241 void GpuCompositorFrameSink::OnPrivateConnectionLost() { | 238 void GpuCompositorFrameSink::OnPrivateConnectionLost() { |
242 private_connection_lost_ = true; | 239 private_connection_lost_ = true; |
243 // Request destruction of |this| only if both connections are lost. | 240 // Request destruction of |this| only if both connections are lost. |
244 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( | 241 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( |
245 frame_sink_id_, client_connection_lost_); | 242 frame_sink_id_, client_connection_lost_); |
246 } | 243 } |
247 | 244 |
248 } // namespace ui | 245 } // namespace ui |
OLD | NEW |