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

Unified Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 1879833002: Android: Browser-side scheduling latency tweaks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/compositor/CompositorViewHolder.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/compositor_impl_android.cc
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
index 56b9201dcc5b70abac801a1e398ffac1b25a33d9..98d0838af47ea92a7e70d0bb5eb83cf1bc48c8aa 100644
--- a/content/browser/renderer_host/compositor_impl_android.cc
+++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -169,20 +169,46 @@ class ExternalBeginFrameSource : public cc::BeginFrameSourceBase,
}
// cc::BeginFrameSourceBase implementation:
+ void AddObserver(cc::BeginFrameObserver* obs) override {
enne (OOO) 2016/04/22 19:58:14 I do think that maybe we should just put this in t
no sievers 2016/04/22 19:59:43 Yea, I'll let Sunny consolidate this in his patch
+ cc::BeginFrameSourceBase::AddObserver(obs);
+ DCHECK(needs_begin_frames());
+ if (!last_begin_frame_args_.IsValid())
+ return;
+
+ // Send a MISSED begin frame if necessary.
+ cc::BeginFrameArgs last_args = obs->LastUsedBeginFrameArgs();
+ if (!last_args.IsValid() ||
+ (last_begin_frame_args_.frame_time > last_args.frame_time)) {
+ last_begin_frame_args_.type = cc::BeginFrameArgs::MISSED;
+ // TODO(crbug.com/602485): A deadline doesn't make too much sense
+ // for a missed BeginFrame (the intention rather is 'immediately'),
+ // but currently the retro frame logic is very strict in discarding
+ // BeginFrames.
+ last_begin_frame_args_.deadline =
+ base::TimeTicks::Now() + last_begin_frame_args_.interval;
+ obs->OnBeginFrame(last_begin_frame_args_);
+ }
+ }
+
void OnNeedsBeginFramesChanged(bool needs_begin_frames) override {
+ TRACE_EVENT1("compositor", "OnNeedsBeginFramesChanged",
+ "needs_begin_frames", needs_begin_frames);
compositor_->OnNeedsBeginFramesChange(needs_begin_frames);
}
// CompositorImpl::VSyncObserver implementation:
void OnVSync(base::TimeTicks frame_time,
base::TimeDelta vsync_period) override {
- CallOnBeginFrame(cc::BeginFrameArgs::Create(
- BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks::Now(), vsync_period,
- cc::BeginFrameArgs::NORMAL));
+ base::TimeTicks deadline = std::max(base::TimeTicks::Now(), frame_time);
+ last_begin_frame_args_ =
+ cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline,
+ vsync_period, cc::BeginFrameArgs::NORMAL);
+ CallOnBeginFrame(last_begin_frame_args_);
}
private:
CompositorImpl* compositor_;
+ cc::BeginFrameArgs last_begin_frame_args_;
};
static bool g_initialized = false;
@@ -406,6 +432,7 @@ void CompositorImpl::SetHasTransparentBackground(bool flag) {
void CompositorImpl::SetNeedsComposite() {
if (!host_->visible())
return;
+ TRACE_EVENT0("compositor", "Compositor::SetNeedsComposite");
host_->SetNeedsAnimate();
}
@@ -585,10 +612,12 @@ void CompositorImpl::RemoveObserver(VSyncObserver* observer) {
cc::UIResourceId CompositorImpl::CreateUIResource(
cc::UIResourceClient* client) {
+ TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource");
return host_->CreateUIResource(client);
}
void CompositorImpl::DeleteUIResource(cc::UIResourceId resource_id) {
+ TRACE_EVENT0("compositor", "CompositorImpl::DeleteUIResource");
host_->DeleteUIResource(resource_id);
}
@@ -649,6 +678,7 @@ void CompositorImpl::SetNeedsAnimate() {
if (!host_->visible())
return;
+ TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate");
host_->SetNeedsAnimate();
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/compositor/CompositorViewHolder.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698