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

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

Issue 2810813004: Hide fullscreen rotation jank (Closed)
Patch Set: Refer to static layer as thumbnail layer within content. Rebase 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 558
559 RenderWidgetHost* 559 RenderWidgetHost*
560 RenderWidgetHostViewAndroid::GetRenderWidgetHost() const { 560 RenderWidgetHostViewAndroid::GetRenderWidgetHost() const {
561 return host_; 561 return host_;
562 } 562 }
563 563
564 void RenderWidgetHostViewAndroid::WasResized() { 564 void RenderWidgetHostViewAndroid::WasResized() {
565 host_->WasResized(); 565 host_->WasResized();
566 } 566 }
567 567
568 void RenderWidgetHostViewAndroid::OnFullscreenStateChanged(
569 bool entered_fullscreen) {
570 web_contents_is_fullscreen_ = entered_fullscreen;
571 EvictFrameIfNecessary(false);
Khushal 2017/06/14 19:43:14 nit: UpdateFullscreenState?
steimel 2017/06/14 21:46:16 Done.
572 }
573
568 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) { 574 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) {
569 // Ignore the given size as only the Java code has the power to 575 // Ignore the given size as only the Java code has the power to
570 // resize the view on Android. 576 // resize the view on Android.
571 default_bounds_ = gfx::Rect(default_bounds_.origin(), size); 577 default_bounds_ = gfx::Rect(default_bounds_.origin(), size);
572 } 578 }
573 579
574 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { 580 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) {
575 default_bounds_ = rect; 581 default_bounds_ = rect;
576 } 582 }
577 583
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 bad_message::RWH_BAD_FRAME_SINK_REQUEST); 1183 bad_message::RWH_BAD_FRAME_SINK_REQUEST);
1178 return; 1184 return;
1179 } 1185 }
1180 delegated_frame_host_->CompositorFrameSinkChanged(); 1186 delegated_frame_host_->CompositorFrameSinkChanged();
1181 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink; 1187 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink;
1182 // Accumulated resources belong to the old RendererCompositorFrameSink and 1188 // Accumulated resources belong to the old RendererCompositorFrameSink and
1183 // should not be returned. 1189 // should not be returned.
1184 surface_returned_resources_.clear(); 1190 surface_returned_resources_.clear();
1185 } 1191 }
1186 1192
1193 void RenderWidgetHostViewAndroid::EvictFrameIfNecessary(
1194 bool physical_backing_resized) {
1195 bool mismatched_fullscreen_states =
1196 web_contents_is_fullscreen_ != current_frame_is_fullscreen_;
1197 bool mismatched_sizes =
1198 view_.GetPhysicalBackingSize() != current_surface_size_;
1199
1200 if (physical_backing_resized) {
liberato (no reviews please) 2017/06/14 21:01:50 nit: no need for {}
steimel 2017/06/14 21:46:16 Done.
1201 awaiting_resize_ = false;
1202 }
1203
1204 switch (fullscreen_state_) {
1205 // From kNotFullscreen, we transition to kEnteringFullscreen whenever the
1206 // fullscreen state changes.
1207 case FullscreenState::kNotFullscreen:
1208 if (mismatched_fullscreen_states) {
Khushal 2017/06/14 19:43:14 Should this be a DCHECK that web_contents_is_fulls
steimel 2017/06/14 21:46:16 Done.
1209 fullscreen_state_ = FullscreenState::kEnteringFullscreen;
1210 awaiting_resize_ = !physical_backing_resized;
Khushal 2017/06/14 19:43:14 This should also be a DCHECK I think. You should d
steimel 2017/06/14 21:46:16 Done.
1211 }
1212 break;
1213 // From kFullscreen, we transition to kExitingFullscreen on a fullscreen
1214 // state change, or to kFullscreenRotation if we get a new size.
1215 case FullscreenState::kFullscreen:
1216 if (mismatched_fullscreen_states) {
Khushal 2017/06/14 19:43:14 Same DCHECKs here but flipped. Browser transitions
steimel 2017/06/14 21:46:16 Done.
1217 fullscreen_state_ = FullscreenState::kExitingFullscreen;
1218 awaiting_resize_ = !physical_backing_resized;
1219 }
1220 if (mismatched_sizes) {
1221 // TODO(steimel): Do we want to restrict this transition to when the
1222 // width/height have swapped (indicating a proper rotation), or are we
1223 // fine with any size change being treated as a rotation?
1224 fullscreen_state_ = FullscreenState::kFullscreenRotation;
Khushal 2017/06/14 19:43:14 The only reason we needed the extra state was to u
steimel 2017/06/14 21:46:16 Acknowledged.
1225 }
1226 break;
1227 // From any transition state, once we receive a "good" frame we transition
1228 // to the proper "good" state.
1229 case FullscreenState::kExitingFullscreen:
1230 case FullscreenState::kEnteringFullscreen:
1231 case FullscreenState::kFullscreenRotation:
1232 if (!mismatched_fullscreen_states && !mismatched_sizes &&
1233 !awaiting_resize_) {
1234 fullscreen_state_ = web_contents_is_fullscreen_
1235 ? FullscreenState::kFullscreen
1236 : FullscreenState::kNotFullscreen;
1237 }
1238 break;
1239 }
1240
1241 if (fullscreen_state_ == FullscreenState::kEnteringFullscreen ||
1242 fullscreen_state_ == FullscreenState::kExitingFullscreen ||
1243 fullscreen_state_ == FullscreenState::kFullscreenRotation) {
1244 EvictDelegatedFrame();
1245 UpdateBackgroundColor(SK_ColorBLACK);
1246 }
1247 }
1248
1187 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( 1249 void RenderWidgetHostViewAndroid::SubmitCompositorFrame(
1188 const cc::LocalSurfaceId& local_surface_id, 1250 const cc::LocalSurfaceId& local_surface_id,
1189 cc::CompositorFrame frame) { 1251 cc::CompositorFrame frame) {
1190 if (!delegated_frame_host_) { 1252 if (!delegated_frame_host_) {
1191 DCHECK(!using_browser_compositor_); 1253 DCHECK(!using_browser_compositor_);
1192 return; 1254 return;
1193 } 1255 }
1194 1256
1195 last_scroll_offset_ = frame.metadata.root_scroll_offset; 1257 last_scroll_offset_ = frame.metadata.root_scroll_offset;
1196 DCHECK(!frame.render_pass_list.empty()); 1258 DCHECK(!frame.render_pass_list.empty());
1197 1259
1198 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); 1260 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
1199 current_surface_size_ = root_pass->output_rect.size(); 1261 current_surface_size_ = root_pass->output_rect.size();
1262 current_frame_is_fullscreen_ = frame.metadata.is_fullscreen;
1200 bool is_transparent = root_pass->has_transparent_background; 1263 bool is_transparent = root_pass->has_transparent_background;
1201 1264
1202 cc::CompositorFrameMetadata metadata = frame.metadata.Clone(); 1265 cc::CompositorFrameMetadata metadata = frame.metadata.Clone();
1203 1266
1204 bool has_content = !current_surface_size_.IsEmpty(); 1267 bool has_content = !current_surface_size_.IsEmpty();
1205 1268
1206 base::Closure ack_callback = 1269 base::Closure ack_callback =
1207 base::Bind(&RenderWidgetHostViewAndroid::SendReclaimCompositorResources, 1270 base::Bind(&RenderWidgetHostViewAndroid::SendReclaimCompositorResources,
1208 weak_ptr_factory_.GetWeakPtr(), true /* is_swap_ack */); 1271 weak_ptr_factory_.GetWeakPtr(), true /* is_swap_ack */);
1209 1272
(...skipping 11 matching lines...) Expand all
1221 frame_evictor_->SwappedFrame(!host_->is_hidden()); 1284 frame_evictor_->SwappedFrame(!host_->is_hidden());
1222 AcknowledgeBeginFrame(ack); 1285 AcknowledgeBeginFrame(ack);
1223 } 1286 }
1224 1287
1225 if (host_->is_hidden()) 1288 if (host_->is_hidden())
1226 RunAckCallbacks(); 1289 RunAckCallbacks();
1227 1290
1228 // As the metadata update may trigger view invalidation, always call it after 1291 // As the metadata update may trigger view invalidation, always call it after
1229 // any potential compositor scheduling. 1292 // any potential compositor scheduling.
1230 OnFrameMetadataUpdated(std::move(metadata), is_transparent); 1293 OnFrameMetadataUpdated(std::move(metadata), is_transparent);
1294
1295 EvictFrameIfNecessary(false);
1231 } 1296 }
1232 1297
1233 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { 1298 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() {
1234 DCHECK(!delegated_frame_host_ || 1299 DCHECK(!delegated_frame_host_ ||
1235 delegated_frame_host_->HasDelegatedContent() == 1300 delegated_frame_host_->HasDelegatedContent() ==
1236 frame_evictor_->HasFrame()); 1301 frame_evictor_->HasFrame());
1237 1302
1238 if (!delegated_frame_host_) 1303 if (!delegated_frame_host_)
1239 return; 1304 return;
1240 1305
1241 if (!delegated_frame_host_->HasDelegatedContent()) 1306 if (!delegated_frame_host_->HasDelegatedContent())
1242 return; 1307 return;
1243 1308
1244 frame_evictor_->DiscardedFrame(); 1309 frame_evictor_->DiscardedFrame();
1245 delegated_frame_host_->DestroyDelegatedContent(); 1310 delegated_frame_host_->DestroyDelegatedContent();
1311 current_surface_size_.SetSize(0, 0);
1246 } 1312 }
1247 1313
1248 void RenderWidgetHostViewAndroid::OnDidNotProduceFrame( 1314 void RenderWidgetHostViewAndroid::OnDidNotProduceFrame(
1249 const cc::BeginFrameAck& ack) { 1315 const cc::BeginFrameAck& ack) {
1250 if (!delegated_frame_host_) { 1316 if (!delegated_frame_host_) {
1251 // We are not using the browser compositor and there's no DisplayScheduler 1317 // 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. 1318 // that needs to be notified about the BeginFrameAck, so we can drop it.
1253 DCHECK(!using_browser_compositor_); 1319 DCHECK(!using_browser_compositor_);
1254 return; 1320 return;
1255 } 1321 }
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 // unintended shift+click interpretation of all accessibility clicks. 2118 // unintended shift+click interpretation of all accessibility clicks.
2053 // See crbug.com/443247. 2119 // See crbug.com/443247.
2054 if (web_gesture.GetType() == blink::WebInputEvent::kGestureTap && 2120 if (web_gesture.GetType() == blink::WebInputEvent::kGestureTap &&
2055 web_gesture.GetModifiers() == blink::WebInputEvent::kShiftKey) { 2121 web_gesture.GetModifiers() == blink::WebInputEvent::kShiftKey) {
2056 web_gesture.SetModifiers(blink::WebInputEvent::kNoModifiers); 2122 web_gesture.SetModifiers(blink::WebInputEvent::kNoModifiers);
2057 } 2123 }
2058 SendGestureEvent(web_gesture); 2124 SendGestureEvent(web_gesture);
2059 } 2125 }
2060 2126
2061 void RenderWidgetHostViewAndroid::OnPhysicalBackingSizeChanged() { 2127 void RenderWidgetHostViewAndroid::OnPhysicalBackingSizeChanged() {
2128 // If we're entering a fullscreen transition, show black until the transition
2129 // is completed.
2130 EvictFrameIfNecessary(true);
2062 WasResized(); 2131 WasResized();
2063 } 2132 }
2064 2133
2065 void RenderWidgetHostViewAndroid::OnContentViewCoreDestroyed() { 2134 void RenderWidgetHostViewAndroid::OnContentViewCoreDestroyed() {
2066 SetContentViewCore(NULL); 2135 SetContentViewCore(NULL);
2067 overscroll_controller_.reset(); 2136 overscroll_controller_.reset();
2068 } 2137 }
2069 2138
2070 void RenderWidgetHostViewAndroid::OnRootWindowVisibilityChanged(bool visible) { 2139 void RenderWidgetHostViewAndroid::OnRootWindowVisibilityChanged(bool visible) {
2071 TRACE_EVENT1("browser", 2140 TRACE_EVENT1("browser",
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 2349
2281 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); 2350 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor();
2282 if (!compositor) 2351 if (!compositor)
2283 return; 2352 return;
2284 2353
2285 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( 2354 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>(
2286 overscroll_refresh_handler, compositor, view_.GetDipScale()); 2355 overscroll_refresh_handler, compositor, view_.GetDipScale());
2287 } 2356 }
2288 2357
2289 } // namespace content 2358 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698