Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 : routing_id_(routing_id), | 28 : routing_id_(routing_id), |
| 29 sender_(sender), | 29 sender_(sender), |
| 30 input_handler_proxy_(input_handler_proxy), | 30 input_handler_proxy_(input_handler_proxy), |
| 31 use_in_process_zero_copy_software_draw_( | 31 use_in_process_zero_copy_software_draw_( |
| 32 base::CommandLine::ForCurrentProcess()->HasSwitch( | 32 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 33 switches::kSingleProcess)), | 33 switches::kSingleProcess)), |
| 34 output_surface_(nullptr), | 34 output_surface_(nullptr), |
| 35 inside_receive_(false), | 35 inside_receive_(false), |
| 36 hardware_draw_reply_(nullptr), | 36 hardware_draw_reply_(nullptr), |
| 37 software_draw_reply_(nullptr), | 37 software_draw_reply_(nullptr), |
| 38 hardware_draw_reply_async_(false), | |
| 38 version_(0u), | 39 version_(0u), |
| 39 page_scale_factor_(0.f), | 40 page_scale_factor_(0.f), |
| 40 min_page_scale_factor_(0.f), | 41 min_page_scale_factor_(0.f), |
| 41 max_page_scale_factor_(0.f), | 42 max_page_scale_factor_(0.f), |
| 42 need_animate_scroll_(false), | 43 need_animate_scroll_(false), |
| 43 need_invalidate_count_(0u), | 44 need_invalidate_count_(0u), |
| 44 did_activate_pending_tree_count_(0u) { | 45 did_activate_pending_tree_count_(0u) { |
| 45 DCHECK(input_handler_proxy_); | 46 DCHECK(input_handler_proxy_); |
| 46 input_handler_proxy_->SetOnlySynchronouslyAnimateRootFlings(this); | 47 input_handler_proxy_->SetOnlySynchronouslyAnimateRootFlings(this); |
| 47 } | 48 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 | 129 |
| 129 void SynchronousCompositorProxy::OnMessageReceived( | 130 void SynchronousCompositorProxy::OnMessageReceived( |
| 130 const IPC::Message& message) { | 131 const IPC::Message& message) { |
| 131 if (output_surface_ && output_surface_->OnMessageReceived(message)) | 132 if (output_surface_ && output_surface_->OnMessageReceived(message)) |
| 132 return; | 133 return; |
| 133 | 134 |
| 134 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorProxy, message) | 135 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorProxy, message) |
| 135 IPC_MESSAGE_HANDLER(SyncCompositorMsg_ComputeScroll, OnComputeScroll) | 136 IPC_MESSAGE_HANDLER(SyncCompositorMsg_ComputeScroll, OnComputeScroll) |
| 136 IPC_MESSAGE_HANDLER_DELAY_REPLY(SyncCompositorMsg_DemandDrawHw, | 137 IPC_MESSAGE_HANDLER_DELAY_REPLY(SyncCompositorMsg_DemandDrawHw, |
| 137 DemandDrawHw) | 138 DemandDrawHw) |
| 139 IPC_MESSAGE_HANDLER(CompositorMsg_DemandDrawHw, DemandDrawHw_Async) | |
| 138 IPC_MESSAGE_HANDLER(SyncCompositorMsg_SetSharedMemory, SetSharedMemory) | 140 IPC_MESSAGE_HANDLER(SyncCompositorMsg_SetSharedMemory, SetSharedMemory) |
| 139 IPC_MESSAGE_HANDLER(SyncCompositorMsg_ZeroSharedMemory, ZeroSharedMemory) | 141 IPC_MESSAGE_HANDLER(SyncCompositorMsg_ZeroSharedMemory, ZeroSharedMemory) |
| 140 IPC_MESSAGE_HANDLER_DELAY_REPLY(SyncCompositorMsg_DemandDrawSw, | 142 IPC_MESSAGE_HANDLER_DELAY_REPLY(SyncCompositorMsg_DemandDrawSw, |
| 141 DemandDrawSw) | 143 DemandDrawSw) |
| 142 IPC_MESSAGE_HANDLER(SyncCompositorMsg_ZoomBy, SynchronouslyZoomBy) | 144 IPC_MESSAGE_HANDLER(SyncCompositorMsg_ZoomBy, SynchronouslyZoomBy) |
| 143 IPC_MESSAGE_HANDLER(SyncCompositorMsg_SetScroll, SetScroll) | 145 IPC_MESSAGE_HANDLER(SyncCompositorMsg_SetScroll, SetScroll) |
| 144 IPC_END_MESSAGE_MAP() | 146 IPC_END_MESSAGE_MAP() |
| 145 } | 147 } |
| 146 | 148 |
| 147 bool SynchronousCompositorProxy::Send(IPC::Message* message) { | 149 bool SynchronousCompositorProxy::Send(IPC::Message* message) { |
| 148 return sender_->Send(message); | 150 return sender_->Send(message); |
| 149 } | 151 } |
| 150 | 152 |
| 153 void SynchronousCompositorProxy::DemandDrawHw_Async( | |
|
boliu
2016/08/11 19:23:40
this is mostly identical to DemandDrawHw so should
ojars
2016/08/23 02:15:42
Done.
| |
| 154 const SyncCompositorDemandDrawHwParams& params) { | |
| 155 // const SyncCompositorDemandDrawHwParams& params, | |
| 156 // IPC::Message* reply_message) { | |
| 157 DCHECK(!inside_receive_); | |
| 158 inside_receive_ = true; | |
| 159 | |
| 160 // SyncCompositorCommonRendererParams common_renderer_params; | |
| 161 // PopulateCommonParams(&common_renderer_params); | |
| 162 // CompositorMsg_DemandDrawHw::WriteReplyParams( | |
| 163 // reply_message, common_renderer_params); | |
| 164 // Send(reply_message); | |
| 165 | |
| 166 if (output_surface_) { | |
| 167 base::AutoReset<bool> scoped_hardware_draw_reply_async( | |
| 168 &hardware_draw_reply_async_, true); | |
| 169 output_surface_->DemandDrawHw(params.viewport_size, | |
| 170 params.viewport_rect_for_tile_priority, | |
| 171 params.transform_for_tile_priority); | |
| 172 } | |
| 173 | |
| 174 if (inside_receive_) { | |
| 175 // Did not swap. | |
| 176 SendDemandDrawHwReply_Async(cc::CompositorFrame(), 0u); | |
| 177 inside_receive_ = false; | |
| 178 } | |
| 179 } | |
| 180 | |
| 151 void SynchronousCompositorProxy::DemandDrawHw( | 181 void SynchronousCompositorProxy::DemandDrawHw( |
| 152 const SyncCompositorDemandDrawHwParams& params, | 182 const SyncCompositorDemandDrawHwParams& params, |
| 153 IPC::Message* reply_message) { | 183 IPC::Message* reply_message) { |
| 154 DCHECK(!inside_receive_); | 184 DCHECK(!inside_receive_); |
| 155 DCHECK(reply_message); | 185 DCHECK(reply_message); |
| 156 | 186 |
| 157 inside_receive_ = true; | 187 inside_receive_ = true; |
| 158 | 188 |
| 159 if (output_surface_) { | 189 if (output_surface_) { |
| 160 base::AutoReset<IPC::Message*> scoped_hardware_draw_reply( | 190 base::AutoReset<IPC::Message*> scoped_hardware_draw_reply( |
| 161 &hardware_draw_reply_, reply_message); | 191 &hardware_draw_reply_, reply_message); |
| 162 output_surface_->DemandDrawHw(params.viewport_size, | 192 output_surface_->DemandDrawHw(params.viewport_size, |
| 163 params.viewport_rect_for_tile_priority, | 193 params.viewport_rect_for_tile_priority, |
| 164 params.transform_for_tile_priority); | 194 params.transform_for_tile_priority); |
| 165 } | 195 } |
| 166 | 196 |
| 167 if (inside_receive_) { | 197 if (inside_receive_) { |
| 168 // Did not swap. | 198 // Did not swap. |
| 169 SendDemandDrawHwReply(cc::CompositorFrame(), 0u, reply_message); | 199 SendDemandDrawHwReply(cc::CompositorFrame(), 0u, reply_message); |
| 170 inside_receive_ = false; | 200 inside_receive_ = false; |
| 171 } | 201 } |
| 172 } | 202 } |
| 173 | 203 |
| 204 void SynchronousCompositorProxy::SwapBuffersHw_Async( | |
| 205 uint32_t output_surface_id, | |
| 206 cc::CompositorFrame frame) { | |
| 207 DCHECK(inside_receive_); | |
| 208 DCHECK(hardware_draw_reply_async_); | |
| 209 SendDemandDrawHwReply_Async(std::move(frame), output_surface_id); | |
| 210 inside_receive_ = false; | |
| 211 } | |
| 212 | |
| 174 void SynchronousCompositorProxy::SwapBuffersHw(uint32_t output_surface_id, | 213 void SynchronousCompositorProxy::SwapBuffersHw(uint32_t output_surface_id, |
| 175 cc::CompositorFrame frame) { | 214 cc::CompositorFrame frame) { |
| 176 DCHECK(inside_receive_); | 215 DCHECK(inside_receive_); |
| 177 DCHECK(hardware_draw_reply_); | 216 DCHECK(hardware_draw_reply_); |
| 178 SendDemandDrawHwReply(std::move(frame), output_surface_id, | 217 SendDemandDrawHwReply(std::move(frame), output_surface_id, |
| 179 hardware_draw_reply_); | 218 hardware_draw_reply_); |
| 180 inside_receive_ = false; | 219 inside_receive_ = false; |
| 181 } | 220 } |
| 182 | 221 |
| 222 void SynchronousCompositorProxy::SendDemandDrawHwReply_Async( | |
| 223 cc::CompositorFrame frame, | |
| 224 uint32_t output_surface_id) { | |
| 225 Send(new CompositorHostMsg_Frame(routing_id_, output_surface_id, frame)); | |
| 226 } | |
| 227 | |
| 183 void SynchronousCompositorProxy::SendDemandDrawHwReply( | 228 void SynchronousCompositorProxy::SendDemandDrawHwReply( |
| 184 cc::CompositorFrame frame, | 229 cc::CompositorFrame frame, |
| 185 uint32_t output_surface_id, | 230 uint32_t output_surface_id, |
| 186 IPC::Message* reply_message) { | 231 IPC::Message* reply_message) { |
| 187 SyncCompositorCommonRendererParams common_renderer_params; | 232 SyncCompositorCommonRendererParams common_renderer_params; |
| 188 PopulateCommonParams(&common_renderer_params); | 233 PopulateCommonParams(&common_renderer_params); |
| 189 SyncCompositorMsg_DemandDrawHw::WriteReplyParams( | 234 SyncCompositorMsg_DemandDrawHw::WriteReplyParams( |
| 190 reply_message, common_renderer_params, output_surface_id, frame); | 235 reply_message, common_renderer_params, output_surface_id, frame); |
| 191 Send(reply_message); | 236 Send(reply_message); |
| 192 } | 237 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 IPC::Message* reply_message) { | 335 IPC::Message* reply_message) { |
| 291 SyncCompositorCommonRendererParams common_renderer_params; | 336 SyncCompositorCommonRendererParams common_renderer_params; |
| 292 PopulateCommonParams(&common_renderer_params); | 337 PopulateCommonParams(&common_renderer_params); |
| 293 SyncCompositorMsg_DemandDrawSw::WriteReplyParams( | 338 SyncCompositorMsg_DemandDrawSw::WriteReplyParams( |
| 294 reply_message, success, common_renderer_params, frame); | 339 reply_message, success, common_renderer_params, frame); |
| 295 Send(reply_message); | 340 Send(reply_message); |
| 296 } | 341 } |
| 297 | 342 |
| 298 void SynchronousCompositorProxy::SwapBuffers(uint32_t output_surface_id, | 343 void SynchronousCompositorProxy::SwapBuffers(uint32_t output_surface_id, |
| 299 cc::CompositorFrame frame) { | 344 cc::CompositorFrame frame) { |
| 300 DCHECK(hardware_draw_reply_ || software_draw_reply_); | 345 DCHECK(hardware_draw_reply_async_ || hardware_draw_reply_ || |
| 301 DCHECK(!(hardware_draw_reply_ && software_draw_reply_)); | 346 software_draw_reply_); |
| 302 if (hardware_draw_reply_) { | 347 DCHECK(!((hardware_draw_reply_ || hardware_draw_reply_async_) && |
| 348 software_draw_reply_)); | |
|
boliu
2016/08/11 19:23:40
the DCHECKs were for exactly one of these things b
ojars
2016/08/23 02:15:42
Done.
| |
| 349 if (hardware_draw_reply_async_) { | |
| 350 SwapBuffersHw_Async(output_surface_id, std::move(frame)); | |
| 351 } else if (hardware_draw_reply_) { | |
| 303 SwapBuffersHw(output_surface_id, std::move(frame)); | 352 SwapBuffersHw(output_surface_id, std::move(frame)); |
| 304 } else if (software_draw_reply_) { | 353 } else if (software_draw_reply_) { |
| 305 SwapBuffersSw(std::move(frame)); | 354 SwapBuffersSw(std::move(frame)); |
| 306 } | 355 } |
| 307 } | 356 } |
| 308 | 357 |
| 309 void SynchronousCompositorProxy::OnComputeScroll( | 358 void SynchronousCompositorProxy::OnComputeScroll( |
| 310 base::TimeTicks animation_time) { | 359 base::TimeTicks animation_time) { |
| 311 if (need_animate_scroll_) { | 360 if (need_animate_scroll_) { |
| 312 need_animate_scroll_ = false; | 361 need_animate_scroll_ = false; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 326 | 375 |
| 327 void SynchronousCompositorProxy::SetScroll( | 376 void SynchronousCompositorProxy::SetScroll( |
| 328 const gfx::ScrollOffset& new_total_scroll_offset) { | 377 const gfx::ScrollOffset& new_total_scroll_offset) { |
| 329 if (total_scroll_offset_ == new_total_scroll_offset) | 378 if (total_scroll_offset_ == new_total_scroll_offset) |
| 330 return; | 379 return; |
| 331 total_scroll_offset_ = new_total_scroll_offset; | 380 total_scroll_offset_ = new_total_scroll_offset; |
| 332 input_handler_proxy_->SynchronouslySetRootScrollOffset(total_scroll_offset_); | 381 input_handler_proxy_->SynchronouslySetRootScrollOffset(total_scroll_offset_); |
| 333 } | 382 } |
| 334 | 383 |
| 335 } // namespace content | 384 } // namespace content |
| OLD | NEW |