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

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: blow up the patchset :( 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 fe08825927b101acaa91ff6d03e2b1fab00f0c61..1f097c845fea4cefbb73eec7d52a30c04a506c0e 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -436,7 +436,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();
@@ -445,8 +445,9 @@ void LayerTreeHostImpl::StartPageScaleAnimation(
scoped_ptr<TimingFunction> timing_function =
CubicBezierTimingFunction::Create(.8, 0, .3, .9).PassAs<TimingFunction>();
+ // TODO(miletus) : Pass in ScrollOffset.
page_scale_animation_ =
- PageScaleAnimation::Create(scroll_total,
+ PageScaleAnimation::Create(ScrollOffsetToVector2dF(scroll_total),
active_tree_->total_page_scale_factor(),
viewport_size,
scaled_scrollable_size,
@@ -1487,7 +1488,9 @@ CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const {
if (!InnerViewportScrollLayer())
return metadata;
- metadata.root_scroll_offset = active_tree_->TotalScrollOffset();
+ // TODO(miletus) : Change the metadata to hold ScrollOffset.
+ metadata.root_scroll_offset = gfx::ScrollOffsetToVector2dF(
+ active_tree_->TotalScrollOffset());
return metadata;
}
@@ -2375,8 +2378,9 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
ScrollOffsetAnimationCurve* curve =
animation->curve()->ToScrollOffsetAnimationCurve();
- gfx::Vector2dF new_target = curve->target_value() + scroll_delta;
- new_target.SetToMax(gfx::Vector2dF());
+ gfx::ScrollOffset new_target =
+ gfx::ScrollOffsetWithDelta(curve->target_value(), scroll_delta);
+ new_target.SetToMax(gfx::ScrollOffset());
new_target.SetToMin(layer_impl->MaxScrollOffset());
curve->UpdateTarget(animation->TrimTimeToCurrentIteration(
@@ -2396,11 +2400,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 =
+ ScrollOffsetWithDelta(current_offset, 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 =
+ gfx::ScrollOffsetToVector2dF(target_offset - current_offset);
const float kEpsilon = 0.1f;
bool can_layer_scroll = (std::abs(actual_delta.x()) > kEpsilon ||
@@ -2621,7 +2627,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;
}
@@ -2969,7 +2975,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);
@@ -2977,10 +2983,10 @@ void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) {
active_tree_->SetPageScaleDelta(
page_scale_animation_->PageScaleFactorAtTime(monotonic_time) /
active_tree_->page_scale_factor());
- gfx::Vector2dF next_scroll =
- page_scale_animation_->ScrollOffsetAtTime(monotonic_time);
+ gfx::ScrollOffset next_scroll = gfx::ScrollOffset(
+ page_scale_animation_->ScrollOffsetAtTime(monotonic_time));
- ScrollViewportBy(next_scroll - scroll_total);
+ ScrollViewportBy(ScrollOffsetToVector2dF(next_scroll - scroll_total));
SetNeedsRedraw();
if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) {

Powered by Google App Engine
This is Rietveld 408576698