Commit 8ec06d20 authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

cc: Update the approximate scale math to use rect bounds.

This patch changes the approximate scale math to use rect bounds instead
of a vector, which yields more accurate results.

This means that if a layer is effectively shrunk after the transformation
we won't use a larger scale which could have been the case with the
scale math.

R=chrishtr@chromium.org

Bug: 766021
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I42aea3e7b9900b2a1e5499c8c24d7264b7bd6d3f
Reviewed-on: https://chromium-review.googlesource.com/693303
Commit-Queue: vmpstr <vmpstr@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506489}
parent 9942de34
......@@ -587,9 +587,9 @@ gfx::Vector2dF MathUtil::ComputeTransform2dScaleComponents(
}
float MathUtil::ComputeApproximateMaxScale(const gfx::Transform& transform) {
gfx::Vector3dF unit(1, 1, 0);
transform.TransformVector(&unit);
return std::max(std::abs(unit.x()), std::abs(unit.y()));
gfx::RectF unit(0.f, 0.f, 1.f, 1.f);
transform.TransformRect(&unit);
return std::max(unit.width(), unit.height());
}
float MathUtil::SmallestAngleBetweenVectors(const gfx::Vector2dF& v1,
......
......@@ -474,6 +474,17 @@ TEST(LayerImplTest, PerspectiveTransformHasReasonableScale) {
ASSERT_TRUE(layer->ScreenSpaceTransform().HasPerspective());
EXPECT_FLOAT_EQ(127.f, layer->GetIdealContentsScale());
}
// Test case from crbug.com/766021.
{
gfx::Transform transform(-0.9397f, -0.7019f, 0.2796f, 2383.4521f, // row 1
-0.0038f, 0.0785f, 1.0613f, 1876.4553f, // row 2
-0.0835f, 0.9081f, -0.4105f, -2208.3035f, // row 3
0.0001f, -0.0008f, 0.0003f, 2.8435f); // row 4
layer->draw_properties().screen_space_transform = transform;
ASSERT_TRUE(layer->ScreenSpaceTransform().HasPerspective());
EXPECT_FLOAT_EQ(1.f, layer->GetIdealContentsScale());
}
}
class LayerImplScrollTest : public testing::Test {
......
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