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

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

Issue 2781103002: [cc] Forward BeginFrameAcks through RWHVAndroid / DFHAndroid. (Closed)
Patch Set: rebase Created 3 years, 8 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 ->OnLostResources(); 434 ->OnLostResources();
435 } 435 }
436 } 436 }
437 } 437 }
438 438
439 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( 439 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
440 RenderWidgetHostImpl* widget_host, 440 RenderWidgetHostImpl* widget_host,
441 ContentViewCoreImpl* content_view_core) 441 ContentViewCoreImpl* content_view_core)
442 : host_(widget_host), 442 : host_(widget_host),
443 begin_frame_source_(nullptr), 443 begin_frame_source_(nullptr),
444 latest_confirmed_begin_frame_source_id_(0),
445 latest_confirmed_begin_frame_sequence_number_(
446 cc::BeginFrameArgs::kInvalidFrameNumber),
444 outstanding_begin_frame_requests_(0), 447 outstanding_begin_frame_requests_(0),
445 is_showing_(!widget_host->is_hidden()), 448 is_showing_(!widget_host->is_hidden()),
446 is_window_visible_(true), 449 is_window_visible_(true),
447 is_window_activity_started_(true), 450 is_window_activity_started_(true),
448 is_in_vr_(false), 451 is_in_vr_(false),
449 content_view_core_(nullptr), 452 content_view_core_(nullptr),
450 ime_adapter_android_(this), 453 ime_adapter_android_(this),
451 cached_background_color_(SK_ColorWHITE), 454 cached_background_color_(SK_ColorWHITE),
452 view_(this), 455 view_(this),
453 gesture_provider_(ui::GetGestureProviderConfig( 456 gesture_provider_(ui::GetGestureProviderConfig(
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 cc::CompositorFrameMetadata metadata = frame.metadata.Clone(); 1144 cc::CompositorFrameMetadata metadata = frame.metadata.Clone();
1142 1145
1143 bool has_content = !current_surface_size_.IsEmpty(); 1146 bool has_content = !current_surface_size_.IsEmpty();
1144 1147
1145 base::Closure ack_callback = 1148 base::Closure ack_callback =
1146 base::Bind(&RenderWidgetHostViewAndroid::SendReclaimCompositorResources, 1149 base::Bind(&RenderWidgetHostViewAndroid::SendReclaimCompositorResources,
1147 weak_ptr_factory_.GetWeakPtr(), true /* is_swap_ack */); 1150 weak_ptr_factory_.GetWeakPtr(), true /* is_swap_ack */);
1148 1151
1149 ack_callbacks_.push(ack_callback); 1152 ack_callbacks_.push(ack_callback);
1150 1153
1154 cc::BeginFrameAck ack = frame.metadata.begin_frame_ack;
1151 if (!has_content) { 1155 if (!has_content) {
1152 DestroyDelegatedContent(); 1156 DestroyDelegatedContent();
1157
1158 ack.has_damage = false;
1159 OnBeginFrameDidNotSwap(ack);
1153 } else { 1160 } else {
1154 delegated_frame_host_->SubmitCompositorFrame(local_surface_id, 1161 delegated_frame_host_->SubmitCompositorFrame(local_surface_id,
1155 std::move(frame)); 1162 std::move(frame));
1156 frame_evictor_->SwappedFrame(!host_->is_hidden()); 1163 frame_evictor_->SwappedFrame(!host_->is_hidden());
1164 AcknowledgeBeginFrame(ack);
1157 } 1165 }
1158 1166
1159 if (host_->is_hidden()) 1167 if (host_->is_hidden())
1160 RunAckCallbacks(); 1168 RunAckCallbacks();
1161 1169
1162 // As the metadata update may trigger view invalidation, always call it after 1170 // As the metadata update may trigger view invalidation, always call it after
1163 // any potential compositor scheduling. 1171 // any potential compositor scheduling.
1164 OnFrameMetadataUpdated(std::move(metadata), is_transparent); 1172 OnFrameMetadataUpdated(std::move(metadata), is_transparent);
1165 } 1173 }
1166 1174
1167 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { 1175 void RenderWidgetHostViewAndroid::DestroyDelegatedContent() {
1168 DCHECK(!delegated_frame_host_ || 1176 DCHECK(!delegated_frame_host_ ||
1169 delegated_frame_host_->HasDelegatedContent() == 1177 delegated_frame_host_->HasDelegatedContent() ==
1170 frame_evictor_->HasFrame()); 1178 frame_evictor_->HasFrame());
1171 1179
1172 if (!delegated_frame_host_) 1180 if (!delegated_frame_host_)
1173 return; 1181 return;
1174 1182
1175 if (!delegated_frame_host_->HasDelegatedContent()) 1183 if (!delegated_frame_host_->HasDelegatedContent())
1176 return; 1184 return;
1177 1185
1178 frame_evictor_->DiscardedFrame(); 1186 frame_evictor_->DiscardedFrame();
1179 delegated_frame_host_->DestroyDelegatedContent(); 1187 delegated_frame_host_->DestroyDelegatedContent();
1180 } 1188 }
1181 1189
1190 void RenderWidgetHostViewAndroid::OnBeginFrameDidNotSwap(
1191 const cc::BeginFrameAck& ack) {
1192 AcknowledgeBeginFrame(ack);
1193 }
1194
1195 void RenderWidgetHostViewAndroid::AcknowledgeBeginFrame(
1196 const cc::BeginFrameAck& ack) {
1197 latest_confirmed_begin_frame_source_id_ = ack.source_id;
1198 latest_confirmed_begin_frame_sequence_number_ =
1199 ack.latest_confirmed_sequence_number;
1200 if (begin_frame_source_)
1201 begin_frame_source_->DidFinishFrame(this, ack);
1202 }
1203
1182 void RenderWidgetHostViewAndroid::ClearCompositorFrame() { 1204 void RenderWidgetHostViewAndroid::ClearCompositorFrame() {
1183 DestroyDelegatedContent(); 1205 DestroyDelegatedContent();
1184 } 1206 }
1185 1207
1186 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( 1208 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata(
1187 cc::CompositorFrameMetadata frame_metadata) { 1209 cc::CompositorFrameMetadata frame_metadata) {
1188 if (!content_view_core_) 1210 if (!content_view_core_)
1189 return; 1211 return;
1190 1212
1191 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata); 1213 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata);
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 void RenderWidgetHostViewAndroid::OnDetachCompositor() { 1993 void RenderWidgetHostViewAndroid::OnDetachCompositor() {
1972 DCHECK(content_view_core_); 1994 DCHECK(content_view_core_);
1973 DCHECK(using_browser_compositor_); 1995 DCHECK(using_browser_compositor_);
1974 RunAckCallbacks(); 1996 RunAckCallbacks();
1975 overscroll_controller_.reset(); 1997 overscroll_controller_.reset();
1976 delegated_frame_host_->DetachFromCompositor(); 1998 delegated_frame_host_->DetachFromCompositor();
1977 } 1999 }
1978 2000
1979 void RenderWidgetHostViewAndroid::OnBeginFrame(const cc::BeginFrameArgs& args) { 2001 void RenderWidgetHostViewAndroid::OnBeginFrame(const cc::BeginFrameArgs& args) {
1980 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnBeginFrame"); 2002 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnBeginFrame");
1981 if (!host_) 2003 if (!host_) {
2004 OnBeginFrameDidNotSwap(
2005 cc::BeginFrameAck(args.source_id, args.sequence_number,
2006 cc::BeginFrameArgs::kInvalidFrameNumber, false));
1982 return; 2007 return;
2008 }
1983 2009
1984 // In sync mode, we disregard missed frame args to ensure that 2010 // In sync mode, we disregard missed frame args to ensure that
1985 // SynchronousCompositorBrowserFilter::SyncStateAfterVSync will be called 2011 // SynchronousCompositorBrowserFilter::SyncStateAfterVSync will be called
1986 // during WindowAndroid::WindowBeginFrameSource::OnVSync() observer iteration. 2012 // during WindowAndroid::WindowBeginFrameSource::OnVSync() observer iteration.
1987 if (sync_compositor_ && args.type == cc::BeginFrameArgs::MISSED) 2013 if (sync_compositor_ && args.type == cc::BeginFrameArgs::MISSED) {
2014 uint64_t confirmed = cc::BeginFrameArgs::kInvalidFrameNumber;
2015 if (args.source_id == latest_confirmed_begin_frame_source_id_)
2016 confirmed = latest_confirmed_begin_frame_sequence_number_;
2017 OnBeginFrameDidNotSwap(cc::BeginFrameAck(
2018 args.source_id, args.sequence_number, confirmed, false));
1988 return; 2019 return;
2020 }
1989 2021
1990 // Update |last_begin_frame_args_| before handling 2022 // Update |last_begin_frame_args_| before handling
1991 // |outstanding_begin_frame_requests_| to prevent the BeginFrameSource from 2023 // |outstanding_begin_frame_requests_| to prevent the BeginFrameSource from
1992 // sending the same MISSED args in infinite recursion. This may otherwise 2024 // sending the same MISSED args in infinite recursion. This may otherwise
1993 // happen if |host_->FlushInput()| causes a synchronous OnSetNeedsFlushInput() 2025 // happen if |host_->FlushInput()| causes a synchronous OnSetNeedsFlushInput()
1994 // which can lead to |begin_frame_source_->AddObserver()| and OnBeginFrame(). 2026 // which can lead to |begin_frame_source_->AddObserver()| and OnBeginFrame().
1995 // By setting |last_begin_frame_args_|, we indicate to the source not to send 2027 // By setting |last_begin_frame_args_|, we indicate to the source not to send
1996 // the same args during |AddObserver()| again. 2028 // the same args during |AddObserver()| again.
1997 last_begin_frame_args_ = args; 2029 last_begin_frame_args_ = args;
1998 2030
1999 if (outstanding_begin_frame_requests_ & FLUSH_INPUT) { 2031 if (outstanding_begin_frame_requests_ & FLUSH_INPUT) {
2000 ClearBeginFrameRequest(FLUSH_INPUT); 2032 ClearBeginFrameRequest(FLUSH_INPUT);
2001 host_->FlushInput(); 2033 host_->FlushInput();
2002 } 2034 }
2003 2035
2004 if ((outstanding_begin_frame_requests_ & BEGIN_FRAME) || 2036 if ((outstanding_begin_frame_requests_ & BEGIN_FRAME) ||
2005 (outstanding_begin_frame_requests_ & PERSISTENT_BEGIN_FRAME)) { 2037 (outstanding_begin_frame_requests_ & PERSISTENT_BEGIN_FRAME)) {
2006 ClearBeginFrameRequest(BEGIN_FRAME); 2038 ClearBeginFrameRequest(BEGIN_FRAME);
2007 SendBeginFrame(args); 2039 SendBeginFrame(args);
2040 } else {
2041 OnBeginFrameDidNotSwap(cc::BeginFrameAck(
2042 args.source_id, args.sequence_number, args.sequence_number, false));
2008 } 2043 }
2009 } 2044 }
2010 2045
2011 const cc::BeginFrameArgs& RenderWidgetHostViewAndroid::LastUsedBeginFrameArgs() 2046 const cc::BeginFrameArgs& RenderWidgetHostViewAndroid::LastUsedBeginFrameArgs()
2012 const { 2047 const {
2013 return last_begin_frame_args_; 2048 return last_begin_frame_args_;
2014 } 2049 }
2015 2050
2016 void RenderWidgetHostViewAndroid::OnBeginFrameSourcePausedChanged(bool paused) { 2051 void RenderWidgetHostViewAndroid::OnBeginFrameSourcePausedChanged(bool paused) {
2017 // The BeginFrameSources we listen to don't use this. For WebView, we signal 2052 // The BeginFrameSources we listen to don't use this. For WebView, we signal
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 2159
2125 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); 2160 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor();
2126 if (!compositor) 2161 if (!compositor)
2127 return; 2162 return;
2128 2163
2129 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( 2164 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>(
2130 overscroll_refresh_handler, compositor, view_.GetDipScale()); 2165 overscroll_refresh_handler, compositor, view_.GetDipScale());
2131 } 2166 }
2132 2167
2133 } // namespace content 2168 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | ui/android/delegated_frame_host_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698