| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
| 9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
| 10 * disclaimer. | 10 * disclaimer. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 27 * OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "core/layout/shapes/RasterShape.h" | 30 #include "core/layout/shapes/RasterShape.h" |
| 31 | 31 |
| 32 #include "wtf/MathExtras.h" | 32 #include "wtf/MathExtras.h" |
| 33 #include "wtf/PtrUtil.h" | |
| 34 #include <memory> | |
| 35 | 33 |
| 36 namespace blink { | 34 namespace blink { |
| 37 | 35 |
| 38 class MarginIntervalGenerator { | 36 class MarginIntervalGenerator { |
| 39 public: | 37 public: |
| 40 MarginIntervalGenerator(unsigned radius); | 38 MarginIntervalGenerator(unsigned radius); |
| 41 void set(int y, const IntShapeInterval&); | 39 void set(int y, const IntShapeInterval&); |
| 42 IntShapeInterval intervalAt(int y) const; | 40 IntShapeInterval intervalAt(int y) const; |
| 43 | 41 |
| 44 private: | 42 private: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 67 m_x2 = interval.x2(); | 65 m_x2 = interval.x2(); |
| 68 } | 66 } |
| 69 | 67 |
| 70 IntShapeInterval MarginIntervalGenerator::intervalAt(int y) const | 68 IntShapeInterval MarginIntervalGenerator::intervalAt(int y) const |
| 71 { | 69 { |
| 72 unsigned xInterceptsIndex = abs(y - m_y); | 70 unsigned xInterceptsIndex = abs(y - m_y); |
| 73 int dx = (xInterceptsIndex >= m_xIntercepts.size()) ? 0 : m_xIntercepts[xInt
erceptsIndex]; | 71 int dx = (xInterceptsIndex >= m_xIntercepts.size()) ? 0 : m_xIntercepts[xInt
erceptsIndex]; |
| 74 return IntShapeInterval(m_x1 - dx, m_x2 + dx); | 72 return IntShapeInterval(m_x1 - dx, m_x2 + dx); |
| 75 } | 73 } |
| 76 | 74 |
| 77 std::unique_ptr<RasterShapeIntervals> RasterShapeIntervals::computeShapeMarginIn
tervals(int shapeMargin) const | 75 PassOwnPtr<RasterShapeIntervals> RasterShapeIntervals::computeShapeMarginInterva
ls(int shapeMargin) const |
| 78 { | 76 { |
| 79 int marginIntervalsSize = (offset() > shapeMargin) ? size() : size() - offse
t() * 2 + shapeMargin * 2; | 77 int marginIntervalsSize = (offset() > shapeMargin) ? size() : size() - offse
t() * 2 + shapeMargin * 2; |
| 80 std::unique_ptr<RasterShapeIntervals> result = wrapUnique(new RasterShapeInt
ervals(marginIntervalsSize, std::max(shapeMargin, offset()))); | 78 OwnPtr<RasterShapeIntervals> result = adoptPtr(new RasterShapeIntervals(marg
inIntervalsSize, std::max(shapeMargin, offset()))); |
| 81 MarginIntervalGenerator marginIntervalGenerator(shapeMargin); | 79 MarginIntervalGenerator marginIntervalGenerator(shapeMargin); |
| 82 | 80 |
| 83 for (int y = bounds().y(); y < bounds().maxY(); ++y) { | 81 for (int y = bounds().y(); y < bounds().maxY(); ++y) { |
| 84 const IntShapeInterval& intervalAtY = intervalAt(y); | 82 const IntShapeInterval& intervalAtY = intervalAt(y); |
| 85 if (intervalAtY.isEmpty()) | 83 if (intervalAtY.isEmpty()) |
| 86 continue; | 84 continue; |
| 87 | 85 |
| 88 marginIntervalGenerator.set(y, intervalAtY); | 86 marginIntervalGenerator.set(y, intervalAtY); |
| 89 int marginY0 = std::max(minY(), y - shapeMargin); | 87 int marginY0 = std::max(minY(), y - shapeMargin); |
| 90 int marginY1 = std::min(maxY(), y + shapeMargin + 1); | 88 int marginY1 = std::min(maxY(), y + shapeMargin + 1); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 excludedInterval.unite(intervals.intervalAt(y)); | 172 excludedInterval.unite(intervals.intervalAt(y)); |
| 175 } | 173 } |
| 176 | 174 |
| 177 // Note: |marginIntervals()| returns end-point exclusive | 175 // Note: |marginIntervals()| returns end-point exclusive |
| 178 // intervals. |excludedInterval.x2()| contains the left-most pixel | 176 // intervals. |excludedInterval.x2()| contains the left-most pixel |
| 179 // offset to the right of the calculated union. | 177 // offset to the right of the calculated union. |
| 180 return LineSegment(excludedInterval.x1(), excludedInterval.x2()); | 178 return LineSegment(excludedInterval.x1(), excludedInterval.x2()); |
| 181 } | 179 } |
| 182 | 180 |
| 183 } // namespace blink | 181 } // namespace blink |
| OLD | NEW |