| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 MarginIntervalGenerator::MarginIntervalGenerator(unsigned radius) | 51 MarginIntervalGenerator::MarginIntervalGenerator(unsigned radius) |
| 52 : m_y(0), m_x1(0), m_x2(0) { | 52 : m_y(0), m_x1(0), m_x2(0) { |
| 53 m_xIntercepts.resize(radius + 1); | 53 m_xIntercepts.resize(radius + 1); |
| 54 unsigned radiusSquared = radius * radius; | 54 unsigned radiusSquared = radius * radius; |
| 55 for (unsigned y = 0; y <= radius; y++) | 55 for (unsigned y = 0; y <= radius; y++) |
| 56 m_xIntercepts[y] = sqrt(static_cast<double>(radiusSquared - y * y)); | 56 m_xIntercepts[y] = sqrt(static_cast<double>(radiusSquared - y * y)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void MarginIntervalGenerator::set(int y, const IntShapeInterval& interval) { | 59 void MarginIntervalGenerator::set(int y, const IntShapeInterval& interval) { |
| 60 ASSERT(y >= 0 && interval.x1() >= 0); | 60 DCHECK_GE(y, 0); |
| 61 DCHECK_GE(interval.x1(), 0); |
| 61 m_y = y; | 62 m_y = y; |
| 62 m_x1 = interval.x1(); | 63 m_x1 = interval.x1(); |
| 63 m_x2 = interval.x2(); | 64 m_x2 = interval.x2(); |
| 64 } | 65 } |
| 65 | 66 |
| 66 IntShapeInterval MarginIntervalGenerator::intervalAt(int y) const { | 67 IntShapeInterval MarginIntervalGenerator::intervalAt(int y) const { |
| 67 unsigned xInterceptsIndex = abs(y - m_y); | 68 unsigned xInterceptsIndex = abs(y - m_y); |
| 68 int dx = (xInterceptsIndex >= m_xIntercepts.size()) | 69 int dx = (xInterceptsIndex >= m_xIntercepts.size()) |
| 69 ? 0 | 70 ? 0 |
| 70 : m_xIntercepts[xInterceptsIndex]; | 71 : m_xIntercepts[xInterceptsIndex]; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 for (; endY < maxY; endY++) { | 134 for (; endY < maxY; endY++) { |
| 134 if (intervalAt(endY).isEmpty() || intervalAt(endY) != extent) | 135 if (intervalAt(endY).isEmpty() || intervalAt(endY) != extent) |
| 135 break; | 136 break; |
| 136 } | 137 } |
| 137 path.addRect(FloatRect(extent.x1(), y, extent.width(), endY - y)); | 138 path.addRect(FloatRect(extent.x1(), y, extent.width(), endY - y)); |
| 138 y = endY - 1; | 139 y = endY - 1; |
| 139 } | 140 } |
| 140 } | 141 } |
| 141 | 142 |
| 142 const RasterShapeIntervals& RasterShape::marginIntervals() const { | 143 const RasterShapeIntervals& RasterShape::marginIntervals() const { |
| 143 ASSERT(shapeMargin() >= 0); | 144 DCHECK_GE(shapeMargin(), 0); |
| 144 if (!shapeMargin()) | 145 if (!shapeMargin()) |
| 145 return *m_intervals; | 146 return *m_intervals; |
| 146 | 147 |
| 147 int shapeMarginInt = clampTo<int>(ceil(shapeMargin()), 0); | 148 int shapeMarginInt = clampTo<int>(ceil(shapeMargin()), 0); |
| 148 int maxShapeMarginInt = | 149 int maxShapeMarginInt = |
| 149 std::max(m_marginRectSize.width(), m_marginRectSize.height()) * sqrtf(2); | 150 std::max(m_marginRectSize.width(), m_marginRectSize.height()) * sqrtf(2); |
| 150 if (!m_marginIntervals) | 151 if (!m_marginIntervals) |
| 151 m_marginIntervals = m_intervals->computeShapeMarginIntervals( | 152 m_marginIntervals = m_intervals->computeShapeMarginIntervals( |
| 152 std::min(shapeMarginInt, maxShapeMarginInt)); | 153 std::min(shapeMarginInt, maxShapeMarginInt)); |
| 153 | 154 |
| 154 return *m_marginIntervals; | 155 return *m_marginIntervals; |
| 155 } | 156 } |
| 156 | 157 |
| 157 LineSegment RasterShape::getExcludedInterval(LayoutUnit logicalTop, | 158 LineSegment RasterShape::getExcludedInterval(LayoutUnit logicalTop, |
| 158 LayoutUnit logicalHeight) const { | 159 LayoutUnit logicalHeight) const { |
| 159 const RasterShapeIntervals& intervals = marginIntervals(); | 160 const RasterShapeIntervals& intervals = marginIntervals(); |
| 160 if (intervals.isEmpty()) | 161 if (intervals.isEmpty()) |
| 161 return LineSegment(); | 162 return LineSegment(); |
| 162 | 163 |
| 163 int y1 = logicalTop.toInt(); | 164 int y1 = logicalTop.toInt(); |
| 164 int y2 = (logicalTop + logicalHeight).toInt(); | 165 int y2 = (logicalTop + logicalHeight).toInt(); |
| 165 ASSERT(y2 >= y1); | 166 DCHECK_GE(y2, y1); |
| 166 if (y2 < intervals.bounds().y() || y1 >= intervals.bounds().maxY()) | 167 if (y2 < intervals.bounds().y() || y1 >= intervals.bounds().maxY()) |
| 167 return LineSegment(); | 168 return LineSegment(); |
| 168 | 169 |
| 169 y1 = std::max(y1, intervals.bounds().y()); | 170 y1 = std::max(y1, intervals.bounds().y()); |
| 170 y2 = std::min(y2, intervals.bounds().maxY()); | 171 y2 = std::min(y2, intervals.bounds().maxY()); |
| 171 IntShapeInterval excludedInterval; | 172 IntShapeInterval excludedInterval; |
| 172 | 173 |
| 173 if (y1 == y2) { | 174 if (y1 == y2) { |
| 174 excludedInterval = intervals.intervalAt(y1); | 175 excludedInterval = intervals.intervalAt(y1); |
| 175 } else { | 176 } else { |
| 176 for (int y = y1; y < y2; y++) | 177 for (int y = y1; y < y2; y++) |
| 177 excludedInterval.unite(intervals.intervalAt(y)); | 178 excludedInterval.unite(intervals.intervalAt(y)); |
| 178 } | 179 } |
| 179 | 180 |
| 180 // Note: |marginIntervals()| returns end-point exclusive | 181 // Note: |marginIntervals()| returns end-point exclusive |
| 181 // intervals. |excludedInterval.x2()| contains the left-most pixel | 182 // intervals. |excludedInterval.x2()| contains the left-most pixel |
| 182 // offset to the right of the calculated union. | 183 // offset to the right of the calculated union. |
| 183 return LineSegment(excludedInterval.x1(), excludedInterval.x2()); | 184 return LineSegment(excludedInterval.x1(), excludedInterval.x2()); |
| 184 } | 185 } |
| 185 | 186 |
| 186 } // namespace blink | 187 } // namespace blink |
| OLD | NEW |