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

Side by Side Diff: cc/layer_tree_host_common_unittest.cc

Issue 11418197: Move temporary MathUtil wrappers to permanent home in gfx::Transform (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years 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
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/layer_tree_host_common.h" 5 #include "cc/layer_tree_host_common.h"
6 6
7 #include "cc/content_layer.h" 7 #include "cc/content_layer.h"
8 #include "cc/content_layer_client.h" 8 #include "cc/content_layer_client.h"
9 #include "cc/layer.h" 9 #include "cc/layer.h"
10 #include "cc/layer_animation_controller.h" 10 #include "cc/layer_animation_controller.h"
(...skipping 2439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 backFacingChild->setDoubleSided(false); 2450 backFacingChild->setDoubleSided(false);
2451 frontFacingSurface->setDoubleSided(false); 2451 frontFacingSurface->setDoubleSided(false);
2452 backFacingSurface->setDoubleSided(false); 2452 backFacingSurface->setDoubleSided(false);
2453 frontFacingChildOfFrontFacingSurface->setDoubleSided(false); 2453 frontFacingChildOfFrontFacingSurface->setDoubleSided(false);
2454 backFacingChildOfFrontFacingSurface->setDoubleSided(false); 2454 backFacingChildOfFrontFacingSurface->setDoubleSided(false);
2455 frontFacingChildOfBackFacingSurface->setDoubleSided(false); 2455 frontFacingChildOfBackFacingSurface->setDoubleSided(false);
2456 backFacingChildOfBackFacingSurface->setDoubleSided(false); 2456 backFacingChildOfBackFacingSurface->setDoubleSided(false);
2457 2457
2458 gfx::Transform backfaceMatrix; 2458 gfx::Transform backfaceMatrix;
2459 backfaceMatrix.Translate(50, 50); 2459 backfaceMatrix.Translate(50, 50);
2460 MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180); 2460 backfaceMatrix.RotateAbout(gfx::Vector3dF::YAxis(), 180);
2461 backfaceMatrix.Translate(-50, -50); 2461 backfaceMatrix.Translate(-50, -50);
2462 2462
2463 // Having a descendant and opacity will force these to have render surfaces. 2463 // Having a descendant and opacity will force these to have render surfaces.
2464 frontFacingSurface->setOpacity(0.5); 2464 frontFacingSurface->setOpacity(0.5);
2465 backFacingSurface->setOpacity(0.5); 2465 backFacingSurface->setOpacity(0.5);
2466 2466
2467 // Nothing preserves 3d. According to current W3C CSS gfx::Transforms spec, these layers 2467 // Nothing preserves 3d. According to current W3C CSS gfx::Transforms spec, these layers
2468 // should blindly use their own local transforms to determine back-face cull ing. 2468 // should blindly use their own local transforms to determine back-face cull ing.
2469 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2469 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2470 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2470 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 backFacingChild->setDoubleSided(false); 2544 backFacingChild->setDoubleSided(false);
2545 frontFacingSurface->setDoubleSided(false); 2545 frontFacingSurface->setDoubleSided(false);
2546 backFacingSurface->setDoubleSided(false); 2546 backFacingSurface->setDoubleSided(false);
2547 frontFacingChildOfFrontFacingSurface->setDoubleSided(false); 2547 frontFacingChildOfFrontFacingSurface->setDoubleSided(false);
2548 backFacingChildOfFrontFacingSurface->setDoubleSided(false); 2548 backFacingChildOfFrontFacingSurface->setDoubleSided(false);
2549 frontFacingChildOfBackFacingSurface->setDoubleSided(false); 2549 frontFacingChildOfBackFacingSurface->setDoubleSided(false);
2550 backFacingChildOfBackFacingSurface->setDoubleSided(false); 2550 backFacingChildOfBackFacingSurface->setDoubleSided(false);
2551 2551
2552 gfx::Transform backfaceMatrix; 2552 gfx::Transform backfaceMatrix;
2553 backfaceMatrix.Translate(50, 50); 2553 backfaceMatrix.Translate(50, 50);
2554 MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180); 2554 backfaceMatrix.RotateAbout(gfx::Vector3dF::YAxis(), 180);
2555 backfaceMatrix.Translate(-50, -50); 2555 backfaceMatrix.Translate(-50, -50);
2556 2556
2557 // Opacity will not force creation of renderSurfaces in this case because of the 2557 // Opacity will not force creation of renderSurfaces in this case because of the
2558 // preserve-3d transform style. Instead, an example of when a surface would be 2558 // preserve-3d transform style. Instead, an example of when a surface would be
2559 // created with preserve-3d is when there is a replica layer. 2559 // created with preserve-3d is when there is a replica layer.
2560 frontFacingSurface->setReplicaLayer(dummyReplicaLayer1.get()); 2560 frontFacingSurface->setReplicaLayer(dummyReplicaLayer1.get());
2561 backFacingSurface->setReplicaLayer(dummyReplicaLayer2.get()); 2561 backFacingSurface->setReplicaLayer(dummyReplicaLayer2.get());
2562 2562
2563 // Each surface creates its own new 3d rendering context (as defined by W3C spec). 2563 // Each surface creates its own new 3d rendering context (as defined by W3C spec).
2564 // According to current W3C CSS gfx::Transforms spec, layers in a 3d renderi ng context 2564 // According to current W3C CSS gfx::Transforms spec, layers in a 3d renderi ng context
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2630 2630
2631 // Nothing is double-sided 2631 // Nothing is double-sided
2632 child->setDoubleSided(false); 2632 child->setDoubleSided(false);
2633 child2->setDoubleSided(false); 2633 child2->setDoubleSided(false);
2634 animatingSurface->setDoubleSided(false); 2634 animatingSurface->setDoubleSided(false);
2635 childOfAnimatingSurface->setDoubleSided(false); 2635 childOfAnimatingSurface->setDoubleSided(false);
2636 animatingChild->setDoubleSided(false); 2636 animatingChild->setDoubleSided(false);
2637 2637
2638 gfx::Transform backfaceMatrix; 2638 gfx::Transform backfaceMatrix;
2639 backfaceMatrix.Translate(50, 50); 2639 backfaceMatrix.Translate(50, 50);
2640 MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180); 2640 backfaceMatrix.RotateAbout(gfx::Vector3dF::YAxis(), 180);
2641 backfaceMatrix.Translate(-50, -50); 2641 backfaceMatrix.Translate(-50, -50);
2642 2642
2643 // Make our render surface. 2643 // Make our render surface.
2644 animatingSurface->setForceRenderSurface(true); 2644 animatingSurface->setForceRenderSurface(true);
2645 2645
2646 // Animate the transform on the render surface. 2646 // Animate the transform on the render surface.
2647 addAnimatedTransformToController(*animatingSurface->layerAnimationController (), 10, 30, 0); 2647 addAnimatedTransformToController(*animatingSurface->layerAnimationController (), 10, 30, 0);
2648 // This is just an animating layer, not a surface. 2648 // This is just an animating layer, not a surface.
2649 addAnimatedTransformToController(*animatingChild->layerAnimationController() , 10, 30, 0); 2649 addAnimatedTransformToController(*animatingChild->layerAnimationController() , 10, 30, 0);
2650 2650
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2705 parent->addChild(backFacingSurface); 2705 parent->addChild(backFacingSurface);
2706 frontFacingSurface->addChild(child1); 2706 frontFacingSurface->addChild(child1);
2707 backFacingSurface->addChild(child2); 2707 backFacingSurface->addChild(child2);
2708 2708
2709 // RenderSurfaces are not double-sided 2709 // RenderSurfaces are not double-sided
2710 frontFacingSurface->setDoubleSided(false); 2710 frontFacingSurface->setDoubleSided(false);
2711 backFacingSurface->setDoubleSided(false); 2711 backFacingSurface->setDoubleSided(false);
2712 2712
2713 gfx::Transform backfaceMatrix; 2713 gfx::Transform backfaceMatrix;
2714 backfaceMatrix.Translate(50, 50); 2714 backfaceMatrix.Translate(50, 50);
2715 MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180); 2715 backfaceMatrix.RotateAbout(gfx::Vector3dF::YAxis(), 180);
2716 backfaceMatrix.Translate(-50, -50); 2716 backfaceMatrix.Translate(-50, -50);
2717 2717
2718 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent trans form style is preserve3d. 2718 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent trans form style is preserve3d.
2719 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat. 2719 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat.
2720 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat. 2720 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat.
2721 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2721 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2722 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); 2722 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false);
2723 2723
2724 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 2724 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
2725 int dummyMaxTextureSize = 512; 2725 int dummyMaxTextureSize = 512;
(...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after
4606 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ())); 4606 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ()));
4607 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id())); 4607 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id()));
4608 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id())); 4608 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id()));
4609 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id())); 4609 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id()));
4610 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); 4610 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id()));
4611 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id)); 4611 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id));
4612 } 4612 }
4613 4613
4614 } // namespace 4614 } // namespace
4615 } // namespace cc 4615 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698