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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_OutputSurfaceCreated, |
92 OutputSurfaceCreated) | 92 OutputSurfaceCreated) |
93 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_UpdateState, ProcessCommonParams) | 93 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_UpdateState, ProcessCommonParams) |
| 94 IPC_MESSAGE_HANDLER_GENERIC(SyncCompositorHostMsg_ReturnFrame, |
| 95 DemandDrawHwReceiveFrame(message)) |
94 IPC_MESSAGE_UNHANDLED(handled = false) | 96 IPC_MESSAGE_UNHANDLED(handled = false) |
95 IPC_END_MESSAGE_MAP() | 97 IPC_END_MESSAGE_MAP() |
96 return handled; | 98 return handled; |
97 } | 99 } |
98 | 100 |
| 101 void SynchronousCompositorHost::DemandDrawHwAsync( |
| 102 const gfx::Size& viewport_size, |
| 103 const gfx::Rect& viewport_rect_for_tile_priority, |
| 104 const gfx::Transform& transform_for_tile_priority) { |
| 105 SyncCompositorDemandDrawHwParams params(viewport_size, |
| 106 viewport_rect_for_tile_priority, |
| 107 transform_for_tile_priority); |
| 108 sender_->Send(new SyncCompositorMsg_DemandDrawHwAsync(routing_id_, params)); |
| 109 } |
| 110 |
99 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHw( | 111 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHw( |
100 const gfx::Size& viewport_size, | 112 const gfx::Size& viewport_size, |
101 const gfx::Rect& viewport_rect_for_tile_priority, | 113 const gfx::Rect& viewport_rect_for_tile_priority, |
102 const gfx::Transform& transform_for_tile_priority) { | 114 const gfx::Transform& transform_for_tile_priority) { |
103 SyncCompositorDemandDrawHwParams params(viewport_size, | 115 SyncCompositorDemandDrawHwParams params(viewport_size, |
104 viewport_rect_for_tile_priority, | 116 viewport_rect_for_tile_priority, |
105 transform_for_tile_priority); | 117 transform_for_tile_priority); |
| 118 uint32_t output_surface_id; |
| 119 cc::CompositorFrame compositor_frame; |
| 120 SyncCompositorCommonRendererParams common_renderer_params; |
| 121 |
| 122 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( |
| 123 routing_id_, params, &common_renderer_params, &output_surface_id, |
| 124 &compositor_frame))) { |
| 125 return SynchronousCompositor::Frame(); |
| 126 } |
| 127 |
| 128 ProcessCommonParams(common_renderer_params); |
| 129 |
| 130 return ProcessHardwareFrame(output_surface_id, std::move(compositor_frame)); |
| 131 } |
| 132 |
| 133 bool SynchronousCompositorHost::DemandDrawHwReceiveFrame( |
| 134 const IPC::Message& message) { |
| 135 SyncCompositorHostMsg_ReturnFrame::Param param; |
| 136 if (!SyncCompositorHostMsg_ReturnFrame::Read(&message, ¶m)) |
| 137 return false; |
| 138 uint32_t output_surface_id = std::get<0>(param); |
| 139 cc::CompositorFrame compositor_frame = std::move(std::get<1>(param)); |
| 140 client_->OnDrawHardwareProcessFrame( |
| 141 ProcessHardwareFrame(output_surface_id, std::move(compositor_frame))); |
| 142 return true; |
| 143 } |
| 144 |
| 145 SynchronousCompositor::Frame SynchronousCompositorHost::ProcessHardwareFrame( |
| 146 uint32_t output_surface_id, |
| 147 cc::CompositorFrame compositor_frame) { |
106 SynchronousCompositor::Frame frame; | 148 SynchronousCompositor::Frame frame; |
107 frame.frame.reset(new cc::CompositorFrame); | 149 frame.frame.reset(new cc::CompositorFrame); |
108 SyncCompositorCommonRendererParams common_renderer_params; | 150 frame.output_surface_id = output_surface_id; |
109 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( | 151 *frame.frame = std::move(compositor_frame); |
110 routing_id_, params, &common_renderer_params, | |
111 &frame.output_surface_id, frame.frame.get()))) { | |
112 return SynchronousCompositor::Frame(); | |
113 } | |
114 ProcessCommonParams(common_renderer_params); | |
115 if (!frame.frame->delegated_frame_data) { | 152 if (!frame.frame->delegated_frame_data) { |
116 // This can happen if compositor did not swap in this draw. | 153 // This can happen if compositor did not swap in this draw. |
117 frame.frame.reset(); | 154 frame.frame.reset(); |
118 } | 155 } |
119 if (frame.frame) { | 156 if (frame.frame) { |
120 UpdateFrameMetaData(frame.frame->metadata.Clone()); | 157 UpdateFrameMetaData(frame.frame->metadata.Clone()); |
121 } | 158 } |
122 return frame; | 159 return frame; |
123 } | 160 } |
124 | 161 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 if (params.page_scale_factor) { | 414 if (params.page_scale_factor) { |
378 client_->UpdateRootLayerState( | 415 client_->UpdateRootLayerState( |
379 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), | 416 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), |
380 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), | 417 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), |
381 params.scrollable_size, params.page_scale_factor, | 418 params.scrollable_size, params.page_scale_factor, |
382 params.min_page_scale_factor, params.max_page_scale_factor); | 419 params.min_page_scale_factor, params.max_page_scale_factor); |
383 } | 420 } |
384 } | 421 } |
385 | 422 |
386 } // namespace content | 423 } // namespace content |
OLD | NEW |