[Webkit-unassigned] [Bug 72294] Add contains() test to Region

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Nov 15 09:54:23 PST 2011


https://bugs.webkit.org/show_bug.cgi?id=72294


Anders Carlsson <andersca at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #115172|review?                     |review-
               Flag|                            |




--- Comment #21 from Anders Carlsson <andersca at apple.com>  2011-11-15 09:54:23 PST ---
(From update of attachment 115172)
View in context: https://bugs.webkit.org/attachment.cgi?id=115172&action=review

This is looking much better! It looks like it will break the Windows build though.

> Source/WebCore/platform/graphics/Region.cpp:72
> +    Region test(subset);
> +    test.intersect(*this);
> +    return test == subset;

I think this can be written more as:

return intersect(*this, subset) == subset;

(And I'd rename subset to region).

> Source/WebCore/platform/graphics/Region.cpp:103
> +    Shape a = m_shape;
> +    Shape b = other.m_shape;
> +
> +    Shape::SpanIterator aSpan = a.spans_begin();
> +    Shape::SpanIterator bSpan = b.spans_begin();
> +    const Shape::SpanIterator aSpanEnd = a.spans_end();
> +    const Shape::SpanIterator bSpanEnd = b.spans_end();
> +
> +    if (aSpanEnd - aSpan != bSpanEnd - bSpan) // Test for equal number of spans
> +        return false;
> +
> +    for (; aSpan != aSpanEnd; ++aSpan, ++bSpan) {
> +        if (aSpan->y != bSpan->y) // Test if spans are at same position
> +            return false;
> +
> +        Shape::SegmentIterator aSegment = a.segments_begin(aSpan);
> +        Shape::SegmentIterator bSegment = b.segments_begin(bSpan);
> +        const Shape::SegmentIterator aSegmentEnd = a.segments_end(aSpan);
> +        const Shape::SegmentIterator bSegmentEnd = b.segments_end(bSpan);
> +
> +        if (aSegmentEnd - aSegment != bSegmentEnd - bSegment) // Test for equal number of segments
> +            return false;
> +        if (!std::equal(aSegment, aSegmentEnd, bSegment)) // Test if segments are at same positions
> +            return false;
> +    }
> +
> +    return true;

If you write an operator== for Shape, I think this can become much simpler.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list