Commit 9d3da524 authored by miletus's avatar miletus Committed by Commit bot

Record root layer's position in its TransformNode

Currently we only record non-root layer's position in the
associated TransformNode. In practice, root layer might always
be positioned at (0,0), so we might not be seeing the problem.
But in tests we can manually set root layer to have non-zero
position which will cause visible rects mismatch for property
tree verification.

One example is the unittest in this CL that root layer is positioned
at (60, 70, 100x100). Viewport size is (0, 0, 100x100) in target
space, so the visible rects of the root layer is clipped to be
size 40x30.

With the fix the unittest pass with property tree verification
turned on.

BUG=None
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1159983010

Cr-Commit-Position: refs/heads/master@{#333109}
parent 3a8ebb01
...@@ -2676,6 +2676,30 @@ TEST_F(LayerTreeHostCommonTest, VisibleRectForPerspectiveUnprojection) { ...@@ -2676,6 +2676,30 @@ TEST_F(LayerTreeHostCommonTest, VisibleRectForPerspectiveUnprojection) {
EXPECT_EQ(expected, actual); EXPECT_EQ(expected, actual);
} }
TEST_F(LayerTreeHostCommonTest,
VisibleRectsForPositionedRootLayerClippedByViewport) {
scoped_refptr<Layer> root =
make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
host->SetRootLayer(root);
gfx::Transform identity_matrix;
// Root layer is positioned at (60, 70). The default device viewport size
// is (0, 0, 100x100) in target space. So the root layer's visible rect
// will be clipped by the viewport to be (0, 0, 40x30) in layer's space.
SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
gfx::PointF(60, 70), gfx::Size(100, 100), true,
false);
ExecuteCalculateDrawProperties(root.get());
EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
root->render_surface()->DrawableContentRect());
// In target space, not clipped.
EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect());
// In layer space, clipped.
EXPECT_EQ(gfx::Rect(0, 0, 40, 30), root->visible_content_rect());
}
TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) { TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) {
scoped_refptr<Layer> root = Layer::Create(layer_settings()); scoped_refptr<Layer> root = Layer::Create(layer_settings());
scoped_refptr<LayerWithForcedDrawsContent> child1 = scoped_refptr<LayerWithForcedDrawsContent> child1 =
......
...@@ -282,6 +282,8 @@ bool AddTransformNodeIfNeeded( ...@@ -282,6 +282,8 @@ bool AddTransformNodeIfNeeded(
if (is_root) { if (is_root) {
node->data.post_local.Scale(post_local_scale_factor, node->data.post_local.Scale(post_local_scale_factor,
post_local_scale_factor); post_local_scale_factor);
node->data.post_local.Translate(layer->position().x(),
layer->position().y());
} else { } else {
node->data.post_local_scale_factor = post_local_scale_factor; node->data.post_local_scale_factor = post_local_scale_factor;
node->data.source_offset = source_offset; node->data.source_offset = source_offset;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment