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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 SynchronousCompositorHost::~SynchronousCompositorHost() { | 83 SynchronousCompositorHost::~SynchronousCompositorHost() { |
| 84 client_->DidDestroyCompositor(this, process_id_, routing_id_); | 84 client_->DidDestroyCompositor(this, process_id_, routing_id_); |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool SynchronousCompositorHost::OnMessageReceived(const IPC::Message& message) { | 87 bool SynchronousCompositorHost::OnMessageReceived(const IPC::Message& message) { |
| 88 bool handled = true; | 88 bool handled = true; |
| 89 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorHost, message) | 89 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorHost, message) |
| 90 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_OutputSurfaceCreated, | 90 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_OutputSurfaceCreated, |
| 91 OutputSurfaceCreated) | 91 OutputSurfaceCreated) |
| 92 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_UpdateState, ProcessCommonParams) | 92 IPC_MESSAGE_HANDLER(SyncCompositorHostMsg_UpdateState, ProcessCommonParams) |
| 93 IPC_MESSAGE_HANDLER(CompositorHostMsg_Frame, DemandDrawHwReceiveFrame) | |
| 93 IPC_MESSAGE_UNHANDLED(handled = false) | 94 IPC_MESSAGE_UNHANDLED(handled = false) |
| 94 IPC_END_MESSAGE_MAP() | 95 IPC_END_MESSAGE_MAP() |
| 95 return handled; | 96 return handled; |
| 96 } | 97 } |
| 97 | 98 |
| 99 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHw_Async( | |
| 100 const gfx::Size& viewport_size, | |
| 101 const gfx::Rect& viewport_rect_for_tile_priority, | |
| 102 const gfx::Transform& transform_for_tile_priority) { | |
| 103 SyncCompositorDemandDrawHwParams params(viewport_size, | |
| 104 viewport_rect_for_tile_priority, | |
| 105 transform_for_tile_priority); | |
| 106 sender_->Send(new CompositorMsg_DemandDrawHw(routing_id_, params)); | |
| 107 | |
| 108 SynchronousCompositor::Frame frame; | |
| 109 return frame; | |
| 110 } | |
| 111 | |
| 98 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHw( | 112 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHw( |
| 99 const gfx::Size& viewport_size, | 113 const gfx::Size& viewport_size, |
| 100 const gfx::Rect& viewport_rect_for_tile_priority, | 114 const gfx::Rect& viewport_rect_for_tile_priority, |
| 101 const gfx::Transform& transform_for_tile_priority) { | 115 const gfx::Transform& transform_for_tile_priority) { |
| 102 SyncCompositorDemandDrawHwParams params(viewport_size, | 116 SyncCompositorDemandDrawHwParams params(viewport_size, |
| 103 viewport_rect_for_tile_priority, | 117 viewport_rect_for_tile_priority, |
| 104 transform_for_tile_priority); | 118 transform_for_tile_priority); |
| 105 SynchronousCompositor::Frame frame; | 119 SynchronousCompositor::Frame frame; |
| 106 frame.frame.reset(new cc::CompositorFrame); | 120 frame.frame.reset(new cc::CompositorFrame); |
| 107 SyncCompositorCommonRendererParams common_renderer_params; | 121 SyncCompositorCommonRendererParams common_renderer_params; |
| 108 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( | 122 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( |
| 109 routing_id_, params, &common_renderer_params, | 123 routing_id_, params, &common_renderer_params, |
| 110 &frame.output_surface_id, frame.frame.get()))) { | 124 &frame.output_surface_id, frame.frame.get()))) { |
| 111 return SynchronousCompositor::Frame(); | 125 return SynchronousCompositor::Frame(); |
| 112 } | 126 } |
| 113 ProcessCommonParams(common_renderer_params); | 127 ProcessCommonParams(common_renderer_params); |
| 114 if (!frame.frame->delegated_frame_data) { | 128 if (!frame.frame->delegated_frame_data) { |
|
boliu
2016/08/11 19:23:39
this code is duplicated
actually, let's do this,
ojars
2016/08/23 02:15:42
Done.
| |
| 115 // This can happen if compositor did not swap in this draw. | 129 // This can happen if compositor did not swap in this draw. |
| 116 frame.frame.reset(); | 130 frame.frame.reset(); |
| 117 } | 131 } |
| 118 if (frame.frame) { | 132 if (frame.frame) { |
| 119 UpdateFrameMetaData(frame.frame->metadata.Clone()); | 133 UpdateFrameMetaData(frame.frame->metadata.Clone()); |
| 120 } | 134 } |
| 121 return frame; | 135 return frame; |
| 122 } | 136 } |
| 123 | 137 |
| 138 void SynchronousCompositorHost::DemandDrawHwReceiveFrame( | |
| 139 uint32_t output_surface_id, | |
| 140 const cc::CompositorFrame& compositor_frame) { | |
| 141 SynchronousCompositor::Frame frame; | |
| 142 frame.frame.reset(new cc::CompositorFrame); | |
| 143 frame.output_surface_id = output_surface_id; | |
| 144 *frame.frame = std::move(const_cast<cc::CompositorFrame&>(compositor_frame)); | |
| 145 frame.output_surface_id = output_surface_id; | |
| 146 | |
| 147 if (!frame.frame->delegated_frame_data) { | |
| 148 // This can happen if compositor did not swap in this draw. | |
| 149 frame.frame.reset(); | |
| 150 } | |
| 151 if (frame.frame) { | |
| 152 UpdateFrameMetaData(frame.frame->metadata.Clone()); | |
| 153 } | |
| 154 | |
| 155 client_->OnDrawHardwareProcessFrame(std::move(frame)); | |
| 156 } | |
| 157 | |
| 124 void SynchronousCompositorHost::UpdateFrameMetaData( | 158 void SynchronousCompositorHost::UpdateFrameMetaData( |
| 125 cc::CompositorFrameMetadata frame_metadata) { | 159 cc::CompositorFrameMetadata frame_metadata) { |
| 126 rwhva_->SynchronousFrameMetadata(std::move(frame_metadata)); | 160 rwhva_->SynchronousFrameMetadata(std::move(frame_metadata)); |
| 127 } | 161 } |
| 128 | 162 |
| 129 namespace { | 163 namespace { |
| 130 | 164 |
| 131 class ScopedSetSkCanvas { | 165 class ScopedSetSkCanvas { |
| 132 public: | 166 public: |
| 133 explicit ScopedSetSkCanvas(SkCanvas* canvas) { | 167 explicit ScopedSetSkCanvas(SkCanvas* canvas) { |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 if (params.page_scale_factor) { | 410 if (params.page_scale_factor) { |
| 377 client_->UpdateRootLayerState( | 411 client_->UpdateRootLayerState( |
| 378 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), | 412 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), |
| 379 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), | 413 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), |
| 380 params.scrollable_size, params.page_scale_factor, | 414 params.scrollable_size, params.page_scale_factor, |
| 381 params.min_page_scale_factor, params.max_page_scale_factor); | 415 params.min_page_scale_factor, params.max_page_scale_factor); |
| 382 } | 416 } |
| 383 } | 417 } |
| 384 | 418 |
| 385 } // namespace content | 419 } // namespace content |
| OLD | NEW |