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> |
33 | 35 |
34 namespace blink { | 36 namespace blink { |
35 | 37 |
36 class MarginIntervalGenerator { | 38 class MarginIntervalGenerator { |
37 public: | 39 public: |
38 MarginIntervalGenerator(unsigned radius); | 40 MarginIntervalGenerator(unsigned radius); |
39 void set(int y, const IntShapeInterval&); | 41 void set(int y, const IntShapeInterval&); |
40 IntShapeInterval intervalAt(int y) const; | 42 IntShapeInterval intervalAt(int y) const; |
41 | 43 |
42 private: | 44 private: |
(...skipping 22 matching lines...) Expand all Loading... |
65 m_x2 = interval.x2(); | 67 m_x2 = interval.x2(); |
66 } | 68 } |
67 | 69 |
68 IntShapeInterval MarginIntervalGenerator::intervalAt(int y) const | 70 IntShapeInterval MarginIntervalGenerator::intervalAt(int y) const |
69 { | 71 { |
70 unsigned xInterceptsIndex = abs(y - m_y); | 72 unsigned xInterceptsIndex = abs(y - m_y); |
71 int dx = (xInterceptsIndex >= m_xIntercepts.size()) ? 0 : m_xIntercepts[xInt
erceptsIndex]; | 73 int dx = (xInterceptsIndex >= m_xIntercepts.size()) ? 0 : m_xIntercepts[xInt
erceptsIndex]; |
72 return IntShapeInterval(m_x1 - dx, m_x2 + dx); | 74 return IntShapeInterval(m_x1 - dx, m_x2 + dx); |
73 } | 75 } |
74 | 76 |
75 PassOwnPtr<RasterShapeIntervals> RasterShapeIntervals::computeShapeMarginInterva
ls(int shapeMargin) const | 77 std::unique_ptr<RasterShapeIntervals> RasterShapeIntervals::computeShapeMarginIn
tervals(int shapeMargin) const |
76 { | 78 { |
77 int marginIntervalsSize = (offset() > shapeMargin) ? size() : size() - offse
t() * 2 + shapeMargin * 2; | 79 int marginIntervalsSize = (offset() > shapeMargin) ? size() : size() - offse
t() * 2 + shapeMargin * 2; |
78 OwnPtr<RasterShapeIntervals> result = adoptPtr(new RasterShapeIntervals(marg
inIntervalsSize, std::max(shapeMargin, offset()))); | 80 std::unique_ptr<RasterShapeIntervals> result = wrapUnique(new RasterShapeInt
ervals(marginIntervalsSize, std::max(shapeMargin, offset()))); |
79 MarginIntervalGenerator marginIntervalGenerator(shapeMargin); | 81 MarginIntervalGenerator marginIntervalGenerator(shapeMargin); |
80 | 82 |
81 for (int y = bounds().y(); y < bounds().maxY(); ++y) { | 83 for (int y = bounds().y(); y < bounds().maxY(); ++y) { |
82 const IntShapeInterval& intervalAtY = intervalAt(y); | 84 const IntShapeInterval& intervalAtY = intervalAt(y); |
83 if (intervalAtY.isEmpty()) | 85 if (intervalAtY.isEmpty()) |
84 continue; | 86 continue; |
85 | 87 |
86 marginIntervalGenerator.set(y, intervalAtY); | 88 marginIntervalGenerator.set(y, intervalAtY); |
87 int marginY0 = std::max(minY(), y - shapeMargin); | 89 int marginY0 = std::max(minY(), y - shapeMargin); |
88 int marginY1 = std::min(maxY(), y + shapeMargin + 1); | 90 int marginY1 = std::min(maxY(), y + shapeMargin + 1); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 excludedInterval.unite(intervals.intervalAt(y)); | 174 excludedInterval.unite(intervals.intervalAt(y)); |
173 } | 175 } |
174 | 176 |
175 // Note: |marginIntervals()| returns end-point exclusive | 177 // Note: |marginIntervals()| returns end-point exclusive |
176 // intervals. |excludedInterval.x2()| contains the left-most pixel | 178 // intervals. |excludedInterval.x2()| contains the left-most pixel |
177 // offset to the right of the calculated union. | 179 // offset to the right of the calculated union. |
178 return LineSegment(excludedInterval.x1(), excludedInterval.x2()); | 180 return LineSegment(excludedInterval.x1(), excludedInterval.x2()); |
179 } | 181 } |
180 | 182 |
181 } // namespace blink | 183 } // namespace blink |
OLD | NEW |