PassOwnPtr<RasterShapeIntervals> RasterShapeIntervals::computeShapeMarginIntervals(unsigned margin) const { OwnPtr<RasterShapeIntervals> result = adoptPtr(new RasterShapeIntervals(size() + margin)); MarginIntervalGenerator marginIntervalGenerator(margin); for (int y = bounds().y(); y < bounds().maxY(); ++y) { const IntShapeInterval& intervalAtY = limitIntervalAt(y); if (intervalAtY.isEmpty()) continue; marginIntervalGenerator.set(y, intervalAtY); int marginY0 = std::max(0, clampToPositiveInteger(y - margin)); int marginY1 = std::min(result->size() - 1, clampToPositiveInteger(y + margin)); for (int marginY = y - 1; marginY >= marginY0; --marginY) { if (limitIntervalAt(marginY).contains(intervalAtY)) break; result->uniteMarginInterval(marginY, marginIntervalGenerator.intervalAt(marginY)); } result->uniteMarginInterval(y, marginIntervalGenerator.intervalAt(y)); for (int marginY = y + 1; marginY <= marginY1; ++marginY) { if (marginY < size() && limitIntervalAt(marginY).contains(intervalAtY)) break; result->uniteMarginInterval(marginY, marginIntervalGenerator.intervalAt(marginY)); } } return result.release(); }
PassOwnPtr<RasterShapeIntervals> RasterShapeIntervals::computeShapeMarginIntervals(int shapeMargin) const { int marginIntervalsSize = (offset() > shapeMargin) ? size() : size() - offset() * 2 + shapeMargin * 2; OwnPtr<RasterShapeIntervals> result = adoptPtr(new RasterShapeIntervals(marginIntervalsSize, std::max(shapeMargin, offset()))); MarginIntervalGenerator marginIntervalGenerator(shapeMargin); for (int y = bounds().y(); y < bounds().maxY(); ++y) { const IntShapeInterval& intervalAtY = intervalAt(y); if (intervalAtY.isEmpty()) continue; marginIntervalGenerator.set(y, intervalAtY); int marginY0 = std::max(minY(), y - shapeMargin); int marginY1 = std::min(maxY(), y + shapeMargin + 1); for (int marginY = y - 1; marginY >= marginY0; --marginY) { if (marginY > bounds().y() && intervalAt(marginY).contains(intervalAtY)) break; result->intervalAt(marginY).unite(marginIntervalGenerator.intervalAt(marginY)); } result->intervalAt(y).unite(marginIntervalGenerator.intervalAt(y)); for (int marginY = y + 1; marginY < marginY1; ++marginY) { if (marginY < bounds().maxY() && intervalAt(marginY).contains(intervalAtY)) break; result->intervalAt(marginY).unite(marginIntervalGenerator.intervalAt(marginY)); } } result->initializeBounds(); return result.release(); }
PassOwnPtr<RasterShapeIntervals> RasterShapeIntervals::computeShapeMarginIntervals(unsigned shapeMargin) const { OwnPtr<RasterShapeIntervals> result = adoptPtr(new RasterShapeIntervals(size(), shapeMargin)); MarginIntervalGenerator marginIntervalGenerator(shapeMargin); int minY = bounds().y(); int maxY = bounds().maxY(); for (int y = minY; y < maxY; ++y) { const IntShapeInterval& intervalAtY = limitIntervalAt(y); if (intervalAtY.isEmpty()) continue; marginIntervalGenerator.set(y, intervalAtY); int marginY0 = y - clampToInteger(shapeMargin); int marginY1 = y + clampToInteger(shapeMargin); for (int marginY = y - 1; marginY >= marginY0; --marginY) { if (marginY > minY && limitIntervalAt(marginY).contains(intervalAtY)) break; result->uniteMarginInterval(marginY, marginIntervalGenerator.intervalAt(marginY)); } result->uniteMarginInterval(y, marginIntervalGenerator.intervalAt(y)); for (int marginY = y + 1; marginY <= marginY1; ++marginY) { if (marginY < maxY && limitIntervalAt(marginY).contains(intervalAtY)) break; result->uniteMarginInterval(marginY, marginIntervalGenerator.intervalAt(marginY)); } } return result.release(); }