⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 101300 in webkit


Ignore:
Timestamp:
Nov 28, 2011, 4:16:58 PM (15 years ago)
Author:
commit-queue@webkit.org
Message:

FloatQuad::isRectilinear() returns false for 180degree rotations
https://bugs.webkit.org/show_bug.cgi?id=73040

Patch by Dana Jansens <danakj@chromium.org> on 2011-11-28
Reviewed by James Robinson.

Source/WebCore:

Added unit test FloatQuadTest.cpp.

  • platform/graphics/FloatQuad.cpp:

(WebCore::withinEpsilon): Check two values are as close as can be represented by floats.
(WebCore::FloatQuad::isRectilinear): Use withinEpsilon().

Source/WebKit/chromium:

  • WebKit.gypi:
  • tests/FloatQuadTest.cpp: Added.

(WebCore::TEST):

Location:
trunk/Source
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r101296 r101300  
     12011-11-28  Dana Jansens  <danakj@chromium.org>
     2
     3        FloatQuad::isRectilinear() returns false for 180degree rotations
     4        https://bugs.webkit.org/show_bug.cgi?id=73040
     5
     6        Reviewed by James Robinson.
     7
     8        Added unit test FloatQuadTest.cpp.
     9
     10        * platform/graphics/FloatQuad.cpp:
     11        (WebCore::withinEpsilon): Check two values are as close as can be represented by floats.
     12        (WebCore::FloatQuad::isRectilinear): Use withinEpsilon().
     13
    1142011-11-28  Beth Dakin  <bdakin@apple.com>
    215
  • trunk/Source/WebCore/platform/graphics/FloatQuad.cpp

    r95901 r101300  
    3131
    3232#include <algorithm>
     33#include <limits>
    3334
    34 using std::max;
    35 using std::min;
     35using namespace std;
    3636
    3737namespace WebCore {
     
    8686}
    8787
     88static inline bool withinEpsilon(float a, float b)
     89{
     90    return fabs(a - b) < numeric_limits<float>::epsilon();
     91}
     92
    8893bool FloatQuad::isRectilinear() const
    8994{
    90     return (m_p1.x() == m_p2.x() && m_p2.y() == m_p3.y() && m_p3.x() == m_p4.x() && m_p4.y() == m_p1.y())
    91         || (m_p1.y() == m_p2.y() && m_p2.x() == m_p3.x() && m_p3.y() == m_p4.y() && m_p4.x() == m_p1.x());
     95    return (withinEpsilon(m_p1.x(), m_p2.x()) && withinEpsilon(m_p2.y(), m_p3.y()) && withinEpsilon(m_p3.x(), m_p4.x()) && withinEpsilon(m_p4.y(), m_p1.y()))
     96        || (withinEpsilon(m_p1.y(), m_p2.y()) && withinEpsilon(m_p2.x(), m_p3.x()) && withinEpsilon(m_p3.y(), m_p4.y()) && withinEpsilon(m_p4.x(), m_p1.x()));
    9297}
    9398
  • trunk/Source/WebKit/chromium/ChangeLog

    r101276 r101300  
     12011-11-28  Dana Jansens  <danakj@chromium.org>
     2
     3        FloatQuad::isRectilinear() returns false for 180degree rotations
     4        https://bugs.webkit.org/show_bug.cgi?id=73040
     5
     6        Reviewed by James Robinson.
     7
     8        * WebKit.gypi:
     9        * tests/FloatQuadTest.cpp: Added.
     10        (WebCore::TEST):
     11
    1122011-11-28  Sheriff Bot  <webkit.review.bot@gmail.com>
    213
  • trunk/Source/WebKit/chromium/WebKit.gypi

    r100958 r101300  
    6767            'tests/CCSchedulerTestCommon.h',
    6868            'tests/CCThreadTaskTest.cpp',
     69            'tests/FloatQuadTest.cpp',
    6970            'tests/FrameTestHelpers.cpp',
    7071            'tests/FrameTestHelpers.h',
Note: See TracChangeset for help on using the changeset viewer.