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/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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_CompositorFrameSinkCreated, | 91 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_CompositorFrameSinkCreated, |
| 92 CompositorFrameSinkCreated) | 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 scoped_refptr<SynchronousCompositor::FrameFuture> |
| 102 SynchronousCompositorHost::DemandDrawHwAsync( | |
| 102 const gfx::Size& viewport_size, | 103 const gfx::Size& viewport_size, |
| 103 const gfx::Rect& viewport_rect_for_tile_priority, | 104 const gfx::Rect& viewport_rect_for_tile_priority, |
| 104 const gfx::Transform& transform_for_tile_priority) { | 105 const gfx::Transform& transform_for_tile_priority) { |
| 105 SyncCompositorDemandDrawHwParams params(viewport_size, | 106 SyncCompositorDemandDrawHwParams params(viewport_size, |
| 106 viewport_rect_for_tile_priority, | 107 viewport_rect_for_tile_priority, |
| 107 transform_for_tile_priority); | 108 transform_for_tile_priority); |
| 108 sender_->Send(new SyncCompositorMsg_DemandDrawHwAsync(routing_id_, params)); | 109 sender_->Send(new SyncCompositorMsg_DemandDrawHwAsync(routing_id_, params)); |
| 110 | |
| 111 frame_future_ = new SynchronousCompositor::FrameFuture(); | |
| 112 return frame_future_; | |
| 109 } | 113 } |
| 110 | 114 |
| 111 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHw( | 115 scoped_refptr<SynchronousCompositor::FrameFuture> |
| 116 SynchronousCompositorHost::DemandDrawHw( | |
| 112 const gfx::Size& viewport_size, | 117 const gfx::Size& viewport_size, |
| 113 const gfx::Rect& viewport_rect_for_tile_priority, | 118 const gfx::Rect& viewport_rect_for_tile_priority, |
| 114 const gfx::Transform& transform_for_tile_priority) { | 119 const gfx::Transform& transform_for_tile_priority) { |
| 115 SyncCompositorDemandDrawHwParams params(viewport_size, | 120 SyncCompositorDemandDrawHwParams params(viewport_size, |
| 116 viewport_rect_for_tile_priority, | 121 viewport_rect_for_tile_priority, |
| 117 transform_for_tile_priority); | 122 transform_for_tile_priority); |
| 118 uint32_t compositor_frame_sink_id; | 123 uint32_t compositor_frame_sink_id; |
| 119 cc::CompositorFrame compositor_frame; | 124 cc::CompositorFrame compositor_frame; |
| 120 SyncCompositorCommonRendererParams common_renderer_params; | 125 SyncCompositorCommonRendererParams common_renderer_params; |
| 121 | 126 |
| 122 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( | 127 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( |
| 123 routing_id_, params, &common_renderer_params, | 128 routing_id_, params, &common_renderer_params, |
| 124 &compositor_frame_sink_id, &compositor_frame))) { | 129 &compositor_frame_sink_id, &compositor_frame))) { |
| 125 return SynchronousCompositor::Frame(); | 130 // return SynchronousCompositor::Frame(); |
| 131 return nullptr; | |
| 126 } | 132 } |
| 127 | 133 |
| 128 ProcessCommonParams(common_renderer_params); | 134 ProcessCommonParams(common_renderer_params); |
| 129 | 135 |
| 130 return ProcessHardwareFrame(compositor_frame_sink_id, | 136 frame_future_ = new SynchronousCompositor::FrameFuture(); |
| 131 std::move(compositor_frame)); | 137 frame_future_->setFrame(ProcessHardwareFrame(compositor_frame_sink_id, |
| 138 std::move(compositor_frame))); | |
| 139 | |
| 140 return frame_future_; | |
| 132 } | 141 } |
| 133 | 142 |
| 134 bool SynchronousCompositorHost::DemandDrawHwReceiveFrame( | 143 bool SynchronousCompositorHost::DemandDrawHwReceiveFrame( |
| 135 const IPC::Message& message) { | 144 const IPC::Message& message) { |
| 136 SyncCompositorHostMsg_ReturnFrame::Param param; | 145 SyncCompositorHostMsg_ReturnFrame::Param param; |
| 137 if (!SyncCompositorHostMsg_ReturnFrame::Read(&message, ¶m)) | 146 if (!SyncCompositorHostMsg_ReturnFrame::Read(&message, ¶m)) |
| 138 return false; | 147 return false; |
| 139 uint32_t compositor_frame_sink_id = std::get<0>(param); | 148 |
| 140 cc::CompositorFrame compositor_frame = std::move(std::get<1>(param)); | 149 // uint32_t compositor_frame_sink_id = std::get<0>(param); |
| 141 client_->OnDrawHardwareProcessFrame(ProcessHardwareFrame( | 150 // cc::CompositorFrame compositor_frame = std::move(std::get<1>(param)); |
| 142 compositor_frame_sink_id, std::move(compositor_frame))); | 151 // TODO(ojars): |
| 152 // client_->OnDrawHardwareProcessFrame( | |
| 153 // ProcessHardwareFrame(compositor_frame_sink_id, | |
| 154 // std::move(compositor_frame))); | |
| 143 return true; | 155 return true; |
| 144 } | 156 } |
| 145 | 157 |
| 146 SynchronousCompositor::Frame SynchronousCompositorHost::ProcessHardwareFrame( | 158 std::unique_ptr<SynchronousCompositor::Frame> |
| 159 SynchronousCompositorHost::ProcessHardwareFrame( | |
| 147 uint32_t compositor_frame_sink_id, | 160 uint32_t compositor_frame_sink_id, |
| 148 cc::CompositorFrame compositor_frame) { | 161 cc::CompositorFrame compositor_frame) { |
| 149 SynchronousCompositor::Frame frame; | 162 auto frame = base::MakeUnique<SynchronousCompositor::Frame>(); |
|
boliu
2016/09/20 00:27:56
Don't use auto here
ojars
2016/09/22 18:21:38
Done.
| |
| 150 frame.frame.reset(new cc::CompositorFrame); | 163 // SynchronousCompositor::Frame frame; |
| 151 frame.compositor_frame_sink_id = compositor_frame_sink_id; | 164 frame->frame.reset(new cc::CompositorFrame); |
| 152 *frame.frame = std::move(compositor_frame); | 165 frame->compositor_frame_sink_id = compositor_frame_sink_id; |
| 153 if (!frame.frame->delegated_frame_data) { | 166 *(frame->frame) = std::move(compositor_frame); |
| 167 if (!frame->frame->delegated_frame_data) { | |
| 154 // This can happen if compositor did not swap in this draw. | 168 // This can happen if compositor did not swap in this draw. |
| 155 frame.frame.reset(); | 169 frame->frame.reset(); |
| 156 } | 170 } |
| 157 if (frame.frame) { | 171 if (frame->frame) { |
| 158 UpdateFrameMetaData(frame.frame->metadata.Clone()); | 172 UpdateFrameMetaData(frame->frame->metadata.Clone()); |
| 159 } | 173 } |
| 174 // return base::MakeUnique<SynchronousCompositor::Frame>(frame); | |
| 160 return frame; | 175 return frame; |
| 161 } | 176 } |
| 162 | 177 |
| 163 void SynchronousCompositorHost::UpdateFrameMetaData( | 178 void SynchronousCompositorHost::UpdateFrameMetaData( |
| 164 cc::CompositorFrameMetadata frame_metadata) { | 179 cc::CompositorFrameMetadata frame_metadata) { |
| 165 rwhva_->SynchronousFrameMetadata(std::move(frame_metadata)); | 180 rwhva_->SynchronousFrameMetadata(std::move(frame_metadata)); |
| 166 } | 181 } |
| 167 | 182 |
| 168 namespace { | 183 namespace { |
| 169 | 184 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 if (params.page_scale_factor) { | 430 if (params.page_scale_factor) { |
| 416 client_->UpdateRootLayerState( | 431 client_->UpdateRootLayerState( |
| 417 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), | 432 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), |
| 418 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), | 433 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), |
| 419 params.scrollable_size, params.page_scale_factor, | 434 params.scrollable_size, params.page_scale_factor, |
| 420 params.min_page_scale_factor, params.max_page_scale_factor); | 435 params.min_page_scale_factor, params.max_page_scale_factor); |
| 421 } | 436 } |
| 422 } | 437 } |
| 423 | 438 |
| 424 } // namespace content | 439 } // namespace content |
| OLD | NEW |