Index: cc/layer_tree_impl.cc |
diff --git a/cc/layer_tree_impl.cc b/cc/layer_tree_impl.cc |
index f16ec0035e93d2d3e7b66be833c00fdac28fa69e..560d0a40e8366287d54e8363769b7d77cb81df29 100644 |
--- a/cc/layer_tree_impl.cc |
+++ b/cc/layer_tree_impl.cc |
@@ -5,9 +5,14 @@ |
#include "cc/layer_tree_impl.h" |
#include "base/debug/trace_event.h" |
+#include "cc/animation.h" |
+#include "cc/animation_id_provider.h" |
#include "cc/heads_up_display_layer_impl.h" |
+#include "cc/keyframed_animation_curve.h" |
#include "cc/layer_tree_host_common.h" |
#include "cc/layer_tree_host_impl.h" |
+#include "cc/pinch_zoom_scrollbar.h" |
+#include "cc/scrollbar_layer_impl.h" |
#include "ui/gfx/vector2d_conversions.h" |
namespace cc { |
@@ -116,6 +121,9 @@ void LayerTreeImpl::pushPropertiesTo(LayerTreeImpl* target_tree) { |
target_tree->RootLayer(), hud_layer()->id()))); |
else |
target_tree->set_hud_layer(NULL); |
+ |
+ target_tree->SetPinchZoomHorizontalLayerId(pinch_zoom_scrollbar_horizontal_layer_id); |
+ target_tree->SetPinchZoomVerticalLayerId(pinch_zoom_scrollbar_vertical_layer_id); |
} |
LayerImpl* LayerTreeImpl::RootScrollLayer() { |
@@ -334,6 +342,9 @@ void LayerTreeImpl::DidBecomeActive() { |
DidBecomeActiveRecursive(RootLayer()); |
FindRootScrollLayer(); |
UpdateMaxScrollOffset(); |
+ // When becoming active there may not be a currently scrolling layer so we |
+ // need to force the update. |
+ UpdatePinchZoomScrollbarsIfNeeded(UPDATE_MAIN_THREAD_SCROLL); |
enne (OOO)
2013/03/06 19:32:58
Can you explain this more clearly? Why would the s
wjmaclean
2013/03/06 22:36:53
Main-thread scrolls just update properties on the
|
} |
bool LayerTreeImpl::ContentsTexturesPurged() const { |
@@ -486,4 +497,88 @@ scoped_ptr<base::Value> LayerTreeImpl::AsValue() const { |
return state.PassAs<base::Value>(); |
} |
+void LayerTreeImpl::SetPinchZoomHorizontalLayerId(int layer_id) { |
+ pinch_zoom_scrollbar_horizontal_layer_id = layer_id; |
+} |
+ |
+ScrollbarLayerImpl* LayerTreeImpl::PinchZoomScrollbarHorizontal() { |
+ return static_cast<ScrollbarLayerImpl*>(LayerById( |
+ pinch_zoom_scrollbar_horizontal_layer_id)); |
+} |
+ |
+void LayerTreeImpl::SetPinchZoomVerticalLayerId(int layer_id) { |
+ pinch_zoom_scrollbar_vertical_layer_id = layer_id; |
+} |
+ |
+ScrollbarLayerImpl* LayerTreeImpl::PinchZoomScrollbarVertical() { |
+ return static_cast<ScrollbarLayerImpl*>(LayerById( |
+ pinch_zoom_scrollbar_vertical_layer_id)); |
+} |
+ |
+void LayerTreeImpl::UpdatePinchZoomScrollbarsIfNeeded( |
+ PinchZoomScrollbarUpdateReason update_reason) { |
+ LayerImpl* root_scroll_layer = RootScrollLayer(); |
+ if (!root_scroll_layer || |
+ (update_reason == UPDATE_IMPL_THREAD_SCROLL && |
+ root_scroll_layer != CurrentlyScrollingLayer())) |
enne (OOO)
2013/03/06 19:32:58
What does the currently scrolling layer have to do
wjmaclean
2013/03/06 22:36:53
I had intended not to update the PZ scrollbars if
|
+ return; |
+ |
+ if (ScrollbarLayerImpl* scrollbar = PinchZoomScrollbarHorizontal()) { |
+ scrollbar->setCurrentPos(root_scroll_layer->scrollOffset().x()); |
+ scrollbar->setTotalSize(root_scroll_layer->bounds().width()); |
+ scrollbar->setMaximum(root_scroll_layer->maxScrollOffset().x()); |
+ } |
+ if (ScrollbarLayerImpl* scrollbar = PinchZoomScrollbarVertical()) { |
+ scrollbar->setCurrentPos(root_scroll_layer->scrollOffset().y()); |
+ scrollbar->setTotalSize(root_scroll_layer->bounds().height()); |
+ scrollbar->setMaximum(root_scroll_layer->maxScrollOffset().y()); |
+ } |
+} |
+ |
+static scoped_ptr<Animation> MakePinchZoomFadeAnimation( |
+ float start_opacity, float end_opacity) { |
+ scoped_ptr<KeyframedFloatAnimationCurve> curve = |
+ KeyframedFloatAnimationCurve::create(); |
+ curve->addKeyframe(FloatKeyframe::create( |
+ 0, start_opacity, EaseInTimingFunction::create())); |
+ curve->addKeyframe(FloatKeyframe::create( |
+ PinchZoomScrollbar::kFadeDuration, end_opacity, |
+ EaseInTimingFunction::create())); |
+ |
+ scoped_ptr<Animation> animation = Animation::create(curve.PassAs<AnimationCurve>(), AnimationIdProvider::NextAnimationId(), 0, Animation::Opacity); |
+ animation->setIsImplAnimationOnly(true); |
+ |
+ return animation.Pass(); |
+} |
+ |
+void LayerTreeImpl::FadeInPinchZoomScrollbars() { |
+ if (!HasPinchZoomScrollbars() || page_scale_factor_ == 1) |
+ return; |
+ |
+ animationRegistrar()->GetAnimationControllerForId( |
+ pinch_zoom_scrollbar_horizontal_layer_id)->addAnimation( |
+ MakePinchZoomFadeAnimation(0.01, PinchZoomScrollbar::kDefaultOpacity)); |
enne (OOO)
2013/03/06 19:32:58
Shouldn't you start the fade animation from the cu
wjmaclean
2013/03/06 22:36:53
Agreed, but we need the start opacity to be non-ze
enne (OOO)
2013/03/06 22:45:38
This is an impl-only animation. How does that int
wjmaclean
2013/03/07 22:57:39
Since the PZ scrollbar starts with opacity 0, it d
|
+ |
+ animationRegistrar()->GetAnimationControllerForId( |
+ pinch_zoom_scrollbar_vertical_layer_id)->addAnimation( |
+ MakePinchZoomFadeAnimation(0.01, PinchZoomScrollbar::kDefaultOpacity)); |
+} |
+ |
+void LayerTreeImpl::FadeOutPinchZoomScrollbars() { |
+ if (!HasPinchZoomScrollbars()) |
+ return; |
+ |
+ if (PinchZoomScrollbarHorizontal()->opacity() == 0 && |
+ PinchZoomScrollbarVertical()->opacity() == 0) |
+ return; |
+ |
+ animationRegistrar()->GetAnimationControllerForId( |
+ pinch_zoom_scrollbar_horizontal_layer_id)->addAnimation( |
+ MakePinchZoomFadeAnimation(PinchZoomScrollbar::kDefaultOpacity, 0)); |
+ |
+ animationRegistrar()->GetAnimationControllerForId( |
+ pinch_zoom_scrollbar_vertical_layer_id)->addAnimation( |
+ MakePinchZoomFadeAnimation(PinchZoomScrollbar::kDefaultOpacity, 0)); |
+} |
+ |
} // namespace cc |