diff options
author | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-06 23:23:32 +0000 |
---|---|---|
committer | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-06 23:23:32 +0000 |
commit | f224cc9a660a41bf5115fb2db7564cd0c87d68b5 (patch) | |
tree | 367cecabdd2f47685b214c92833567a44140ba99 /cc/layers/layer_position_constraint_unittest.cc | |
parent | 2ed80f0145fc03eb7eac6333b11eb27645bb37ea (diff) | |
download | chromium_src-f224cc9a660a41bf5115fb2db7564cd0c87d68b5.zip chromium_src-f224cc9a660a41bf5115fb2db7564cd0c87d68b5.tar.gz chromium_src-f224cc9a660a41bf5115fb2db7564cd0c87d68b5.tar.bz2 |
Implement transform/clip support for Android WebView.
Transforms are applied above the root-layer. I fixed LTHCommon to forward
root-layer transforms to sublayers, as the RenderSurface-based logic was previously
clearing transforms and copying over only the scale portion.
The clip rect is treated as the viewport for the purposes of DrawQuads and Renderer
(this is required to avoid awful performance when the WebView is much larger than
the screen). Because y-flipping the clip rect depends on knowledge of the true
surface size, I also needed to add a new OutputSurface::SurfaceSize() getter and refactored
viewport size throughout the Renderers to separate render-pass draw rect, glViewport rect,
and surface size.
Scale and translate transforms work with this patch, but rotation is still broken.
New tests: LayerTreeHostCommonTest.TransformAboveRootLayer,
GLRendererTest2.ScissorAndViewportWithinNonreshapableSurface,
RendererPixelTest/2* and 3*
NOTRY=true
BUG=230463
Review URL: https://chromiumcodereview.appspot.com/15579002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204650 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layers/layer_position_constraint_unittest.cc')
-rw-r--r-- | cc/layers/layer_position_constraint_unittest.cc | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/cc/layers/layer_position_constraint_unittest.cc b/cc/layers/layer_position_constraint_unittest.cc index af1af4e..1e6084f 100644 --- a/cc/layers/layer_position_constraint_unittest.cc +++ b/cc/layers/layer_position_constraint_unittest.cc @@ -50,6 +50,7 @@ void ExecuteCalculateDrawProperties(LayerImpl* root_layer, LayerTreeHostCommon::CalculateDrawProperties( root_layer, device_viewport_size, + gfx::Transform(), device_scale_factor, page_scale_factor, page_scale_application_layer, @@ -1034,8 +1035,7 @@ TEST_F(LayerPositionConstraintTest, ScrollCompensationForFixedPositionLayerThatHasNoContainer) { // This test checks scroll compensation when a fixed-position layer does not // find any ancestor that is a "containerForFixedPositionLayers". In this - // situation, the layer should be fixed to the viewport -- not the root_layer, - // which may have transforms of its own. + // situation, the layer should be fixed to the root layer. LayerImpl* child = root_->children()[0]; LayerImpl* grand_child = child->children()[0]; @@ -1051,46 +1051,43 @@ TEST_F(LayerPositionConstraintTest, gfx::Transform identity_matrix; - EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); - EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, + EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_by_z, child->draw_transform()); + EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_by_z, grand_child->draw_transform()); // Case 2: root scroll delta of 10, 10 root_->SetScrollDelta(gfx::Vector2d(10, 20)); ExecuteCalculateDrawProperties(root_.get()); - // The child is affected by scroll delta, but it is already implcitly - // accounted for by the child's target surface (i.e. the root render surface). - // The grand_child is not affected by the scroll delta, so its draw transform - // needs to explicitly inverse-compensate for the scroll that's embedded in - // the target surface. - gfx::Transform expected_grand_child_transform; - expected_grand_child_transform.PreconcatTransform(Inverse(rotation_by_z)); - // explicit cancelling out the scroll delta that gets embedded in the fixed - // position layer's surface. - expected_grand_child_transform.Translate(10.0, 20.0); - expected_grand_child_transform.PreconcatTransform(rotation_by_z); + gfx::Transform expected_child_transform; + expected_child_transform.Translate(-10.0, -20.0); + expected_child_transform.PreconcatTransform(rotation_by_z); - EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); - EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, + EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, + child->draw_transform()); + EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_by_z, grand_child->draw_transform()); - // Case 3: fixed-container size delta of 20, 20 root_->SetFixedContainerSizeDelta(gfx::Vector2d(20, 20)); ExecuteCalculateDrawProperties(root_.get()); // Top-left fixed-position layer should not be affected by container size. - EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); - EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, + EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, + child->draw_transform()); + EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_by_z, grand_child->draw_transform()); // Case 4: Bottom-right fixed-position layer. grand_child->SetPositionConstraint(fixed_to_bottom_right_); ExecuteCalculateDrawProperties(root_.get()); - // Root layer is not the fixed-container anyway. - EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); + gfx::Transform expected_grand_child_transform; + expected_grand_child_transform.Translate(-20.0, 20.0); + expected_grand_child_transform.PreconcatTransform(rotation_by_z); + + EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, + child->draw_transform()); EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, grand_child->draw_transform()); } |