OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 | 1135 |
1136 if (!surface_returned_resources_.empty()) | 1136 if (!surface_returned_resources_.empty()) |
1137 SendReclaimCompositorResources(last_compositor_frame_sink_id_, | 1137 SendReclaimCompositorResources(last_compositor_frame_sink_id_, |
1138 false /* is_swap_ack */); | 1138 false /* is_swap_ack */); |
1139 | 1139 |
1140 last_compositor_frame_sink_id_ = compositor_frame_sink_id; | 1140 last_compositor_frame_sink_id_ = compositor_frame_sink_id; |
1141 } | 1141 } |
1142 | 1142 |
1143 void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame( | 1143 void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame( |
1144 uint32_t compositor_frame_sink_id, | 1144 uint32_t compositor_frame_sink_id, |
| 1145 const cc::LocalSurfaceId& local_surface_id, |
1145 cc::CompositorFrame frame) { | 1146 cc::CompositorFrame frame) { |
1146 last_scroll_offset_ = frame.metadata.root_scroll_offset; | 1147 last_scroll_offset_ = frame.metadata.root_scroll_offset; |
1147 DCHECK(delegated_frame_host_); | 1148 DCHECK(delegated_frame_host_); |
1148 DCHECK(!frame.render_pass_list.empty()); | 1149 DCHECK(!frame.render_pass_list.empty()); |
1149 | 1150 |
1150 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); | 1151 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); |
1151 current_surface_size_ = root_pass->output_rect.size(); | 1152 current_surface_size_ = root_pass->output_rect.size(); |
1152 bool is_transparent = root_pass->has_transparent_background; | 1153 bool is_transparent = root_pass->has_transparent_background; |
1153 | 1154 |
1154 cc::CompositorFrameMetadata metadata = frame.metadata.Clone(); | 1155 cc::CompositorFrameMetadata metadata = frame.metadata.Clone(); |
1155 | 1156 |
1156 CheckCompositorFrameSinkChanged(compositor_frame_sink_id); | 1157 CheckCompositorFrameSinkChanged(compositor_frame_sink_id); |
1157 bool has_content = !current_surface_size_.IsEmpty(); | 1158 bool has_content = !current_surface_size_.IsEmpty(); |
1158 | 1159 |
1159 base::Closure ack_callback = | 1160 base::Closure ack_callback = |
1160 base::Bind(&RenderWidgetHostViewAndroid::SendReclaimCompositorResources, | 1161 base::Bind(&RenderWidgetHostViewAndroid::SendReclaimCompositorResources, |
1161 weak_ptr_factory_.GetWeakPtr(), compositor_frame_sink_id, | 1162 weak_ptr_factory_.GetWeakPtr(), compositor_frame_sink_id, |
1162 true /* is_swap_ack */); | 1163 true /* is_swap_ack */); |
1163 | 1164 |
1164 ack_callbacks_.push(ack_callback); | 1165 ack_callbacks_.push(ack_callback); |
1165 | 1166 |
1166 if (!has_content) { | 1167 if (!has_content) { |
1167 DestroyDelegatedContent(); | 1168 DestroyDelegatedContent(); |
1168 } else { | 1169 } else { |
1169 delegated_frame_host_->SubmitCompositorFrame(std::move(frame)); | 1170 delegated_frame_host_->SubmitCompositorFrame(local_surface_id, |
| 1171 std::move(frame)); |
1170 frame_evictor_->SwappedFrame(!host_->is_hidden()); | 1172 frame_evictor_->SwappedFrame(!host_->is_hidden()); |
1171 } | 1173 } |
1172 | 1174 |
1173 if (host_->is_hidden()) | 1175 if (host_->is_hidden()) |
1174 RunAckCallbacks(); | 1176 RunAckCallbacks(); |
1175 | 1177 |
1176 // As the metadata update may trigger view invalidation, always call it after | 1178 // As the metadata update may trigger view invalidation, always call it after |
1177 // any potential compositor scheduling. | 1179 // any potential compositor scheduling. |
1178 OnFrameMetadataUpdated(std::move(metadata), is_transparent); | 1180 OnFrameMetadataUpdated(std::move(metadata), is_transparent); |
1179 } | 1181 } |
1180 | 1182 |
1181 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { | 1183 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { |
1182 DCHECK(!delegated_frame_host_ || | 1184 DCHECK(!delegated_frame_host_ || |
1183 delegated_frame_host_->HasDelegatedContent() == | 1185 delegated_frame_host_->HasDelegatedContent() == |
1184 frame_evictor_->HasFrame()); | 1186 frame_evictor_->HasFrame()); |
1185 | 1187 |
1186 if (!delegated_frame_host_) | 1188 if (!delegated_frame_host_) |
1187 return; | 1189 return; |
1188 | 1190 |
1189 if (!delegated_frame_host_->HasDelegatedContent()) | 1191 if (!delegated_frame_host_->HasDelegatedContent()) |
1190 return; | 1192 return; |
1191 | 1193 |
1192 frame_evictor_->DiscardedFrame(); | 1194 frame_evictor_->DiscardedFrame(); |
1193 delegated_frame_host_->DestroyDelegatedContent(); | 1195 delegated_frame_host_->DestroyDelegatedContent(); |
1194 } | 1196 } |
1195 | 1197 |
1196 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame( | 1198 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame( |
1197 uint32_t compositor_frame_sink_id, | 1199 uint32_t compositor_frame_sink_id, |
| 1200 const cc::LocalSurfaceId& local_surface_id, |
1198 cc::CompositorFrame frame) { | 1201 cc::CompositorFrame frame) { |
1199 InternalSwapCompositorFrame(compositor_frame_sink_id, std::move(frame)); | 1202 InternalSwapCompositorFrame(compositor_frame_sink_id, local_surface_id, |
| 1203 std::move(frame)); |
1200 } | 1204 } |
1201 | 1205 |
1202 void RenderWidgetHostViewAndroid::ClearCompositorFrame() { | 1206 void RenderWidgetHostViewAndroid::ClearCompositorFrame() { |
1203 DestroyDelegatedContent(); | 1207 DestroyDelegatedContent(); |
1204 } | 1208 } |
1205 | 1209 |
1206 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( | 1210 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( |
1207 cc::CompositorFrameMetadata frame_metadata) { | 1211 cc::CompositorFrameMetadata frame_metadata) { |
1208 if (!content_view_core_) | 1212 if (!content_view_core_) |
1209 return; | 1213 return; |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2130 | 2134 |
2131 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2135 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
2132 if (!compositor) | 2136 if (!compositor) |
2133 return; | 2137 return; |
2134 | 2138 |
2135 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2139 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
2136 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2140 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
2137 } | 2141 } |
2138 | 2142 |
2139 } // namespace content | 2143 } // namespace content |
OLD | NEW |