Changeset 116332 in webkit


Ignore:
Timestamp:
May 7, 2012 11:48:06 AM (12 years ago)
Author:
shawnsingh@chromium.org
Message:

[chromium] CCMathUtil projectPoint needs to avoid divide-by-zero
https://bugs.webkit.org/show_bug.cgi?id=85560

Reviewed by Adrienne Walker.

Source/WebCore:

Unit test added: CCMathUtilTest.cpp - verifyProjectionOfPerpendicularPlane
Unit test updated/renamed: CCLayerTreeHostCommonTest.cpp - verifyVisibleRectFor3dPerspectiveWhenClippedByW

The divide-by-zero occurs in an innocuous case where the layers
are probably invisible anyway. However, producing Infs and NaNs
could cause values to be used when un-intended, so its appropriate
to handle the divide-by-zero correctly.

  • platform/graphics/chromium/cc/CCMathUtil.cpp:

(WebCore::projectPoint):

Source/WebKit/chromium:

  • tests/CCLayerTreeHostCommonTest.cpp:

(WebKitTests::TEST):

  • tests/CCMathUtilTest.cpp:

(WebCore::TEST):
(WebCore):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r116331 r116332  
     12012-05-07  Shawn Singh  <shawnsingh@chromium.org>
     2
     3        [chromium] CCMathUtil projectPoint needs to avoid divide-by-zero
     4        https://bugs.webkit.org/show_bug.cgi?id=85560
     5
     6        Reviewed by Adrienne Walker.
     7
     8        Unit test added: CCMathUtilTest.cpp - verifyProjectionOfPerpendicularPlane
     9        Unit test updated/renamed: CCLayerTreeHostCommonTest.cpp - verifyVisibleRectFor3dPerspectiveWhenClippedByW
     10
     11        The divide-by-zero occurs in an innocuous case where the layers
     12        are probably invisible anyway. However, producing Infs and NaNs
     13        could cause values to be used when un-intended, so its appropriate
     14        to handle the divide-by-zero correctly.
     15
     16        * platform/graphics/chromium/cc/CCMathUtil.cpp:
     17        (WebCore::projectPoint):
     18
    1192012-05-07  Pravin D  <pravind.2k4@gmail.com>
    220
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCMathUtil.cpp

    r113637 r116332  
    6767static HomogeneousCoordinate projectPoint(const TransformationMatrix& transform, const FloatPoint& p)
    6868{
     69    // In this case, the layer we are trying to project onto is perpendicular to ray
     70    // (point p and z-axis direction) that we are trying to project. This happens when the
     71    // layer is rotated so that it is infinitesimally thin, or when it is co-planar with
     72    // the camera origin -- i.e. when the layer is invisible anyway.
     73    if (!transform.m33())
     74        return HomogeneousCoordinate(0, 0, 0, 1);
     75
    6976    double x = p.x();
    7077    double y = p.y();
  • trunk/Source/WebKit/chromium/ChangeLog

    r116319 r116332  
     12012-05-07  Shawn Singh  <shawnsingh@chromium.org>
     2
     3        [chromium] CCMathUtil projectPoint needs to avoid divide-by-zero
     4        https://bugs.webkit.org/show_bug.cgi?id=85560
     5
     6        Reviewed by Adrienne Walker.
     7
     8        * tests/CCLayerTreeHostCommonTest.cpp:
     9        (WebKitTests::TEST):
     10        * tests/CCMathUtilTest.cpp:
     11        (WebCore::TEST):
     12        (WebCore):
     13
    1142012-05-07  Nat Duca  <nduca@chromium.org>
    215
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp

    r116142 r116332  
    11731173}
    11741174
    1175 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveIsClipped)
     1175TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW)
    11761176{
    11771177    // Test the calculateVisibleRect() function works correctly when projecting a surface
     
    11911191    layerToSurfaceTransform.makeIdentity();
    11921192    layerToSurfaceTransform.applyPerspective(1);
    1193     layerToSurfaceTransform.translate3d(0, 0, 1);
     1193    layerToSurfaceTransform.translate3d(-1, 0, 1);
    11941194    layerToSurfaceTransform.rotate3d(0, 45, 0);
    11951195
     
    12001200    ASSERT_TRUE(clipped);
    12011201
    1202     int expectedXPosition = -10;
     1202    int expectedXPosition = 0;
    12031203    int expectedWidth = 10;
    12041204    IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform);
  • trunk/Source/WebKit/chromium/tests/CCMathUtilTest.cpp

    r115386 r116332  
    100100}
    101101
     102TEST(CCMathUtilTest, verifyProjectionOfPerpendicularPlane)
     103{
     104    // In this case, the m33() element of the transform becomes zero, which could cause a
     105    // divide-by-zero when projecting points/quads.
     106
     107    TransformationMatrix transform;
     108    transform.makeIdentity();
     109    transform.setM33(0);
     110
     111    FloatRect rect = FloatRect(0, 0, 1, 1);
     112    FloatRect projectedRect = CCMathUtil::projectClippedRect(transform, rect);
     113
     114    EXPECT_EQ(0, projectedRect.x());
     115    EXPECT_EQ(0, projectedRect.y());
     116    EXPECT_TRUE(projectedRect.isEmpty());
     117}
     118
    102119} // namespace
Note: See TracChangeset for help on using the changeset viewer.