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

Side by Side Diff: cc/CCLayerTreeHostCommonTest.cpp

Issue 10920059: Rolls cc and webkit_compositor up to 127340 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months 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/CCDamageTrackerTest.cpp ('k') | cc/CCLayerTreeHostImplTest.cpp » ('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 "CCLayerTreeHostCommon.h" 7 #include "CCLayerTreeHostCommon.h"
8 8
9 #include "CCAnimationTestCommon.h" 9 #include "CCAnimationTestCommon.h"
10 #include "CCGeometryTestUtils.h"
10 #include "CCLayerAnimationController.h" 11 #include "CCLayerAnimationController.h"
11 #include "CCLayerImpl.h" 12 #include "CCLayerImpl.h"
12 #include "CCLayerSorter.h" 13 #include "CCLayerSorter.h"
13 #include "CCLayerTreeTestCommon.h"
14 #include "CCMathUtil.h" 14 #include "CCMathUtil.h"
15 #include "CCProxy.h" 15 #include "CCProxy.h"
16 #include "CCSingleThreadProxy.h" 16 #include "CCSingleThreadProxy.h"
17 #include "CCThread.h" 17 #include "CCThread.h"
18 #include "ContentLayerChromium.h" 18 #include "ContentLayerChromium.h"
19 #include "ContentLayerChromiumClient.h" 19 #include "ContentLayerChromiumClient.h"
20 #include "LayerChromium.h" 20 #include "LayerChromium.h"
21 21
22 #include <gmock/gmock.h> 22 #include <gmock/gmock.h>
23 #include <gtest/gtest.h> 23 #include <gtest/gtest.h>
24 #include <public/WebTransformationMatrix.h> 24 #include <public/WebTransformationMatrix.h>
25 25
26 using namespace WebCore; 26 using namespace WebCore;
27 using namespace WebKitTests; 27 using namespace WebKitTests;
28 using WebKit::WebTransformationMatrix; 28 using WebKit::WebTransformationMatrix;
29 29
30 void WebKitTests::ExpectTransformationMatrixEq(WebTransformationMatrix expected,
31 WebTransformationMatrix actual)
32 {
33 EXPECT_FLOAT_EQ((expected).m11(), (actual).m11());
34 EXPECT_FLOAT_EQ((expected).m12(), (actual).m12());
35 EXPECT_FLOAT_EQ((expected).m13(), (actual).m13());
36 EXPECT_FLOAT_EQ((expected).m14(), (actual).m14());
37 EXPECT_FLOAT_EQ((expected).m21(), (actual).m21());
38 EXPECT_FLOAT_EQ((expected).m22(), (actual).m22());
39 EXPECT_FLOAT_EQ((expected).m23(), (actual).m23());
40 EXPECT_FLOAT_EQ((expected).m24(), (actual).m24());
41 EXPECT_FLOAT_EQ((expected).m31(), (actual).m31());
42 EXPECT_FLOAT_EQ((expected).m32(), (actual).m32());
43 EXPECT_FLOAT_EQ((expected).m33(), (actual).m33());
44 EXPECT_FLOAT_EQ((expected).m34(), (actual).m34());
45 EXPECT_FLOAT_EQ((expected).m41(), (actual).m41());
46 EXPECT_FLOAT_EQ((expected).m42(), (actual).m42());
47 EXPECT_FLOAT_EQ((expected).m43(), (actual).m43());
48 EXPECT_FLOAT_EQ((expected).m44(), (actual).m44());
49 }
50
51 namespace { 30 namespace {
52 31
53 template<typename LayerType> 32 template<typename LayerType>
54 void setLayerPropertiesForTesting(LayerType* layer, const WebTransformationMatri x& transform, const WebTransformationMatrix& sublayerTransform, const FloatPoint & anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D) 33 void setLayerPropertiesForTesting(LayerType* layer, const WebTransformationMatri x& transform, const WebTransformationMatrix& sublayerTransform, const FloatPoint & anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D)
55 { 34 {
56 layer->setTransform(transform); 35 layer->setTransform(transform);
57 layer->setSublayerTransform(sublayerTransform); 36 layer->setSublayerTransform(sublayerTransform);
58 layer->setAnchorPoint(anchor); 37 layer->setAnchorPoint(anchor);
59 layer->setPosition(position); 38 layer->setPosition(position);
60 layer->setBounds(bounds); 39 layer->setBounds(bounds);
(...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 grandChild1->setOpacity(0.5); 1431 grandChild1->setOpacity(0.5);
1453 grandChild2->setOpacity(0.5); 1432 grandChild2->setOpacity(0.5);
1454 grandChild3->setOpacity(0.5); 1433 grandChild3->setOpacity(0.5);
1455 grandChild4->setOpacity(0.5); 1434 grandChild4->setOpacity(0.5);
1456 1435
1457 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; 1436 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
1458 int dummyMaxTextureSize = 512; 1437 int dummyMaxTextureSize = 512;
1459 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds( ), 1, dummyMaxTextureSize, renderSurfaceLayerList); 1438 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds( ), 1, dummyMaxTextureSize, renderSurfaceLayerList);
1460 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); 1439 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
1461 1440
1462 EXPECT_INT_RECT_EQ(IntRect(IntPoint(5, 5), IntSize(10, 10)), grandChild1->dr awableContentRect()); 1441 EXPECT_RECT_EQ(IntRect(IntPoint(5, 5), IntSize(10, 10)), grandChild1->drawab leContentRect());
1463 EXPECT_INT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->dr awableContentRect()); 1442 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab leContentRect());
1464 EXPECT_INT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->dr awableContentRect()); 1443 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab leContentRect());
1465 EXPECT_TRUE(grandChild4->drawableContentRect().isEmpty()); 1444 EXPECT_TRUE(grandChild4->drawableContentRect().isEmpty());
1466 } 1445 }
1467 1446
1468 TEST(CCLayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) 1447 TEST(CCLayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces)
1469 { 1448 {
1470 // Verify that renderSurfaces (and their layers) get the appropriate clipRec ts when their parent masksToBounds is true. 1449 // Verify that renderSurfaces (and their layers) get the appropriate clipRec ts when their parent masksToBounds is true.
1471 // 1450 //
1472 // Layers that own renderSurfaces (at least for now) do not inherit any clip ping; 1451 // Layers that own renderSurfaces (at least for now) do not inherit any clip ping;
1473 // instead the surface will enforce the clip for the entire subtree. They ma y still 1452 // instead the surface will enforce the clip for the entire subtree. They ma y still
1474 // have a clipRect of their own layer bounds, however, if masksToBounds was true. 1453 // have a clipRect of their own layer bounds, however, if masksToBounds was true.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 int dummyMaxTextureSize = 512; 1503 int dummyMaxTextureSize = 512;
1525 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds( ), 1, dummyMaxTextureSize, renderSurfaceLayerList); 1504 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds( ), 1, dummyMaxTextureSize, renderSurfaceLayerList);
1526 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); 1505 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
1527 1506
1528 ASSERT_TRUE(grandChild1->renderSurface()); 1507 ASSERT_TRUE(grandChild1->renderSurface());
1529 ASSERT_TRUE(grandChild2->renderSurface()); 1508 ASSERT_TRUE(grandChild2->renderSurface());
1530 ASSERT_TRUE(grandChild3->renderSurface()); 1509 ASSERT_TRUE(grandChild3->renderSurface());
1531 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire ly clipped, it is expected to not have a renderSurface. 1510 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire ly clipped, it is expected to not have a renderSurface.
1532 1511
1533 // Surfaces are clipped by their parent, but un-affected by the owning layer 's masksToBounds. 1512 // Surfaces are clipped by their parent, but un-affected by the owning layer 's masksToBounds.
1534 EXPECT_INT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild1->re nderSurface()->clipRect()); 1513 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild1->render Surface()->clipRect());
1535 EXPECT_INT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild2->re nderSurface()->clipRect()); 1514 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild2->render Surface()->clipRect());
1536 EXPECT_INT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild3->re nderSurface()->clipRect()); 1515 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild3->render Surface()->clipRect());
1537 } 1516 }
1538 1517
1539 TEST(CCLayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy) 1518 TEST(CCLayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy)
1540 { 1519 {
1541 RefPtr<LayerChromium> parent = LayerChromium::create(); 1520 RefPtr<LayerChromium> parent = LayerChromium::create();
1542 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create(); 1521 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create();
1543 RefPtr<LayerChromium> renderSurface2 = LayerChromium::create(); 1522 RefPtr<LayerChromium> renderSurface2 = LayerChromium::create();
1544 RefPtr<LayerChromium> childOfRoot = LayerChromium::create(); 1523 RefPtr<LayerChromium> childOfRoot = LayerChromium::create();
1545 RefPtr<LayerChromium> childOfRS1 = LayerChromium::create(); 1524 RefPtr<LayerChromium> childOfRS1 = LayerChromium::create();
1546 RefPtr<LayerChromium> childOfRS2 = LayerChromium::create(); 1525 RefPtr<LayerChromium> childOfRS2 = LayerChromium::create();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 { 1660 {
1682 // Test the calculateVisibleRect() function works correctly for identity tra nsforms. 1661 // Test the calculateVisibleRect() function works correctly for identity tra nsforms.
1683 1662
1684 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); 1663 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
1685 WebTransformationMatrix layerToSurfaceTransform; 1664 WebTransformationMatrix layerToSurfaceTransform;
1686 1665
1687 // Case 1: Layer is contained within the surface. 1666 // Case 1: Layer is contained within the surface.
1688 IntRect layerContentRect = IntRect(IntPoint(10, 10), IntSize(30, 30)); 1667 IntRect layerContentRect = IntRect(IntPoint(10, 10), IntSize(30, 30));
1689 IntRect expected = IntRect(IntPoint(10, 10), IntSize(30, 30)); 1668 IntRect expected = IntRect(IntPoint(10, 10), IntSize(30, 30));
1690 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); 1669 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform);
1691 EXPECT_INT_RECT_EQ(expected, actual); 1670 EXPECT_RECT_EQ(expected, actual);
1692 1671
1693 // Case 2: Layer is outside the surface rect. 1672 // Case 2: Layer is outside the surface rect.
1694 layerContentRect = IntRect(IntPoint(120, 120), IntSize(30, 30)); 1673 layerContentRect = IntRect(IntPoint(120, 120), IntSize(30, 30));
1695 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform); 1674 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform);
1696 EXPECT_TRUE(actual.isEmpty()); 1675 EXPECT_TRUE(actual.isEmpty());
1697 1676
1698 // Case 3: Layer is partially overlapping the surface rect. 1677 // Case 3: Layer is partially overlapping the surface rect.
1699 layerContentRect = IntRect(IntPoint(80, 80), IntSize(30, 30)); 1678 layerContentRect = IntRect(IntPoint(80, 80), IntSize(30, 30));
1700 expected = IntRect(IntPoint(80, 80), IntSize(20, 20)); 1679 expected = IntRect(IntPoint(80, 80), IntSize(20, 20));
1701 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform); 1680 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform);
1702 EXPECT_INT_RECT_EQ(expected, actual); 1681 EXPECT_RECT_EQ(expected, actual);
1703 } 1682 }
1704 1683
1705 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectForTranslations) 1684 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectForTranslations)
1706 { 1685 {
1707 // Test the calculateVisibleRect() function works correctly for scaling tran sforms. 1686 // Test the calculateVisibleRect() function works correctly for scaling tran sforms.
1708 1687
1709 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); 1688 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
1710 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(30, 30)); 1689 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(30, 30));
1711 WebTransformationMatrix layerToSurfaceTransform; 1690 WebTransformationMatrix layerToSurfaceTransform;
1712 1691
1713 // Case 1: Layer is contained within the surface. 1692 // Case 1: Layer is contained within the surface.
1714 layerToSurfaceTransform.makeIdentity(); 1693 layerToSurfaceTransform.makeIdentity();
1715 layerToSurfaceTransform.translate(10, 10); 1694 layerToSurfaceTransform.translate(10, 10);
1716 IntRect expected = IntRect(IntPoint(0, 0), IntSize(30, 30)); 1695 IntRect expected = IntRect(IntPoint(0, 0), IntSize(30, 30));
1717 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); 1696 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform);
1718 EXPECT_INT_RECT_EQ(expected, actual); 1697 EXPECT_RECT_EQ(expected, actual);
1719 1698
1720 // Case 2: Layer is outside the surface rect. 1699 // Case 2: Layer is outside the surface rect.
1721 layerToSurfaceTransform.makeIdentity(); 1700 layerToSurfaceTransform.makeIdentity();
1722 layerToSurfaceTransform.translate(120, 120); 1701 layerToSurfaceTransform.translate(120, 120);
1723 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform); 1702 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform);
1724 EXPECT_TRUE(actual.isEmpty()); 1703 EXPECT_TRUE(actual.isEmpty());
1725 1704
1726 // Case 3: Layer is partially overlapping the surface rect. 1705 // Case 3: Layer is partially overlapping the surface rect.
1727 layerToSurfaceTransform.makeIdentity(); 1706 layerToSurfaceTransform.makeIdentity();
1728 layerToSurfaceTransform.translate(80, 80); 1707 layerToSurfaceTransform.translate(80, 80);
1729 expected = IntRect(IntPoint(0, 0), IntSize(20, 20)); 1708 expected = IntRect(IntPoint(0, 0), IntSize(20, 20));
1730 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform); 1709 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform);
1731 EXPECT_INT_RECT_EQ(expected, actual); 1710 EXPECT_RECT_EQ(expected, actual);
1732 } 1711 }
1733 1712
1734 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor2DRotations) 1713 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor2DRotations)
1735 { 1714 {
1736 // Test the calculateVisibleRect() function works correctly for rotations ab out z-axis (i.e. 2D rotations). 1715 // Test the calculateVisibleRect() function works correctly for rotations ab out z-axis (i.e. 2D rotations).
1737 // Remember that calculateVisibleRect() should return the visible rect in th e layer's space. 1716 // Remember that calculateVisibleRect() should return the visible rect in th e layer's space.
1738 1717
1739 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); 1718 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
1740 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(30, 30)); 1719 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(30, 30));
1741 WebTransformationMatrix layerToSurfaceTransform; 1720 WebTransformationMatrix layerToSurfaceTransform;
1742 1721
1743 // Case 1: Layer is contained within the surface. 1722 // Case 1: Layer is contained within the surface.
1744 layerToSurfaceTransform.makeIdentity(); 1723 layerToSurfaceTransform.makeIdentity();
1745 layerToSurfaceTransform.translate(50, 50); 1724 layerToSurfaceTransform.translate(50, 50);
1746 layerToSurfaceTransform.rotate(45); 1725 layerToSurfaceTransform.rotate(45);
1747 IntRect expected = IntRect(IntPoint(0, 0), IntSize(30, 30)); 1726 IntRect expected = IntRect(IntPoint(0, 0), IntSize(30, 30));
1748 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); 1727 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform);
1749 EXPECT_INT_RECT_EQ(expected, actual); 1728 EXPECT_RECT_EQ(expected, actual);
1750 1729
1751 // Case 2: Layer is outside the surface rect. 1730 // Case 2: Layer is outside the surface rect.
1752 layerToSurfaceTransform.makeIdentity(); 1731 layerToSurfaceTransform.makeIdentity();
1753 layerToSurfaceTransform.translate(-50, 0); 1732 layerToSurfaceTransform.translate(-50, 0);
1754 layerToSurfaceTransform.rotate(45); 1733 layerToSurfaceTransform.rotate(45);
1755 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform); 1734 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform);
1756 EXPECT_TRUE(actual.isEmpty()); 1735 EXPECT_TRUE(actual.isEmpty());
1757 1736
1758 // Case 3: The layer is rotated about its top-left corner. In surface space, the layer 1737 // Case 3: The layer is rotated about its top-left corner. In surface space, the layer
1759 // is oriented diagonally, with the left half outside of the renderS urface. In 1738 // is oriented diagonally, with the left half outside of the renderS urface. In
1760 // this case, the visible rect should still be the entire layer (rem ember the 1739 // this case, the visible rect should still be the entire layer (rem ember the
1761 // visible rect is computed in layer space); both the top-left and 1740 // visible rect is computed in layer space); both the top-left and
1762 // bottom-right corners of the layer are still visible. 1741 // bottom-right corners of the layer are still visible.
1763 layerToSurfaceTransform.makeIdentity(); 1742 layerToSurfaceTransform.makeIdentity();
1764 layerToSurfaceTransform.rotate(45); 1743 layerToSurfaceTransform.rotate(45);
1765 expected = IntRect(IntPoint(0, 0), IntSize(30, 30)); 1744 expected = IntRect(IntPoint(0, 0), IntSize(30, 30));
1766 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform); 1745 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform);
1767 EXPECT_INT_RECT_EQ(expected, actual); 1746 EXPECT_RECT_EQ(expected, actual);
1768 1747
1769 // Case 4: The layer is rotated about its top-left corner, and translated up wards. In 1748 // Case 4: The layer is rotated about its top-left corner, and translated up wards. In
1770 // surface space, the layer is oriented diagonally, with only the to p corner 1749 // surface space, the layer is oriented diagonally, with only the to p corner
1771 // of the surface overlapping the layer. In layer space, the render surface 1750 // of the surface overlapping the layer. In layer space, the render surface
1772 // overlaps the right side of the layer. The visible rect should be the 1751 // overlaps the right side of the layer. The visible rect should be the
1773 // layer's right half. 1752 // layer's right half.
1774 layerToSurfaceTransform.makeIdentity(); 1753 layerToSurfaceTransform.makeIdentity();
1775 layerToSurfaceTransform.translate(0, -sqrt(2.0) * 15); 1754 layerToSurfaceTransform.translate(0, -sqrt(2.0) * 15);
1776 layerToSurfaceTransform.rotate(45); 1755 layerToSurfaceTransform.rotate(45);
1777 expected = IntRect(IntPoint(15, 0), IntSize(15, 30)); // right half of layer bounds. 1756 expected = IntRect(IntPoint(15, 0), IntSize(15, 30)); // right half of layer bounds.
1778 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform); 1757 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform);
1779 EXPECT_INT_RECT_EQ(expected, actual); 1758 EXPECT_RECT_EQ(expected, actual);
1780 } 1759 }
1781 1760
1782 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform) 1761 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform)
1783 { 1762 {
1784 // Test that the calculateVisibleRect() function works correctly for 3d tran sforms. 1763 // Test that the calculateVisibleRect() function works correctly for 3d tran sforms.
1785 1764
1786 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); 1765 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
1787 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); 1766 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
1788 WebTransformationMatrix layerToSurfaceTransform; 1767 WebTransformationMatrix layerToSurfaceTransform;
1789 1768
1790 // Case 1: Orthographic projection of a layer rotated about y-axis by 45 deg rees, should be fully contained in the renderSurface. 1769 // Case 1: Orthographic projection of a layer rotated about y-axis by 45 deg rees, should be fully contained in the renderSurface.
1791 layerToSurfaceTransform.makeIdentity(); 1770 layerToSurfaceTransform.makeIdentity();
1792 layerToSurfaceTransform.rotate3d(0, 45, 0); 1771 layerToSurfaceTransform.rotate3d(0, 45, 0);
1793 IntRect expected = IntRect(IntPoint(0, 0), IntSize(100, 100)); 1772 IntRect expected = IntRect(IntPoint(0, 0), IntSize(100, 100));
1794 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); 1773 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform);
1795 EXPECT_INT_RECT_EQ(expected, actual); 1774 EXPECT_RECT_EQ(expected, actual);
1796 1775
1797 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 deg rees, but 1776 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 deg rees, but
1798 // shifted to the side so only the right-half the layer would be vis ible on 1777 // shifted to the side so only the right-half the layer would be vis ible on
1799 // the surface. 1778 // the surface.
1800 double halfWidthOfRotatedLayer = (100 / sqrt(2.0)) * 0.5; // 100 is the un-r otated layer width; divided by sqrt(2) is the rotated width. 1779 double halfWidthOfRotatedLayer = (100 / sqrt(2.0)) * 0.5; // 100 is the un-r otated layer width; divided by sqrt(2) is the rotated width.
1801 layerToSurfaceTransform.makeIdentity(); 1780 layerToSurfaceTransform.makeIdentity();
1802 layerToSurfaceTransform.translate(-halfWidthOfRotatedLayer, 0); 1781 layerToSurfaceTransform.translate(-halfWidthOfRotatedLayer, 0);
1803 layerToSurfaceTransform.rotate3d(0, 45, 0); // rotates about the left edge o f the layer 1782 layerToSurfaceTransform.rotate3d(0, 45, 0); // rotates about the left edge o f the layer
1804 expected = IntRect(IntPoint(50, 0), IntSize(50, 100)); // right half of the layer. 1783 expected = IntRect(IntPoint(50, 0), IntSize(50, 100)); // right half of the layer.
1805 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform); 1784 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform);
1806 EXPECT_INT_RECT_EQ(expected, actual); 1785 EXPECT_RECT_EQ(expected, actual);
1807 } 1786 }
1808 1787
1809 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform) 1788 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform)
1810 { 1789 {
1811 // Test the calculateVisibleRect() function works correctly when the layer h as a 1790 // Test the calculateVisibleRect() function works correctly when the layer h as a
1812 // perspective projection onto the target surface. 1791 // perspective projection onto the target surface.
1813 1792
1814 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); 1793 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
1815 IntRect layerContentRect = IntRect(IntPoint(-50, -50), IntSize(200, 200)); 1794 IntRect layerContentRect = IntRect(IntPoint(-50, -50), IntSize(200, 200));
1816 WebTransformationMatrix layerToSurfaceTransform; 1795 WebTransformationMatrix layerToSurfaceTransform;
1817 1796
1818 // Case 1: Even though the layer is twice as large as the surface, due to pe rspective 1797 // Case 1: Even though the layer is twice as large as the surface, due to pe rspective
1819 // foreshortening, the layer will fit fully in the surface when its translated 1798 // foreshortening, the layer will fit fully in the surface when its translated
1820 // more than the perspective amount. 1799 // more than the perspective amount.
1821 layerToSurfaceTransform.makeIdentity(); 1800 layerToSurfaceTransform.makeIdentity();
1822 1801
1823 // The following sequence of transforms applies the perspective about the ce nter of the surface. 1802 // The following sequence of transforms applies the perspective about the ce nter of the surface.
1824 layerToSurfaceTransform.translate(50, 50); 1803 layerToSurfaceTransform.translate(50, 50);
1825 layerToSurfaceTransform.applyPerspective(9); 1804 layerToSurfaceTransform.applyPerspective(9);
1826 layerToSurfaceTransform.translate(-50, -50); 1805 layerToSurfaceTransform.translate(-50, -50);
1827 1806
1828 // This translate places the layer in front of the surface's projection plan e. 1807 // This translate places the layer in front of the surface's projection plan e.
1829 layerToSurfaceTransform.translate3d(0, 0, -27); 1808 layerToSurfaceTransform.translate3d(0, 0, -27);
1830 1809
1831 IntRect expected = IntRect(IntPoint(-50, -50), IntSize(200, 200)); 1810 IntRect expected = IntRect(IntPoint(-50, -50), IntSize(200, 200));
1832 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); 1811 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform);
1833 EXPECT_INT_RECT_EQ(expected, actual); 1812 EXPECT_RECT_EQ(expected, actual);
1834 1813
1835 // Case 2: same projection as before, except that the layer is also translat ed to the 1814 // Case 2: same projection as before, except that the layer is also translat ed to the
1836 // side, so that only the right half of the layer should be visible. 1815 // side, so that only the right half of the layer should be visible.
1837 // 1816 //
1838 // Explanation of expected result: 1817 // Explanation of expected result:
1839 // The perspective ratio is (z distance between layer and camera origin) / ( z distance between projection plane and camera origin) == ((-27 - 9) / 9) 1818 // The perspective ratio is (z distance between layer and camera origin) / ( z distance between projection plane and camera origin) == ((-27 - 9) / 9)
1840 // Then, by similar triangles, if we want to move a layer by translating -50 units in projected surface units (so that only half of it is 1819 // Then, by similar triangles, if we want to move a layer by translating -50 units in projected surface units (so that only half of it is
1841 // visible), then we would need to translate by (-36 / 9) * -50 == -200 in t he layer's units. 1820 // visible), then we would need to translate by (-36 / 9) * -50 == -200 in t he layer's units.
1842 // 1821 //
1843 layerToSurfaceTransform.translate3d(-200, 0, 0); 1822 layerToSurfaceTransform.translate3d(-200, 0, 0);
1844 expected = IntRect(IntPoint(50, -50), IntSize(100, 200)); // The right half of the layer's bounding rect. 1823 expected = IntRect(IntPoint(50, -50), IntSize(100, 200)); // The right half of the layer's bounding rect.
1845 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform); 1824 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye rContentRect, layerToSurfaceTransform);
1846 EXPECT_INT_RECT_EQ(expected, actual); 1825 EXPECT_RECT_EQ(expected, actual);
1847 } 1826 }
1848 1827
1849 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBe hindSurface) 1828 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBe hindSurface)
1850 { 1829 {
1851 // There is currently no explicit concept of an orthographic projection plan e in our 1830 // There is currently no explicit concept of an orthographic projection plan e in our
1852 // code (nor in the CSS spec to my knowledge). Therefore, layers that are te chnically 1831 // code (nor in the CSS spec to my knowledge). Therefore, layers that are te chnically
1853 // behind the surface in an orthographic world should not be clipped when th ey are 1832 // behind the surface in an orthographic world should not be clipped when th ey are
1854 // flattened to the surface. 1833 // flattened to the surface.
1855 1834
1856 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); 1835 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
1857 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); 1836 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
1858 WebTransformationMatrix layerToSurfaceTransform; 1837 WebTransformationMatrix layerToSurfaceTransform;
1859 1838
1860 // This sequence of transforms effectively rotates the layer about the y-axi s at the 1839 // This sequence of transforms effectively rotates the layer about the y-axi s at the
1861 // center of the layer. 1840 // center of the layer.
1862 layerToSurfaceTransform.makeIdentity(); 1841 layerToSurfaceTransform.makeIdentity();
1863 layerToSurfaceTransform.translate(50, 0); 1842 layerToSurfaceTransform.translate(50, 0);
1864 layerToSurfaceTransform.rotate3d(0, 45, 0); 1843 layerToSurfaceTransform.rotate3d(0, 45, 0);
1865 layerToSurfaceTransform.translate(-50, 0); 1844 layerToSurfaceTransform.translate(-50, 0);
1866 1845
1867 IntRect expected = IntRect(IntPoint(0, 0), IntSize(100, 100)); 1846 IntRect expected = IntRect(IntPoint(0, 0), IntSize(100, 100));
1868 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); 1847 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform);
1869 EXPECT_INT_RECT_EQ(expected, actual); 1848 EXPECT_RECT_EQ(expected, actual);
1870 } 1849 }
1871 1850
1872 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW) 1851 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW)
1873 { 1852 {
1874 // Test the calculateVisibleRect() function works correctly when projecting a surface 1853 // Test the calculateVisibleRect() function works correctly when projecting a surface
1875 // onto a layer, but the layer is partially behind the camera (not just behi nd the 1854 // onto a layer, but the layer is partially behind the camera (not just behi nd the
1876 // projection plane). In this case, the cartesian coordinates may seem to be valid, 1855 // projection plane). In this case, the cartesian coordinates may seem to be valid,
1877 // but actually they are not. The visibleRect needs to be properly clipped b y the 1856 // but actually they are not. The visibleRect needs to be properly clipped b y the
1878 // w = 0 plane in homogeneous coordinates before converting to cartesian coo rdinates. 1857 // w = 0 plane in homogeneous coordinates before converting to cartesian coo rdinates.
1879 1858
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 bool clipped = false; 1904 bool clipped = false;
1926 FloatRect clippedRect = CCMathUtil::mapClippedRect(layerToSurfaceTransform, layerContentRect); 1905 FloatRect clippedRect = CCMathUtil::mapClippedRect(layerToSurfaceTransform, layerContentRect);
1927 CCMathUtil::projectQuad(layerToSurfaceTransform.inverse(), FloatQuad(clipped Rect), clipped); 1906 CCMathUtil::projectQuad(layerToSurfaceTransform.inverse(), FloatQuad(clipped Rect), clipped);
1928 ASSERT_TRUE(clipped); 1907 ASSERT_TRUE(clipped);
1929 1908
1930 // Only the corner of the layer is not visible on the surface because of bei ng 1909 // Only the corner of the layer is not visible on the surface because of bei ng
1931 // clipped. But, the net result of rounding visible region to an axis-aligne d rect is 1910 // clipped. But, the net result of rounding visible region to an axis-aligne d rect is
1932 // that the entire layer should still be considered visible. 1911 // that the entire layer should still be considered visible.
1933 IntRect expected = IntRect(IntPoint(-10, -10), IntSize(20, 20)); 1912 IntRect expected = IntRect(IntPoint(-10, -10), IntSize(20, 20));
1934 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); 1913 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform);
1935 EXPECT_INT_RECT_EQ(expected, actual); 1914 EXPECT_RECT_EQ(expected, actual);
1936 } 1915 }
1937 1916
1938 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLay ers) 1917 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLay ers)
1939 { 1918 {
1940 RefPtr<LayerChromium> root = LayerChromium::create(); 1919 RefPtr<LayerChromium> root = LayerChromium::create();
1941 RefPtr<LayerChromiumWithForcedDrawsContent> child1 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 1920 RefPtr<LayerChromiumWithForcedDrawsContent> child1 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
1942 RefPtr<LayerChromiumWithForcedDrawsContent> child2 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 1921 RefPtr<LayerChromiumWithForcedDrawsContent> child2 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
1943 RefPtr<LayerChromiumWithForcedDrawsContent> child3 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 1922 RefPtr<LayerChromiumWithForcedDrawsContent> child3 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
1944 root->addChild(child1); 1923 root->addChild(child1);
1945 root->addChild(child2); 1924 root->addChild(child2);
1946 root->addChild(child3); 1925 root->addChild(child3);
1947 1926
1948 WebTransformationMatrix identityMatrix; 1927 WebTransformationMatrix identityMatrix;
1949 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); 1928 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false);
1950 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(0, 0), IntSize(50, 50), false); 1929 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(0, 0), IntSize(50, 50), false);
1951 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false); 1930 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false);
1952 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(125, 125), IntSize(50, 50), false); 1931 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(125, 125), IntSize(50, 50), false);
1953 1932
1954 executeCalculateDrawTransformsAndVisibility(root.get()); 1933 executeCalculateDrawTransformsAndVisibility(root.get());
1955 1934
1956 EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableC ontentRect()); 1935 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableConte ntRect());
1957 EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect()); 1936 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect());
1958 1937
1959 // Layers that do not draw content should have empty visibleContentRects. 1938 // Layers that do not draw content should have empty visibleContentRects.
1960 EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect()); 1939 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect());
1961 1940
1962 // layer visibleContentRects are clipped by their targetSurface 1941 // layer visibleContentRects are clipped by their targetSurface
1963 EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); 1942 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect());
1964 EXPECT_INT_RECT_EQ(IntRect(0, 0, 25, 25), child2->visibleContentRect()); 1943 EXPECT_RECT_EQ(IntRect(0, 0, 25, 25), child2->visibleContentRect());
1965 EXPECT_TRUE(child3->visibleContentRect().isEmpty()); 1944 EXPECT_TRUE(child3->visibleContentRect().isEmpty());
1966 1945
1967 // layer drawableContentRects are not clipped. 1946 // layer drawableContentRects are not clipped.
1968 EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), child1->drawableContentRect()); 1947 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->drawableContentRect());
1969 EXPECT_INT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect()); 1948 EXPECT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect());
1970 EXPECT_INT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect()) ; 1949 EXPECT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect());
1971 } 1950 }
1972 1951
1973 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersCli ppedByLayer) 1952 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersCli ppedByLayer)
1974 { 1953 {
1975 RefPtr<LayerChromium> root = LayerChromium::create(); 1954 RefPtr<LayerChromium> root = LayerChromium::create();
1976 RefPtr<LayerChromium> child = LayerChromium::create(); 1955 RefPtr<LayerChromium> child = LayerChromium::create();
1977 RefPtr<LayerChromiumWithForcedDrawsContent> grandChild1 = adoptRef(new Layer ChromiumWithForcedDrawsContent()); 1956 RefPtr<LayerChromiumWithForcedDrawsContent> grandChild1 = adoptRef(new Layer ChromiumWithForcedDrawsContent());
1978 RefPtr<LayerChromiumWithForcedDrawsContent> grandChild2 = adoptRef(new Layer ChromiumWithForcedDrawsContent()); 1957 RefPtr<LayerChromiumWithForcedDrawsContent> grandChild2 = adoptRef(new Layer ChromiumWithForcedDrawsContent());
1979 RefPtr<LayerChromiumWithForcedDrawsContent> grandChild3 = adoptRef(new Layer ChromiumWithForcedDrawsContent()); 1958 RefPtr<LayerChromiumWithForcedDrawsContent> grandChild3 = adoptRef(new Layer ChromiumWithForcedDrawsContent());
1980 root->addChild(child); 1959 root->addChild(child);
1981 child->addChild(grandChild1); 1960 child->addChild(grandChild1);
1982 child->addChild(grandChild2); 1961 child->addChild(grandChild2);
1983 child->addChild(grandChild3); 1962 child->addChild(grandChild3);
1984 1963
1985 WebTransformationMatrix identityMatrix; 1964 WebTransformationMatrix identityMatrix;
1986 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); 1965 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false);
1987 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl oatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); 1966 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl oatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false);
1988 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr ix, FloatPoint(0, 0), FloatPoint(5, 5), IntSize(50, 50), false); 1967 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr ix, FloatPoint(0, 0), FloatPoint(5, 5), IntSize(50, 50), false);
1989 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr ix, FloatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false); 1968 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr ix, FloatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false);
1990 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr ix, FloatPoint(0, 0), FloatPoint(125, 125), IntSize(50, 50), false); 1969 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr ix, FloatPoint(0, 0), FloatPoint(125, 125), IntSize(50, 50), false);
1991 1970
1992 child->setMasksToBounds(true); 1971 child->setMasksToBounds(true);
1993 executeCalculateDrawTransformsAndVisibility(root.get()); 1972 executeCalculateDrawTransformsAndVisibility(root.get());
1994 1973
1995 ASSERT_FALSE(child->renderSurface()); 1974 ASSERT_FALSE(child->renderSurface());
1996 1975
1997 EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableC ontentRect()); 1976 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableConte ntRect());
1998 EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect()); 1977 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect());
1999 1978
2000 // Layers that do not draw content should have empty visibleContentRects. 1979 // Layers that do not draw content should have empty visibleContentRects.
2001 EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect()); 1980 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect());
2002 EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), child->visibleContentRect()); 1981 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), child->visibleContentRect());
2003 1982
2004 // All grandchild visibleContentRects should be clipped by child. 1983 // All grandchild visibleContentRects should be clipped by child.
2005 EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), grandChild1->visibleContentRect()) ; 1984 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), grandChild1->visibleContentRect());
2006 EXPECT_INT_RECT_EQ(IntRect(0, 0, 25, 25), grandChild2->visibleContentRect()) ; 1985 EXPECT_RECT_EQ(IntRect(0, 0, 25, 25), grandChild2->visibleContentRect());
2007 EXPECT_TRUE(grandChild3->visibleContentRect().isEmpty()); 1986 EXPECT_TRUE(grandChild3->visibleContentRect().isEmpty());
2008 1987
2009 // All grandchild drawableContentRects should also be clipped by child. 1988 // All grandchild drawableContentRects should also be clipped by child.
2010 EXPECT_INT_RECT_EQ(IntRect(5, 5, 50, 50), grandChild1->drawableContentRect() ); 1989 EXPECT_RECT_EQ(IntRect(5, 5, 50, 50), grandChild1->drawableContentRect());
2011 EXPECT_INT_RECT_EQ(IntRect(75, 75, 25, 25), grandChild2->drawableContentRect ()); 1990 EXPECT_RECT_EQ(IntRect(75, 75, 25, 25), grandChild2->drawableContentRect());
2012 EXPECT_TRUE(grandChild3->drawableContentRect().isEmpty()); 1991 EXPECT_TRUE(grandChild3->drawableContentRect().isEmpty());
2013 } 1992 }
2014 1993
2015 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInU nclippedRenderSurface) 1994 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInU nclippedRenderSurface)
2016 { 1995 {
2017 RefPtr<LayerChromium> root = LayerChromium::create(); 1996 RefPtr<LayerChromium> root = LayerChromium::create();
2018 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create(); 1997 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create();
2019 RefPtr<LayerChromiumWithForcedDrawsContent> child1 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 1998 RefPtr<LayerChromiumWithForcedDrawsContent> child1 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
2020 RefPtr<LayerChromiumWithForcedDrawsContent> child2 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 1999 RefPtr<LayerChromiumWithForcedDrawsContent> child2 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
2021 RefPtr<LayerChromiumWithForcedDrawsContent> child3 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 2000 RefPtr<LayerChromiumWithForcedDrawsContent> child3 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
2022 root->addChild(renderSurface1); 2001 root->addChild(renderSurface1);
2023 renderSurface1->addChild(child1); 2002 renderSurface1->addChild(child1);
2024 renderSurface1->addChild(child2); 2003 renderSurface1->addChild(child2);
2025 renderSurface1->addChild(child3); 2004 renderSurface1->addChild(child3);
2026 2005
2027 WebTransformationMatrix identityMatrix; 2006 WebTransformationMatrix identityMatrix;
2028 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); 2007 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false);
2029 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); 2008 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false);
2030 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(5, 5), IntSize(50, 50), false); 2009 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(5, 5), IntSize(50, 50), false);
2031 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false); 2010 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false);
2032 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(125, 125), IntSize(50, 50), false); 2011 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(125, 125), IntSize(50, 50), false);
2033 2012
2034 renderSurface1->setForceRenderSurface(true); 2013 renderSurface1->setForceRenderSurface(true);
2035 executeCalculateDrawTransformsAndVisibility(root.get()); 2014 executeCalculateDrawTransformsAndVisibility(root.get());
2036 2015
2037 ASSERT_TRUE(renderSurface1->renderSurface()); 2016 ASSERT_TRUE(renderSurface1->renderSurface());
2038 2017
2039 EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableC ontentRect()); 2018 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableConte ntRect());
2040 EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect()); 2019 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect());
2041 2020
2042 // Layers that do not draw content should have empty visibleContentRects. 2021 // Layers that do not draw content should have empty visibleContentRects.
2043 EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect()); 2022 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect());
2044 EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), renderSurface1->visibleContentRect() ); 2023 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), renderSurface1->visibleContentRect());
2045 2024
2046 // An unclipped surface grows its drawableContentRect to include all drawabl e regions of the subtree. 2025 // An unclipped surface grows its drawableContentRect to include all drawabl e regions of the subtree.
2047 EXPECT_INT_RECT_EQ(IntRect(5, 5, 170, 170), renderSurface1->renderSurface()- >drawableContentRect()); 2026 EXPECT_RECT_EQ(IntRect(5, 5, 170, 170), renderSurface1->renderSurface()->dra wableContentRect());
2048 2027
2049 // All layers that draw content into the unclipped surface are also unclippe d. 2028 // All layers that draw content into the unclipped surface are also unclippe d.
2050 EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); 2029 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect());
2051 EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), child2->visibleContentRect()); 2030 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child2->visibleContentRect());
2052 EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), child3->visibleContentRect()); 2031 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child3->visibleContentRect());
2053 2032
2054 EXPECT_INT_RECT_EQ(IntRect(5, 5, 50, 50), child1->drawableContentRect()); 2033 EXPECT_RECT_EQ(IntRect(5, 5, 50, 50), child1->drawableContentRect());
2055 EXPECT_INT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect()); 2034 EXPECT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect());
2056 EXPECT_INT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect()) ; 2035 EXPECT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect());
2057 } 2036 }
2058 2037
2059 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInC lippedRenderSurface) 2038 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInC lippedRenderSurface)
2060 { 2039 {
2061 RefPtr<LayerChromium> root = LayerChromium::create(); 2040 RefPtr<LayerChromium> root = LayerChromium::create();
2062 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create(); 2041 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create();
2063 RefPtr<LayerChromiumWithForcedDrawsContent> child1 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 2042 RefPtr<LayerChromiumWithForcedDrawsContent> child1 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
2064 RefPtr<LayerChromiumWithForcedDrawsContent> child2 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 2043 RefPtr<LayerChromiumWithForcedDrawsContent> child2 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
2065 RefPtr<LayerChromiumWithForcedDrawsContent> child3 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 2044 RefPtr<LayerChromiumWithForcedDrawsContent> child3 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
2066 root->addChild(renderSurface1); 2045 root->addChild(renderSurface1);
2067 renderSurface1->addChild(child1); 2046 renderSurface1->addChild(child1);
2068 renderSurface1->addChild(child2); 2047 renderSurface1->addChild(child2);
2069 renderSurface1->addChild(child3); 2048 renderSurface1->addChild(child3);
2070 2049
2071 WebTransformationMatrix identityMatrix; 2050 WebTransformationMatrix identityMatrix;
2072 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); 2051 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false);
2073 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); 2052 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false);
2074 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(5, 5), IntSize(50, 50), false); 2053 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(5, 5), IntSize(50, 50), false);
2075 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false); 2054 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false);
2076 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(125, 125), IntSize(50, 50), false); 2055 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(125, 125), IntSize(50, 50), false);
2077 2056
2078 root->setMasksToBounds(true); 2057 root->setMasksToBounds(true);
2079 renderSurface1->setForceRenderSurface(true); 2058 renderSurface1->setForceRenderSurface(true);
2080 executeCalculateDrawTransformsAndVisibility(root.get()); 2059 executeCalculateDrawTransformsAndVisibility(root.get());
2081 2060
2082 ASSERT_TRUE(renderSurface1->renderSurface()); 2061 ASSERT_TRUE(renderSurface1->renderSurface());
2083 2062
2084 EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableC ontentRect()); 2063 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableConte ntRect());
2085 EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect()); 2064 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect());
2086 2065
2087 // Layers that do not draw content should have empty visibleContentRects. 2066 // Layers that do not draw content should have empty visibleContentRects.
2088 EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect()); 2067 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect());
2089 EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), renderSurface1->visibleContentRect() ); 2068 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), renderSurface1->visibleContentRect());
2090 2069
2091 // A clipped surface grows its drawableContentRect to include all drawable r egions of the subtree, 2070 // A clipped surface grows its drawableContentRect to include all drawable r egions of the subtree,
2092 // but also gets clamped by the ancestor's clip. 2071 // but also gets clamped by the ancestor's clip.
2093 EXPECT_INT_RECT_EQ(IntRect(5, 5, 95, 95), renderSurface1->renderSurface()->d rawableContentRect()); 2072 EXPECT_RECT_EQ(IntRect(5, 5, 95, 95), renderSurface1->renderSurface()->drawa bleContentRect());
2094 2073
2095 // All layers that draw content into the surface have their visibleContentRe ct clipped by the surface clipRect. 2074 // All layers that draw content into the surface have their visibleContentRe ct clipped by the surface clipRect.
2096 EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); 2075 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect());
2097 EXPECT_INT_RECT_EQ(IntRect(0, 0, 25, 25), child2->visibleContentRect()); 2076 EXPECT_RECT_EQ(IntRect(0, 0, 25, 25), child2->visibleContentRect());
2098 EXPECT_TRUE(child3->visibleContentRect().isEmpty()); 2077 EXPECT_TRUE(child3->visibleContentRect().isEmpty());
2099 2078
2100 // But the drawableContentRects are unclipped. 2079 // But the drawableContentRects are unclipped.
2101 EXPECT_INT_RECT_EQ(IntRect(5, 5, 50, 50), child1->drawableContentRect()); 2080 EXPECT_RECT_EQ(IntRect(5, 5, 50, 50), child1->drawableContentRect());
2102 EXPECT_INT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect()); 2081 EXPECT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect());
2103 EXPECT_INT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect()) ; 2082 EXPECT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect());
2104 } 2083 }
2105 2084
2106 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSurfaceHi erarchy) 2085 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSurfaceHi erarchy)
2107 { 2086 {
2108 // Check that clipping does not propagate down surfaces. 2087 // Check that clipping does not propagate down surfaces.
2109 RefPtr<LayerChromium> root = LayerChromium::create(); 2088 RefPtr<LayerChromium> root = LayerChromium::create();
2110 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create(); 2089 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create();
2111 RefPtr<LayerChromium> renderSurface2 = LayerChromium::create(); 2090 RefPtr<LayerChromium> renderSurface2 = LayerChromium::create();
2112 RefPtr<LayerChromiumWithForcedDrawsContent> child1 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 2091 RefPtr<LayerChromiumWithForcedDrawsContent> child1 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
2113 RefPtr<LayerChromiumWithForcedDrawsContent> child2 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 2092 RefPtr<LayerChromiumWithForcedDrawsContent> child2 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
(...skipping 13 matching lines...) Expand all
2127 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(125, 125), IntSize(50, 50), false); 2106 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, F loatPoint(0, 0), FloatPoint(125, 125), IntSize(50, 50), false);
2128 2107
2129 root->setMasksToBounds(true); 2108 root->setMasksToBounds(true);
2130 renderSurface1->setForceRenderSurface(true); 2109 renderSurface1->setForceRenderSurface(true);
2131 renderSurface2->setForceRenderSurface(true); 2110 renderSurface2->setForceRenderSurface(true);
2132 executeCalculateDrawTransformsAndVisibility(root.get()); 2111 executeCalculateDrawTransformsAndVisibility(root.get());
2133 2112
2134 ASSERT_TRUE(renderSurface1->renderSurface()); 2113 ASSERT_TRUE(renderSurface1->renderSurface());
2135 ASSERT_TRUE(renderSurface2->renderSurface()); 2114 ASSERT_TRUE(renderSurface2->renderSurface());
2136 2115
2137 EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableC ontentRect()); 2116 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableConte ntRect());
2138 EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect()); 2117 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect());
2139 2118
2140 // Layers that do not draw content should have empty visibleContentRects. 2119 // Layers that do not draw content should have empty visibleContentRects.
2141 EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect()); 2120 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect());
2142 EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), renderSurface1->visibleContentRect() ); 2121 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), renderSurface1->visibleContentRect());
2143 EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), renderSurface2->visibleContentRect() ); 2122 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), renderSurface2->visibleContentRect());
2144 2123
2145 // A clipped surface grows its drawableContentRect to include all drawable r egions of the subtree, 2124 // A clipped surface grows its drawableContentRect to include all drawable r egions of the subtree,
2146 // but also gets clamped by the ancestor's clip. 2125 // but also gets clamped by the ancestor's clip.
2147 EXPECT_INT_RECT_EQ(IntRect(5, 5, 95, 95), renderSurface1->renderSurface()->d rawableContentRect()); 2126 EXPECT_RECT_EQ(IntRect(5, 5, 95, 95), renderSurface1->renderSurface()->drawa bleContentRect());
2148 2127
2149 // renderSurface1 lives in the "unclipped universe" of renderSurface1, and i s only 2128 // renderSurface1 lives in the "unclipped universe" of renderSurface1, and i s only
2150 // implicitly clipped by renderSurface1's contentRect. So, renderSurface2 gr ows to 2129 // implicitly clipped by renderSurface1's contentRect. So, renderSurface2 gr ows to
2151 // enclose all drawable content of its subtree. 2130 // enclose all drawable content of its subtree.
2152 EXPECT_INT_RECT_EQ(IntRect(5, 5, 170, 170), renderSurface2->renderSurface()- >drawableContentRect()); 2131 EXPECT_RECT_EQ(IntRect(5, 5, 170, 170), renderSurface2->renderSurface()->dra wableContentRect());
2153 2132
2154 // All layers that draw content into renderSurface2 think they are unclipped . 2133 // All layers that draw content into renderSurface2 think they are unclipped .
2155 EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); 2134 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect());
2156 EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), child2->visibleContentRect()); 2135 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child2->visibleContentRect());
2157 EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), child3->visibleContentRect()); 2136 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child3->visibleContentRect());
2158 2137
2159 // drawableContentRects are also unclipped. 2138 // drawableContentRects are also unclipped.
2160 EXPECT_INT_RECT_EQ(IntRect(5, 5, 50, 50), child1->drawableContentRect()); 2139 EXPECT_RECT_EQ(IntRect(5, 5, 50, 50), child1->drawableContentRect());
2161 EXPECT_INT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect()); 2140 EXPECT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect());
2162 EXPECT_INT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect()) ; 2141 EXPECT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect());
2163 } 2142 }
2164 2143
2165 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransfor mOnUnclippedSurface) 2144 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransfor mOnUnclippedSurface)
2166 { 2145 {
2167 // Layers that have non-axis aligned bounds (due to transforms) have an expa nded, 2146 // Layers that have non-axis aligned bounds (due to transforms) have an expa nded,
2168 // axis-aligned drawableContentRect and visibleContentRect. 2147 // axis-aligned drawableContentRect and visibleContentRect.
2169 2148
2170 RefPtr<LayerChromium> root = LayerChromium::create(); 2149 RefPtr<LayerChromium> root = LayerChromium::create();
2171 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create(); 2150 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create();
2172 RefPtr<LayerChromiumWithForcedDrawsContent> child1 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 2151 RefPtr<LayerChromiumWithForcedDrawsContent> child1 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
2173 root->addChild(renderSurface1); 2152 root->addChild(renderSurface1);
2174 renderSurface1->addChild(child1); 2153 renderSurface1->addChild(child1);
2175 2154
2176 WebTransformationMatrix identityMatrix; 2155 WebTransformationMatrix identityMatrix;
2177 WebTransformationMatrix childRotation; 2156 WebTransformationMatrix childRotation;
2178 childRotation.rotate(45); 2157 childRotation.rotate(45);
2179 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); 2158 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false);
2180 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); 2159 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false);
2181 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, Fl oatPoint(0.5, 0.5), FloatPoint(25, 25), IntSize(50, 50), false); 2160 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, Fl oatPoint(0.5, 0.5), FloatPoint(25, 25), IntSize(50, 50), false);
2182 2161
2183 renderSurface1->setForceRenderSurface(true); 2162 renderSurface1->setForceRenderSurface(true);
2184 executeCalculateDrawTransformsAndVisibility(root.get()); 2163 executeCalculateDrawTransformsAndVisibility(root.get());
2185 2164
2186 ASSERT_TRUE(renderSurface1->renderSurface()); 2165 ASSERT_TRUE(renderSurface1->renderSurface());
2187 2166
2188 EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableC ontentRect()); 2167 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableConte ntRect());
2189 EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect()); 2168 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect());
2190 2169
2191 // Layers that do not draw content should have empty visibleContentRects. 2170 // Layers that do not draw content should have empty visibleContentRects.
2192 EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect()); 2171 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect());
2193 EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), renderSurface1->visibleContentRect() ); 2172 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), renderSurface1->visibleContentRect());
2194 2173
2195 // The unclipped surface grows its drawableContentRect to include all drawab le regions of the subtree. 2174 // The unclipped surface grows its drawableContentRect to include all drawab le regions of the subtree.
2196 int diagonalRadius = ceil(sqrt(2.0) * 25); 2175 int diagonalRadius = ceil(sqrt(2.0) * 25);
2197 IntRect expectedSurfaceDrawableContent = IntRect(50 - diagonalRadius, 50 - d iagonalRadius, diagonalRadius * 2, diagonalRadius * 2); 2176 IntRect expectedSurfaceDrawableContent = IntRect(50 - diagonalRadius, 50 - d iagonalRadius, diagonalRadius * 2, diagonalRadius * 2);
2198 EXPECT_INT_RECT_EQ(expectedSurfaceDrawableContent, renderSurface1->renderSur face()->drawableContentRect()); 2177 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, renderSurface1->renderSurface ()->drawableContentRect());
2199 2178
2200 // All layers that draw content into the unclipped surface are also unclippe d. 2179 // All layers that draw content into the unclipped surface are also unclippe d.
2201 EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); 2180 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect());
2202 EXPECT_INT_RECT_EQ(expectedSurfaceDrawableContent, child1->drawableContentRe ct()); 2181 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, child1->drawableContentRect() );
2203 } 2182 }
2204 2183
2205 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransfor mOnClippedSurface) 2184 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransfor mOnClippedSurface)
2206 { 2185 {
2207 // Layers that have non-axis aligned bounds (due to transforms) have an expa nded, 2186 // Layers that have non-axis aligned bounds (due to transforms) have an expa nded,
2208 // axis-aligned drawableContentRect and visibleContentRect. 2187 // axis-aligned drawableContentRect and visibleContentRect.
2209 2188
2210 RefPtr<LayerChromium> root = LayerChromium::create(); 2189 RefPtr<LayerChromium> root = LayerChromium::create();
2211 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create(); 2190 RefPtr<LayerChromium> renderSurface1 = LayerChromium::create();
2212 RefPtr<LayerChromiumWithForcedDrawsContent> child1 = adoptRef(new LayerChrom iumWithForcedDrawsContent()); 2191 RefPtr<LayerChromiumWithForcedDrawsContent> child1 = adoptRef(new LayerChrom iumWithForcedDrawsContent());
(...skipping 10 matching lines...) Expand all
2223 root->setMasksToBounds(true); 2202 root->setMasksToBounds(true);
2224 renderSurface1->setForceRenderSurface(true); 2203 renderSurface1->setForceRenderSurface(true);
2225 executeCalculateDrawTransformsAndVisibility(root.get()); 2204 executeCalculateDrawTransformsAndVisibility(root.get());
2226 2205
2227 ASSERT_TRUE(renderSurface1->renderSurface()); 2206 ASSERT_TRUE(renderSurface1->renderSurface());
2228 2207
2229 // The clipped surface clamps the drawableContentRect that encloses the rota ted layer. 2208 // The clipped surface clamps the drawableContentRect that encloses the rota ted layer.
2230 int diagonalRadius = ceil(sqrt(2.0) * 25); 2209 int diagonalRadius = ceil(sqrt(2.0) * 25);
2231 IntRect unclippedSurfaceContent = IntRect(50 - diagonalRadius, 50 - diagonal Radius, diagonalRadius * 2, diagonalRadius * 2); 2210 IntRect unclippedSurfaceContent = IntRect(50 - diagonalRadius, 50 - diagonal Radius, diagonalRadius * 2, diagonalRadius * 2);
2232 IntRect expectedSurfaceDrawableContent = intersection(unclippedSurfaceConten t, IntRect(0, 0, 50, 50)); 2211 IntRect expectedSurfaceDrawableContent = intersection(unclippedSurfaceConten t, IntRect(0, 0, 50, 50));
2233 EXPECT_INT_RECT_EQ(expectedSurfaceDrawableContent, renderSurface1->renderSur face()->drawableContentRect()); 2212 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, renderSurface1->renderSurface ()->drawableContentRect());
2234 2213
2235 // On the clipped surface, only a quarter of the child1 is visible, but whe n rotating 2214 // On the clipped surface, only a quarter of the child1 is visible, but whe n rotating
2236 // it back to child1's content space, the actual enclosing rect ends up cov ering the 2215 // it back to child1's content space, the actual enclosing rect ends up cov ering the
2237 // full left half of child1. 2216 // full left half of child1.
2238 EXPECT_INT_RECT_EQ(IntRect(0, 0, 26, 50), child1->visibleContentRect()); 2217 EXPECT_RECT_EQ(IntRect(0, 0, 26, 50), child1->visibleContentRect());
2239 2218
2240 // The child's drawableContentRect is unclipped. 2219 // The child's drawableContentRect is unclipped.
2241 EXPECT_INT_RECT_EQ(unclippedSurfaceContent, child1->drawableContentRect()); 2220 EXPECT_RECT_EQ(unclippedSurfaceContent, child1->drawableContentRect());
2242 } 2221 }
2243 2222
2244 TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d) 2223 TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d)
2245 { 2224 {
2246 // Verify the behavior of back-face culling when there are no preserve-3d la yers. Note 2225 // Verify the behavior of back-face culling when there are no preserve-3d la yers. Note
2247 // that 3d transforms still apply in this case, but they are "flattened" to each 2226 // that 3d transforms still apply in this case, but they are "flattened" to each
2248 // parent layer according to current W3C spec. 2227 // parent layer according to current W3C spec.
2249 2228
2250 const WebTransformationMatrix identityMatrix; 2229 const WebTransformationMatrix identityMatrix;
2251 RefPtr<LayerChromium> parent = LayerChromium::create(); 2230 RefPtr<LayerChromium> parent = LayerChromium::create();
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
2874 } 2853 }
2875 2854
2876 Vector<CCLayerImpl*> renderSurfaceLayerList; 2855 Vector<CCLayerImpl*> renderSurfaceLayerList;
2877 int dummyMaxTextureSize = 512; 2856 int dummyMaxTextureSize = 512;
2878 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1 , 0, dummyMaxTextureSize, renderSurfaceLayerList); 2857 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1 , 0, dummyMaxTextureSize, renderSurfaceLayerList);
2879 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); 2858 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList);
2880 2859
2881 // Sanity check the scenario we just created. 2860 // Sanity check the scenario we just created.
2882 // The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25. 2861 // The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25.
2883 CCLayerImpl* testLayer = root->children()[0].get(); 2862 CCLayerImpl* testLayer = root->children()[0].get();
2884 EXPECT_INT_RECT_EQ(IntRect(IntPoint::zero(), IntSize(100, 100)), testLayer-> visibleContentRect()); 2863 EXPECT_RECT_EQ(IntRect(IntPoint::zero(), IntSize(100, 100)), testLayer->visi bleContentRect());
2885 ASSERT_EQ(1u, renderSurfaceLayerList.size()); 2864 ASSERT_EQ(1u, renderSurfaceLayerList.size());
2886 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); 2865 ASSERT_EQ(1u, root->renderSurface()->layerList().size());
2887 2866
2888 // Hit testing for a point outside the layer should return a null pointer (t he root layer does not draw content, so it will not be hit tested either). 2867 // Hit testing for a point outside the layer should return a null pointer (t he root layer does not draw content, so it will not be hit tested either).
2889 IntPoint testPoint(101, 101); 2868 IntPoint testPoint(101, 101);
2890 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint( testPoint, renderSurfaceLayerList); 2869 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint( testPoint, renderSurfaceLayerList);
2891 EXPECT_FALSE(resultLayer); 2870 EXPECT_FALSE(resultLayer);
2892 2871
2893 testPoint = IntPoint(24, 24); 2872 testPoint = IntPoint(24, 24);
2894 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re nderSurfaceLayerList); 2873 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re nderSurfaceLayerList);
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
3495 WebTransformationMatrix expectedDrawTransform; 3474 WebTransformationMatrix expectedDrawTransform;
3496 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, child->drawTransform( )); 3475 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, child->drawTransform( ));
3497 3476
3498 WebTransformationMatrix expectedScreenSpaceTransform; 3477 WebTransformationMatrix expectedScreenSpaceTransform;
3499 expectedScreenSpaceTransform.translate(deviceScaleFactor * child->position() .x(), deviceScaleFactor * child->position().y()); 3478 expectedScreenSpaceTransform.translate(deviceScaleFactor * child->position() .x(), deviceScaleFactor * child->position().y());
3500 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScreenSpaceTransform, child->screenS paceTransform()); 3479 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScreenSpaceTransform, child->screenS paceTransform());
3501 3480
3502 WebTransformationMatrix expectedDuplicateChildDrawTransform = child->drawTra nsform(); 3481 WebTransformationMatrix expectedDuplicateChildDrawTransform = child->drawTra nsform();
3503 EXPECT_TRANSFORMATION_MATRIX_EQ(child->drawTransform(), duplicateChildNonOwn er->drawTransform()); 3482 EXPECT_TRANSFORMATION_MATRIX_EQ(child->drawTransform(), duplicateChildNonOwn er->drawTransform());
3504 EXPECT_TRANSFORMATION_MATRIX_EQ(child->screenSpaceTransform(), duplicateChil dNonOwner->screenSpaceTransform()); 3483 EXPECT_TRANSFORMATION_MATRIX_EQ(child->screenSpaceTransform(), duplicateChil dNonOwner->screenSpaceTransform());
3505 EXPECT_INT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->dra wableContentRect()); 3484 EXPECT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawabl eContentRect());
3506 EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds()); 3485 EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds());
3507 3486
3508 WebTransformationMatrix expectedRenderSurfaceDrawTransform; 3487 WebTransformationMatrix expectedRenderSurfaceDrawTransform;
3509 expectedRenderSurfaceDrawTransform.translate(deviceScaleFactor * child->posi tion().x(), deviceScaleFactor * child->position().y()); 3488 expectedRenderSurfaceDrawTransform.translate(deviceScaleFactor * child->posi tion().x(), deviceScaleFactor * child->position().y());
3510 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedRenderSurfaceDrawTransform, child->r enderSurface()->drawTransform()); 3489 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedRenderSurfaceDrawTransform, child->r enderSurface()->drawTransform());
3511 3490
3512 WebTransformationMatrix expectedSurfaceDrawTransform; 3491 WebTransformationMatrix expectedSurfaceDrawTransform;
3513 expectedSurfaceDrawTransform.translate(deviceScaleFactor * 2, deviceScaleFac tor * 2); 3492 expectedSurfaceDrawTransform.translate(deviceScaleFactor * 2, deviceScaleFac tor * 2);
3514 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS urface()->drawTransform()); 3493 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS urface()->drawTransform());
3515 3494
(...skipping 30 matching lines...) Expand all
3546 int nonexistentId = -1; 3525 int nonexistentId = -1;
3547 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root-> id())); 3526 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root-> id()));
3548 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child ->id())); 3527 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child ->id()));
3549 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), grandChild->id())); 3528 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), grandChild->id()));
3550 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m askLayer->id())); 3529 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m askLayer->id()));
3551 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get() , replicaLayer->id())); 3530 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get() , replicaLayer->id()));
3552 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste ntId)); 3531 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste ntId));
3553 } 3532 }
3554 3533
3555 } // namespace 3534 } // namespace
OLDNEW
« no previous file with comments | « cc/CCDamageTrackerTest.cpp ('k') | cc/CCLayerTreeHostImplTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698