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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 584503005: Make scroll offset type of float in cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scroll delta -> vector2dF, scroll offset -> ScrollOffset Created 6 years, 3 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
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index e4aaf8aa7e1352a4fca378a604f0116830e3a5b7..29d31e99fc3452f8dcdd33f79317c65a58680fff 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -433,7 +433,7 @@ void LayerTreeHostImpl::StartPageScaleAnimation(
if (!InnerViewportScrollLayer())
return;
- gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset();
+ gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset();
gfx::SizeF scaled_scrollable_size = active_tree_->ScrollableSize();
gfx::SizeF viewport_size =
active_tree_->InnerViewportContainerLayer()->bounds();
@@ -443,7 +443,7 @@ void LayerTreeHostImpl::StartPageScaleAnimation(
CubicBezierTimingFunction::Create(.8, 0, .3, .9).PassAs<TimingFunction>();
page_scale_animation_ =
- PageScaleAnimation::Create(scroll_total,
+ PageScaleAnimation::Create(scroll_total.ToVector2dF(),
danakj 2014/09/25 22:01:27 TODO to pass a ScrollOffset?
Yufeng Shen (Slow to review) 2014/09/26 20:19:08 Done.
active_tree_->total_page_scale_factor(),
viewport_size,
scaled_scrollable_size,
@@ -1483,7 +1483,7 @@ CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const {
if (!InnerViewportScrollLayer())
return metadata;
- metadata.root_scroll_offset = active_tree_->TotalScrollOffset();
+ metadata.root_scroll_offset = active_tree_->TotalScrollOffset().ToVector2dF();
danakj 2014/09/25 22:01:27 TODO to change the IPC to hold a ScrollOffset?
Yufeng Shen (Slow to review) 2014/09/26 20:19:08 Done.
return metadata;
}
@@ -2377,7 +2377,7 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
gfx::Vector2dF new_target = curve->target_value() + scroll_delta;
danakj 2014/09/25 22:01:27 target_value should be a ScrollOffset? So a bunch
Yufeng Shen (Slow to review) 2014/09/26 20:19:08 Done.
new_target.SetToMax(gfx::Vector2dF());
- new_target.SetToMin(layer_impl->MaxScrollOffset());
+ new_target.SetToMin(layer_impl->MaxScrollOffset().ToVector2dF());
curve->UpdateTarget(animation->TrimTimeToCurrentIteration(
CurrentBeginFrameArgs().frame_time),
@@ -2396,11 +2396,13 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
if (!layer_impl->scrollable())
continue;
- gfx::Vector2dF current_offset = layer_impl->TotalScrollOffset();
- gfx::Vector2dF target_offset = current_offset + pending_delta;
- target_offset.SetToMax(gfx::Vector2dF());
+ gfx::ScrollOffset current_offset = layer_impl->TotalScrollOffset();
+ gfx::ScrollOffset target_offset =
+ current_offset + gfx::ScrollOffset(pending_delta);
+ target_offset.SetToMax(gfx::ScrollOffset());
target_offset.SetToMin(layer_impl->MaxScrollOffset());
- gfx::Vector2dF actual_delta = target_offset - current_offset;
+ gfx::Vector2dF actual_delta =
+ (target_offset - current_offset).ToVector2dF();
const float kEpsilon = 0.1f;
bool can_layer_scroll = (std::abs(actual_delta.x()) > kEpsilon ||
@@ -2415,9 +2417,9 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
active_tree_->SetCurrentlyScrollingLayer(layer_impl);
scoped_ptr<ScrollOffsetAnimationCurve> curve =
- ScrollOffsetAnimationCurve::Create(target_offset,
+ ScrollOffsetAnimationCurve::Create(target_offset.ToVector2dF(),
danakj 2014/09/25 22:01:26 should just pass a ScrollOffset?
Yufeng Shen (Slow to review) 2014/09/26 20:19:08 Done.
EaseInOutTimingFunction::Create());
- curve->SetInitialValue(current_offset);
+ curve->SetInitialValue(current_offset.ToVector2dF());
danakj 2014/09/25 22:01:27 and here?
Yufeng Shen (Slow to review) 2014/09/26 20:19:08 Done.
scoped_ptr<Animation> animation =
Animation::Create(curve.PassAs<AnimationCurve>(),
@@ -2621,7 +2623,7 @@ bool LayerTreeHostImpl::ScrollBy(const gfx::Point& viewport_point,
float angle_threshold = 45;
if (MathUtil::SmallestAngleBetweenVectors(
applied_delta, pending_delta) < angle_threshold) {
- pending_delta = gfx::Vector2d();
+ pending_delta = gfx::Vector2dF();
break;
}
@@ -2881,7 +2883,9 @@ void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta,
move.Scale(1 / active_tree_->page_scale_factor());
// If clamping the inner viewport scroll offset causes a change, it should
// be accounted for from the intended move.
- move -= InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset();
+ gfx::ScrollOffset max_offset =
danakj 2014/09/25 22:01:26 This would become Vector2dF based on other comment
Yufeng Shen (Slow to review) 2014/09/26 20:19:08 Done.
+ InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset();
+ move -= max_offset.ToVector2dF();
// We manually manage the bubbling behaviour here as it is different to that
// implemented in LayerTreeHostImpl::ScrollBy(). Specifically:
@@ -2922,8 +2926,7 @@ static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info,
if (!layer_impl)
return;
- gfx::Vector2d scroll_delta =
- gfx::ToFlooredVector2d(layer_impl->ScrollDelta());
+ gfx::Vector2dF scroll_delta = layer_impl->ScrollDelta();
if (!scroll_delta.IsZero()) {
LayerTreeHostCommon::ScrollUpdateInfo scroll;
scroll.layer_id = layer_impl->id();
@@ -2969,7 +2972,7 @@ void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) {
if (!page_scale_animation_)
return;
- gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset();
+ gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset();
if (!page_scale_animation_->IsAnimationStarted())
page_scale_animation_->StartAnimation(monotonic_time);
@@ -2980,7 +2983,7 @@ void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) {
gfx::Vector2dF next_scroll =
danakj 2014/09/25 22:01:27 ScrollOffset
Yufeng Shen (Slow to review) 2014/09/26 20:19:07 Done.
page_scale_animation_->ScrollOffsetAtTime(monotonic_time);
- ScrollViewportBy(next_scroll - scroll_total);
+ ScrollViewportBy(next_scroll - scroll_total.ToVector2dF());
danakj 2014/09/25 22:01:26 convert after subtracting
Yufeng Shen (Slow to review) 2014/09/26 20:19:08 Done.
SetNeedsRedraw();
if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) {

Powered by Google App Engine
This is Rietveld 408576698