Changeset 116543 in webkit


Ignore:
Timestamp:
May 9, 2012 10:57:50 AM (12 years ago)
Author:
shawnsingh@chromium.org
Message:

Hit testing is incorrect in some cases with perspective transforms
https://bugs.webkit.org/show_bug.cgi?id=79136

Reviewed by Simon Fraser.

Source/WebCore:

Tests: transforms/3d/hit-testing/coplanar-with-camera.html

transforms/3d/hit-testing/perspective-clipped.html

  • platform/graphics/transforms/TransformationMatrix.cpp:

(WebCore::TransformationMatrix::projectPoint): Fix a
divide-by-zero error so that values do not become Inf or Nan. Also
fix an overflow error by using a large, but not-too-large constant
to represent infinity.

(WebCore::TransformationMatrix::projectQuad): Fix an error where
incorrect quads were being returned. Incorrect quads can occur
when projectPoint clamped==true after returning.

LayoutTests:

  • transforms/3d/hit-testing/coplanar-with-camera-expected.txt: Added.
  • transforms/3d/hit-testing/coplanar-with-camera.html: Added.
  • transforms/3d/hit-testing/perspective-clipped-expected.txt: Added.
  • transforms/3d/hit-testing/perspective-clipped.html: Added.
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r116542 r116543  
     12012-05-03  Shawn Singh  <shawnsingh@chromium.org>
     2
     3        Hit testing is incorrect in some cases with perspective transforms
     4        https://bugs.webkit.org/show_bug.cgi?id=79136
     5
     6        Reviewed by Simon Fraser.
     7
     8        * transforms/3d/hit-testing/coplanar-with-camera-expected.txt: Added.
     9        * transforms/3d/hit-testing/coplanar-with-camera.html: Added.
     10        * transforms/3d/hit-testing/perspective-clipped-expected.txt: Added.
     11        * transforms/3d/hit-testing/perspective-clipped.html: Added.
     12
    1132012-05-09  Dominik Röttsches  <dominik.rottsches@intel.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r116540 r116543  
     12012-05-03  Shawn Singh  <shawnsingh@chromium.org>
     2
     3        Hit testing is incorrect in some cases with perspective transforms
     4        https://bugs.webkit.org/show_bug.cgi?id=79136
     5
     6        Reviewed by Simon Fraser.
     7
     8        Tests: transforms/3d/hit-testing/coplanar-with-camera.html
     9               transforms/3d/hit-testing/perspective-clipped.html
     10
     11        * platform/graphics/transforms/TransformationMatrix.cpp:
     12        (WebCore::TransformationMatrix::projectPoint): Fix a
     13        divide-by-zero error so that values do not become Inf or Nan. Also
     14        fix an overflow error by using a large, but not-too-large constant
     15        to represent infinity.
     16
     17        (WebCore::TransformationMatrix::projectQuad): Fix an error where
     18        incorrect quads were being returned. Incorrect quads can occur
     19        when projectPoint clamped==true after returning.
     20
    1212012-05-09  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
    222
  • trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp

    r115386 r116543  
    552552    if (clamped)
    553553        *clamped = false;
     554
     555    if (m33() == 0) {
     556        // In this case, the projection plane is parallel to the ray we are trying to
     557        // trace, and there is no well-defined value for the projection.
     558        return FloatPoint();
     559    }
    554560   
    555561    double x = p.x();
     
    563569    double w = x * m14() + y * m24() + z * m34() + m44();
    564570    if (w <= 0) {
    565         outX = copysign(numeric_limits<int>::max(), outX);
    566         outY = copysign(numeric_limits<int>::max(), outY);
     571        // Using int max causes overflow when other code uses the projected point. To
     572        // represent infinity yet reduce the risk of overflow, we use a large but
     573        // not-too-large number here when clamping.
     574        const int kLargeNumber = 100000000;
     575        outX = copysign(kLargeNumber, outX);
     576        outY = copysign(kLargeNumber, outY);
    567577        if (clamped)
    568578            *clamped = true;
     
    578588{
    579589    FloatQuad projectedQuad;
    580     projectedQuad.setP1(projectPoint(q.p1()));
    581     projectedQuad.setP2(projectPoint(q.p2()));
    582     projectedQuad.setP3(projectPoint(q.p3()));
    583     projectedQuad.setP4(projectPoint(q.p4()));
    584    
     590
     591    bool clamped1 = false;
     592    bool clamped2 = false;
     593    bool clamped3 = false;
     594    bool clamped4 = false;
     595
     596    projectedQuad.setP1(projectPoint(q.p1(), &clamped1));
     597    projectedQuad.setP2(projectPoint(q.p2(), &clamped2));
     598    projectedQuad.setP3(projectPoint(q.p3(), &clamped3));
     599    projectedQuad.setP4(projectPoint(q.p4(), &clamped4));
     600
     601    // If all points on the quad had w < 0, then the entire quad would not be visible to the projected surface.
     602    bool everythingWasClipped = clamped1 && clamped2 && clamped3 && clamped4;
     603    if (everythingWasClipped)
     604        return FloatQuad();
     605
    585606    return projectedQuad;
    586607}
Note: See TracChangeset for help on using the changeset viewer.