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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 #include "content/common/gpu_stream_constants.h" | 65 #include "content/common/gpu_stream_constants.h" |
66 #include "content/common/input_messages.h" | 66 #include "content/common/input_messages.h" |
67 #include "content/common/site_isolation_policy.h" | 67 #include "content/common/site_isolation_policy.h" |
68 #include "content/common/view_messages.h" | 68 #include "content/common/view_messages.h" |
69 #include "content/public/browser/android/compositor.h" | 69 #include "content/public/browser/android/compositor.h" |
70 #include "content/public/browser/android/synchronous_compositor_client.h" | 70 #include "content/public/browser/android/synchronous_compositor_client.h" |
71 #include "content/public/browser/browser_thread.h" | 71 #include "content/public/browser/browser_thread.h" |
72 #include "content/public/browser/devtools_agent_host.h" | 72 #include "content/public/browser/devtools_agent_host.h" |
73 #include "content/public/browser/render_view_host.h" | 73 #include "content/public/browser/render_view_host.h" |
74 #include "content/public/browser/render_widget_host_iterator.h" | 74 #include "content/public/browser/render_widget_host_iterator.h" |
75 #include "content/public/common/content_features.h" | |
75 #include "content/public/common/content_switches.h" | 76 #include "content/public/common/content_switches.h" |
76 #include "gpu/command_buffer/client/gles2_implementation.h" | 77 #include "gpu/command_buffer/client/gles2_implementation.h" |
77 #include "gpu/command_buffer/client/gles2_interface.h" | 78 #include "gpu/command_buffer/client/gles2_interface.h" |
78 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 79 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
79 #include "ipc/ipc_message_macros.h" | 80 #include "ipc/ipc_message_macros.h" |
80 #include "ipc/ipc_message_start.h" | 81 #include "ipc/ipc_message_start.h" |
81 #include "skia/ext/image_operations.h" | 82 #include "skia/ext/image_operations.h" |
82 #include "third_party/khronos/GLES2/gl2.h" | 83 #include "third_party/khronos/GLES2/gl2.h" |
83 #include "third_party/khronos/GLES2/gl2ext.h" | 84 #include "third_party/khronos/GLES2/gl2ext.h" |
84 #include "third_party/skia/include/core/SkCanvas.h" | 85 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
462 gesture_provider_(ui::GetGestureProviderConfig( | 463 gesture_provider_(ui::GetGestureProviderConfig( |
463 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 464 ui::GestureProviderConfigType::CURRENT_PLATFORM), |
464 this), | 465 this), |
465 stylus_text_selector_(this), | 466 stylus_text_selector_(this), |
466 using_browser_compositor_(CompositorImpl::IsInitialized()), | 467 using_browser_compositor_(CompositorImpl::IsInitialized()), |
467 synchronous_compositor_client_(nullptr), | 468 synchronous_compositor_client_(nullptr), |
468 frame_evictor_(new viz::FrameEvictor(this)), | 469 frame_evictor_(new viz::FrameEvictor(this)), |
469 observing_root_window_(false), | 470 observing_root_window_(false), |
470 prev_top_shown_pix_(0.f), | 471 prev_top_shown_pix_(0.f), |
471 prev_bottom_shown_pix_(0.f), | 472 prev_bottom_shown_pix_(0.f), |
473 fullscreen_jank_detector_(new FullscreenJankDetector()), | |
472 mouse_wheel_phase_handler_(widget_host, this), | 474 mouse_wheel_phase_handler_(widget_host, this), |
473 weak_ptr_factory_(this) { | 475 weak_ptr_factory_(this) { |
474 // Set the layer which will hold the content layer for this view. The content | 476 // Set the layer which will hold the content layer for this view. The content |
475 // layer is managed by the DelegatedFrameHost. | 477 // layer is managed by the DelegatedFrameHost. |
476 view_.SetLayer(cc::Layer::Create()); | 478 view_.SetLayer(cc::Layer::Create()); |
477 view_.SetLayout(ui::ViewAndroid::LayoutParams::MatchParent()); | 479 view_.SetLayout(ui::ViewAndroid::LayoutParams::MatchParent()); |
478 | 480 |
479 if (using_browser_compositor_) { | 481 if (using_browser_compositor_) { |
480 cc::FrameSinkId frame_sink_id = | 482 cc::FrameSinkId frame_sink_id = |
481 host_->AllocateFrameSinkId(false /* is_guest_view_hack */); | 483 host_->AllocateFrameSinkId(false /* is_guest_view_hack */); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 | 564 |
563 RenderWidgetHost* | 565 RenderWidgetHost* |
564 RenderWidgetHostViewAndroid::GetRenderWidgetHost() const { | 566 RenderWidgetHostViewAndroid::GetRenderWidgetHost() const { |
565 return host_; | 567 return host_; |
566 } | 568 } |
567 | 569 |
568 void RenderWidgetHostViewAndroid::WasResized() { | 570 void RenderWidgetHostViewAndroid::WasResized() { |
569 host_->WasResized(); | 571 host_->WasResized(); |
570 } | 572 } |
571 | 573 |
574 void RenderWidgetHostViewAndroid::OnFullscreenStateChanged() { | |
575 fullscreen_jank_detector_->OnFullscreenStateChanged( | |
576 host_->delegate()->IsFullscreenForCurrentTab()); | |
577 EvictFrameIfNecessary(); | |
578 } | |
579 | |
572 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) { | 580 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) { |
573 // Ignore the given size as only the Java code has the power to | 581 // Ignore the given size as only the Java code has the power to |
574 // resize the view on Android. | 582 // resize the view on Android. |
575 default_bounds_ = gfx::Rect(default_bounds_.origin(), size); | 583 default_bounds_ = gfx::Rect(default_bounds_.origin(), size); |
576 } | 584 } |
577 | 585 |
578 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { | 586 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { |
579 default_bounds_ = rect; | 587 default_bounds_ = rect; |
580 } | 588 } |
581 | 589 |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1188 bad_message::RWH_BAD_FRAME_SINK_REQUEST); | 1196 bad_message::RWH_BAD_FRAME_SINK_REQUEST); |
1189 return; | 1197 return; |
1190 } | 1198 } |
1191 delegated_frame_host_->CompositorFrameSinkChanged(); | 1199 delegated_frame_host_->CompositorFrameSinkChanged(); |
1192 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink; | 1200 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink; |
1193 // Accumulated resources belong to the old RendererCompositorFrameSink and | 1201 // Accumulated resources belong to the old RendererCompositorFrameSink and |
1194 // should not be returned. | 1202 // should not be returned. |
1195 surface_returned_resources_.clear(); | 1203 surface_returned_resources_.clear(); |
1196 } | 1204 } |
1197 | 1205 |
1206 void RenderWidgetHostViewAndroid::EvictFrameIfNecessary() { | |
1207 // TODO(steimel): Remove this feature flag once we're confident that the | |
1208 // fullscreen transition hiding is working correctly. | |
mlamouri (slow - plz ping)
2017/07/05 13:55:31
I would rephrase the TODO to say that we should re
| |
1209 if (base::FeatureList::IsEnabled(features::kHideFullscreenTransitionJank) && | |
1210 fullscreen_jank_detector_->IsInFullscreenTransition()) { | |
1211 // When we're in a fullscreen transition, we don't want to show a frame | |
1212 // since it will look janky, so instead we show black. | |
1213 EvictDelegatedFrame(); | |
1214 UpdateBackgroundColor(SK_ColorBLACK); | |
1215 ClearThumbnailPlaceholder(); | |
1216 } | |
1217 } | |
1218 | |
1198 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( | 1219 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( |
1199 const cc::LocalSurfaceId& local_surface_id, | 1220 const cc::LocalSurfaceId& local_surface_id, |
1200 cc::CompositorFrame frame) { | 1221 cc::CompositorFrame frame) { |
1201 if (!delegated_frame_host_) { | 1222 if (!delegated_frame_host_) { |
1202 DCHECK(!using_browser_compositor_); | 1223 DCHECK(!using_browser_compositor_); |
1203 return; | 1224 return; |
1204 } | 1225 } |
1205 | 1226 |
1206 last_scroll_offset_ = frame.metadata.root_scroll_offset; | 1227 last_scroll_offset_ = frame.metadata.root_scroll_offset; |
1207 DCHECK(!frame.render_pass_list.empty()); | 1228 DCHECK(!frame.render_pass_list.empty()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1247 frame_evictor_->HasFrame()); | 1268 frame_evictor_->HasFrame()); |
1248 | 1269 |
1249 if (!delegated_frame_host_) | 1270 if (!delegated_frame_host_) |
1250 return; | 1271 return; |
1251 | 1272 |
1252 if (!delegated_frame_host_->HasDelegatedContent()) | 1273 if (!delegated_frame_host_->HasDelegatedContent()) |
1253 return; | 1274 return; |
1254 | 1275 |
1255 frame_evictor_->DiscardedFrame(); | 1276 frame_evictor_->DiscardedFrame(); |
1256 delegated_frame_host_->DestroyDelegatedContent(); | 1277 delegated_frame_host_->DestroyDelegatedContent(); |
1278 current_surface_size_.SetSize(0, 0); | |
1257 } | 1279 } |
1258 | 1280 |
1259 void RenderWidgetHostViewAndroid::OnDidNotProduceFrame( | 1281 void RenderWidgetHostViewAndroid::OnDidNotProduceFrame( |
1260 const cc::BeginFrameAck& ack) { | 1282 const cc::BeginFrameAck& ack) { |
1261 if (!delegated_frame_host_) { | 1283 if (!delegated_frame_host_) { |
1262 // We are not using the browser compositor and there's no DisplayScheduler | 1284 // We are not using the browser compositor and there's no DisplayScheduler |
1263 // that needs to be notified about the BeginFrameAck, so we can drop it. | 1285 // that needs to be notified about the BeginFrameAck, so we can drop it. |
1264 DCHECK(!using_browser_compositor_); | 1286 DCHECK(!using_browser_compositor_); |
1265 return; | 1287 return; |
1266 } | 1288 } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1490 prev_bottom_shown_pix_ = bottom_shown_pix; | 1512 prev_bottom_shown_pix_ = bottom_shown_pix; |
1491 } | 1513 } |
1492 | 1514 |
1493 // All offsets and sizes are in CSS pixels. | 1515 // All offsets and sizes are in CSS pixels. |
1494 content_view_core_->UpdateFrameInfo( | 1516 content_view_core_->UpdateFrameInfo( |
1495 frame_metadata.root_scroll_offset, frame_metadata.page_scale_factor, | 1517 frame_metadata.root_scroll_offset, frame_metadata.page_scale_factor, |
1496 gfx::Vector2dF(frame_metadata.min_page_scale_factor, | 1518 gfx::Vector2dF(frame_metadata.min_page_scale_factor, |
1497 frame_metadata.max_page_scale_factor), | 1519 frame_metadata.max_page_scale_factor), |
1498 frame_metadata.root_layer_size, frame_metadata.scrollable_viewport_size, | 1520 frame_metadata.root_layer_size, frame_metadata.scrollable_viewport_size, |
1499 top_content_offset, top_shown_pix, top_changed, is_mobile_optimized); | 1521 top_content_offset, top_shown_pix, top_changed, is_mobile_optimized); |
1522 | |
1523 fullscreen_jank_detector_->OnFrameMetadataUpdated( | |
1524 frame_metadata.is_fullscreen, current_surface_size_); | |
1525 EvictFrameIfNecessary(); | |
1500 } | 1526 } |
1501 | 1527 |
1502 void RenderWidgetHostViewAndroid::ShowInternal() { | 1528 void RenderWidgetHostViewAndroid::ShowInternal() { |
1503 bool show = is_showing_ && is_window_activity_started_ && is_window_visible_; | 1529 bool show = is_showing_ && is_window_activity_started_ && is_window_visible_; |
1504 if (!show) | 1530 if (!show) |
1505 return; | 1531 return; |
1506 | 1532 |
1507 if (!host_ || !host_->is_hidden()) | 1533 if (!host_ || !host_->is_hidden()) |
1508 return; | 1534 return; |
1509 | 1535 |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1972 | 1998 |
1973 void RenderWidgetHostViewAndroid::SetTextHandlesTemporarilyHidden(bool hidden) { | 1999 void RenderWidgetHostViewAndroid::SetTextHandlesTemporarilyHidden(bool hidden) { |
1974 if (touch_selection_controller_) | 2000 if (touch_selection_controller_) |
1975 touch_selection_controller_->SetTemporarilyHidden(hidden); | 2001 touch_selection_controller_->SetTemporarilyHidden(hidden); |
1976 } | 2002 } |
1977 | 2003 |
1978 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { | 2004 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { |
1979 return cached_background_color_; | 2005 return cached_background_color_; |
1980 } | 2006 } |
1981 | 2007 |
2008 void RenderWidgetHostViewAndroid::ClearThumbnailPlaceholder() { | |
2009 view_.ClearThumbnailPlaceholder(); | |
2010 } | |
2011 | |
1982 void RenderWidgetHostViewAndroid::SetIsInVR(bool is_in_vr) { | 2012 void RenderWidgetHostViewAndroid::SetIsInVR(bool is_in_vr) { |
1983 is_in_vr_ = is_in_vr; | 2013 is_in_vr_ = is_in_vr; |
1984 } | 2014 } |
1985 | 2015 |
1986 bool RenderWidgetHostViewAndroid::IsInVR() const { | 2016 bool RenderWidgetHostViewAndroid::IsInVR() const { |
1987 return is_in_vr_; | 2017 return is_in_vr_; |
1988 } | 2018 } |
1989 | 2019 |
1990 void RenderWidgetHostViewAndroid::DidOverscroll( | 2020 void RenderWidgetHostViewAndroid::DidOverscroll( |
1991 const ui::DidOverscrollParams& params) { | 2021 const ui::DidOverscrollParams& params) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2101 // unintended shift+click interpretation of all accessibility clicks. | 2131 // unintended shift+click interpretation of all accessibility clicks. |
2102 // See crbug.com/443247. | 2132 // See crbug.com/443247. |
2103 if (web_gesture.GetType() == blink::WebInputEvent::kGestureTap && | 2133 if (web_gesture.GetType() == blink::WebInputEvent::kGestureTap && |
2104 web_gesture.GetModifiers() == blink::WebInputEvent::kShiftKey) { | 2134 web_gesture.GetModifiers() == blink::WebInputEvent::kShiftKey) { |
2105 web_gesture.SetModifiers(blink::WebInputEvent::kNoModifiers); | 2135 web_gesture.SetModifiers(blink::WebInputEvent::kNoModifiers); |
2106 } | 2136 } |
2107 SendGestureEvent(web_gesture); | 2137 SendGestureEvent(web_gesture); |
2108 } | 2138 } |
2109 | 2139 |
2110 void RenderWidgetHostViewAndroid::OnPhysicalBackingSizeChanged() { | 2140 void RenderWidgetHostViewAndroid::OnPhysicalBackingSizeChanged() { |
2141 fullscreen_jank_detector_->OnPhysicalBackingSizeChanged( | |
2142 view_.GetPhysicalBackingSize()); | |
2143 EvictFrameIfNecessary(); | |
2111 WasResized(); | 2144 WasResized(); |
2112 } | 2145 } |
2113 | 2146 |
2114 void RenderWidgetHostViewAndroid::OnContentViewCoreDestroyed() { | 2147 void RenderWidgetHostViewAndroid::OnContentViewCoreDestroyed() { |
2115 SetContentViewCore(NULL); | 2148 SetContentViewCore(NULL); |
2116 overscroll_controller_.reset(); | 2149 overscroll_controller_.reset(); |
2117 } | 2150 } |
2118 | 2151 |
2119 void RenderWidgetHostViewAndroid::OnRootWindowVisibilityChanged(bool visible) { | 2152 void RenderWidgetHostViewAndroid::OnRootWindowVisibilityChanged(bool visible) { |
2120 TRACE_EVENT1("browser", | 2153 TRACE_EVENT1("browser", |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2319 | 2352 |
2320 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2353 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
2321 if (!compositor) | 2354 if (!compositor) |
2322 return; | 2355 return; |
2323 | 2356 |
2324 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2357 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
2325 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2358 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
2326 } | 2359 } |
2327 | 2360 |
2328 } // namespace content | 2361 } // namespace content |
OLD | NEW |