Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 2810813004: Hide fullscreen rotation jank (Closed)
Patch Set: Added as feature (temporarily enabled-by-default for testing CQ failures). Other cr feedback Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "content/common/gpu_stream_constants.h" 64 #include "content/common/gpu_stream_constants.h"
65 #include "content/common/input_messages.h" 65 #include "content/common/input_messages.h"
66 #include "content/common/site_isolation_policy.h" 66 #include "content/common/site_isolation_policy.h"
67 #include "content/common/view_messages.h" 67 #include "content/common/view_messages.h"
68 #include "content/public/browser/android/compositor.h" 68 #include "content/public/browser/android/compositor.h"
69 #include "content/public/browser/android/synchronous_compositor_client.h" 69 #include "content/public/browser/android/synchronous_compositor_client.h"
70 #include "content/public/browser/browser_thread.h" 70 #include "content/public/browser/browser_thread.h"
71 #include "content/public/browser/devtools_agent_host.h" 71 #include "content/public/browser/devtools_agent_host.h"
72 #include "content/public/browser/render_view_host.h" 72 #include "content/public/browser/render_view_host.h"
73 #include "content/public/browser/render_widget_host_iterator.h" 73 #include "content/public/browser/render_widget_host_iterator.h"
74 #include "content/public/common/content_features.h"
74 #include "content/public/common/content_switches.h" 75 #include "content/public/common/content_switches.h"
75 #include "gpu/command_buffer/client/gles2_implementation.h" 76 #include "gpu/command_buffer/client/gles2_implementation.h"
76 #include "gpu/command_buffer/client/gles2_interface.h" 77 #include "gpu/command_buffer/client/gles2_interface.h"
77 #include "gpu/config/gpu_driver_bug_workaround_type.h" 78 #include "gpu/config/gpu_driver_bug_workaround_type.h"
78 #include "ipc/ipc_message_macros.h" 79 #include "ipc/ipc_message_macros.h"
79 #include "ipc/ipc_message_start.h" 80 #include "ipc/ipc_message_start.h"
80 #include "skia/ext/image_operations.h" 81 #include "skia/ext/image_operations.h"
81 #include "third_party/khronos/GLES2/gl2.h" 82 #include "third_party/khronos/GLES2/gl2.h"
82 #include "third_party/khronos/GLES2/gl2ext.h" 83 #include "third_party/khronos/GLES2/gl2ext.h"
83 #include "third_party/skia/include/core/SkCanvas.h" 84 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 559
559 RenderWidgetHost* 560 RenderWidgetHost*
560 RenderWidgetHostViewAndroid::GetRenderWidgetHost() const { 561 RenderWidgetHostViewAndroid::GetRenderWidgetHost() const {
561 return host_; 562 return host_;
562 } 563 }
563 564
564 void RenderWidgetHostViewAndroid::WasResized() { 565 void RenderWidgetHostViewAndroid::WasResized() {
565 host_->WasResized(); 566 host_->WasResized();
566 } 567 }
567 568
569 void RenderWidgetHostViewAndroid::OnFullscreenStateChanged(
570 bool entered_fullscreen) {
571 web_contents_is_fullscreen_ = entered_fullscreen;
572 UpdateFullscreenState(false);
573 }
574
568 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) { 575 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) {
569 // Ignore the given size as only the Java code has the power to 576 // Ignore the given size as only the Java code has the power to
570 // resize the view on Android. 577 // resize the view on Android.
571 default_bounds_ = gfx::Rect(default_bounds_.origin(), size); 578 default_bounds_ = gfx::Rect(default_bounds_.origin(), size);
572 } 579 }
573 580
574 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { 581 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) {
575 default_bounds_ = rect; 582 default_bounds_ = rect;
576 } 583 }
577 584
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 bad_message::RWH_BAD_FRAME_SINK_REQUEST); 1184 bad_message::RWH_BAD_FRAME_SINK_REQUEST);
1178 return; 1185 return;
1179 } 1186 }
1180 delegated_frame_host_->CompositorFrameSinkChanged(); 1187 delegated_frame_host_->CompositorFrameSinkChanged();
1181 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink; 1188 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink;
1182 // Accumulated resources belong to the old RendererCompositorFrameSink and 1189 // Accumulated resources belong to the old RendererCompositorFrameSink and
1183 // should not be returned. 1190 // should not be returned.
1184 surface_returned_resources_.clear(); 1191 surface_returned_resources_.clear();
1185 } 1192 }
1186 1193
1194 void RenderWidgetHostViewAndroid::UpdateFullscreenState(
1195 bool physical_backing_resized) {
1196 if (!base::FeatureList::IsEnabled(features::kHideFullscreenTransitionJank))
1197 return;
1198
1199 bool mismatched_fullscreen_states =
1200 web_contents_is_fullscreen_ != current_frame_is_fullscreen_;
1201 bool mismatched_sizes =
1202 view_.GetPhysicalBackingSize() != current_surface_size_;
1203
1204 if (physical_backing_resized)
1205 fullscreen_transition_awaiting_resize_ = false;
Khushal 2017/06/15 23:44:50 I'm still a bit unsure about whether this is the b
1206
1207 switch (fullscreen_state_) {
1208 // From kNotFullscreen, we transition to kEnteringFullscreen whenever the
1209 // fullscreen state changes.
1210 case FullscreenState::kNotFullscreen:
1211 if (mismatched_fullscreen_states) {
1212 DCHECK(web_contents_is_fullscreen_);
1213 DCHECK(!physical_backing_resized);
1214 fullscreen_state_ = FullscreenState::kEnteringFullscreen;
1215 fullscreen_transition_awaiting_resize_ = true;
1216 }
1217 break;
1218 // From kFullscreen, we transition to kExitingFullscreen on a fullscreen
1219 // state change, or to kFullscreenRotation if we get a new size.
1220 case FullscreenState::kFullscreen:
1221 if (mismatched_fullscreen_states) {
1222 DCHECK(!web_contents_is_fullscreen_);
1223 DCHECK(!physical_backing_resized);
1224 fullscreen_state_ = FullscreenState::kExitingFullscreen;
1225 fullscreen_transition_awaiting_resize_ = true;
1226 }
1227 if (mismatched_sizes)
1228 fullscreen_state_ = FullscreenState::kFullscreenRotation;
1229 break;
1230 // From any transition state, once we receive a "good" frame we transition
1231 // to the proper "good" state.
1232 case FullscreenState::kExitingFullscreen:
1233 case FullscreenState::kEnteringFullscreen:
1234 case FullscreenState::kFullscreenRotation:
1235 if (!mismatched_fullscreen_states && !mismatched_sizes &&
1236 !fullscreen_transition_awaiting_resize_) {
1237 fullscreen_state_ = web_contents_is_fullscreen_
1238 ? FullscreenState::kFullscreen
1239 : FullscreenState::kNotFullscreen;
1240 }
1241 break;
1242 }
1243
1244 if (fullscreen_state_ == FullscreenState::kEnteringFullscreen ||
1245 fullscreen_state_ == FullscreenState::kExitingFullscreen ||
1246 fullscreen_state_ == FullscreenState::kFullscreenRotation) {
1247 EvictDelegatedFrame();
1248 UpdateBackgroundColor(SK_ColorBLACK);
1249 }
1250 }
1251
1187 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( 1252 void RenderWidgetHostViewAndroid::SubmitCompositorFrame(
1188 const cc::LocalSurfaceId& local_surface_id, 1253 const cc::LocalSurfaceId& local_surface_id,
1189 cc::CompositorFrame frame) { 1254 cc::CompositorFrame frame) {
1190 if (!delegated_frame_host_) { 1255 if (!delegated_frame_host_) {
1191 DCHECK(!using_browser_compositor_); 1256 DCHECK(!using_browser_compositor_);
1192 return; 1257 return;
1193 } 1258 }
1194 1259
1195 last_scroll_offset_ = frame.metadata.root_scroll_offset; 1260 last_scroll_offset_ = frame.metadata.root_scroll_offset;
1196 DCHECK(!frame.render_pass_list.empty()); 1261 DCHECK(!frame.render_pass_list.empty());
1197 1262
1198 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); 1263 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
1199 current_surface_size_ = root_pass->output_rect.size(); 1264 current_surface_size_ = root_pass->output_rect.size();
1265 current_frame_is_fullscreen_ = frame.metadata.is_fullscreen;
1200 bool is_transparent = root_pass->has_transparent_background; 1266 bool is_transparent = root_pass->has_transparent_background;
1201 1267
1202 cc::CompositorFrameMetadata metadata = frame.metadata.Clone(); 1268 cc::CompositorFrameMetadata metadata = frame.metadata.Clone();
1203 1269
1204 bool has_content = !current_surface_size_.IsEmpty(); 1270 bool has_content = !current_surface_size_.IsEmpty();
1205 1271
1206 base::Closure ack_callback = 1272 base::Closure ack_callback =
1207 base::Bind(&RenderWidgetHostViewAndroid::SendReclaimCompositorResources, 1273 base::Bind(&RenderWidgetHostViewAndroid::SendReclaimCompositorResources,
1208 weak_ptr_factory_.GetWeakPtr(), true /* is_swap_ack */); 1274 weak_ptr_factory_.GetWeakPtr(), true /* is_swap_ack */);
1209 1275
(...skipping 11 matching lines...) Expand all
1221 frame_evictor_->SwappedFrame(!host_->is_hidden()); 1287 frame_evictor_->SwappedFrame(!host_->is_hidden());
1222 AcknowledgeBeginFrame(ack); 1288 AcknowledgeBeginFrame(ack);
1223 } 1289 }
1224 1290
1225 if (host_->is_hidden()) 1291 if (host_->is_hidden())
1226 RunAckCallbacks(); 1292 RunAckCallbacks();
1227 1293
1228 // As the metadata update may trigger view invalidation, always call it after 1294 // As the metadata update may trigger view invalidation, always call it after
1229 // any potential compositor scheduling. 1295 // any potential compositor scheduling.
1230 OnFrameMetadataUpdated(std::move(metadata), is_transparent); 1296 OnFrameMetadataUpdated(std::move(metadata), is_transparent);
1297
1298 UpdateFullscreenState(false);
1231 } 1299 }
1232 1300
1233 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { 1301 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() {
1234 DCHECK(!delegated_frame_host_ || 1302 DCHECK(!delegated_frame_host_ ||
1235 delegated_frame_host_->HasDelegatedContent() == 1303 delegated_frame_host_->HasDelegatedContent() ==
1236 frame_evictor_->HasFrame()); 1304 frame_evictor_->HasFrame());
1237 1305
1238 if (!delegated_frame_host_) 1306 if (!delegated_frame_host_)
1239 return; 1307 return;
1240 1308
1241 if (!delegated_frame_host_->HasDelegatedContent()) 1309 if (!delegated_frame_host_->HasDelegatedContent())
1242 return; 1310 return;
1243 1311
1244 frame_evictor_->DiscardedFrame(); 1312 frame_evictor_->DiscardedFrame();
1245 delegated_frame_host_->DestroyDelegatedContent(); 1313 delegated_frame_host_->DestroyDelegatedContent();
1314 current_surface_size_.SetSize(0, 0);
1246 } 1315 }
1247 1316
1248 void RenderWidgetHostViewAndroid::OnDidNotProduceFrame( 1317 void RenderWidgetHostViewAndroid::OnDidNotProduceFrame(
1249 const cc::BeginFrameAck& ack) { 1318 const cc::BeginFrameAck& ack) {
1250 if (!delegated_frame_host_) { 1319 if (!delegated_frame_host_) {
1251 // We are not using the browser compositor and there's no DisplayScheduler 1320 // We are not using the browser compositor and there's no DisplayScheduler
1252 // that needs to be notified about the BeginFrameAck, so we can drop it. 1321 // that needs to be notified about the BeginFrameAck, so we can drop it.
1253 DCHECK(!using_browser_compositor_); 1322 DCHECK(!using_browser_compositor_);
1254 return; 1323 return;
1255 } 1324 }
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 1992
1924 void RenderWidgetHostViewAndroid::SetTextHandlesTemporarilyHidden(bool hidden) { 1993 void RenderWidgetHostViewAndroid::SetTextHandlesTemporarilyHidden(bool hidden) {
1925 if (touch_selection_controller_) 1994 if (touch_selection_controller_)
1926 touch_selection_controller_->SetTemporarilyHidden(hidden); 1995 touch_selection_controller_->SetTemporarilyHidden(hidden);
1927 } 1996 }
1928 1997
1929 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { 1998 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const {
1930 return cached_background_color_; 1999 return cached_background_color_;
1931 } 2000 }
1932 2001
2002 bool RenderWidgetHostViewAndroid::CanShowThumbnailPlaceholder() const {
2003 return !(fullscreen_state_ == FullscreenState::kEnteringFullscreen ||
2004 fullscreen_state_ == FullscreenState::kExitingFullscreen ||
2005 fullscreen_state_ == FullscreenState::kFullscreenRotation);
2006 }
2007
1933 void RenderWidgetHostViewAndroid::SetIsInVR(bool is_in_vr) { 2008 void RenderWidgetHostViewAndroid::SetIsInVR(bool is_in_vr) {
1934 is_in_vr_ = is_in_vr; 2009 is_in_vr_ = is_in_vr;
1935 } 2010 }
1936 2011
1937 bool RenderWidgetHostViewAndroid::IsInVR() const { 2012 bool RenderWidgetHostViewAndroid::IsInVR() const {
1938 return is_in_vr_; 2013 return is_in_vr_;
1939 } 2014 }
1940 2015
1941 void RenderWidgetHostViewAndroid::DidOverscroll( 2016 void RenderWidgetHostViewAndroid::DidOverscroll(
1942 const ui::DidOverscrollParams& params) { 2017 const ui::DidOverscrollParams& params) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 // unintended shift+click interpretation of all accessibility clicks. 2127 // unintended shift+click interpretation of all accessibility clicks.
2053 // See crbug.com/443247. 2128 // See crbug.com/443247.
2054 if (web_gesture.GetType() == blink::WebInputEvent::kGestureTap && 2129 if (web_gesture.GetType() == blink::WebInputEvent::kGestureTap &&
2055 web_gesture.GetModifiers() == blink::WebInputEvent::kShiftKey) { 2130 web_gesture.GetModifiers() == blink::WebInputEvent::kShiftKey) {
2056 web_gesture.SetModifiers(blink::WebInputEvent::kNoModifiers); 2131 web_gesture.SetModifiers(blink::WebInputEvent::kNoModifiers);
2057 } 2132 }
2058 SendGestureEvent(web_gesture); 2133 SendGestureEvent(web_gesture);
2059 } 2134 }
2060 2135
2061 void RenderWidgetHostViewAndroid::OnPhysicalBackingSizeChanged() { 2136 void RenderWidgetHostViewAndroid::OnPhysicalBackingSizeChanged() {
2137 // If we're entering a fullscreen transition, show black until the transition
2138 // is completed.
2139 UpdateFullscreenState(true);
2062 WasResized(); 2140 WasResized();
2063 } 2141 }
2064 2142
2065 void RenderWidgetHostViewAndroid::OnContentViewCoreDestroyed() { 2143 void RenderWidgetHostViewAndroid::OnContentViewCoreDestroyed() {
2066 SetContentViewCore(NULL); 2144 SetContentViewCore(NULL);
2067 overscroll_controller_.reset(); 2145 overscroll_controller_.reset();
2068 } 2146 }
2069 2147
2070 void RenderWidgetHostViewAndroid::OnRootWindowVisibilityChanged(bool visible) { 2148 void RenderWidgetHostViewAndroid::OnRootWindowVisibilityChanged(bool visible) {
2071 TRACE_EVENT1("browser", 2149 TRACE_EVENT1("browser",
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 2358
2281 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); 2359 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor();
2282 if (!compositor) 2360 if (!compositor)
2283 return; 2361 return;
2284 2362
2285 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( 2363 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>(
2286 overscroll_refresh_handler, compositor, view_.GetDipScale()); 2364 overscroll_refresh_handler, compositor, view_.GetDipScale());
2287 } 2365 }
2288 2366
2289 } // namespace content 2367 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698