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

Side by Side Diff: content/renderer/android/synchronous_compositor_proxy.cc

Issue 2096493002: Make cc::CompositorFrames movable [Part 1 of 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Dana's nits Created 4 years, 5 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 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 "content/renderer/android/synchronous_compositor_proxy.h" 5 #include "content/renderer/android/synchronous_compositor_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "cc/ipc/cc_param_traits.h" 10 #include "cc/ipc/cc_param_traits.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 base::AutoReset<IPC::Message*> scoped_hardware_draw_reply( 160 base::AutoReset<IPC::Message*> scoped_hardware_draw_reply(
161 &hardware_draw_reply_, reply_message); 161 &hardware_draw_reply_, reply_message);
162 output_surface_->DemandDrawHw(params.surface_size, params.transform, 162 output_surface_->DemandDrawHw(params.surface_size, params.transform,
163 params.viewport, params.clip, 163 params.viewport, params.clip,
164 params.viewport_rect_for_tile_priority, 164 params.viewport_rect_for_tile_priority,
165 params.transform_for_tile_priority); 165 params.transform_for_tile_priority);
166 } 166 }
167 167
168 if (inside_receive_) { 168 if (inside_receive_) {
169 // Did not swap. 169 // Did not swap.
170 cc::CompositorFrame empty_frame; 170 SendDemandDrawHwReply(cc::CompositorFrame(), 0u, reply_message);
171 SendDemandDrawHwReply(&empty_frame, 0u, reply_message);
172 inside_receive_ = false; 171 inside_receive_ = false;
173 } 172 }
174 } 173 }
175 174
176 void SynchronousCompositorProxy::SwapBuffersHw(uint32_t output_surface_id, 175 void SynchronousCompositorProxy::SwapBuffersHw(uint32_t output_surface_id,
177 cc::CompositorFrame* frame) { 176 cc::CompositorFrame frame) {
178 DCHECK(inside_receive_); 177 DCHECK(inside_receive_);
179 DCHECK(hardware_draw_reply_); 178 DCHECK(hardware_draw_reply_);
180 DCHECK(frame); 179 SendDemandDrawHwReply(std::move(frame), output_surface_id,
181 SendDemandDrawHwReply(frame, output_surface_id, hardware_draw_reply_); 180 hardware_draw_reply_);
182 inside_receive_ = false; 181 inside_receive_ = false;
183 } 182 }
184 183
185 void SynchronousCompositorProxy::SendDemandDrawHwReply( 184 void SynchronousCompositorProxy::SendDemandDrawHwReply(
186 cc::CompositorFrame* frame, 185 cc::CompositorFrame frame,
187 uint32_t output_surface_id, 186 uint32_t output_surface_id,
188 IPC::Message* reply_message) { 187 IPC::Message* reply_message) {
189 SyncCompositorCommonRendererParams common_renderer_params; 188 SyncCompositorCommonRendererParams common_renderer_params;
190 PopulateCommonParams(&common_renderer_params); 189 PopulateCommonParams(&common_renderer_params);
191 SyncCompositorMsg_DemandDrawHw::WriteReplyParams( 190 SyncCompositorMsg_DemandDrawHw::WriteReplyParams(
192 reply_message, common_renderer_params, output_surface_id, *frame); 191 reply_message, common_renderer_params, output_surface_id, frame);
193 Send(reply_message); 192 Send(reply_message);
194 } 193 }
195 194
196 struct SynchronousCompositorProxy::SharedMemoryWithSize { 195 struct SynchronousCompositorProxy::SharedMemoryWithSize {
197 base::SharedMemory shm; 196 base::SharedMemory shm;
198 const size_t buffer_size; 197 const size_t buffer_size;
199 bool zeroed; 198 bool zeroed;
200 199
201 SharedMemoryWithSize(base::SharedMemoryHandle shm_handle, size_t buffer_size) 200 SharedMemoryWithSize(base::SharedMemoryHandle shm_handle, size_t buffer_size)
202 : shm(shm_handle, false), buffer_size(buffer_size), zeroed(true) {} 201 : shm(shm_handle, false), buffer_size(buffer_size), zeroed(true) {}
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 if (use_in_process_zero_copy_software_draw_) { 244 if (use_in_process_zero_copy_software_draw_) {
246 DCHECK(sk_canvas_for_draw); 245 DCHECK(sk_canvas_for_draw);
247 output_surface_->DemandDrawSw(sk_canvas_for_draw); 246 output_surface_->DemandDrawSw(sk_canvas_for_draw);
248 } else { 247 } else {
249 DCHECK(!sk_canvas_for_draw); 248 DCHECK(!sk_canvas_for_draw);
250 DoDemandDrawSw(params); 249 DoDemandDrawSw(params);
251 } 250 }
252 } 251 }
253 if (inside_receive_) { 252 if (inside_receive_) {
254 // Did not swap. 253 // Did not swap.
255 cc::CompositorFrame empty_frame; 254 SendDemandDrawSwReply(false, cc::CompositorFrame(), reply_message);
256 SendDemandDrawSwReply(false, &empty_frame, reply_message);
257 inside_receive_ = false; 255 inside_receive_ = false;
258 } 256 }
259 } 257 }
260 258
261 void SynchronousCompositorProxy::DoDemandDrawSw( 259 void SynchronousCompositorProxy::DoDemandDrawSw(
262 const SyncCompositorDemandDrawSwParams& params) { 260 const SyncCompositorDemandDrawSwParams& params) {
263 DCHECK(output_surface_); 261 DCHECK(output_surface_);
264 DCHECK(software_draw_shm_->zeroed); 262 DCHECK(software_draw_shm_->zeroed);
265 software_draw_shm_->zeroed = false; 263 software_draw_shm_->zeroed = false;
266 264
267 SkImageInfo info = 265 SkImageInfo info =
268 SkImageInfo::MakeN32Premul(params.size.width(), params.size.height()); 266 SkImageInfo::MakeN32Premul(params.size.width(), params.size.height());
269 size_t stride = info.minRowBytes(); 267 size_t stride = info.minRowBytes();
270 size_t buffer_size = info.getSafeSize(stride); 268 size_t buffer_size = info.getSafeSize(stride);
271 DCHECK_EQ(software_draw_shm_->buffer_size, buffer_size); 269 DCHECK_EQ(software_draw_shm_->buffer_size, buffer_size);
272 270
273 SkBitmap bitmap; 271 SkBitmap bitmap;
274 if (!bitmap.installPixels(info, software_draw_shm_->shm.memory(), stride)) 272 if (!bitmap.installPixels(info, software_draw_shm_->shm.memory(), stride))
275 return; 273 return;
276 SkCanvas canvas(bitmap); 274 SkCanvas canvas(bitmap);
277 canvas.setMatrix(params.transform.matrix()); 275 canvas.setMatrix(params.transform.matrix());
278 canvas.setClipRegion(SkRegion(gfx::RectToSkIRect(params.clip))); 276 canvas.setClipRegion(SkRegion(gfx::RectToSkIRect(params.clip)));
279 277
280 output_surface_->DemandDrawSw(&canvas); 278 output_surface_->DemandDrawSw(&canvas);
281 } 279 }
282 280
283 void SynchronousCompositorProxy::SwapBuffersSw(cc::CompositorFrame* frame) { 281 void SynchronousCompositorProxy::SwapBuffersSw(cc::CompositorFrame frame) {
284 DCHECK(inside_receive_); 282 DCHECK(inside_receive_);
285 DCHECK(software_draw_reply_); 283 DCHECK(software_draw_reply_);
286 DCHECK(frame); 284 SendDemandDrawSwReply(true, std::move(frame), software_draw_reply_);
287 SendDemandDrawSwReply(true, frame, software_draw_reply_);
288 inside_receive_ = false; 285 inside_receive_ = false;
289 } 286 }
290 287
291 void SynchronousCompositorProxy::SendDemandDrawSwReply( 288 void SynchronousCompositorProxy::SendDemandDrawSwReply(
292 bool success, 289 bool success,
293 cc::CompositorFrame* frame, 290 cc::CompositorFrame frame,
294 IPC::Message* reply_message) { 291 IPC::Message* reply_message) {
295 SyncCompositorCommonRendererParams common_renderer_params; 292 SyncCompositorCommonRendererParams common_renderer_params;
296 PopulateCommonParams(&common_renderer_params); 293 PopulateCommonParams(&common_renderer_params);
297 SyncCompositorMsg_DemandDrawSw::WriteReplyParams( 294 SyncCompositorMsg_DemandDrawSw::WriteReplyParams(
298 reply_message, success, common_renderer_params, *frame); 295 reply_message, success, common_renderer_params, frame);
299 Send(reply_message); 296 Send(reply_message);
300 } 297 }
301 298
302 void SynchronousCompositorProxy::SwapBuffers(uint32_t output_surface_id, 299 void SynchronousCompositorProxy::SwapBuffers(uint32_t output_surface_id,
303 cc::CompositorFrame* frame) { 300 cc::CompositorFrame frame) {
304 DCHECK(hardware_draw_reply_ || software_draw_reply_); 301 DCHECK(hardware_draw_reply_ || software_draw_reply_);
305 DCHECK(!(hardware_draw_reply_ && software_draw_reply_)); 302 DCHECK(!(hardware_draw_reply_ && software_draw_reply_));
306 if (hardware_draw_reply_) { 303 if (hardware_draw_reply_) {
307 SwapBuffersHw(output_surface_id, frame); 304 SwapBuffersHw(output_surface_id, std::move(frame));
308 } else if (software_draw_reply_) { 305 } else if (software_draw_reply_) {
309 SwapBuffersSw(frame); 306 SwapBuffersSw(std::move(frame));
310 } 307 }
311 } 308 }
312 309
313 void SynchronousCompositorProxy::OnComputeScroll( 310 void SynchronousCompositorProxy::OnComputeScroll(
314 base::TimeTicks animation_time) { 311 base::TimeTicks animation_time) {
315 if (need_animate_scroll_) { 312 if (need_animate_scroll_) {
316 need_animate_scroll_ = false; 313 need_animate_scroll_ = false;
317 input_handler_proxy_->SynchronouslyAnimate(animation_time); 314 input_handler_proxy_->SynchronouslyAnimate(animation_time);
318 } 315 }
319 } 316 }
(...skipping 10 matching lines...) Expand all
330 327
331 void SynchronousCompositorProxy::SetScroll( 328 void SynchronousCompositorProxy::SetScroll(
332 const gfx::ScrollOffset& new_total_scroll_offset) { 329 const gfx::ScrollOffset& new_total_scroll_offset) {
333 if (total_scroll_offset_ == new_total_scroll_offset) 330 if (total_scroll_offset_ == new_total_scroll_offset)
334 return; 331 return;
335 total_scroll_offset_ = new_total_scroll_offset; 332 total_scroll_offset_ = new_total_scroll_offset;
336 input_handler_proxy_->SynchronouslySetRootScrollOffset(total_scroll_offset_); 333 input_handler_proxy_->SynchronouslySetRootScrollOffset(total_scroll_offset_);
337 } 334 }
338 335
339 } // namespace content 336 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/android/synchronous_compositor_proxy.h ('k') | content/renderer/gpu/compositor_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698