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(SyncCompositorMsg_DemandDrawHwAsync, DemandDrawHwAsync) | |
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::DemandDrawHwAsync( | |
154 const SyncCompositorDemandDrawHwParams& params) { | |
155 DoDemandDrawHw(params, nullptr, true); | |
156 } | |
157 | |
151 void SynchronousCompositorProxy::DemandDrawHw( | 158 void SynchronousCompositorProxy::DemandDrawHw( |
152 const SyncCompositorDemandDrawHwParams& params, | 159 const SyncCompositorDemandDrawHwParams& params, |
153 IPC::Message* reply_message) { | 160 IPC::Message* reply_message) { |
161 DCHECK(reply_message); | |
162 DoDemandDrawHw(params, reply_message, false); | |
163 } | |
164 | |
165 void SynchronousCompositorProxy::DoDemandDrawHw( | |
166 const SyncCompositorDemandDrawHwParams& params, | |
167 IPC::Message* reply_message, | |
168 bool async) { | |
boliu
2016/08/23 22:08:02
you don't need this param, it's exactly equivalent
ojars
2016/08/29 21:54:45
Done.
| |
154 DCHECK(!inside_receive_); | 169 DCHECK(!inside_receive_); |
155 DCHECK(reply_message); | |
156 | |
157 inside_receive_ = true; | 170 inside_receive_ = true; |
158 | 171 |
159 if (output_surface_) { | 172 if (output_surface_) { |
160 base::AutoReset<IPC::Message*> scoped_hardware_draw_reply( | 173 if (async) { |
161 &hardware_draw_reply_, reply_message); | 174 base::AutoReset<bool> scoped_hardware_draw_reply_async( |
162 output_surface_->DemandDrawHw(params.viewport_size, | 175 &hardware_draw_reply_async_, true); |
163 params.viewport_rect_for_tile_priority, | 176 output_surface_->DemandDrawHw(params.viewport_size, |
164 params.transform_for_tile_priority); | 177 params.viewport_rect_for_tile_priority, |
178 params.transform_for_tile_priority); | |
179 } else { | |
180 base::AutoReset<IPC::Message*> scoped_hardware_draw_reply( | |
181 &hardware_draw_reply_, reply_message); | |
182 output_surface_->DemandDrawHw(params.viewport_size, | |
183 params.viewport_rect_for_tile_priority, | |
184 params.transform_for_tile_priority); | |
185 } | |
165 } | 186 } |
166 | 187 |
167 if (inside_receive_) { | 188 if (inside_receive_) { |
168 // Did not swap. | 189 // Did not swap. |
169 SendDemandDrawHwReply(cc::CompositorFrame(), 0u, reply_message); | 190 if (async) { |
191 SendDemandDrawHwReplyAsync(cc::CompositorFrame(), 0u); | |
192 } else { | |
193 SendDemandDrawHwReply(cc::CompositorFrame(), 0u, reply_message); | |
194 } | |
170 inside_receive_ = false; | 195 inside_receive_ = false; |
171 } | 196 } |
172 } | 197 } |
173 | 198 |
199 void SynchronousCompositorProxy::SwapBuffersHwAsync(uint32_t output_surface_id, | |
200 cc::CompositorFrame frame) { | |
201 DCHECK(inside_receive_); | |
202 DCHECK(hardware_draw_reply_async_); | |
203 SendDemandDrawHwReplyAsync(std::move(frame), output_surface_id); | |
204 inside_receive_ = false; | |
205 } | |
206 | |
174 void SynchronousCompositorProxy::SwapBuffersHw(uint32_t output_surface_id, | 207 void SynchronousCompositorProxy::SwapBuffersHw(uint32_t output_surface_id, |
175 cc::CompositorFrame frame) { | 208 cc::CompositorFrame frame) { |
176 DCHECK(inside_receive_); | 209 DCHECK(inside_receive_); |
177 DCHECK(hardware_draw_reply_); | 210 DCHECK(hardware_draw_reply_); |
178 SendDemandDrawHwReply(std::move(frame), output_surface_id, | 211 SendDemandDrawHwReply(std::move(frame), output_surface_id, |
179 hardware_draw_reply_); | 212 hardware_draw_reply_); |
180 inside_receive_ = false; | 213 inside_receive_ = false; |
181 } | 214 } |
182 | 215 |
216 void SynchronousCompositorProxy::SendDemandDrawHwReplyAsync( | |
217 cc::CompositorFrame frame, | |
218 uint32_t output_surface_id) { | |
219 Send(new SyncCompositorHostMsg_ReturnFrame(routing_id_, output_surface_id, | |
220 frame)); | |
221 } | |
222 | |
183 void SynchronousCompositorProxy::SendDemandDrawHwReply( | 223 void SynchronousCompositorProxy::SendDemandDrawHwReply( |
184 cc::CompositorFrame frame, | 224 cc::CompositorFrame frame, |
185 uint32_t output_surface_id, | 225 uint32_t output_surface_id, |
186 IPC::Message* reply_message) { | 226 IPC::Message* reply_message) { |
187 SyncCompositorCommonRendererParams common_renderer_params; | 227 SyncCompositorCommonRendererParams common_renderer_params; |
188 PopulateCommonParams(&common_renderer_params); | 228 PopulateCommonParams(&common_renderer_params); |
189 SyncCompositorMsg_DemandDrawHw::WriteReplyParams( | 229 SyncCompositorMsg_DemandDrawHw::WriteReplyParams( |
190 reply_message, common_renderer_params, output_surface_id, frame); | 230 reply_message, common_renderer_params, output_surface_id, frame); |
191 Send(reply_message); | 231 Send(reply_message); |
192 } | 232 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 IPC::Message* reply_message) { | 330 IPC::Message* reply_message) { |
291 SyncCompositorCommonRendererParams common_renderer_params; | 331 SyncCompositorCommonRendererParams common_renderer_params; |
292 PopulateCommonParams(&common_renderer_params); | 332 PopulateCommonParams(&common_renderer_params); |
293 SyncCompositorMsg_DemandDrawSw::WriteReplyParams( | 333 SyncCompositorMsg_DemandDrawSw::WriteReplyParams( |
294 reply_message, success, common_renderer_params, frame); | 334 reply_message, success, common_renderer_params, frame); |
295 Send(reply_message); | 335 Send(reply_message); |
296 } | 336 } |
297 | 337 |
298 void SynchronousCompositorProxy::SwapBuffers(uint32_t output_surface_id, | 338 void SynchronousCompositorProxy::SwapBuffers(uint32_t output_surface_id, |
299 cc::CompositorFrame frame) { | 339 cc::CompositorFrame frame) { |
300 DCHECK(hardware_draw_reply_ || software_draw_reply_); | 340 // Verify that exactly one of these is true. |
301 DCHECK(!(hardware_draw_reply_ && software_draw_reply_)); | 341 DCHECK(hardware_draw_reply_async_ || hardware_draw_reply_ || |
302 if (hardware_draw_reply_) { | 342 software_draw_reply_); |
343 DCHECK(!((hardware_draw_reply_ && software_draw_reply_) || | |
344 (hardware_draw_reply_ && hardware_draw_reply_async_) || | |
345 (software_draw_reply_ && hardware_draw_reply_async_))); | |
346 if (hardware_draw_reply_async_) { | |
347 SwapBuffersHwAsync(output_surface_id, std::move(frame)); | |
348 } else if (hardware_draw_reply_) { | |
303 SwapBuffersHw(output_surface_id, std::move(frame)); | 349 SwapBuffersHw(output_surface_id, std::move(frame)); |
304 } else if (software_draw_reply_) { | 350 } else if (software_draw_reply_) { |
305 SwapBuffersSw(std::move(frame)); | 351 SwapBuffersSw(std::move(frame)); |
306 } | 352 } |
307 } | 353 } |
308 | 354 |
309 void SynchronousCompositorProxy::OnComputeScroll( | 355 void SynchronousCompositorProxy::OnComputeScroll( |
310 base::TimeTicks animation_time) { | 356 base::TimeTicks animation_time) { |
311 if (need_animate_scroll_) { | 357 if (need_animate_scroll_) { |
312 need_animate_scroll_ = false; | 358 need_animate_scroll_ = false; |
(...skipping 13 matching lines...) Expand all Loading... | |
326 | 372 |
327 void SynchronousCompositorProxy::SetScroll( | 373 void SynchronousCompositorProxy::SetScroll( |
328 const gfx::ScrollOffset& new_total_scroll_offset) { | 374 const gfx::ScrollOffset& new_total_scroll_offset) { |
329 if (total_scroll_offset_ == new_total_scroll_offset) | 375 if (total_scroll_offset_ == new_total_scroll_offset) |
330 return; | 376 return; |
331 total_scroll_offset_ = new_total_scroll_offset; | 377 total_scroll_offset_ = new_total_scroll_offset; |
332 input_handler_proxy_->SynchronouslySetRootScrollOffset(total_scroll_offset_); | 378 input_handler_proxy_->SynchronouslySetRootScrollOffset(total_scroll_offset_); |
333 } | 379 } |
334 | 380 |
335 } // namespace content | 381 } // namespace content |
OLD | NEW |