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

Changeset 110624 in webkit


Ignore:
Timestamp:
Mar 13, 2012, 3:35:16 PM (15 years ago)
Author:
commit-queue@webkit.org
Message:

Region::contains(IntPoint) is slow
​https://bugs.webkit.org/show_bug.cgi?id=81008

Patch by Dana Jansens <​danakj@chromium.org> on 2012-03-13
Reviewed by Anders Carlsson.

Source/WebCore:

Speed up Region::contains(IntPoint) by directly testing if the point
is inside the Region's shape, rather than using a temporary 1x1 Region
for the test.

Unit test: RegionTest.containsPoint

  • platform/graphics/Region.cpp:

(WebCore::Region::contains):

Source/WebKit/chromium:

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

(WebCore):
(WebCore::TEST):

Location:
trunk/Source
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r110620 r110624  
     12012-03-13  Dana Jansens  <danakj@chromium.org>
     2
     3        Region::contains(IntPoint) is slow
     4        https://bugs.webkit.org/show_bug.cgi?id=81008
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Speed up Region::contains(IntPoint) by directly testing if the point
     9        is inside the Region's shape, rather than using a temporary 1x1 Region
     10        for the test.
     11
     12        Unit test: RegionTest.containsPoint
     13
     14        * platform/graphics/Region.cpp:
     15        (WebCore::Region::contains):
     16
    1172012-03-13  Adrienne Walker  <enne@google.com>
    218
  • trunk/Source/WebCore/platform/graphics/Region.cpp

    r109851 r110624  
    7373bool Region::contains(const IntPoint& point) const
    7474{
    75     // FIXME: This is inefficient. We should be able to iterate over the spans and find
    76     // out if the region contains the point.
    77     return contains(IntRect(point, IntSize(1, 1)));
     75    if (!m_bounds.contains(point))
     76        return false;
     77
     78    for (Shape::SpanIterator span = m_shape.spans_begin(), end = m_shape.spans_end(); span != end && span + 1 != end; ++span) {
     79        int y = span->y;
     80        int maxY = (span + 1)->y;
     81
     82        if (y > point.y())
     83            break;
     84        if (maxY <= point.y())
     85            continue;
     86
     87        for (Shape::SegmentIterator segment = m_shape.segments_begin(span), end = m_shape.segments_end(span); segment != end && segment + 1 != end; segment += 2) {
     88            int x = *segment;
     89            int maxX = *(segment + 1);
     90
     91            if (x > point.x())
     92                break;
     93            if (maxX > point.x())
     94                return true;
     95        }
     96    }
     97
     98    return false;
    7899}
    79100
  • trunk/Source/WebKit/chromium/ChangeLog

    r110600 r110624  
     12012-03-13  Dana Jansens  <danakj@chromium.org>
     2
     3        Region::contains(IntPoint) is slow
     4        https://bugs.webkit.org/show_bug.cgi?id=81008
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebKit.gypi:
     9        * tests/RegionTest.cpp: Added.
     10        (WebCore):
     11        (WebCore::TEST):
     12
    1132012-03-13  Gavin Peters  <gavinp@chromium.org>
    214
  • trunk/Source/WebKit/chromium/WebKit.gypi

    r110596 r110624  
    117117            'tests/PODIntervalTreeTest.cpp',
    118118            'tests/PODRedBlackTreeTest.cpp',
     119            'tests/RegionTest.cpp',
    119120            'tests/RenderTableCellTest.cpp',
    120121            'tests/ScrollbarLayerChromiumTest.cpp',
Note: See TracChangeset for help on using the changeset viewer.