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

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

Issue 2810813004: Hide fullscreen rotation jank (Closed)
Patch Set: make overlay_video_mode not affect background transparency 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.
mlamouri (slow - plz ping) 2017/06/05 12:57:44 We should probably have a content or cc Feature in
steimel 2017/06/06 03:07:54 Good idea. I don't know much about hiding features
564 if (content_view_core_ &&
565 view_.GetPhysicalBackingSize() != prev_physical_backing_size_) {
566 bool is_fullscreen = content_view_core_->GetWebContents()->IsFullscreen();
567 if (is_fullscreen || was_fullscreen_) {
568 fullscreen_transitioning_ = true;
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 // TODO change logic to not require these variables.
578 was_fullscreen_ = is_fullscreen;
579 prev_physical_backing_size_ = view_.GetPhysicalBackingSize();
580 }
562 host_->WasResized(); 581 host_->WasResized();
563 } 582 }
564 583
565 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) { 584 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) {
566 // Ignore the given size as only the Java code has the power to 585 // Ignore the given size as only the Java code has the power to
567 // resize the view on Android. 586 // resize the view on Android.
568 default_bounds_ = gfx::Rect(default_bounds_.origin(), size); 587 default_bounds_ = gfx::Rect(default_bounds_.origin(), size);
569 } 588 }
570 589
571 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { 590 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) {
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 bad_message::RWH_BAD_FRAME_SINK_REQUEST); 1193 bad_message::RWH_BAD_FRAME_SINK_REQUEST);
1175 return; 1194 return;
1176 } 1195 }
1177 delegated_frame_host_->CompositorFrameSinkChanged(); 1196 delegated_frame_host_->CompositorFrameSinkChanged();
1178 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink; 1197 renderer_compositor_frame_sink_ = renderer_compositor_frame_sink;
1179 // Accumulated resources belong to the old RendererCompositorFrameSink and 1198 // Accumulated resources belong to the old RendererCompositorFrameSink and
1180 // should not be returned. 1199 // should not be returned.
1181 surface_returned_resources_.clear(); 1200 surface_returned_resources_.clear();
1182 } 1201 }
1183 1202
1203 bool RenderWidgetHostViewAndroid::CheckForFullscreenTransitionJank(
1204 const cc::CompositorFrameMetadata& metadata) {
1205 // TODO simplify this logic.
1206 if (content_view_core_ &&
1207 content_view_core_->GetWebContents()->IsFullscreen() != was_fullscreen_) {
1208 was_fullscreen_ = !was_fullscreen_;
mlamouri (slow - plz ping) 2017/06/05 12:57:44 Here and below, it is fairly confusing that a meth
steimel 2017/06/06 03:07:54 I'm assuming you mean "ends up modifying state". I
1209 fullscreen_transitioning_ = true;
1210 return true;
1211 }
1212
1213 // We only check for fullscreen jank during a fullscreen transition.
1214 if (fullscreen_transitioning_) {
1215 bool mismatched_fullscreen_states =
1216 content_view_core_ &&
1217 (content_view_core_->GetWebContents()->IsFullscreen() !=
1218 metadata.is_fullscreen);
1219 bool mismatched_layer_sizes =
1220 view_.GetPhysicalBackingSize() != metadata.device_viewport_size;
1221 if (mismatched_fullscreen_states || mismatched_layer_sizes) {
1222 return true;
1223 } else {
1224 // Done with current fullscreen transition.
1225 fullscreen_transitioning_ = false;
1226 }
1227 }
1228
1229 return false;
1230 }
1231
1184 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( 1232 void RenderWidgetHostViewAndroid::SubmitCompositorFrame(
1185 const cc::LocalSurfaceId& local_surface_id, 1233 const cc::LocalSurfaceId& local_surface_id,
1186 cc::CompositorFrame frame) { 1234 cc::CompositorFrame frame) {
1187 if (!delegated_frame_host_) { 1235 if (!delegated_frame_host_) {
1188 DCHECK(!using_browser_compositor_); 1236 DCHECK(!using_browser_compositor_);
1189 return; 1237 return;
1190 } 1238 }
1191 1239
1240 bool has_jank = CheckForFullscreenTransitionJank(frame.metadata);
1241
1192 last_scroll_offset_ = frame.metadata.root_scroll_offset; 1242 last_scroll_offset_ = frame.metadata.root_scroll_offset;
1193 DCHECK(!frame.render_pass_list.empty()); 1243 DCHECK(!frame.render_pass_list.empty());
1194 1244
1195 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); 1245 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
1196 current_surface_size_ = root_pass->output_rect.size(); 1246 current_surface_size_ = root_pass->output_rect.size();
1197 bool is_transparent = root_pass->has_transparent_background; 1247 bool is_transparent = root_pass->has_transparent_background;
1198 1248
1199 cc::CompositorFrameMetadata metadata = frame.metadata.Clone(); 1249 cc::CompositorFrameMetadata metadata = frame.metadata.Clone();
1200 1250
1201 bool has_content = !current_surface_size_.IsEmpty(); 1251 bool has_content = !current_surface_size_.IsEmpty();
(...skipping 16 matching lines...) Expand all
1218 frame_evictor_->SwappedFrame(!host_->is_hidden()); 1268 frame_evictor_->SwappedFrame(!host_->is_hidden());
1219 AcknowledgeBeginFrame(ack); 1269 AcknowledgeBeginFrame(ack);
1220 } 1270 }
1221 1271
1222 if (host_->is_hidden()) 1272 if (host_->is_hidden())
1223 RunAckCallbacks(); 1273 RunAckCallbacks();
1224 1274
1225 // As the metadata update may trigger view invalidation, always call it after 1275 // As the metadata update may trigger view invalidation, always call it after
1226 // any potential compositor scheduling. 1276 // any potential compositor scheduling.
1227 OnFrameMetadataUpdated(std::move(metadata), is_transparent); 1277 OnFrameMetadataUpdated(std::move(metadata), is_transparent);
1278
1279 if (has_jank) {
1280 TRACE_EVENT_BEGIN0("frame_eviction", "RenderWidgetHostViewAndroid::SubmitCom positorFrame Eviction");
1281 EvictDelegatedFrame();
1282 TRACE_EVENT_END0("frame_eviction", "RenderWidgetHostViewAndroid::SubmitCompo sitorFrame Eviction");
1283 UpdateBackgroundColor(SK_ColorBLACK);
1284 }
mlamouri (slow - plz ping) 2017/06/05 12:57:44 For my culture, why do we have to repeat the logic
steimel 2017/06/06 03:07:54 I have fixed this in my cleanup. It was separate h
1228 } 1285 }
1229 1286
1230 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { 1287 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() {
1231 DCHECK(!delegated_frame_host_ || 1288 DCHECK(!delegated_frame_host_ ||
1232 delegated_frame_host_->HasDelegatedContent() == 1289 delegated_frame_host_->HasDelegatedContent() ==
1233 frame_evictor_->HasFrame()); 1290 frame_evictor_->HasFrame());
1234 1291
1235 if (!delegated_frame_host_) 1292 if (!delegated_frame_host_)
1236 return; 1293 return;
1237 1294
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
2238 2295
2239 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); 2296 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor();
2240 if (!compositor) 2297 if (!compositor)
2241 return; 2298 return;
2242 2299
2243 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( 2300 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>(
2244 overscroll_refresh_handler, compositor, view_.GetDipScale()); 2301 overscroll_refresh_handler, compositor, view_.GetDipScale());
2245 } 2302 }
2246 2303
2247 } // namespace content 2304 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698