diff options
author | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-26 23:39:51 +0000 |
---|---|---|
committer | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-26 23:39:51 +0000 |
commit | 6fc4ee00f1512d35fdf381cf4284d9dae9be8bb9 (patch) | |
tree | a9e10126f2a8a26a39232fdd8d0357516c1da966 /cc | |
parent | af3754a2b0c0fd476003647fa3b12b6a35373317 (diff) | |
download | chromium_src-6fc4ee00f1512d35fdf381cf4284d9dae9be8bb9.zip chromium_src-6fc4ee00f1512d35fdf381cf4284d9dae9be8bb9.tar.gz chromium_src-6fc4ee00f1512d35fdf381cf4284d9dae9be8bb9.tar.bz2 |
cc: Fix viewport size for page scale animations on keyboard bringup.
This fixes two viewport-related problems with page scale animations:
1. Switch to using VisibleViewportSize instead of device_viewport_size.
This takes into account the size of the on-screen keyboard
("overdraw_bottom_height").
2. Start page scale animations at the end of commits instead of as a
separate task on the message loop. This avoids a race between the
resize commit and the animation.
NOTRY=true
BUG=180009,178295
Review URL: https://chromiumcodereview.appspot.com/13082002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190796 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/test/fake_proxy.h | 4 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.cc | 17 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.h | 8 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 3 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 92 | ||||
-rw-r--r-- | cc/trees/proxy.h | 5 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.cc | 8 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.h | 4 | ||||
-rw-r--r-- | cc/trees/thread_proxy.cc | 26 | ||||
-rw-r--r-- | cc/trees/thread_proxy.h | 8 |
10 files changed, 60 insertions, 115 deletions
diff --git a/cc/test/fake_proxy.h b/cc/test/fake_proxy.h index b9d37a3..60bbdf7 100644 --- a/cc/test/fake_proxy.h +++ b/cc/test/fake_proxy.h @@ -17,10 +17,6 @@ class FakeProxy : public Proxy { : Proxy(impl_thread.Pass()) {} virtual bool CompositeAndReadback(void* pixels, gfx::Rect rect) OVERRIDE; - virtual void StartPageScaleAnimation(gfx::Vector2d target_position, - bool use_anchor, - float scale, - base::TimeDelta duration) OVERRIDE {} virtual void FinishAllRendering() OVERRIDE {} virtual bool IsStarted() const OVERRIDE; virtual bool InitializeOutputSurface() OVERRIDE; diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index dd57226..16f6be7 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -329,6 +329,15 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { host_impl->SetOverdrawBottomHeight(overdraw_bottom_height_); host_impl->SetDeviceScaleFactor(device_scale_factor_); host_impl->SetDebugState(debug_state_); + if (pending_page_scale_animation_) { + host_impl->StartPageScaleAnimation( + pending_page_scale_animation_->target_offset, + pending_page_scale_animation_->use_anchor, + pending_page_scale_animation_->scale, + base::TimeTicks::Now(), + pending_page_scale_animation_->duration); + pending_page_scale_animation_.reset(); + } DCHECK(!sync_tree->ViewportSizeInvalid()); @@ -616,7 +625,13 @@ void LayerTreeHost::StartPageScaleAnimation(gfx::Vector2d target_offset, bool use_anchor, float scale, base::TimeDelta duration) { - proxy_->StartPageScaleAnimation(target_offset, use_anchor, scale, duration); + pending_page_scale_animation_.reset(new PendingPageScaleAnimation); + pending_page_scale_animation_->target_offset = target_offset; + pending_page_scale_animation_->use_anchor = use_anchor; + pending_page_scale_animation_->scale = scale; + pending_page_scale_animation_->duration = duration; + + SetNeedsCommit(); } void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) { diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index bbd2259..220cbb5 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -327,6 +327,14 @@ class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { scoped_ptr<AnimationRegistrar> animation_registrar_; + struct PendingPageScaleAnimation { + gfx::Vector2d target_offset; + bool use_anchor; + float scale; + base::TimeDelta duration; + }; + scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; + DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); }; diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 3332839..aaf0ada 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -306,8 +306,7 @@ void LayerTreeHostImpl::StartPageScaleAnimation(gfx::Vector2d target_offset, gfx::Vector2dF scroll_total = RootScrollLayer()->scroll_offset() + RootScrollLayer()->scroll_delta(); gfx::SizeF scaled_scrollable_size = active_tree_->ScrollableSize(); - gfx::SizeF viewport_size = - gfx::ScaleSize(device_viewport_size_, 1.f / device_scale_factor_); + gfx::SizeF viewport_size = VisibleViewportSize(); double start_time_seconds = (start_time - base::TimeTicks()).InSecondsF(); page_scale_animation_ = diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index eeddab3..28a0ba7 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -467,67 +467,45 @@ class LayerTreeHostTestCommit : public LayerTreeHostTest { MULTI_THREAD_TEST_F(LayerTreeHostTestCommit); -// Verifies that startPageScaleAnimation events propagate correctly +// Verifies that StartPageScaleAnimation events propagate correctly // from LayerTreeHost to LayerTreeHostImpl in the MT compositor. class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest { - public: - LayerTreeHostTestStartPageScaleAnimation() : animation_requested_(false) {} - - virtual void BeginTest() OVERRIDE { - layer_tree_host()->root_layer()->SetScrollable(true); - layer_tree_host()->root_layer()->SetScrollOffset(gfx::Vector2d()); - PostSetNeedsCommitToMainThread(); - PostSetNeedsRedrawToMainThread(); - } - - void RequestStartPageScaleAnimation() { - layer_tree_host()->StartPageScaleAnimation( - gfx::Vector2d(), false, 1.25f, base::TimeDelta()); - } - - virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { - impl->active_tree()->root_layer()->SetScrollable(true); - impl->active_tree()->root_layer()->SetScrollOffset(gfx::Vector2d()); - impl->active_tree()->SetPageScaleFactorAndLimits( - impl->active_tree()->page_scale_factor(), 0.5f, 2.f); - - // We request animation only once. - if (!animation_requested_) { - impl->proxy()->MainThread()->PostTask( - base::Bind(&LayerTreeHostTestStartPageScaleAnimation:: - RequestStartPageScaleAnimation, - base::Unretained(this))); - animation_requested_ = true; - } - } - - virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) - OVERRIDE { - gfx::Vector2d offset = layer_tree_host()->root_layer()->scroll_offset(); - layer_tree_host()->root_layer()->SetScrollOffset(offset + scroll_delta); - layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f); - } - - virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { - impl->ProcessScrollDeltas(); - // We get one commit before the first draw, and the animation doesn't - // happen until the second draw. - if (impl->active_tree()->source_frame_number() == 1) { - EXPECT_EQ(1.25f, impl->active_tree()->page_scale_factor()); - EndTest(); - } else { - PostSetNeedsRedrawToMainThread(); - } - } - - virtual void AfterTest() OVERRIDE {} - - private: - bool animation_requested_; +public: + LayerTreeHostTestStartPageScaleAnimation() {} + + virtual void BeginTest() OVERRIDE { + layer_tree_host()->root_layer()->SetScrollable(true); + layer_tree_host()->root_layer()->SetScrollOffset(gfx::Vector2d()); + layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); + layer_tree_host()->StartPageScaleAnimation( + gfx::Vector2d(), false, 1.25f, base::TimeDelta()); + PostSetNeedsCommitToMainThread(); + PostSetNeedsRedrawToMainThread(); + } + + virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) + OVERRIDE { + gfx::Vector2d offset = layer_tree_host()->root_layer()->scroll_offset(); + layer_tree_host()->root_layer()->SetScrollOffset(offset + scroll_delta); + layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f); + } + + virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { + impl->ProcessScrollDeltas(); + // We get one commit before the first draw, and the animation doesn't happen + // until the second draw. + if (impl->active_tree()->source_frame_number() == 1) { + EXPECT_EQ(1.25f, impl->active_tree()->page_scale_factor()); + EndTest(); + } else { + PostSetNeedsRedrawToMainThread(); + } + } + + virtual void AfterTest() OVERRIDE {} }; -// TODO(aelias): This test is currently broken: http://crbug.com/178295 -// MULTI_THREAD_TEST_F(LayerTreeHostTestStartPageScaleAnimation); +MULTI_THREAD_TEST_F(LayerTreeHostTestStartPageScaleAnimation); class LayerTreeHostTestSetVisible : public LayerTreeHostTest { public: diff --git a/cc/trees/proxy.h b/cc/trees/proxy.h index 7be52d7..51ae7de 100644 --- a/cc/trees/proxy.h +++ b/cc/trees/proxy.h @@ -49,11 +49,6 @@ class CC_EXPORT Proxy { virtual bool CompositeAndReadback(void* pixels, gfx::Rect rect) = 0; - virtual void StartPageScaleAnimation(gfx::Vector2d target_offset, - bool use_anchor, - float scale, - base::TimeDelta duration) = 0; - virtual void FinishAllRendering() = 0; virtual bool IsStarted() const = 0; diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index d2df4ff..e63a8fc 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -72,14 +72,6 @@ bool SingleThreadProxy::CompositeAndReadback(void* pixels, gfx::Rect rect) { return true; } -void SingleThreadProxy::StartPageScaleAnimation(gfx::Vector2d target_offset, - bool use_anchor, - float scale, - base::TimeDelta duration) { - layer_tree_host_impl_->StartPageScaleAnimation( - target_offset, use_anchor, scale, base::TimeTicks::Now(), duration); -} - void SingleThreadProxy::FinishAllRendering() { DCHECK(Proxy::IsMainThread()); { diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index 2322d76..ff8a9d3 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -24,10 +24,6 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { // Proxy implementation virtual bool CompositeAndReadback(void* pixels, gfx::Rect rect) OVERRIDE; - virtual void StartPageScaleAnimation(gfx::Vector2d target_offset, - bool use_anchor, - float scale, - base::TimeDelta duration) OVERRIDE; virtual void FinishAllRendering() OVERRIDE; virtual bool IsStarted() const OVERRIDE; virtual bool InitializeOutputSurface() OVERRIDE; diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index 8c7d9de..8629701 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -130,32 +130,6 @@ void ThreadProxy::RequestReadbackOnImplThread(ReadbackRequest* request) { scheduler_on_impl_thread_->SetNeedsForcedRedraw(); } -void ThreadProxy::StartPageScaleAnimation(gfx::Vector2d target_offset, - bool use_anchor, - float scale, - base::TimeDelta duration) { - DCHECK(Proxy::IsMainThread()); - Proxy::ImplThread()->PostTask( - base::Bind(&ThreadProxy::RequestStartPageScaleAnimationOnImplThread, - impl_thread_weak_ptr_, - target_offset, - use_anchor, - scale, - duration)); -} - -void ThreadProxy::RequestStartPageScaleAnimationOnImplThread( - gfx::Vector2d target_offset, - bool use_anchor, - float scale, - base::TimeDelta duration) { - DCHECK(Proxy::IsImplThread()); - if (layer_tree_host_impl_) { - layer_tree_host_impl_->StartPageScaleAnimation( - target_offset, use_anchor, scale, base::TimeTicks::Now(), duration); - } -} - void ThreadProxy::FinishAllRendering() { DCHECK(Proxy::IsMainThread()); DCHECK(!defer_commits_); diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h index 73193aa..23a3348 100644 --- a/cc/trees/thread_proxy.h +++ b/cc/trees/thread_proxy.h @@ -39,10 +39,6 @@ class ThreadProxy : public Proxy, // Proxy implementation virtual bool CompositeAndReadback(void* pixels, gfx::Rect rect) OVERRIDE; - virtual void StartPageScaleAnimation(gfx::Vector2d target_offset, - bool use_anchor, - float scale, - base::TimeDelta duration) OVERRIDE; virtual void FinishAllRendering() OVERRIDE; virtual bool IsStarted() const OVERRIDE; virtual bool InitializeOutputSurface() OVERRIDE; @@ -154,10 +150,6 @@ class ThreadProxy : public Proxy, scoped_refptr<cc::ContextProvider> offscreen_context_provider); void BeginFrameAbortedOnImplThread(); void RequestReadbackOnImplThread(ReadbackRequest* request); - void RequestStartPageScaleAnimationOnImplThread(gfx::Vector2d target_offset, - bool use_anchor, - float scale, - base::TimeDelta duration); void FinishAllRenderingOnImplThread(CompletionEvent* completion); void InitializeImplOnImplThread(CompletionEvent* completion, InputHandler* input_handler); |