void MarginIntervalGenerator::set(int y, const IntShapeInterval& interval) { ASSERT(y >= 0 && interval.x1() >= 0); m_y = y; m_x1 = interval.x1(); m_x2 = interval.x2(); }
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; } }
void RasterShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const { const RasterShapeIntervals& intervals = marginIntervals(); if (intervals.isEmpty()) return; int y1 = logicalTop; int y2 = logicalTop + logicalHeight; ASSERT(y2 >= y1); if (y2 < intervals.bounds().y() || y1 >= intervals.bounds().maxY()) return; y1 = std::max(y1, intervals.bounds().y()); y2 = std::min(y2, intervals.bounds().maxY()); IntShapeInterval excludedInterval; for (int y = y1; y < y2; y++) excludedInterval.unite(intervals.intervalAt(y)); // Note: |marginIntervals()| returns end-point exclusive // intervals. |excludedInterval.x2()| contains the left-most pixel // offset to the right of the calculated union. result.append(LineSegment(excludedInterval.x1(), excludedInterval.x2())); }