Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: content/renderer/gpu/renderer_compositor_frame_sink.cc

Issue 2882303002: Factor FrameData out of RendererCompositorFrameSink (Closed)
Patch Set: c Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/gpu/renderer_compositor_frame_sink.h" 5 #include "content/renderer/gpu/renderer_compositor_frame_sink.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 sink_.reset(); 118 sink_.reset();
119 sink_client_binding_.Close(); 119 sink_client_binding_.Close();
120 cc::CompositorFrameSink::DetachFromClient(); 120 cc::CompositorFrameSink::DetachFromClient();
121 } 121 }
122 122
123 void RendererCompositorFrameSink::SubmitCompositorFrame( 123 void RendererCompositorFrameSink::SubmitCompositorFrame(
124 cc::CompositorFrame frame) { 124 cc::CompositorFrame frame) {
125 // We should only submit CompositorFrames with valid BeginFrameAcks. 125 // We should only submit CompositorFrames with valid BeginFrameAcks.
126 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, 126 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber,
127 frame.metadata.begin_frame_ack.sequence_number); 127 frame.metadata.begin_frame_ack.sequence_number);
128 if (ShouldAllocateNewLocalSurfaceId(frame)) 128 auto new_surface_properties =
129 RenderWidgetSurfaceProperties::FromCompositorFrame(frame);
130 if (!local_surface_id_.is_valid() ||
131 new_surface_properties != current_surface_properties_) {
129 local_surface_id_ = id_allocator_.GenerateId(); 132 local_surface_id_ = id_allocator_.GenerateId();
130 UpdateFrameData(frame); 133 current_surface_properties_ = new_surface_properties;
134 }
131 135
132 { 136 {
133 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> 137 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope>
134 send_message_scope = 138 send_message_scope =
135 frame_swap_message_queue_->AcquireSendMessageScope(); 139 frame_swap_message_queue_->AcquireSendMessageScope();
136 std::vector<std::unique_ptr<IPC::Message>> messages; 140 std::vector<std::unique_ptr<IPC::Message>> messages;
137 frame_swap_message_queue_->DrainMessages(&messages); 141 frame_swap_message_queue_->DrainMessages(&messages);
138 std::vector<IPC::Message> messages_to_send; 142 std::vector<IPC::Message> messages_to_send;
139 FrameSwapMessageQueue::TransferMessages(&messages, &messages_to_send); 143 FrameSwapMessageQueue::TransferMessages(&messages, &messages_to_send);
140 uint32_t frame_token = 0; 144 uint32_t frame_token = 0;
(...skipping 16 matching lines...) Expand all
157 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrameIPC) 161 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrameIPC)
158 IPC_END_MESSAGE_MAP() 162 IPC_END_MESSAGE_MAP()
159 } 163 }
160 164
161 void RendererCompositorFrameSink::OnBeginFrameIPC( 165 void RendererCompositorFrameSink::OnBeginFrameIPC(
162 const cc::BeginFrameArgs& args) { 166 const cc::BeginFrameArgs& args) {
163 if (external_begin_frame_source_) 167 if (external_begin_frame_source_)
164 external_begin_frame_source_->OnBeginFrame(args); 168 external_begin_frame_source_->OnBeginFrame(args);
165 } 169 }
166 170
167 bool RendererCompositorFrameSink::ShouldAllocateNewLocalSurfaceId(
168 const cc::CompositorFrame& frame) {
169 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
170 gfx::Size frame_size = root_pass->output_rect.size();
171
172 // Once the proposal in crbug.com/689754 is implemented, the LocalSurfaceId
173 // allocation logic will be unified across all platforms.
174 return !local_surface_id_.is_valid() ||
175 current_frame_data_.device_scale_factor !=
176 frame.metadata.device_scale_factor ||
177 #ifdef OS_ANDROID
178 current_frame_data_.top_controls_height !=
179 frame.metadata.top_controls_height ||
180 current_frame_data_.top_controls_shown_ratio !=
181 frame.metadata.top_controls_shown_ratio ||
182 current_frame_data_.bottom_controls_height !=
183 frame.metadata.bottom_controls_height ||
184 current_frame_data_.bottom_controls_shown_ratio !=
185 frame.metadata.bottom_controls_shown_ratio ||
186 current_frame_data_.viewport_selection != frame.metadata.selection ||
187 current_frame_data_.has_transparent_background !=
188 root_pass->has_transparent_background ||
189 #endif
190 current_frame_data_.frame_size != frame_size;
191 }
192
193 void RendererCompositorFrameSink::UpdateFrameData(
194 const cc::CompositorFrame& frame) {
195 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
196 gfx::Size frame_size = root_pass->output_rect.size();
197
198 current_frame_data_.frame_size = frame_size;
199 current_frame_data_.device_scale_factor = frame.metadata.device_scale_factor;
200 #ifdef OS_ANDROID
201 current_frame_data_.top_controls_height = frame.metadata.top_controls_height;
202 current_frame_data_.top_controls_shown_ratio =
203 frame.metadata.top_controls_shown_ratio;
204 current_frame_data_.bottom_controls_height =
205 frame.metadata.bottom_controls_height;
206 current_frame_data_.bottom_controls_shown_ratio =
207 frame.metadata.bottom_controls_shown_ratio;
208 current_frame_data_.viewport_selection = frame.metadata.selection;
209 current_frame_data_.has_transparent_background =
210 root_pass->has_transparent_background;
211 #endif
212 }
213
214 void RendererCompositorFrameSink::DidReceiveCompositorFrameAck( 171 void RendererCompositorFrameSink::DidReceiveCompositorFrameAck(
215 const cc::ReturnedResourceArray& resources) { 172 const cc::ReturnedResourceArray& resources) {
216 ReclaimResources(resources); 173 ReclaimResources(resources);
217 client_->DidReceiveCompositorFrameAck(); 174 client_->DidReceiveCompositorFrameAck();
218 } 175 }
219 176
220 void RendererCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) { 177 void RendererCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) {
221 // See crbug.com/709689. 178 // See crbug.com/709689.
222 NOTREACHED() << "BeginFrames are delivered using Chrome IPC."; 179 NOTREACHED() << "BeginFrames are delivered using Chrome IPC.";
223 } 180 }
(...skipping 20 matching lines...) Expand all
244 cc::mojom::MojoCompositorFrameSinkRequest sink_request = 201 cc::mojom::MojoCompositorFrameSinkRequest sink_request =
245 mojo::MakeRequest(&sink); 202 mojo::MakeRequest(&sink);
246 cc::mojom::MojoCompositorFrameSinkClientPtr sink_client; 203 cc::mojom::MojoCompositorFrameSinkClientPtr sink_client;
247 sink_client_request_ = mojo::MakeRequest(&sink_client); 204 sink_client_request_ = mojo::MakeRequest(&sink_client);
248 RenderThreadImpl::current()->GetFrameSinkProvider()->CreateForWidget( 205 RenderThreadImpl::current()->GetFrameSinkProvider()->CreateForWidget(
249 routing_id_, std::move(sink_request), std::move(sink_client)); 206 routing_id_, std::move(sink_request), std::move(sink_client));
250 sink_ptr_info_ = sink.PassInterface(); 207 sink_ptr_info_ = sink.PassInterface();
251 } 208 }
252 209
253 } // namespace content 210 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/renderer_compositor_frame_sink.h ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698