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 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(SyncCompositorHostMsg_ReturnFrame, | |
| 95 DemandDrawHwReceiveFrame) | |
| 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 SynchronousCompositor::Frame frame = | |
| 131 DemandDrawHwHelper(output_surface_id, compositor_frame); | |
|
boliu
2016/08/23 02:39:52
just directly return from this
ojars
2016/08/23 21:58:43
Done.
| |
| 132 return frame; | |
| 133 } | |
| 134 | |
| 135 void SynchronousCompositorHost::DemandDrawHwReceiveFrame( | |
| 136 uint32_t output_surface_id, | |
| 137 const cc::CompositorFrame& compositor_frame) { | |
| 138 SynchronousCompositor::Frame frame = | |
| 139 DemandDrawHwHelper(output_surface_id, compositor_frame); | |
| 140 client_->OnDrawHardwareProcessFrame(std::move(frame)); | |
| 141 } | |
| 142 | |
| 143 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHwHelper( | |
| 144 uint32_t output_surface_id, | |
| 145 const cc::CompositorFrame& compositor_frame) { | |
| 106 SynchronousCompositor::Frame frame; | 146 SynchronousCompositor::Frame frame; |
| 107 frame.frame.reset(new cc::CompositorFrame); | 147 frame.frame.reset(new cc::CompositorFrame); |
| 108 SyncCompositorCommonRendererParams common_renderer_params; | 148 frame.output_surface_id = output_surface_id; |
| 109 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( | 149 *frame.frame = std::move(const_cast<cc::CompositorFrame&>(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) { | 150 if (!frame.frame->delegated_frame_data) { |
| 116 // This can happen if compositor did not swap in this draw. | 151 // This can happen if compositor did not swap in this draw. |
| 117 frame.frame.reset(); | 152 frame.frame.reset(); |
| 118 } | 153 } |
| 119 if (frame.frame) { | 154 if (frame.frame) { |
| 120 UpdateFrameMetaData(frame.frame->metadata.Clone()); | 155 UpdateFrameMetaData(frame.frame->metadata.Clone()); |
| 121 } | 156 } |
| 122 return frame; | 157 return frame; |
| 123 } | 158 } |
| 124 | 159 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 if (params.page_scale_factor) { | 412 if (params.page_scale_factor) { |
| 378 client_->UpdateRootLayerState( | 413 client_->UpdateRootLayerState( |
| 379 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), | 414 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), |
| 380 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), | 415 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), |
| 381 params.scrollable_size, params.page_scale_factor, | 416 params.scrollable_size, params.page_scale_factor, |
| 382 params.min_page_scale_factor, params.max_page_scale_factor); | 417 params.min_page_scale_factor, params.max_page_scale_factor); |
| 383 } | 418 } |
| 384 } | 419 } |
| 385 | 420 |
| 386 } // namespace content | 421 } // namespace content |
| OLD | NEW |