| 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 SynchronousCompositorHost::~SynchronousCompositorHost() { | 81 SynchronousCompositorHost::~SynchronousCompositorHost() { |
| 82 client_->DidDestroyCompositor(this, process_id_, routing_id_); | 82 client_->DidDestroyCompositor(this, process_id_, routing_id_); |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool SynchronousCompositorHost::OnMessageReceived(const IPC::Message& message) { | 85 bool SynchronousCompositorHost::OnMessageReceived(const IPC::Message& message) { |
| 86 bool handled = true; | 86 bool handled = true; |
| 87 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorHost, message) | 87 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorHost, message) |
| 88 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_OutputSurfaceCreated, | 88 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_OutputSurfaceCreated, |
| 89 OutputSurfaceCreated) | 89 OutputSurfaceCreated) |
| 90 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_UpdateState, ProcessCommonParams) | 90 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_UpdateState, ProcessCommonParams) |
| 91 IPC_MESSAGE_HANDLER(CompositorHostMsg_Frame, ReceiveFrame) |
| 91 IPC_MESSAGE_UNHANDLED(handled = false) | 92 IPC_MESSAGE_UNHANDLED(handled = false) |
| 92 IPC_END_MESSAGE_MAP() | 93 IPC_END_MESSAGE_MAP() |
| 93 return handled; | 94 return handled; |
| 94 } | 95 } |
| 95 | 96 |
| 96 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHw( | 97 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHw( |
| 97 const gfx::Size& surface_size, | 98 const gfx::Size& surface_size, |
| 98 const gfx::Transform& transform, | 99 const gfx::Transform& transform, |
| 99 const gfx::Rect& viewport, | 100 const gfx::Rect& viewport, |
| 100 const gfx::Rect& clip, | 101 const gfx::Rect& clip, |
| 101 const gfx::Rect& viewport_rect_for_tile_priority, | 102 const gfx::Rect& viewport_rect_for_tile_priority, |
| 102 const gfx::Transform& transform_for_tile_priority) { | 103 const gfx::Transform& transform_for_tile_priority) { |
| 103 SyncCompositorDemandDrawHwParams params(surface_size, transform, viewport, | 104 SyncCompositorDemandDrawHwParams params(surface_size, transform, viewport, |
| 104 clip, viewport_rect_for_tile_priority, | 105 clip, viewport_rect_for_tile_priority, |
| 105 transform_for_tile_priority); | 106 transform_for_tile_priority); |
| 106 SynchronousCompositor::Frame frame; | 107 SynchronousCompositor::Frame frame; |
| 107 frame.frame.reset(new cc::CompositorFrame); | 108 frame.frame.reset(new cc::CompositorFrame); |
| 108 SyncCompositorCommonRendererParams common_renderer_params; | 109 SyncCompositorCommonRendererParams common_renderer_params; |
| 109 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( | 110 |
| 110 routing_id_, params, &common_renderer_params, | 111 /* Send an async message instead of a synchronous one. |
| 111 &frame.output_surface_id, frame.frame.get()))) { | 112 * Currently not sure what to do in the analogous case |
| 112 return SynchronousCompositor::Frame(); | 113 * when sending sync message returns false. */ |
| 113 } | 114 // if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( |
| 114 ProcessCommonParams(common_renderer_params); | 115 // routing_id_, params, &common_renderer_params, |
| 115 if (!frame.frame->delegated_frame_data) { | 116 // &frame.output_surface_id, frame.frame.get()))) { |
| 116 // This can happen if compositor did not swap in this draw. | 117 // return SynchronousCompositor::Frame(); |
| 117 frame.frame.reset(); | 118 // } |
| 118 } | 119 |
| 119 if (frame.frame) { | 120 sender_->Send(new CompositorMsg_DemandDrawHw(routing_id_, params)); |
| 120 UpdateFrameMetaData(frame.frame->metadata.Clone()); | 121 /* Now that the sent message is async, the following processing |
| 121 } | 122 * of the result has to be done upon receiving the reply. */ |
| 122 return frame; | 123 |
| 124 // ProcessCommonParams(common_renderer_params); |
| 125 // if (!frame.frame->delegated_frame_data) { |
| 126 // // This can happen if compositor did not swap in this draw. |
| 127 // frame.frame.reset(); |
| 128 // } |
| 129 // if (frame.frame) { |
| 130 // UpdateFrameMetaData(frame.frame->metadata.Clone()); |
| 131 // } |
| 132 // return frame; |
| 133 // |
| 134 return nullptr; |
| 135 } |
| 136 |
| 137 void SynchronousCompositorHost::ReceiveFrame( |
| 138 content::SyncCompositorCommonRendererParams params, |
| 139 uint32_t output_surface_id, |
| 140 cc::CompositorFrame) { |
| 141 // TODO: the return message is received in this class, but |
| 142 // the received frame should be processed in BVR class (should it?) |
| 143 // because other data is stored there (e.g. current frame consumer) |
| 144 // |
| 145 // Either: |
| 146 // 1. pass the received frame back to browser view renderer (is it |
| 147 // appropriate?) |
| 148 // or |
| 149 // 2. pass the necessary things from bvr to here |
| 123 } | 150 } |
| 124 | 151 |
| 125 void SynchronousCompositorHost::UpdateFrameMetaData( | 152 void SynchronousCompositorHost::UpdateFrameMetaData( |
| 126 cc::CompositorFrameMetadata frame_metadata) { | 153 cc::CompositorFrameMetadata frame_metadata) { |
| 127 rwhva_->SynchronousFrameMetadata(std::move(frame_metadata)); | 154 rwhva_->SynchronousFrameMetadata(std::move(frame_metadata)); |
| 128 } | 155 } |
| 129 | 156 |
| 130 namespace { | 157 namespace { |
| 131 | 158 |
| 132 class ScopedSetSkCanvas { | 159 class ScopedSetSkCanvas { |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 if (params.page_scale_factor) { | 408 if (params.page_scale_factor) { |
| 382 client_->UpdateRootLayerState( | 409 client_->UpdateRootLayerState( |
| 383 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), | 410 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), |
| 384 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), | 411 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), |
| 385 params.scrollable_size, params.page_scale_factor, | 412 params.scrollable_size, params.page_scale_factor, |
| 386 params.min_page_scale_factor, params.max_page_scale_factor); | 413 params.min_page_scale_factor, params.max_page_scale_factor); |
| 387 } | 414 } |
| 388 } | 415 } |
| 389 | 416 |
| 390 } // namespace content | 417 } // namespace content |
| OLD | NEW |