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

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_common_unittest.cc
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 238c3cb28a9e30fbb9e8018d7a61a774c8ca2dec..df2b30e1f22e446b09a58272fa9b2c130fd0d12c 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -34,6 +34,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/quad_f.h"
+#include "ui/gfx/geometry/vector2d_conversions.h"
#include "ui/gfx/transform.h"
namespace cc {
@@ -347,7 +348,7 @@ TEST_F(LayerTreeHostCommonTest, TransformsAboutScrollOffset) {
scroll_layer->AddChild(sublayer_scoped_ptr.Pass());
LayerImpl* scroll_layer_raw_ptr = scroll_layer_scoped_ptr.get();
clip_layer->AddChild(scroll_layer_scoped_ptr.Pass());
- scroll_layer_raw_ptr->SetScrollOffset(kScrollOffset);
+ scroll_layer_raw_ptr->PushScrollOffsetFromMainThread(kScrollOffset);
scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3));
SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
@@ -7763,6 +7764,90 @@ TEST_F(LayerTreeHostCommonTest, ScrollCompensationWithRounding) {
}
}
+TEST_F(LayerTreeHostCommonTest,
+ ScrollCompensationMainScrollOffsetFractionalPart) {
+ // This test verifies that a scrolling layer that has fractional scroll offset
+ // from main doesn't move a fixed position child.
+ //
+ // + root
+ // + container
+ // + scroller
+ // + fixed
+ //
+ FakeImplProxy proxy;
+ TestSharedBitmapManager shared_bitmap_manager;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
+ host_impl.CreatePendingTree();
+ scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
+ scoped_ptr<LayerImpl> container =
+ LayerImpl::Create(host_impl.active_tree(), 2);
+ LayerImpl* container_layer = container.get();
+ scoped_ptr<LayerImpl> scroller =
+ LayerImpl::Create(host_impl.active_tree(), 3);
+ LayerImpl* scroll_layer = scroller.get();
+ scoped_ptr<LayerImpl> fixed = LayerImpl::Create(host_impl.active_tree(), 4);
+ LayerImpl* fixed_layer = fixed.get();
+
+ container->SetIsContainerForFixedPositionLayers(true);
+
+ LayerPositionConstraint constraint;
+ constraint.set_is_fixed_position(true);
+ fixed->SetPositionConstraint(constraint);
+
+ scroller->SetScrollClipLayer(container->id());
+
+ gfx::Transform identity_transform;
+ gfx::Transform container_transform;
+ container_transform.Translate3d(10.0, 20.0, 0.0);
+ gfx::Vector2dF container_offset = container_transform.To2dTranslation();
+
+ SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(50, 50), true, false,
+ true);
+ SetLayerPropertiesForTesting(container.get(), container_transform,
+ gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40),
+ true, false, false);
+ SetLayerPropertiesForTesting(scroller.get(), identity_transform,
+ gfx::Point3F(), gfx::PointF(0.0, 0.0),
+ gfx::Size(30, 30), true, false, false);
+
+ gfx::ScrollOffset scroll_offset(3.3, 4.2);
+ gfx::Vector2dF main_scroll_fractional_part(0.3f, 0.2f);
+ gfx::Vector2dF scroll_delta(0.1f, 0.4f);
+ // Blink only uses the integer part of the scroll_offset for fixed
+ // position layer.
+ SetLayerPropertiesForTesting(fixed.get(), identity_transform, gfx::Point3F(),
+ gfx::PointF(3.0f, 4.0f), gfx::Size(50, 50), true,
+ false, false);
+ scroll_layer->PushScrollOffsetFromMainThread(scroll_offset);
+ scroll_layer->SetScrollDelta(scroll_delta);
+ scroll_layer->SetScrollCompensationAdjustment(main_scroll_fractional_part);
+
+ scroller->AddChild(fixed.Pass());
+ container->AddChild(scroller.Pass());
+ root->AddChild(container.Pass());
+
+ LayerImplList render_surface_layer_list;
+ LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
+ root.get(), root->bounds(), &render_surface_layer_list);
+ LayerTreeHostCommon::CalculateDrawProperties(&inputs);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ container_layer->draw_properties().screen_space_transform,
+ fixed_layer->draw_properties().screen_space_transform);
+ EXPECT_VECTOR_EQ(
+ fixed_layer->draw_properties().screen_space_transform.To2dTranslation(),
+ container_offset);
+
+ gfx::ScrollOffset effective_scroll_offset =
+ ScrollOffsetWithDelta(scroll_offset, scroll_delta);
+ gfx::Vector2d rounded_effective_scroll_offset =
+ ToRoundedVector2d(ScrollOffsetToVector2dF(effective_scroll_offset));
+ EXPECT_VECTOR_EQ(
+ scroll_layer->draw_properties().screen_space_transform.To2dTranslation(),
+ container_offset - rounded_effective_scroll_offset);
+}
+
class AnimationScaleFactorTrackingLayerImpl : public LayerImpl {
public:
static scoped_ptr<AnimationScaleFactorTrackingLayerImpl> Create(
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698