| OLD | NEW |
| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // Did not swap. | 189 // Did not swap. |
| 190 if (!reply_message) { | 190 if (!reply_message) { |
| 191 SendDemandDrawHwReplyAsync(cc::CompositorFrame(), 0u); | 191 SendDemandDrawHwReplyAsync(cc::CompositorFrame(), 0u); |
| 192 } else { | 192 } else { |
| 193 SendDemandDrawHwReply(cc::CompositorFrame(), 0u, reply_message); | 193 SendDemandDrawHwReply(cc::CompositorFrame(), 0u, reply_message); |
| 194 } | 194 } |
| 195 inside_receive_ = false; | 195 inside_receive_ = false; |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 void SynchronousCompositorProxy::SwapBuffersHwAsync( | 199 void SynchronousCompositorProxy::SubmitCompositorFrameHwAsync( |
| 200 uint32_t compositor_frame_sink_id, | 200 uint32_t compositor_frame_sink_id, |
| 201 cc::CompositorFrame frame) { | 201 cc::CompositorFrame frame) { |
| 202 DCHECK(inside_receive_); | 202 DCHECK(inside_receive_); |
| 203 DCHECK(hardware_draw_reply_async_); | 203 DCHECK(hardware_draw_reply_async_); |
| 204 SendDemandDrawHwReplyAsync(std::move(frame), compositor_frame_sink_id); | 204 SendDemandDrawHwReplyAsync(std::move(frame), compositor_frame_sink_id); |
| 205 inside_receive_ = false; | 205 inside_receive_ = false; |
| 206 } | 206 } |
| 207 | 207 |
| 208 void SynchronousCompositorProxy::SwapBuffersHw( | 208 void SynchronousCompositorProxy::SubmitCompositorFrameHw( |
| 209 uint32_t compositor_frame_sink_id, | 209 uint32_t compositor_frame_sink_id, |
| 210 cc::CompositorFrame frame) { | 210 cc::CompositorFrame frame) { |
| 211 DCHECK(inside_receive_); | 211 DCHECK(inside_receive_); |
| 212 DCHECK(hardware_draw_reply_); | 212 DCHECK(hardware_draw_reply_); |
| 213 SendDemandDrawHwReply(std::move(frame), compositor_frame_sink_id, | 213 SendDemandDrawHwReply(std::move(frame), compositor_frame_sink_id, |
| 214 hardware_draw_reply_); | 214 hardware_draw_reply_); |
| 215 inside_receive_ = false; | 215 inside_receive_ = false; |
| 216 } | 216 } |
| 217 | 217 |
| 218 void SynchronousCompositorProxy::SendDemandDrawHwReplyAsync( | 218 void SynchronousCompositorProxy::SendDemandDrawHwReplyAsync( |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 SkBitmap bitmap; | 312 SkBitmap bitmap; |
| 313 if (!bitmap.installPixels(info, software_draw_shm_->shm.memory(), stride)) | 313 if (!bitmap.installPixels(info, software_draw_shm_->shm.memory(), stride)) |
| 314 return; | 314 return; |
| 315 SkCanvas canvas(bitmap); | 315 SkCanvas canvas(bitmap); |
| 316 canvas.concat(params.transform.matrix()); | 316 canvas.concat(params.transform.matrix()); |
| 317 canvas.clipRect(gfx::RectToSkRect(params.clip)); | 317 canvas.clipRect(gfx::RectToSkRect(params.clip)); |
| 318 | 318 |
| 319 compositor_frame_sink_->DemandDrawSw(&canvas); | 319 compositor_frame_sink_->DemandDrawSw(&canvas); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void SynchronousCompositorProxy::SwapBuffersSw(cc::CompositorFrame frame) { | 322 void SynchronousCompositorProxy::SubmitCompositorFrameSw( |
| 323 cc::CompositorFrame frame) { |
| 323 DCHECK(inside_receive_); | 324 DCHECK(inside_receive_); |
| 324 DCHECK(software_draw_reply_); | 325 DCHECK(software_draw_reply_); |
| 325 SendDemandDrawSwReply(true, std::move(frame), software_draw_reply_); | 326 SendDemandDrawSwReply(true, std::move(frame), software_draw_reply_); |
| 326 inside_receive_ = false; | 327 inside_receive_ = false; |
| 327 } | 328 } |
| 328 | 329 |
| 329 void SynchronousCompositorProxy::SendDemandDrawSwReply( | 330 void SynchronousCompositorProxy::SendDemandDrawSwReply( |
| 330 bool success, | 331 bool success, |
| 331 cc::CompositorFrame frame, | 332 cc::CompositorFrame frame, |
| 332 IPC::Message* reply_message) { | 333 IPC::Message* reply_message) { |
| 333 SyncCompositorCommonRendererParams common_renderer_params; | 334 SyncCompositorCommonRendererParams common_renderer_params; |
| 334 PopulateCommonParams(&common_renderer_params); | 335 PopulateCommonParams(&common_renderer_params); |
| 335 SyncCompositorMsg_DemandDrawSw::WriteReplyParams( | 336 SyncCompositorMsg_DemandDrawSw::WriteReplyParams( |
| 336 reply_message, success, common_renderer_params, frame); | 337 reply_message, success, common_renderer_params, frame); |
| 337 Send(reply_message); | 338 Send(reply_message); |
| 338 } | 339 } |
| 339 | 340 |
| 340 void SynchronousCompositorProxy::SwapBuffers(uint32_t compositor_frame_sink_id, | 341 void SynchronousCompositorProxy::SubmitCompositorFrame( |
| 341 cc::CompositorFrame frame) { | 342 uint32_t compositor_frame_sink_id, |
| 343 cc::CompositorFrame frame) { |
| 342 // Verify that exactly one of these is true. | 344 // Verify that exactly one of these is true. |
| 343 DCHECK(hardware_draw_reply_async_ || hardware_draw_reply_ || | 345 DCHECK(hardware_draw_reply_async_ || hardware_draw_reply_ || |
| 344 software_draw_reply_); | 346 software_draw_reply_); |
| 345 DCHECK(!((hardware_draw_reply_ && software_draw_reply_) || | 347 DCHECK(!((hardware_draw_reply_ && software_draw_reply_) || |
| 346 (hardware_draw_reply_ && hardware_draw_reply_async_) || | 348 (hardware_draw_reply_ && hardware_draw_reply_async_) || |
| 347 (software_draw_reply_ && hardware_draw_reply_async_))); | 349 (software_draw_reply_ && hardware_draw_reply_async_))); |
| 348 if (hardware_draw_reply_async_) { | 350 if (hardware_draw_reply_async_) { |
| 349 SwapBuffersHwAsync(compositor_frame_sink_id, std::move(frame)); | 351 SubmitCompositorFrameHwAsync(compositor_frame_sink_id, std::move(frame)); |
| 350 } else if (hardware_draw_reply_) { | 352 } else if (hardware_draw_reply_) { |
| 351 SwapBuffersHw(compositor_frame_sink_id, std::move(frame)); | 353 SubmitCompositorFrameHw(compositor_frame_sink_id, std::move(frame)); |
| 352 } else if (software_draw_reply_) { | 354 } else if (software_draw_reply_) { |
| 353 SwapBuffersSw(std::move(frame)); | 355 SubmitCompositorFrameSw(std::move(frame)); |
| 354 } | 356 } |
| 355 } | 357 } |
| 356 | 358 |
| 357 void SynchronousCompositorProxy::OnComputeScroll( | 359 void SynchronousCompositorProxy::OnComputeScroll( |
| 358 base::TimeTicks animation_time) { | 360 base::TimeTicks animation_time) { |
| 359 if (need_animate_scroll_) { | 361 if (need_animate_scroll_) { |
| 360 need_animate_scroll_ = false; | 362 need_animate_scroll_ = false; |
| 361 input_handler_proxy_->SynchronouslyAnimate(animation_time); | 363 input_handler_proxy_->SynchronouslyAnimate(animation_time); |
| 362 } | 364 } |
| 363 } | 365 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 374 | 376 |
| 375 void SynchronousCompositorProxy::SetScroll( | 377 void SynchronousCompositorProxy::SetScroll( |
| 376 const gfx::ScrollOffset& new_total_scroll_offset) { | 378 const gfx::ScrollOffset& new_total_scroll_offset) { |
| 377 if (total_scroll_offset_ == new_total_scroll_offset) | 379 if (total_scroll_offset_ == new_total_scroll_offset) |
| 378 return; | 380 return; |
| 379 total_scroll_offset_ = new_total_scroll_offset; | 381 total_scroll_offset_ = new_total_scroll_offset; |
| 380 input_handler_proxy_->SynchronouslySetRootScrollOffset(total_scroll_offset_); | 382 input_handler_proxy_->SynchronouslySetRootScrollOffset(total_scroll_offset_); |
| 381 } | 383 } |
| 382 | 384 |
| 383 } // namespace content | 385 } // namespace content |
| OLD | NEW |