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

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: 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 ->OnLostResources(); 436 ->OnLostResources();
437 } 437 }
438 } 438 }
439 } 439 }
440 440
441 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( 441 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
442 RenderWidgetHostImpl* widget_host, 442 RenderWidgetHostImpl* widget_host,
443 ContentViewCoreImpl* content_view_core) 443 ContentViewCoreImpl* content_view_core)
444 : host_(widget_host), 444 : host_(widget_host),
445 begin_frame_source_(nullptr), 445 begin_frame_source_(nullptr),
446 latest_confirmed_begin_frame_source_id_(0),
447 latest_confirmed_begin_frame_sequence_number_(
448 cc::BeginFrameArgs::kInvalidFrameNumber),
446 outstanding_begin_frame_requests_(0), 449 outstanding_begin_frame_requests_(0),
447 is_showing_(!widget_host->is_hidden()), 450 is_showing_(!widget_host->is_hidden()),
448 is_window_visible_(true), 451 is_window_visible_(true),
449 is_window_activity_started_(true), 452 is_window_activity_started_(true),
450 is_in_vr_(false), 453 is_in_vr_(false),
451 content_view_core_(nullptr), 454 content_view_core_(nullptr),
452 ime_adapter_android_(this), 455 ime_adapter_android_(this),
453 cached_background_color_(SK_ColorWHITE), 456 cached_background_color_(SK_ColorWHITE),
454 view_(this), 457 view_(this),
455 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId), 458 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId),
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 CheckCompositorFrameSinkChanged(compositor_frame_sink_id); 1160 CheckCompositorFrameSinkChanged(compositor_frame_sink_id);
1158 bool has_content = !current_surface_size_.IsEmpty(); 1161 bool has_content = !current_surface_size_.IsEmpty();
1159 1162
1160 base::Closure ack_callback = 1163 base::Closure ack_callback =
1161 base::Bind(&RenderWidgetHostViewAndroid::SendReclaimCompositorResources, 1164 base::Bind(&RenderWidgetHostViewAndroid::SendReclaimCompositorResources,
1162 weak_ptr_factory_.GetWeakPtr(), compositor_frame_sink_id, 1165 weak_ptr_factory_.GetWeakPtr(), compositor_frame_sink_id,
1163 true /* is_swap_ack */); 1166 true /* is_swap_ack */);
1164 1167
1165 ack_callbacks_.push(ack_callback); 1168 ack_callbacks_.push(ack_callback);
1166 1169
1170 cc::BeginFrameAck ack = frame.metadata.begin_frame_ack;
1167 if (!has_content) { 1171 if (!has_content) {
1168 DestroyDelegatedContent(); 1172 DestroyDelegatedContent();
1173
1174 ack.has_damage = false;
1175 OnBeginFrameDidNotSwap(ack);
1169 } else { 1176 } else {
1170 delegated_frame_host_->SubmitCompositorFrame(local_surface_id, 1177 delegated_frame_host_->SubmitCompositorFrame(local_surface_id,
1171 std::move(frame)); 1178 std::move(frame));
1172 frame_evictor_->SwappedFrame(!host_->is_hidden()); 1179 frame_evictor_->SwappedFrame(!host_->is_hidden());
1180
1181 latest_confirmed_begin_frame_source_id_ = ack.source_id;
boliu 2017/03/29 16:03:59 this is an exact duplicate of OnBeginFrameDidNotSw
Eric Seckler 2017/03/30 10:59:25 True, done! :)
1182 latest_confirmed_begin_frame_sequence_number_ =
1183 ack.latest_confirmed_sequence_number;
1184 if (begin_frame_source_)
1185 begin_frame_source_->DidFinishFrame(this, ack);
1173 } 1186 }
1174 1187
1175 if (host_->is_hidden()) 1188 if (host_->is_hidden())
1176 RunAckCallbacks(); 1189 RunAckCallbacks();
1177 1190
1178 // As the metadata update may trigger view invalidation, always call it after 1191 // As the metadata update may trigger view invalidation, always call it after
1179 // any potential compositor scheduling. 1192 // any potential compositor scheduling.
1180 OnFrameMetadataUpdated(std::move(metadata), is_transparent); 1193 OnFrameMetadataUpdated(std::move(metadata), is_transparent);
1181 } 1194 }
1182 1195
(...skipping 13 matching lines...) Expand all
1196 } 1209 }
1197 1210
1198 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame( 1211 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame(
1199 uint32_t compositor_frame_sink_id, 1212 uint32_t compositor_frame_sink_id,
1200 const cc::LocalSurfaceId& local_surface_id, 1213 const cc::LocalSurfaceId& local_surface_id,
1201 cc::CompositorFrame frame) { 1214 cc::CompositorFrame frame) {
1202 InternalSwapCompositorFrame(compositor_frame_sink_id, local_surface_id, 1215 InternalSwapCompositorFrame(compositor_frame_sink_id, local_surface_id,
1203 std::move(frame)); 1216 std::move(frame));
1204 } 1217 }
1205 1218
1219 void RenderWidgetHostViewAndroid::OnBeginFrameDidNotSwap(
1220 const cc::BeginFrameAck& ack) {
1221 latest_confirmed_begin_frame_source_id_ = ack.source_id;
1222 latest_confirmed_begin_frame_sequence_number_ =
1223 ack.latest_confirmed_sequence_number;
1224 if (begin_frame_source_)
1225 begin_frame_source_->DidFinishFrame(this, ack);
1226 }
1227
1206 void RenderWidgetHostViewAndroid::ClearCompositorFrame() { 1228 void RenderWidgetHostViewAndroid::ClearCompositorFrame() {
1207 DestroyDelegatedContent(); 1229 DestroyDelegatedContent();
1208 } 1230 }
1209 1231
1210 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( 1232 void RenderWidgetHostViewAndroid::SynchronousFrameMetadata(
1211 cc::CompositorFrameMetadata frame_metadata) { 1233 cc::CompositorFrameMetadata frame_metadata) {
1212 if (!content_view_core_) 1234 if (!content_view_core_)
1213 return; 1235 return;
1214 1236
1215 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata); 1237 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata);
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 void RenderWidgetHostViewAndroid::OnDetachCompositor() { 2009 void RenderWidgetHostViewAndroid::OnDetachCompositor() {
1988 DCHECK(content_view_core_); 2010 DCHECK(content_view_core_);
1989 DCHECK(using_browser_compositor_); 2011 DCHECK(using_browser_compositor_);
1990 RunAckCallbacks(); 2012 RunAckCallbacks();
1991 overscroll_controller_.reset(); 2013 overscroll_controller_.reset();
1992 delegated_frame_host_->DetachFromCompositor(); 2014 delegated_frame_host_->DetachFromCompositor();
1993 } 2015 }
1994 2016
1995 void RenderWidgetHostViewAndroid::OnBeginFrame(const cc::BeginFrameArgs& args) { 2017 void RenderWidgetHostViewAndroid::OnBeginFrame(const cc::BeginFrameArgs& args) {
1996 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnBeginFrame"); 2018 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnBeginFrame");
1997 if (!host_) 2019 if (!host_) {
2020 OnBeginFrameDidNotSwap(
2021 cc::BeginFrameAck(args.source_id, args.sequence_number,
2022 cc::BeginFrameArgs::kInvalidFrameNumber, false));
1998 return; 2023 return;
2024 }
1999 2025
2000 // In sync mode, we disregard missed frame args to ensure that 2026 // In sync mode, we disregard missed frame args to ensure that
2001 // SynchronousCompositorBrowserFilter::SyncStateAfterVSync will be called 2027 // SynchronousCompositorBrowserFilter::SyncStateAfterVSync will be called
2002 // during WindowAndroid::WindowBeginFrameSource::OnVSync() observer iteration. 2028 // during WindowAndroid::WindowBeginFrameSource::OnVSync() observer iteration.
2003 if (sync_compositor_ && args.type == cc::BeginFrameArgs::MISSED) 2029 if (sync_compositor_ && args.type == cc::BeginFrameArgs::MISSED) {
2030 uint64_t confirmed = cc::BeginFrameArgs::kInvalidFrameNumber;
2031 if (args.source_id == latest_confirmed_begin_frame_source_id_)
2032 confirmed = latest_confirmed_begin_frame_sequence_number_;
2033 OnBeginFrameDidNotSwap(cc::BeginFrameAck(
2034 args.source_id, args.sequence_number, confirmed, false));
2004 return; 2035 return;
2036 }
2005 2037
2006 // Update |last_begin_frame_args_| before handling 2038 // Update |last_begin_frame_args_| before handling
2007 // |outstanding_begin_frame_requests_| to prevent the BeginFrameSource from 2039 // |outstanding_begin_frame_requests_| to prevent the BeginFrameSource from
2008 // sending the same MISSED args in infinite recursion. This may otherwise 2040 // sending the same MISSED args in infinite recursion. This may otherwise
2009 // happen if |host_->FlushInput()| causes a synchronous OnSetNeedsFlushInput() 2041 // happen if |host_->FlushInput()| causes a synchronous OnSetNeedsFlushInput()
2010 // which can lead to |begin_frame_source_->AddObserver()| and OnBeginFrame(). 2042 // which can lead to |begin_frame_source_->AddObserver()| and OnBeginFrame().
2011 // By setting |last_begin_frame_args_|, we indicate to the source not to send 2043 // By setting |last_begin_frame_args_|, we indicate to the source not to send
2012 // the same args during |AddObserver()| again. 2044 // the same args during |AddObserver()| again.
2013 last_begin_frame_args_ = args; 2045 last_begin_frame_args_ = args;
2014 2046
2015 if (outstanding_begin_frame_requests_ & FLUSH_INPUT) { 2047 if (outstanding_begin_frame_requests_ & FLUSH_INPUT) {
2016 ClearBeginFrameRequest(FLUSH_INPUT); 2048 ClearBeginFrameRequest(FLUSH_INPUT);
2017 host_->FlushInput(); 2049 host_->FlushInput();
2018 } 2050 }
2019 2051
2020 if ((outstanding_begin_frame_requests_ & BEGIN_FRAME) || 2052 if ((outstanding_begin_frame_requests_ & BEGIN_FRAME) ||
2021 (outstanding_begin_frame_requests_ & PERSISTENT_BEGIN_FRAME)) { 2053 (outstanding_begin_frame_requests_ & PERSISTENT_BEGIN_FRAME)) {
2022 ClearBeginFrameRequest(BEGIN_FRAME); 2054 ClearBeginFrameRequest(BEGIN_FRAME);
2023 SendBeginFrame(args); 2055 SendBeginFrame(args);
2056 } else {
2057 OnBeginFrameDidNotSwap(cc::BeginFrameAck(
2058 args.source_id, args.sequence_number, args.sequence_number, false));
2024 } 2059 }
2025 } 2060 }
2026 2061
2027 const cc::BeginFrameArgs& RenderWidgetHostViewAndroid::LastUsedBeginFrameArgs() 2062 const cc::BeginFrameArgs& RenderWidgetHostViewAndroid::LastUsedBeginFrameArgs()
2028 const { 2063 const {
2029 return last_begin_frame_args_; 2064 return last_begin_frame_args_;
2030 } 2065 }
2031 2066
2032 void RenderWidgetHostViewAndroid::OnBeginFrameSourcePausedChanged(bool paused) { 2067 void RenderWidgetHostViewAndroid::OnBeginFrameSourcePausedChanged(bool paused) {
2033 // The BeginFrameSources we listen to don't use this. For WebView, we signal 2068 // 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
2140 2175
2141 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); 2176 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor();
2142 if (!compositor) 2177 if (!compositor)
2143 return; 2178 return;
2144 2179
2145 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( 2180 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>(
2146 overscroll_refresh_handler, compositor, view_.GetDipScale()); 2181 overscroll_refresh_handler, compositor, view_.GetDipScale());
2147 } 2182 }
2148 2183
2149 } // namespace content 2184 } // 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