| OLD | NEW |
| 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 "cc/damage_tracker.h" | 5 #include "cc/damage_tracker.h" |
| 6 | 6 |
| 7 #include "cc/layer_impl.h" | 7 #include "cc/layer_impl.h" |
| 8 #include "cc/layer_sorter.h" | 8 #include "cc/layer_sorter.h" |
| 9 #include "cc/layer_tree_host_common.h" | 9 #include "cc/layer_tree_host_common.h" |
| 10 #include "cc/math_util.h" | 10 #include "cc/math_util.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 278 } |
| 279 | 279 |
| 280 TEST_F(DamageTrackerTest, verifyDamageForTransformedLayer) | 280 TEST_F(DamageTrackerTest, verifyDamageForTransformedLayer) |
| 281 { | 281 { |
| 282 // If a layer is transformed, the damage rect should still enclose the entir
e | 282 // If a layer is transformed, the damage rect should still enclose the entir
e |
| 283 // transformed layer. | 283 // transformed layer. |
| 284 | 284 |
| 285 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 285 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
| 286 LayerImpl* child = root->children()[0]; | 286 LayerImpl* child = root->children()[0]; |
| 287 | 287 |
| 288 WebTransformationMatrix rotation; | 288 gfx::Transform rotation; |
| 289 rotation.rotate(45); | 289 rotation.Rotate(45); |
| 290 | 290 |
| 291 clearDamageForAllSurfaces(root.get()); | 291 clearDamageForAllSurfaces(root.get()); |
| 292 child->setAnchorPoint(gfx::PointF(0.5, 0.5)); | 292 child->setAnchorPoint(gfx::PointF(0.5, 0.5)); |
| 293 child->setPosition(gfx::PointF(85, 85)); | 293 child->setPosition(gfx::PointF(85, 85)); |
| 294 emulateDrawingOneFrame(root.get()); | 294 emulateDrawingOneFrame(root.get()); |
| 295 | 295 |
| 296 // Sanity check that the layer actually moved to (85, 85), damaging its old
location and new location. | 296 // Sanity check that the layer actually moved to (85, 85), damaging its old
location and new location. |
| 297 gfx::RectF rootDamageRect = root->renderSurface()->damageTracker()->currentD
amageRect(); | 297 gfx::RectF rootDamageRect = root->renderSurface()->damageTracker()->currentD
amageRect(); |
| 298 EXPECT_FLOAT_RECT_EQ(gfx::RectF(85, 85, 45, 45), rootDamageRect); | 298 EXPECT_FLOAT_RECT_EQ(gfx::RectF(85, 85, 45, 45), rootDamageRect); |
| 299 | 299 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 321 // | 321 // |
| 322 // The transform is constructed so that if w < 0 clipping is not performed,
the | 322 // The transform is constructed so that if w < 0 clipping is not performed,
the |
| 323 // incorrect rect will be very small, specifically: position (500.972504, 49
8.544617) and size 0.056610 x 2.910767. | 323 // incorrect rect will be very small, specifically: position (500.972504, 49
8.544617) and size 0.056610 x 2.910767. |
| 324 // Instead, the correctly transformed rect should actually be very huge (i.e
. in theory, -infinity on the left), | 324 // Instead, the correctly transformed rect should actually be very huge (i.e
. in theory, -infinity on the left), |
| 325 // and positioned so that the right-most bound rect will be approximately 50
1 units in root surface space. | 325 // and positioned so that the right-most bound rect will be approximately 50
1 units in root surface space. |
| 326 // | 326 // |
| 327 | 327 |
| 328 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 328 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
| 329 LayerImpl* child = root->children()[0]; | 329 LayerImpl* child = root->children()[0]; |
| 330 | 330 |
| 331 WebTransformationMatrix transform; | 331 gfx::Transform transform; |
| 332 transform.translate3d(500, 500, 0); | 332 transform.Translate3d(500, 500, 0); |
| 333 transform.applyPerspective(1); | 333 transform.ApplyPerspectiveDepth(1); |
| 334 transform.rotate3d(0, 45, 0); | 334 MathUtil::rotateEulerAngles(&transform, 0, 45, 0); |
| 335 transform.translate3d(-50, -50, 0); | 335 transform.Translate3d(-50, -50, 0); |
| 336 | 336 |
| 337 // Set up the child | 337 // Set up the child |
| 338 child->setPosition(gfx::PointF(0, 0)); | 338 child->setPosition(gfx::PointF(0, 0)); |
| 339 child->setBounds(gfx::Size(100, 100)); | 339 child->setBounds(gfx::Size(100, 100)); |
| 340 child->setContentBounds(gfx::Size(100, 100)); | 340 child->setContentBounds(gfx::Size(100, 100)); |
| 341 child->setTransform(transform); | 341 child->setTransform(transform); |
| 342 emulateDrawingOneFrame(root.get()); | 342 emulateDrawingOneFrame(root.get()); |
| 343 | 343 |
| 344 // Sanity check that the child layer's bounds would actually get clipped by
w < 0, | 344 // Sanity check that the child layer's bounds would actually get clipped by
w < 0, |
| 345 // otherwise this test is not actually testing the intended scenario. | 345 // otherwise this test is not actually testing the intended scenario. |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 child1->setOpacity(0.5); | 826 child1->setOpacity(0.5); |
| 827 emulateDrawingOneFrame(root.get()); | 827 emulateDrawingOneFrame(root.get()); |
| 828 | 828 |
| 829 // CASE 1: adding a reflection about the left edge of grandChild1. | 829 // CASE 1: adding a reflection about the left edge of grandChild1. |
| 830 // | 830 // |
| 831 clearDamageForAllSurfaces(root.get()); | 831 clearDamageForAllSurfaces(root.get()); |
| 832 { | 832 { |
| 833 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(7); | 833 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(7); |
| 834 grandChild1Replica->setPosition(gfx::PointF()); | 834 grandChild1Replica->setPosition(gfx::PointF()); |
| 835 grandChild1Replica->setAnchorPoint(gfx::PointF()); | 835 grandChild1Replica->setAnchorPoint(gfx::PointF()); |
| 836 WebTransformationMatrix reflection; | 836 gfx::Transform reflection; |
| 837 reflection.scale3d(-1, 1, 1); | 837 reflection.Scale3d(-1, 1, 1); |
| 838 grandChild1Replica->setTransform(reflection); | 838 grandChild1Replica->setTransform(reflection); |
| 839 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); | 839 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); |
| 840 } | 840 } |
| 841 emulateDrawingOneFrame(root.get()); | 841 emulateDrawingOneFrame(root.get()); |
| 842 | 842 |
| 843 gfx::RectF grandChildDamageRect = grandChild1->renderSurface()->damageTracke
r()->currentDamageRect(); | 843 gfx::RectF grandChildDamageRect = grandChild1->renderSurface()->damageTracke
r()->currentDamageRect(); |
| 844 gfx::RectF childDamageRect = child1->renderSurface()->damageTracker()->curre
ntDamageRect(); | 844 gfx::RectF childDamageRect = child1->renderSurface()->damageTracker()->curre
ntDamageRect(); |
| 845 gfx::RectF rootDamageRect = root->renderSurface()->damageTracker()->currentD
amageRect(); | 845 gfx::RectF rootDamageRect = root->renderSurface()->damageTracker()->currentD
amageRect(); |
| 846 | 846 |
| 847 // The grandChild surface damage should not include its own replica. The chi
ld | 847 // The grandChild surface damage should not include its own replica. The chi
ld |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 // Changes to a replica's mask should not damage the original surface, becau
se it is | 979 // Changes to a replica's mask should not damage the original surface, becau
se it is |
| 980 // not masked. But it does damage the ancestor target surface. | 980 // not masked. But it does damage the ancestor target surface. |
| 981 | 981 |
| 982 clearDamageForAllSurfaces(root.get()); | 982 clearDamageForAllSurfaces(root.get()); |
| 983 | 983 |
| 984 // Create a reflection about the left edge of grandChild1. | 984 // Create a reflection about the left edge of grandChild1. |
| 985 { | 985 { |
| 986 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6); | 986 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6); |
| 987 grandChild1Replica->setPosition(gfx::PointF()); | 987 grandChild1Replica->setPosition(gfx::PointF()); |
| 988 grandChild1Replica->setAnchorPoint(gfx::PointF()); | 988 grandChild1Replica->setAnchorPoint(gfx::PointF()); |
| 989 WebTransformationMatrix reflection; | 989 gfx::Transform reflection; |
| 990 reflection.scale3d(-1, 1, 1); | 990 reflection.Scale3d(-1, 1, 1); |
| 991 grandChild1Replica->setTransform(reflection); | 991 grandChild1Replica->setTransform(reflection); |
| 992 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); | 992 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); |
| 993 } | 993 } |
| 994 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); | 994 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); |
| 995 | 995 |
| 996 // Set up the mask layer on the replica layer | 996 // Set up the mask layer on the replica layer |
| 997 { | 997 { |
| 998 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(7); | 998 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(7); |
| 999 replicaMaskLayer->setPosition(gfx::PointF()); | 999 replicaMaskLayer->setPosition(gfx::PointF()); |
| 1000 replicaMaskLayer->setAnchorPoint(gfx::PointF()); | 1000 replicaMaskLayer->setAnchorPoint(gfx::PointF()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 | 1041 |
| 1042 // Verify that the correct replicaOriginTransform is used for the replicaMas
k; | 1042 // Verify that the correct replicaOriginTransform is used for the replicaMas
k; |
| 1043 clearDamageForAllSurfaces(root.get()); | 1043 clearDamageForAllSurfaces(root.get()); |
| 1044 | 1044 |
| 1045 grandChild1->setAnchorPoint(gfx::PointF(1, 0)); // This is not exactly the a
nchor being tested, but by convention its expected to be the same as the replica
's anchor point. | 1045 grandChild1->setAnchorPoint(gfx::PointF(1, 0)); // This is not exactly the a
nchor being tested, but by convention its expected to be the same as the replica
's anchor point. |
| 1046 | 1046 |
| 1047 { | 1047 { |
| 1048 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6); | 1048 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6); |
| 1049 grandChild1Replica->setPosition(gfx::PointF()); | 1049 grandChild1Replica->setPosition(gfx::PointF()); |
| 1050 grandChild1Replica->setAnchorPoint(gfx::PointF(1, 0)); // This is the an
chor being tested. | 1050 grandChild1Replica->setAnchorPoint(gfx::PointF(1, 0)); // This is the an
chor being tested. |
| 1051 WebTransformationMatrix reflection; | 1051 gfx::Transform reflection; |
| 1052 reflection.scale3d(-1, 1, 1); | 1052 reflection.Scale3d(-1, 1, 1); |
| 1053 grandChild1Replica->setTransform(reflection); | 1053 grandChild1Replica->setTransform(reflection); |
| 1054 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); | 1054 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); |
| 1055 } | 1055 } |
| 1056 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); | 1056 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); |
| 1057 | 1057 |
| 1058 // Set up the mask layer on the replica layer | 1058 // Set up the mask layer on the replica layer |
| 1059 { | 1059 { |
| 1060 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(7); | 1060 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(7); |
| 1061 replicaMaskLayer->setPosition(gfx::PointF()); | 1061 replicaMaskLayer->setPosition(gfx::PointF()); |
| 1062 replicaMaskLayer->setAnchorPoint(gfx::PointF()); // note, this is not th
e anchor being tested. | 1062 replicaMaskLayer->setAnchorPoint(gfx::PointF()); // note, this is not th
e anchor being tested. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 EXPECT_TRUE(rootDamageRect.IsEmpty()); | 1150 EXPECT_TRUE(rootDamageRect.IsEmpty()); |
| 1151 | 1151 |
| 1152 // Damage should remain empty even after one frame, since there's yet no new
damage | 1152 // Damage should remain empty even after one frame, since there's yet no new
damage |
| 1153 emulateDrawingOneFrame(root.get()); | 1153 emulateDrawingOneFrame(root.get()); |
| 1154 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 1154 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
| 1155 EXPECT_TRUE(rootDamageRect.IsEmpty()); | 1155 EXPECT_TRUE(rootDamageRect.IsEmpty()); |
| 1156 } | 1156 } |
| 1157 | 1157 |
| 1158 } // namespace | 1158 } // namespace |
| 1159 } // namespace cc | 1159 } // namespace cc |
| OLD | NEW |