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

Side by Side Diff: cc/layer_tree_host_common_unittest.cc

Issue 11362151: cc: Do not save the rasterScale for layers until they are finished animating transforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer_tree_host_common.cc ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer_tree_host_common.h" 7 #include "cc/layer_tree_host_common.h"
8 8
9 #include "cc/content_layer.h" 9 #include "cc/content_layer.h"
10 #include "cc/content_layer_client.h" 10 #include "cc/content_layer_client.h"
(...skipping 3858 matching lines...) Expand 10 before | Expand all | Expand 10 after
3869 3869
3870 // The surfaceScaleChildScale can apply contents scale so it shouldn't need to scale during draw. 3870 // The surfaceScaleChildScale can apply contents scale so it shouldn't need to scale during draw.
3871 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().m11()); 3871 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().m11());
3872 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().m22()); 3872 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().m22());
3873 3873
3874 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to be scaled during draw. 3874 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to be scaled during draw.
3875 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf orm().m11()); 3875 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf orm().m11());
3876 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf orm().m22()); 3876 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf orm().m22());
3877 } 3877 }
3878 3878
3879 TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer)
3880 {
3881 MockContentLayerClient delegate;
3882 WebTransformationMatrix identityMatrix;
3883
3884 WebTransformationMatrix parentScaleMatrix;
3885 const double initialParentScale = 1.75;
3886 parentScaleMatrix.scale(initialParentScale);
3887
3888 WebTransformationMatrix childScaleMatrix;
3889 const double initialChildScale = 1.25;
3890 childScaleMatrix.scale(initialChildScale);
3891
3892 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate);
3893 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true);
3894
3895 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat e);
3896 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true);
3897
3898 parent->addChild(childScale);
3899
3900 // Now put an animating transform on child.
3901 int animationId = addAnimatedTransformToController(*childScale->layerAnimati onController(), 10, 30, 0);
3902
3903 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
3904 int dummyMaxTextureSize = 512;
3905
3906 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
3907
3908 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent);
3909 // The layers with animating transforms should not compute a contentsScale o ther than 1 until they finish animating.
3910 EXPECT_CONTENTS_SCALE_EQ(1, childScale);
3911
3912 // Remove the animation, now it can save a raster scale.
3913 childScale->layerAnimationController()->removeAnimation(animationId);
3914
3915 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
3916
3917 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent);
3918 // The layers with animating transforms should not compute a contentsScale o ther than 1 until they finish animating.
3919 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale) ;
3920 }
3921
3922
3879 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) 3923 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI)
3880 { 3924 {
3881 MockContentLayerClient delegate; 3925 MockContentLayerClient delegate;
3882 WebTransformationMatrix identityMatrix; 3926 WebTransformationMatrix identityMatrix;
3883 3927
3884 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); 3928 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate);
3885 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(30, 30), true); 3929 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(30, 30), true);
3886 3930
3887 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); 3931 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate);
3888 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); 3932 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
4039 int nonexistentId = -1; 4083 int nonexistentId = -1;
4040 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ())); 4084 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ()));
4041 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id())); 4085 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id()));
4042 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id())); 4086 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id()));
4043 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id())); 4087 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id()));
4044 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); 4088 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id()));
4045 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id)); 4089 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id));
4046 } 4090 }
4047 4091
4048 } // anonymous namespace 4092 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/layer_tree_host_common.cc ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698