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

Side by Side Diff: cc/damage_tracker_unittest.cc

Issue 11308153: Migrate most of cc/ from WebKit::WebTransformationMatrix to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to tip of tree and addressed feedback 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
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 "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"
11 #include "cc/single_thread_proxy.h" 11 #include "cc/single_thread_proxy.h"
12 #include "cc/test/geometry_test_utils.h" 12 #include "cc/test/geometry_test_utils.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 14 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
15 #include <public/WebFilterOperation.h> 15 #include <public/WebFilterOperation.h>
16 #include <public/WebFilterOperations.h> 16 #include <public/WebFilterOperations.h>
17 17
18 using namespace WebKit; 18 using namespace WebKit;
19 using namespace WebKitTests; 19 using namespace WebKitTests;
20 20
21 using gfx::Transform;
22
21 namespace cc { 23 namespace cc {
22 namespace { 24 namespace {
23 25
24 void executeCalculateDrawTransformsAndVisibility(LayerImpl* root, std::vector<La yerImpl*>& renderSurfaceLayerList) 26 void executeCalculateDrawTransformsAndVisibility(LayerImpl* root, std::vector<La yerImpl*>& renderSurfaceLayerList)
25 { 27 {
26 LayerSorter layerSorter; 28 LayerSorter layerSorter;
27 int dummyMaxTextureSize = 512; 29 int dummyMaxTextureSize = 512;
28 30
29 // Sanity check: The test itself should create the root layer's render surfa ce, so 31 // Sanity check: The test itself should create the root layer's render surfa ce, so
30 // that the surface (and its damage tracker) can persist acros s multiple 32 // that the surface (and its damage tracker) can persist acros s multiple
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 280 }
279 281
280 TEST_F(DamageTrackerTest, verifyDamageForTransformedLayer) 282 TEST_F(DamageTrackerTest, verifyDamageForTransformedLayer)
281 { 283 {
282 // If a layer is transformed, the damage rect should still enclose the entir e 284 // If a layer is transformed, the damage rect should still enclose the entir e
283 // transformed layer. 285 // transformed layer.
284 286
285 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 287 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
286 LayerImpl* child = root->children()[0]; 288 LayerImpl* child = root->children()[0];
287 289
288 WebTransformationMatrix rotation; 290 Transform rotation;
289 rotation.rotate(45); 291 rotation.PreconcatRotate(45);
290 292
291 clearDamageForAllSurfaces(root.get()); 293 clearDamageForAllSurfaces(root.get());
292 child->setAnchorPoint(gfx::PointF(0.5, 0.5)); 294 child->setAnchorPoint(gfx::PointF(0.5, 0.5));
293 child->setPosition(gfx::PointF(85, 85)); 295 child->setPosition(gfx::PointF(85, 85));
294 emulateDrawingOneFrame(root.get()); 296 emulateDrawingOneFrame(root.get());
295 297
296 // Sanity check that the layer actually moved to (85, 85), damaging its old location and new location. 298 // 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(); 299 gfx::RectF rootDamageRect = root->renderSurface()->damageTracker()->currentD amageRect();
298 EXPECT_FLOAT_RECT_EQ(gfx::RectF(85, 85, 45, 45), rootDamageRect); 300 EXPECT_FLOAT_RECT_EQ(gfx::RectF(85, 85, 45, 45), rootDamageRect);
299 301
(...skipping 21 matching lines...) Expand all
321 // 323 //
322 // The transform is constructed so that if w < 0 clipping is not performed, the 324 // 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. 325 // 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), 326 // 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. 327 // and positioned so that the right-most bound rect will be approximately 50 1 units in root surface space.
326 // 328 //
327 329
328 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 330 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
329 LayerImpl* child = root->children()[0]; 331 LayerImpl* child = root->children()[0];
330 332
331 WebTransformationMatrix transform; 333 Transform transform;
332 transform.translate3d(500, 500, 0); 334 transform.PreconcatTranslate3d(500, 500, 0);
333 transform.applyPerspective(1); 335 transform.PreconcatPerspectiveDepth(1);
334 transform.rotate3d(0, 45, 0); 336 MathUtil::rotateEulerAngles(&transform, 0, 45, 0);
335 transform.translate3d(-50, -50, 0); 337 transform.PreconcatTranslate3d(-50, -50, 0);
336 338
337 // Set up the child 339 // Set up the child
338 child->setPosition(gfx::PointF(0, 0)); 340 child->setPosition(gfx::PointF(0, 0));
339 child->setBounds(gfx::Size(100, 100)); 341 child->setBounds(gfx::Size(100, 100));
340 child->setContentBounds(gfx::Size(100, 100)); 342 child->setContentBounds(gfx::Size(100, 100));
341 child->setTransform(transform); 343 child->setTransform(transform);
342 emulateDrawingOneFrame(root.get()); 344 emulateDrawingOneFrame(root.get());
343 345
344 // Sanity check that the child layer's bounds would actually get clipped by w < 0, 346 // 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. 347 // otherwise this test is not actually testing the intended scenario.
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 child1->setOpacity(0.5); 828 child1->setOpacity(0.5);
827 emulateDrawingOneFrame(root.get()); 829 emulateDrawingOneFrame(root.get());
828 830
829 // CASE 1: adding a reflection about the left edge of grandChild1. 831 // CASE 1: adding a reflection about the left edge of grandChild1.
830 // 832 //
831 clearDamageForAllSurfaces(root.get()); 833 clearDamageForAllSurfaces(root.get());
832 { 834 {
833 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(7); 835 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(7);
834 grandChild1Replica->setPosition(gfx::PointF()); 836 grandChild1Replica->setPosition(gfx::PointF());
835 grandChild1Replica->setAnchorPoint(gfx::PointF()); 837 grandChild1Replica->setAnchorPoint(gfx::PointF());
836 WebTransformationMatrix reflection; 838 Transform reflection;
837 reflection.scale3d(-1, 1, 1); 839 reflection.PreconcatScale3d(-1, 1, 1);
838 grandChild1Replica->setTransform(reflection); 840 grandChild1Replica->setTransform(reflection);
839 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); 841 grandChild1->setReplicaLayer(grandChild1Replica.Pass());
840 } 842 }
841 emulateDrawingOneFrame(root.get()); 843 emulateDrawingOneFrame(root.get());
842 844
843 gfx::RectF grandChildDamageRect = grandChild1->renderSurface()->damageTracke r()->currentDamageRect(); 845 gfx::RectF grandChildDamageRect = grandChild1->renderSurface()->damageTracke r()->currentDamageRect();
844 gfx::RectF childDamageRect = child1->renderSurface()->damageTracker()->curre ntDamageRect(); 846 gfx::RectF childDamageRect = child1->renderSurface()->damageTracker()->curre ntDamageRect();
845 gfx::RectF rootDamageRect = root->renderSurface()->damageTracker()->currentD amageRect(); 847 gfx::RectF rootDamageRect = root->renderSurface()->damageTracker()->currentD amageRect();
846 848
847 // The grandChild surface damage should not include its own replica. The chi ld 849 // 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
979 // Changes to a replica's mask should not damage the original surface, becau se it is 981 // 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. 982 // not masked. But it does damage the ancestor target surface.
981 983
982 clearDamageForAllSurfaces(root.get()); 984 clearDamageForAllSurfaces(root.get());
983 985
984 // Create a reflection about the left edge of grandChild1. 986 // Create a reflection about the left edge of grandChild1.
985 { 987 {
986 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6); 988 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6);
987 grandChild1Replica->setPosition(gfx::PointF()); 989 grandChild1Replica->setPosition(gfx::PointF());
988 grandChild1Replica->setAnchorPoint(gfx::PointF()); 990 grandChild1Replica->setAnchorPoint(gfx::PointF());
989 WebTransformationMatrix reflection; 991 Transform reflection;
990 reflection.scale3d(-1, 1, 1); 992 reflection.PreconcatScale3d(-1, 1, 1);
991 grandChild1Replica->setTransform(reflection); 993 grandChild1Replica->setTransform(reflection);
992 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); 994 grandChild1->setReplicaLayer(grandChild1Replica.Pass());
993 } 995 }
994 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); 996 LayerImpl* grandChild1Replica = grandChild1->replicaLayer();
995 997
996 // Set up the mask layer on the replica layer 998 // Set up the mask layer on the replica layer
997 { 999 {
998 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(7); 1000 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(7);
999 replicaMaskLayer->setPosition(gfx::PointF()); 1001 replicaMaskLayer->setPosition(gfx::PointF());
1000 replicaMaskLayer->setAnchorPoint(gfx::PointF()); 1002 replicaMaskLayer->setAnchorPoint(gfx::PointF());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 1043
1042 // Verify that the correct replicaOriginTransform is used for the replicaMas k; 1044 // Verify that the correct replicaOriginTransform is used for the replicaMas k;
1043 clearDamageForAllSurfaces(root.get()); 1045 clearDamageForAllSurfaces(root.get());
1044 1046
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. 1047 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 1048
1047 { 1049 {
1048 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6); 1050 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6);
1049 grandChild1Replica->setPosition(gfx::PointF()); 1051 grandChild1Replica->setPosition(gfx::PointF());
1050 grandChild1Replica->setAnchorPoint(gfx::PointF(1, 0)); // This is the an chor being tested. 1052 grandChild1Replica->setAnchorPoint(gfx::PointF(1, 0)); // This is the an chor being tested.
1051 WebTransformationMatrix reflection; 1053 Transform reflection;
1052 reflection.scale3d(-1, 1, 1); 1054 reflection.PreconcatScale3d(-1, 1, 1);
1053 grandChild1Replica->setTransform(reflection); 1055 grandChild1Replica->setTransform(reflection);
1054 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); 1056 grandChild1->setReplicaLayer(grandChild1Replica.Pass());
1055 } 1057 }
1056 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); 1058 LayerImpl* grandChild1Replica = grandChild1->replicaLayer();
1057 1059
1058 // Set up the mask layer on the replica layer 1060 // Set up the mask layer on the replica layer
1059 { 1061 {
1060 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(7); 1062 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(7);
1061 replicaMaskLayer->setPosition(gfx::PointF()); 1063 replicaMaskLayer->setPosition(gfx::PointF());
1062 replicaMaskLayer->setAnchorPoint(gfx::PointF()); // note, this is not th e anchor being tested. 1064 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
1150 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1152 EXPECT_TRUE(rootDamageRect.IsEmpty());
1151 1153
1152 // Damage should remain empty even after one frame, since there's yet no new damage 1154 // Damage should remain empty even after one frame, since there's yet no new damage
1153 emulateDrawingOneFrame(root.get()); 1155 emulateDrawingOneFrame(root.get());
1154 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; 1156 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
1155 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1157 EXPECT_TRUE(rootDamageRect.IsEmpty());
1156 } 1158 }
1157 1159
1158 } // namespace 1160 } // namespace
1159 } // namespace cc 1161 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698