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/ws/gpu_compositor_frame_sink.h" | 5 #include "services/ui/ws/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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 display_compositor_->manager()->UnregisterSurfaceFactoryClient( | 58 display_compositor_->manager()->UnregisterSurfaceFactoryClient( |
59 frame_sink_id_); | 59 frame_sink_id_); |
60 display_compositor_->manager()->InvalidateFrameSinkId(frame_sink_id_); | 60 display_compositor_->manager()->InvalidateFrameSinkId(frame_sink_id_); |
61 } | 61 } |
62 | 62 |
63 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { | 63 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { |
64 needs_begin_frame_ = needs_begin_frame; | 64 needs_begin_frame_ = needs_begin_frame; |
65 UpdateNeedsBeginFramesInternal(); | 65 UpdateNeedsBeginFramesInternal(); |
66 } | 66 } |
67 | 67 |
68 void GpuCompositorFrameSink::SubmitCompositorFrame(cc::CompositorFrame frame) { | 68 void GpuCompositorFrameSink::SubmitCompositorFrame( |
69 gfx::Size frame_size = frame.render_pass_list[0]->output_rect.size(); | 69 const cc::LocalFrameId& local_frame_id, |
70 cc::CompositorFrame frame) { | |
70 // If the size of the CompostiorFrame has changed then destroy the existing | 71 // If the size of the CompostiorFrame has changed then destroy the existing |
71 // Surface and create a new one of the appropriate size. | 72 // Surface and create a new one of the appropriate size. |
72 if (!local_frame_id_.is_valid() || frame_size != last_submitted_frame_size_) { | 73 if (local_frame_id_ != local_frame_id) { |
73 if (local_frame_id_.is_valid()) | 74 if (local_frame_id_.is_valid()) |
74 surface_factory_.Destroy(local_frame_id_); | 75 surface_factory_.Destroy(local_frame_id_); |
75 local_frame_id_ = surface_id_allocator_.GenerateId(); | 76 local_frame_id_ = local_frame_id; |
76 surface_factory_.Create(local_frame_id_); | 77 surface_factory_.Create(local_frame_id_); |
77 if (display_) | 78 if (display_) { |
79 gfx::Size frame_size; | |
80 if (!frame.render_pass_list.empty()) | |
81 frame_size = frame.render_pass_list[0]->output_rect.size(); | |
78 display_->Resize(frame_size); | 82 display_->Resize(frame_size); |
sadrul
2016/11/22 19:53:29
Do this Resize only if |frame_size| is non-empty?
Fady Samuel
2016/11/22 20:17:26
Done.
| |
83 } | |
79 } | 84 } |
80 ++ack_pending_count_; | 85 ++ack_pending_count_; |
81 surface_factory_.SubmitCompositorFrame( | 86 surface_factory_.SubmitCompositorFrame( |
82 local_frame_id_, std::move(frame), | 87 local_frame_id_, std::move(frame), |
83 base::Bind(&GpuCompositorFrameSink::DidReceiveCompositorFrameAck, | 88 base::Bind(&GpuCompositorFrameSink::DidReceiveCompositorFrameAck, |
84 base::Unretained(this))); | 89 base::Unretained(this))); |
85 if (display_) { | 90 if (display_) { |
86 display_->SetLocalFrameId(local_frame_id_, | 91 display_->SetLocalFrameId(local_frame_id_, |
87 frame.metadata.device_scale_factor); | 92 frame.metadata.device_scale_factor); |
88 } | 93 } |
89 last_submitted_frame_size_ = frame_size; | |
90 } | 94 } |
91 | 95 |
92 void GpuCompositorFrameSink::DidReceiveCompositorFrameAck() { | 96 void GpuCompositorFrameSink::DidReceiveCompositorFrameAck() { |
93 if (!client_) | 97 if (!client_) |
94 return; | 98 return; |
95 client_->DidReceiveCompositorFrameAck(); | 99 client_->DidReceiveCompositorFrameAck(); |
96 DCHECK_GT(ack_pending_count_, 0); | 100 DCHECK_GT(ack_pending_count_, 0); |
97 if (!surface_returned_resources_.empty()) { | 101 if (!surface_returned_resources_.empty()) { |
98 client_->ReclaimResources(surface_returned_resources_); | 102 client_->ReclaimResources(surface_returned_resources_); |
99 surface_returned_resources_.clear(); | 103 surface_returned_resources_.clear(); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 | 218 |
215 added_frame_observer_ = needs_begin_frame_; | 219 added_frame_observer_ = needs_begin_frame_; |
216 if (needs_begin_frame_) | 220 if (needs_begin_frame_) |
217 begin_frame_source_->AddObserver(this); | 221 begin_frame_source_->AddObserver(this); |
218 else | 222 else |
219 begin_frame_source_->RemoveObserver(this); | 223 begin_frame_source_->RemoveObserver(this); |
220 } | 224 } |
221 | 225 |
222 } // namespace ws | 226 } // namespace ws |
223 } // namespace ui | 227 } // namespace ui |
OLD | NEW |