Exemple #1
0
void RasterShapeIntervals::uniteMarginInterval(int y, const IntShapeInterval& interval)
{
    ASSERT(m_intervalLists[y].size() <= 1); // Each m_intervalLists entry has 0 or one interval.

    if (m_intervalLists[y].isEmpty())
        m_intervalLists[y].append(interval);
    else {
        IntShapeInterval& resultInterval = m_intervalLists[y][0];
        resultInterval.set(std::min(resultInterval.x1(), interval.x1()), std::max(resultInterval.x2(), interval.x2()));
    }

    m_bounds.unite(IntRect(interval.x1(), y, interval.width(), 1));
}
void RasterShapeIntervals::buildBoundsPath(Path& path) const
{
    int maxY = bounds().maxY();
    for (int y = bounds().y(); y < maxY; y++) {
        if (intervalAt(y).isEmpty())
            continue;

        IntShapeInterval extent = intervalAt(y);
        int endY = y + 1;
        for (; endY < maxY; endY++) {
            if (intervalAt(endY).isEmpty() || intervalAt(endY) != extent)
                break;
        }
        path.addRect(FloatRect(extent.x1(), y, extent.width(), endY - y));
        y = endY - 1;
    }
}