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

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

Issue 2728183002: RendererCompositorFrameSink should handle local surface id allocation (Closed)
Patch Set: notreached 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // We should only submit CompositorFrames with valid BeginFrameAcks. 112 // We should only submit CompositorFrames with valid BeginFrameAcks.
113 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, 113 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber,
114 frame.metadata.begin_frame_ack.sequence_number); 114 frame.metadata.begin_frame_ack.sequence_number);
115 if (ShouldAllocateNewLocalSurfaceId(frame))
116 local_surface_id_ = id_allocator_.GenerateId();
117 UpdateFrameData(frame);
115 { 118 {
116 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> 119 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope>
117 send_message_scope = 120 send_message_scope =
118 frame_swap_message_queue_->AcquireSendMessageScope(); 121 frame_swap_message_queue_->AcquireSendMessageScope();
119 std::vector<std::unique_ptr<IPC::Message>> messages; 122 std::vector<std::unique_ptr<IPC::Message>> messages;
120 std::vector<IPC::Message> messages_to_deliver_with_frame; 123 std::vector<IPC::Message> messages_to_deliver_with_frame;
121 frame_swap_message_queue_->DrainMessages(&messages); 124 frame_swap_message_queue_->DrainMessages(&messages);
122 FrameSwapMessageQueue::TransferMessages(&messages, 125 FrameSwapMessageQueue::TransferMessages(&messages,
123 &messages_to_deliver_with_frame); 126 &messages_to_deliver_with_frame);
124 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, 127 Send(new ViewHostMsg_SwapCompositorFrame(
125 compositor_frame_sink_id_, frame, 128 routing_id_, compositor_frame_sink_id_, local_surface_id_, frame,
126 messages_to_deliver_with_frame)); 129 messages_to_deliver_with_frame));
127 // ~send_message_scope. 130 // ~send_message_scope.
128 } 131 }
129 } 132 }
130 133
131 void RendererCompositorFrameSink::OnMessageReceived( 134 void RendererCompositorFrameSink::OnMessageReceived(
132 const IPC::Message& message) { 135 const IPC::Message& message) {
133 DCHECK(thread_checker_.CalledOnValidThread()); 136 DCHECK(thread_checker_.CalledOnValidThread());
134 IPC_BEGIN_MESSAGE_MAP(RendererCompositorFrameSink, message) 137 IPC_BEGIN_MESSAGE_MAP(RendererCompositorFrameSink, message)
135 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, 138 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources,
136 OnReclaimCompositorResources); 139 OnReclaimCompositorResources);
(...skipping 10 matching lines...) Expand all
147 return; 150 return;
148 client_->ReclaimResources(resources); 151 client_->ReclaimResources(resources);
149 if (is_swap_ack) 152 if (is_swap_ack)
150 client_->DidReceiveCompositorFrameAck(); 153 client_->DidReceiveCompositorFrameAck();
151 } 154 }
152 155
153 bool RendererCompositorFrameSink::Send(IPC::Message* message) { 156 bool RendererCompositorFrameSink::Send(IPC::Message* message) {
154 return message_sender_->Send(message); 157 return message_sender_->Send(message);
155 } 158 }
156 159
160 bool RendererCompositorFrameSink::ShouldAllocateNewLocalSurfaceId(
161 const cc::CompositorFrame& frame) {
162 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
163 gfx::Size frame_size = root_pass->output_rect.size();
164
165 // Once the proposal in crbug.com/689754 is implemented, the LocalSurfaceId
166 // allocation logic will be unified across all platforms.
167 return !local_surface_id_.is_valid() ||
168 current_frame_data_.device_scale_factor !=
169 frame.metadata.device_scale_factor ||
170 #ifdef OS_ANDROID
171 current_frame_data_.top_controls_height !=
172 frame.metadata.top_controls_height ||
173 current_frame_data_.top_controls_shown_ratio !=
174 frame.metadata.top_controls_shown_ratio ||
175 current_frame_data_.bottom_controls_height !=
176 frame.metadata.bottom_controls_height ||
177 current_frame_data_.bottom_controls_shown_ratio !=
178 frame.metadata.bottom_controls_shown_ratio ||
179 current_frame_data_.viewport_selection != frame.metadata.selection ||
180 current_frame_data_.has_transparent_background !=
181 root_pass->has_transparent_background ||
182 #endif
183 current_frame_data_.frame_size != frame_size;
184 }
185
186 void RendererCompositorFrameSink::UpdateFrameData(
187 const cc::CompositorFrame& frame) {
188 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
189 gfx::Size frame_size = root_pass->output_rect.size();
190
191 current_frame_data_.frame_size = frame_size;
192 current_frame_data_.device_scale_factor = frame.metadata.device_scale_factor;
193 #ifdef OS_ANDROID
194 current_frame_data_.top_controls_height = frame.metadata.top_controls_height;
195 current_frame_data_.top_controls_shown_ratio =
196 frame.metadata.top_controls_shown_ratio;
197 current_frame_data_.bottom_controls_height =
198 frame.metadata.bottom_controls_height;
199 current_frame_data_.bottom_controls_shown_ratio =
200 frame.metadata.bottom_controls_shown_ratio;
201 current_frame_data_.viewport_selection = frame.metadata.selection;
202 current_frame_data_.has_transparent_background =
203 root_pass->has_transparent_background;
204 #endif
205 }
206
157 } // namespace content 207 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698