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/browser/android/synchronous_compositor_host.h" | 5 #include "content/browser/android/synchronous_compositor_host.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/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 client_->DidInitializeCompositor(this, process_id_, routing_id_); | 81 client_->DidInitializeCompositor(this, process_id_, routing_id_); |
82 } | 82 } |
83 | 83 |
84 SynchronousCompositorHost::~SynchronousCompositorHost() { | 84 SynchronousCompositorHost::~SynchronousCompositorHost() { |
85 client_->DidDestroyCompositor(this, process_id_, routing_id_); | 85 client_->DidDestroyCompositor(this, process_id_, routing_id_); |
86 } | 86 } |
87 | 87 |
88 bool SynchronousCompositorHost::OnMessageReceived(const IPC::Message& message) { | 88 bool SynchronousCompositorHost::OnMessageReceived(const IPC::Message& message) { |
89 bool handled = true; | 89 bool handled = true; |
90 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorHost, message) | 90 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorHost, message) |
91 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_OutputSurfaceCreated, | 91 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_CompositorFrameSinkCreated, |
92 OutputSurfaceCreated) | 92 CompositorFrameSinkCreated) |
93 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_UpdateState, ProcessCommonParams) | 93 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_UpdateState, ProcessCommonParams) |
94 IPC_MESSAGE_HANDLER_GENERIC(SyncCompositorHostMsg_ReturnFrame, | 94 IPC_MESSAGE_HANDLER_GENERIC(SyncCompositorHostMsg_ReturnFrame, |
95 DemandDrawHwReceiveFrame(message)) | 95 DemandDrawHwReceiveFrame(message)) |
96 IPC_MESSAGE_UNHANDLED(handled = false) | 96 IPC_MESSAGE_UNHANDLED(handled = false) |
97 IPC_END_MESSAGE_MAP() | 97 IPC_END_MESSAGE_MAP() |
98 return handled; | 98 return handled; |
99 } | 99 } |
100 | 100 |
101 void SynchronousCompositorHost::DemandDrawHwAsync( | 101 void SynchronousCompositorHost::DemandDrawHwAsync( |
102 const gfx::Size& viewport_size, | 102 const gfx::Size& viewport_size, |
103 const gfx::Rect& viewport_rect_for_tile_priority, | 103 const gfx::Rect& viewport_rect_for_tile_priority, |
104 const gfx::Transform& transform_for_tile_priority) { | 104 const gfx::Transform& transform_for_tile_priority) { |
105 SyncCompositorDemandDrawHwParams params(viewport_size, | 105 SyncCompositorDemandDrawHwParams params(viewport_size, |
106 viewport_rect_for_tile_priority, | 106 viewport_rect_for_tile_priority, |
107 transform_for_tile_priority); | 107 transform_for_tile_priority); |
108 sender_->Send(new SyncCompositorMsg_DemandDrawHwAsync(routing_id_, params)); | 108 sender_->Send(new SyncCompositorMsg_DemandDrawHwAsync(routing_id_, params)); |
109 } | 109 } |
110 | 110 |
111 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHw( | 111 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHw( |
112 const gfx::Size& viewport_size, | 112 const gfx::Size& viewport_size, |
113 const gfx::Rect& viewport_rect_for_tile_priority, | 113 const gfx::Rect& viewport_rect_for_tile_priority, |
114 const gfx::Transform& transform_for_tile_priority) { | 114 const gfx::Transform& transform_for_tile_priority) { |
115 SyncCompositorDemandDrawHwParams params(viewport_size, | 115 SyncCompositorDemandDrawHwParams params(viewport_size, |
116 viewport_rect_for_tile_priority, | 116 viewport_rect_for_tile_priority, |
117 transform_for_tile_priority); | 117 transform_for_tile_priority); |
118 uint32_t output_surface_id; | 118 uint32_t compositor_frame_sink_id; |
119 cc::CompositorFrame compositor_frame; | 119 cc::CompositorFrame compositor_frame; |
120 SyncCompositorCommonRendererParams common_renderer_params; | 120 SyncCompositorCommonRendererParams common_renderer_params; |
121 | 121 |
122 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( | 122 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( |
123 routing_id_, params, &common_renderer_params, &output_surface_id, | 123 routing_id_, params, &common_renderer_params, |
124 &compositor_frame))) { | 124 &compositor_frame_sink_id, &compositor_frame))) { |
125 return SynchronousCompositor::Frame(); | 125 return SynchronousCompositor::Frame(); |
126 } | 126 } |
127 | 127 |
128 ProcessCommonParams(common_renderer_params); | 128 ProcessCommonParams(common_renderer_params); |
129 | 129 |
130 return ProcessHardwareFrame(output_surface_id, std::move(compositor_frame)); | 130 return ProcessHardwareFrame(compositor_frame_sink_id, |
| 131 std::move(compositor_frame)); |
131 } | 132 } |
132 | 133 |
133 bool SynchronousCompositorHost::DemandDrawHwReceiveFrame( | 134 bool SynchronousCompositorHost::DemandDrawHwReceiveFrame( |
134 const IPC::Message& message) { | 135 const IPC::Message& message) { |
135 SyncCompositorHostMsg_ReturnFrame::Param param; | 136 SyncCompositorHostMsg_ReturnFrame::Param param; |
136 if (!SyncCompositorHostMsg_ReturnFrame::Read(&message, ¶m)) | 137 if (!SyncCompositorHostMsg_ReturnFrame::Read(&message, ¶m)) |
137 return false; | 138 return false; |
138 uint32_t output_surface_id = std::get<0>(param); | 139 uint32_t compositor_frame_sink_id = std::get<0>(param); |
139 cc::CompositorFrame compositor_frame = std::move(std::get<1>(param)); | 140 cc::CompositorFrame compositor_frame = std::move(std::get<1>(param)); |
140 client_->OnDrawHardwareProcessFrame( | 141 client_->OnDrawHardwareProcessFrame(ProcessHardwareFrame( |
141 ProcessHardwareFrame(output_surface_id, std::move(compositor_frame))); | 142 compositor_frame_sink_id, std::move(compositor_frame))); |
142 return true; | 143 return true; |
143 } | 144 } |
144 | 145 |
145 SynchronousCompositor::Frame SynchronousCompositorHost::ProcessHardwareFrame( | 146 SynchronousCompositor::Frame SynchronousCompositorHost::ProcessHardwareFrame( |
146 uint32_t output_surface_id, | 147 uint32_t compositor_frame_sink_id, |
147 cc::CompositorFrame compositor_frame) { | 148 cc::CompositorFrame compositor_frame) { |
148 SynchronousCompositor::Frame frame; | 149 SynchronousCompositor::Frame frame; |
149 frame.frame.reset(new cc::CompositorFrame); | 150 frame.frame.reset(new cc::CompositorFrame); |
150 frame.output_surface_id = output_surface_id; | 151 frame.compositor_frame_sink_id = compositor_frame_sink_id; |
151 *frame.frame = std::move(compositor_frame); | 152 *frame.frame = std::move(compositor_frame); |
152 if (!frame.frame->delegated_frame_data) { | 153 if (!frame.frame->delegated_frame_data) { |
153 // This can happen if compositor did not swap in this draw. | 154 // This can happen if compositor did not swap in this draw. |
154 frame.frame.reset(); | 155 frame.frame.reset(); |
155 } | 156 } |
156 if (frame.frame) { | 157 if (frame.frame) { |
157 UpdateFrameMetaData(frame.frame->metadata.Clone()); | 158 UpdateFrameMetaData(frame.frame->metadata.Clone()); |
158 } | 159 } |
159 return frame; | 160 return frame; |
160 } | 161 } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 software_draw_shm_ = std::move(software_draw_shm); | 314 software_draw_shm_ = std::move(software_draw_shm); |
314 ProcessCommonParams(common_renderer_params); | 315 ProcessCommonParams(common_renderer_params); |
315 } | 316 } |
316 | 317 |
317 void SynchronousCompositorHost::SendZeroMemory() { | 318 void SynchronousCompositorHost::SendZeroMemory() { |
318 // No need to check return value. | 319 // No need to check return value. |
319 sender_->Send(new SyncCompositorMsg_ZeroSharedMemory(routing_id_)); | 320 sender_->Send(new SyncCompositorMsg_ZeroSharedMemory(routing_id_)); |
320 } | 321 } |
321 | 322 |
322 void SynchronousCompositorHost::ReturnResources( | 323 void SynchronousCompositorHost::ReturnResources( |
323 uint32_t output_surface_id, | 324 uint32_t compositor_frame_sink_id, |
324 const cc::ReturnedResourceArray& resources) { | 325 const cc::ReturnedResourceArray& resources) { |
325 DCHECK(!resources.empty()); | 326 DCHECK(!resources.empty()); |
326 sender_->Send(new SyncCompositorMsg_ReclaimResources( | 327 sender_->Send(new SyncCompositorMsg_ReclaimResources( |
327 routing_id_, output_surface_id, resources)); | 328 routing_id_, compositor_frame_sink_id, resources)); |
328 } | 329 } |
329 | 330 |
330 void SynchronousCompositorHost::SetMemoryPolicy(size_t bytes_limit) { | 331 void SynchronousCompositorHost::SetMemoryPolicy(size_t bytes_limit) { |
331 if (bytes_limit_ == bytes_limit) | 332 if (bytes_limit_ == bytes_limit) |
332 return; | 333 return; |
333 | 334 |
334 if (sender_->Send( | 335 if (sender_->Send( |
335 new SyncCompositorMsg_SetMemoryPolicy(routing_id_, bytes_limit))) { | 336 new SyncCompositorMsg_SetMemoryPolicy(routing_id_, bytes_limit))) { |
336 bytes_limit_ = bytes_limit; | 337 bytes_limit_ = bytes_limit; |
337 } | 338 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 client_->DidOverscroll(this, over_scroll_params.accumulated_overscroll, | 373 client_->DidOverscroll(this, over_scroll_params.accumulated_overscroll, |
373 over_scroll_params.latest_overscroll_delta, | 374 over_scroll_params.latest_overscroll_delta, |
374 over_scroll_params.current_fling_velocity); | 375 over_scroll_params.current_fling_velocity); |
375 } | 376 } |
376 | 377 |
377 void SynchronousCompositorHost::DidSendBeginFrame( | 378 void SynchronousCompositorHost::DidSendBeginFrame( |
378 ui::WindowAndroid* window_android) { | 379 ui::WindowAndroid* window_android) { |
379 rph_observer_->SyncStateAfterVSync(window_android, this); | 380 rph_observer_->SyncStateAfterVSync(window_android, this); |
380 } | 381 } |
381 | 382 |
382 void SynchronousCompositorHost::OutputSurfaceCreated() { | 383 void SynchronousCompositorHost::CompositorFrameSinkCreated() { |
383 // New output surface is not aware of state from Browser side. So need to | 384 // New CompositorFrameSink is not aware of state from Browser side. So need to |
384 // re-send all browser side state here. | 385 // re-send all browser side state here. |
385 sender_->Send( | 386 sender_->Send( |
386 new SyncCompositorMsg_SetMemoryPolicy(routing_id_, bytes_limit_)); | 387 new SyncCompositorMsg_SetMemoryPolicy(routing_id_, bytes_limit_)); |
387 } | 388 } |
388 | 389 |
389 void SynchronousCompositorHost::ProcessCommonParams( | 390 void SynchronousCompositorHost::ProcessCommonParams( |
390 const SyncCompositorCommonRendererParams& params) { | 391 const SyncCompositorCommonRendererParams& params) { |
391 // Ignore if |renderer_param_version_| is newer than |params.version|. This | 392 // Ignore if |renderer_param_version_| is newer than |params.version|. This |
392 // comparison takes into account when the unsigned int wraps. | 393 // comparison takes into account when the unsigned int wraps. |
393 if ((renderer_param_version_ - params.version) < 0x80000000) { | 394 if ((renderer_param_version_ - params.version) < 0x80000000) { |
(...skipping 20 matching lines...) Expand all Loading... |
414 if (params.page_scale_factor) { | 415 if (params.page_scale_factor) { |
415 client_->UpdateRootLayerState( | 416 client_->UpdateRootLayerState( |
416 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), | 417 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), |
417 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), | 418 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), |
418 params.scrollable_size, params.page_scale_factor, | 419 params.scrollable_size, params.page_scale_factor, |
419 params.min_page_scale_factor, params.max_page_scale_factor); | 420 params.min_page_scale_factor, params.max_page_scale_factor); |
420 } | 421 } |
421 } | 422 } |
422 | 423 |
423 } // namespace content | 424 } // namespace content |
OLD | NEW |