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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 RenderWidgetHostView* reference_host_view) { | 552 RenderWidgetHostView* reference_host_view) { |
553 NOTIMPLEMENTED(); | 553 NOTIMPLEMENTED(); |
554 } | 554 } |
555 | 555 |
556 RenderWidgetHost* | 556 RenderWidgetHost* |
557 RenderWidgetHostViewAndroid::GetRenderWidgetHost() const { | 557 RenderWidgetHostViewAndroid::GetRenderWidgetHost() const { |
558 return host_; | 558 return host_; |
559 } | 559 } |
560 | 560 |
561 void RenderWidgetHostViewAndroid::WasResized() { | 561 void RenderWidgetHostViewAndroid::WasResized() { |
562 // If we're entering a fullscreen transition, show black until the transition | |
563 // is completed. | |
564 if (content_view_core_ && | |
565 view_.GetPhysicalBackingSize() != prev_physical_backing_size_) { | |
Khushal
2017/05/26 21:46:18
This should compare the physical backing size with
steimel
2017/06/06 03:07:54
Done.
| |
566 bool is_fullscreen = content_view_core_->GetWebContents()->IsFullscreen(); | |
567 if (is_fullscreen || was_fullscreen_) { | |
568 fullscreen_transitioning_ = true; | |
Khushal
2017/05/26 21:46:18
I think I follow this better now. So for the case
steimel
2017/06/06 03:07:53
The logic has been revamped (albeit without the ad
| |
569 | |
570 // TODO update this comment. Immediately queue a black frame to hide jank while we wait to receive a | |
571 // "good" frame via SubmitCompositorFrame. | |
572 TRACE_EVENT_BEGIN0("frame_eviction", "RenderWidgetHostViewAndroid::WasResi zed Eviction"); | |
573 EvictDelegatedFrame(); | |
574 TRACE_EVENT_END0("frame_eviction", "RenderWidgetHostViewAndroid::WasResize d Eviction"); | |
575 UpdateBackgroundColor(SK_ColorBLACK); | |
576 } | |
577 was_fullscreen_ = is_fullscreen; | |
578 prev_physical_backing_size_ = view_.GetPhysicalBackingSize(); | |
579 } | |
562 host_->WasResized(); | 580 host_->WasResized(); |
563 } | 581 } |
564 | 582 |
565 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) { | 583 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) { |
566 // Ignore the given size as only the Java code has the power to | 584 // Ignore the given size as only the Java code has the power to |
567 // resize the view on Android. | 585 // resize the view on Android. |
568 default_bounds_ = gfx::Rect(default_bounds_.origin(), size); | 586 default_bounds_ = gfx::Rect(default_bounds_.origin(), size); |
569 } | 587 } |
570 | 588 |
571 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { | 589 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1174 bad_message::RWH_BAD_FRAME_SINK_REQUEST); | 1192 bad_message::RWH_BAD_FRAME_SINK_REQUEST); |
1175 return; | 1193 return; |
1176 } | 1194 } |
1177 delegated_frame_host_->CompositorFrameSinkChanged(); | 1195 delegated_frame_host_->CompositorFrameSinkChanged(); |
1178 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink; | 1196 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink; |
1179 // Accumulated resources belong to the old RendererCompositorFrameSink and | 1197 // Accumulated resources belong to the old RendererCompositorFrameSink and |
1180 // should not be returned. | 1198 // should not be returned. |
1181 surface_returned_resources_.clear(); | 1199 surface_returned_resources_.clear(); |
1182 } | 1200 } |
1183 | 1201 |
1202 bool RenderWidgetHostViewAndroid::CheckForFullscreenTransitionJank( | |
1203 const cc::CompositorFrameMetadata& metadata) { | |
1204 // Sometimes we'll receive a new frame before WasResized initializes a | |
1205 // fullscreen transition. In that case, we'll block everything until | |
1206 // WasResized is called. | |
1207 if (content_view_core_ && | |
1208 content_view_core_->GetWebContents()->IsFullscreen() != was_fullscreen_) { | |
1209 return true; | |
1210 } | |
1211 | |
1212 // We only check for fullscreen jank during a fullscreen transition. | |
1213 if (fullscreen_transitioning_) { | |
1214 bool mismatched_fullscreen_states = | |
1215 content_view_core_ && | |
1216 (content_view_core_->GetWebContents()->IsFullscreen() != | |
1217 metadata.is_fullscreen); | |
1218 bool mismatched_layer_sizes = | |
1219 view_.GetPhysicalBackingSize() != metadata.device_viewport_size; | |
Khushal
2017/05/26 21:46:18
I think this should be the same as |current_surfac
steimel
2017/06/06 03:07:54
Done.
| |
1220 if (mismatched_fullscreen_states || mismatched_layer_sizes) { | |
1221 return true; | |
1222 } else { | |
1223 // Done with current fullscreen transition. | |
1224 fullscreen_transitioning_ = false; | |
1225 } | |
1226 } | |
1227 | |
1228 return false; | |
1229 } | |
1230 | |
1184 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( | 1231 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( |
1185 const cc::LocalSurfaceId& local_surface_id, | 1232 const cc::LocalSurfaceId& local_surface_id, |
1186 cc::CompositorFrame frame) { | 1233 cc::CompositorFrame frame) { |
1187 if (!delegated_frame_host_) { | 1234 if (!delegated_frame_host_) { |
1188 DCHECK(!using_browser_compositor_); | 1235 DCHECK(!using_browser_compositor_); |
1189 return; | 1236 return; |
1190 } | 1237 } |
1191 | 1238 |
1239 bool has_jank = CheckForFullscreenTransitionJank(frame.metadata); | |
1240 | |
1192 last_scroll_offset_ = frame.metadata.root_scroll_offset; | 1241 last_scroll_offset_ = frame.metadata.root_scroll_offset; |
1193 DCHECK(!frame.render_pass_list.empty()); | 1242 DCHECK(!frame.render_pass_list.empty()); |
1194 | 1243 |
1195 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); | 1244 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); |
1196 current_surface_size_ = root_pass->output_rect.size(); | 1245 current_surface_size_ = root_pass->output_rect.size(); |
1197 bool is_transparent = root_pass->has_transparent_background; | 1246 bool is_transparent = root_pass->has_transparent_background; |
1198 | 1247 |
1199 cc::CompositorFrameMetadata metadata = frame.metadata.Clone(); | 1248 cc::CompositorFrameMetadata metadata = frame.metadata.Clone(); |
1200 | 1249 |
1201 bool has_content = !current_surface_size_.IsEmpty(); | 1250 bool has_content = !current_surface_size_.IsEmpty(); |
(...skipping 16 matching lines...) Expand all Loading... | |
1218 frame_evictor_->SwappedFrame(!host_->is_hidden()); | 1267 frame_evictor_->SwappedFrame(!host_->is_hidden()); |
1219 AcknowledgeBeginFrame(ack); | 1268 AcknowledgeBeginFrame(ack); |
1220 } | 1269 } |
1221 | 1270 |
1222 if (host_->is_hidden()) | 1271 if (host_->is_hidden()) |
1223 RunAckCallbacks(); | 1272 RunAckCallbacks(); |
1224 | 1273 |
1225 // As the metadata update may trigger view invalidation, always call it after | 1274 // As the metadata update may trigger view invalidation, always call it after |
1226 // any potential compositor scheduling. | 1275 // any potential compositor scheduling. |
1227 OnFrameMetadataUpdated(std::move(metadata), is_transparent); | 1276 OnFrameMetadataUpdated(std::move(metadata), is_transparent); |
1277 | |
1278 if (has_jank) { | |
1279 TRACE_EVENT_BEGIN0("frame_eviction", "RenderWidgetHostViewAndroid::SubmitCom positorFrame Eviction"); | |
1280 EvictDelegatedFrame(); | |
1281 TRACE_EVENT_END0("frame_eviction", "RenderWidgetHostViewAndroid::SubmitCompo sitorFrame Eviction"); | |
1282 UpdateBackgroundColor(SK_ColorBLACK); | |
1283 } | |
1228 } | 1284 } |
1229 | 1285 |
1230 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { | 1286 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { |
1231 DCHECK(!delegated_frame_host_ || | 1287 DCHECK(!delegated_frame_host_ || |
1232 delegated_frame_host_->HasDelegatedContent() == | 1288 delegated_frame_host_->HasDelegatedContent() == |
1233 frame_evictor_->HasFrame()); | 1289 frame_evictor_->HasFrame()); |
1234 | 1290 |
1235 if (!delegated_frame_host_) | 1291 if (!delegated_frame_host_) |
1236 return; | 1292 return; |
1237 | 1293 |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2238 | 2294 |
2239 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2295 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
2240 if (!compositor) | 2296 if (!compositor) |
2241 return; | 2297 return; |
2242 | 2298 |
2243 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2299 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
2244 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2300 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
2245 } | 2301 } |
2246 | 2302 |
2247 } // namespace content | 2303 } // namespace content |
OLD | NEW |