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

Side by Side 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 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 begin_frame_source_ = nullptr; 102 begin_frame_source_ = nullptr;
103 compositor_frame_sink_proxy_->ClearCompositorFrameSink(); 103 compositor_frame_sink_proxy_->ClearCompositorFrameSink();
104 compositor_frame_sink_filter_->RemoveHandlerOnCompositorThread( 104 compositor_frame_sink_filter_->RemoveHandlerOnCompositorThread(
105 routing_id_, compositor_frame_sink_filter_handler_); 105 routing_id_, compositor_frame_sink_filter_handler_);
106 106
107 cc::CompositorFrameSink::DetachFromClient(); 107 cc::CompositorFrameSink::DetachFromClient();
108 } 108 }
109 109
110 void RendererCompositorFrameSink::SubmitCompositorFrame( 110 void RendererCompositorFrameSink::SubmitCompositorFrame(
111 cc::CompositorFrame frame) { 111 cc::CompositorFrame frame) {
112 if (ShouldAllocateNewLocalSurfaceId(frame))
113 local_surface_id_ = id_allocator_.GenerateId();
114 UpdateFrameData(frame);
112 { 115 {
113 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> 116 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope>
114 send_message_scope = 117 send_message_scope =
115 frame_swap_message_queue_->AcquireSendMessageScope(); 118 frame_swap_message_queue_->AcquireSendMessageScope();
116 std::vector<std::unique_ptr<IPC::Message>> messages; 119 std::vector<std::unique_ptr<IPC::Message>> messages;
117 std::vector<IPC::Message> messages_to_deliver_with_frame; 120 std::vector<IPC::Message> messages_to_deliver_with_frame;
118 frame_swap_message_queue_->DrainMessages(&messages); 121 frame_swap_message_queue_->DrainMessages(&messages);
119 FrameSwapMessageQueue::TransferMessages(&messages, 122 FrameSwapMessageQueue::TransferMessages(&messages,
120 &messages_to_deliver_with_frame); 123 &messages_to_deliver_with_frame);
121 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, 124 Send(new ViewHostMsg_SwapCompositorFrame(
122 compositor_frame_sink_id_, frame, 125 routing_id_, compositor_frame_sink_id_, local_surface_id_, frame,
123 messages_to_deliver_with_frame)); 126 messages_to_deliver_with_frame));
124 // ~send_message_scope. 127 // ~send_message_scope.
125 } 128 }
126 } 129 }
127 130
128 void RendererCompositorFrameSink::OnMessageReceived( 131 void RendererCompositorFrameSink::OnMessageReceived(
129 const IPC::Message& message) { 132 const IPC::Message& message) {
130 DCHECK(thread_checker_.CalledOnValidThread()); 133 DCHECK(thread_checker_.CalledOnValidThread());
131 IPC_BEGIN_MESSAGE_MAP(RendererCompositorFrameSink, message) 134 IPC_BEGIN_MESSAGE_MAP(RendererCompositorFrameSink, message)
132 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, 135 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources,
133 OnReclaimCompositorResources); 136 OnReclaimCompositorResources);
(...skipping 10 matching lines...) Expand all
144 return; 147 return;
145 client_->ReclaimResources(resources); 148 client_->ReclaimResources(resources);
146 if (is_swap_ack) 149 if (is_swap_ack)
147 client_->DidReceiveCompositorFrameAck(); 150 client_->DidReceiveCompositorFrameAck();
148 } 151 }
149 152
150 bool RendererCompositorFrameSink::Send(IPC::Message* message) { 153 bool RendererCompositorFrameSink::Send(IPC::Message* message) {
151 return message_sender_->Send(message); 154 return message_sender_->Send(message);
152 } 155 }
153 156
157 bool RendererCompositorFrameSink::ShouldAllocateNewLocalSurfaceId(
158 const cc::CompositorFrame& frame) {
159 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
160 gfx::Size frame_size = root_pass->output_rect.size();
161
162 // Once the proposal in crbug.com/689754 is implemented, the LocalSurfaceId
163 // allocation logic will be unified across all platforms.
164 return !local_surface_id_.is_valid() ||
165 current_frame_data_.device_scale_factor !=
166 frame.metadata.device_scale_factor ||
167 #ifdef OS_ANDROID
168 current_frame_data_.top_controls_height !=
169 frame.metadata.top_controls_height ||
170 current_frame_data_.top_controls_shown_ratio !=
171 frame.metadata.top_controls_shown_ratio ||
172 current_frame_data_.bottom_controls_height !=
173 frame.metadata.bottom_controls_height ||
174 current_frame_data_.bottom_controls_shown_ratio !=
175 frame.metadata.bottom_controls_shown_ratio ||
176 current_frame_data_.viewport_selection != frame.metadata.selection ||
177 current_frame_data_.has_transparent_background !=
178 root_pass->has_transparent_background ||
179 #endif
180 current_frame_data_.frame_size != frame_size;
181 }
182
183 void RendererCompositorFrameSink::UpdateFrameData(
184 const cc::CompositorFrame& frame) {
185 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
186 gfx::Size frame_size = root_pass->output_rect.size();
187
188 current_frame_data_.frame_size = frame_size;
189 current_frame_data_.device_scale_factor = frame.metadata.device_scale_factor;
190 #ifdef OS_ANDROID
191 current_frame_data_.top_controls_height = frame.metadata.top_controls_height;
192 current_frame_data_.top_controls_shown_ratio =
193 frame.metadata.top_controls_shown_ratio;
194 current_frame_data_.bottom_controls_height =
195 frame.metadata.bottom_controls_height;
196 current_frame_data_.bottom_controls_shown_ratio =
197 frame.metadata.bottom_controls_shown_ratio;
198 current_frame_data_.viewport_selection = frame.metadata.selection;
199 current_frame_data_.has_transparent_background =
200 root_pass->has_transparent_background;
201 #endif
202 }
203
154 } // namespace content 204 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698