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