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

Unified Diff: content/renderer/gpu/renderer_compositor_frame_sink.cc

Issue 2728183002: RendererCompositorFrameSink should handle local surface id allocation (Closed)
Patch Set: Added comment Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/gpu/renderer_compositor_frame_sink.cc
diff --git a/content/renderer/gpu/renderer_compositor_frame_sink.cc b/content/renderer/gpu/renderer_compositor_frame_sink.cc
index 16ccae09e0618e338d0de11d2f4676883ea6cb42..131bee3538ee9ff22274fa7ec8765cf5845427ff 100644
--- a/content/renderer/gpu/renderer_compositor_frame_sink.cc
+++ b/content/renderer/gpu/renderer_compositor_frame_sink.cc
@@ -109,6 +109,9 @@ void RendererCompositorFrameSink::DetachFromClient() {
void RendererCompositorFrameSink::SubmitCompositorFrame(
cc::CompositorFrame frame) {
+ if (ShouldAllocateNewLocalSurfaceId(frame))
+ local_surface_id_ = id_allocator_.GenerateId();
+ UpdateFrameData(frame);
{
std::unique_ptr<FrameSwapMessageQueue::SendMessageScope>
send_message_scope =
@@ -118,9 +121,9 @@ void RendererCompositorFrameSink::SubmitCompositorFrame(
frame_swap_message_queue_->DrainMessages(&messages);
FrameSwapMessageQueue::TransferMessages(&messages,
&messages_to_deliver_with_frame);
- Send(new ViewHostMsg_SwapCompositorFrame(routing_id_,
- compositor_frame_sink_id_, frame,
- messages_to_deliver_with_frame));
+ Send(new ViewHostMsg_SwapCompositorFrame(
+ routing_id_, compositor_frame_sink_id_, local_surface_id_, frame,
+ messages_to_deliver_with_frame));
// ~send_message_scope.
}
}
@@ -151,4 +154,51 @@ bool RendererCompositorFrameSink::Send(IPC::Message* message) {
return message_sender_->Send(message);
}
+bool RendererCompositorFrameSink::ShouldAllocateNewLocalSurfaceId(
+ const cc::CompositorFrame& frame) {
+ cc::RenderPass* root_pass = frame.render_pass_list.back().get();
+ gfx::Size frame_size = root_pass->output_rect.size();
+
+ // Once the proposal in crbug.com/689754 is implemented, the LocalSurfaceId
+ // allocation logic will be unified across all platforms.
+ return !local_surface_id_.is_valid() ||
+ current_frame_data_.device_scale_factor !=
+ frame.metadata.device_scale_factor ||
+#ifdef OS_ANDROID
+ current_frame_data_.top_controls_height !=
+ frame.metadata.top_controls_height ||
+ current_frame_data_.top_controls_shown_ratio !=
+ frame.metadata.top_controls_shown_ratio ||
+ current_frame_data_.bottom_controls_height !=
+ frame.metadata.bottom_controls_height ||
+ current_frame_data_.bottom_controls_shown_ratio !=
+ frame.metadata.bottom_controls_shown_ratio ||
+ current_frame_data_.viewport_selection != frame.metadata.selection ||
+ current_frame_data_.has_transparent_background !=
+ root_pass->has_transparent_background ||
+#endif
+ current_frame_data_.frame_size != frame_size;
+}
+
+void RendererCompositorFrameSink::UpdateFrameData(
+ const cc::CompositorFrame& frame) {
+ cc::RenderPass* root_pass = frame.render_pass_list.back().get();
+ gfx::Size frame_size = root_pass->output_rect.size();
+
+ current_frame_data_.frame_size = frame_size;
+ current_frame_data_.device_scale_factor = frame.metadata.device_scale_factor;
+#ifdef OS_ANDROID
+ current_frame_data_.top_controls_height = frame.metadata.top_controls_height;
+ current_frame_data_.top_controls_shown_ratio =
+ frame.metadata.top_controls_shown_ratio;
+ current_frame_data_.bottom_controls_height =
+ frame.metadata.bottom_controls_height;
+ current_frame_data_.bottom_controls_shown_ratio =
+ frame.metadata.bottom_controls_shown_ratio;
+ current_frame_data_.viewport_selection = frame.metadata.selection;
+ current_frame_data_.has_transparent_background =
+ root_pass->has_transparent_background;
+#endif
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698