OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "platform/graphics/ImageBuffer.h" | 46 #include "platform/graphics/ImageBuffer.h" |
47 #include "wtf/MathExtras.h" | 47 #include "wtf/MathExtras.h" |
48 #include "wtf/PtrUtil.h" | 48 #include "wtf/PtrUtil.h" |
49 #include "wtf/typed_arrays/ArrayBufferContents.h" | 49 #include "wtf/typed_arrays/ArrayBufferContents.h" |
50 #include <memory> | 50 #include <memory> |
51 | 51 |
52 namespace blink { | 52 namespace blink { |
53 | 53 |
54 static std::unique_ptr<Shape> createInsetShape(const FloatRoundedRect& bounds) { | 54 static std::unique_ptr<Shape> createInsetShape(const FloatRoundedRect& bounds) { |
55 ASSERT(bounds.rect().width() >= 0 && bounds.rect().height() >= 0); | 55 ASSERT(bounds.rect().width() >= 0 && bounds.rect().height() >= 0); |
56 return makeUnique<BoxShape>(bounds); | 56 return WTF::makeUnique<BoxShape>(bounds); |
57 } | 57 } |
58 | 58 |
59 static std::unique_ptr<Shape> createCircleShape(const FloatPoint& center, | 59 static std::unique_ptr<Shape> createCircleShape(const FloatPoint& center, |
60 float radius) { | 60 float radius) { |
61 ASSERT(radius >= 0); | 61 ASSERT(radius >= 0); |
62 return wrapUnique( | 62 return WTF::wrapUnique( |
63 new RectangleShape(FloatRect(center.x() - radius, center.y() - radius, | 63 new RectangleShape(FloatRect(center.x() - radius, center.y() - radius, |
64 radius * 2, radius * 2), | 64 radius * 2, radius * 2), |
65 FloatSize(radius, radius))); | 65 FloatSize(radius, radius))); |
66 } | 66 } |
67 | 67 |
68 static std::unique_ptr<Shape> createEllipseShape(const FloatPoint& center, | 68 static std::unique_ptr<Shape> createEllipseShape(const FloatPoint& center, |
69 const FloatSize& radii) { | 69 const FloatSize& radii) { |
70 ASSERT(radii.width() >= 0 && radii.height() >= 0); | 70 ASSERT(radii.width() >= 0 && radii.height() >= 0); |
71 return wrapUnique(new RectangleShape( | 71 return WTF::wrapUnique(new RectangleShape( |
72 FloatRect(center.x() - radii.width(), center.y() - radii.height(), | 72 FloatRect(center.x() - radii.width(), center.y() - radii.height(), |
73 radii.width() * 2, radii.height() * 2), | 73 radii.width() * 2, radii.height() * 2), |
74 radii)); | 74 radii)); |
75 } | 75 } |
76 | 76 |
77 static std::unique_ptr<Shape> createPolygonShape( | 77 static std::unique_ptr<Shape> createPolygonShape( |
78 std::unique_ptr<Vector<FloatPoint>> vertices, | 78 std::unique_ptr<Vector<FloatPoint>> vertices, |
79 WindRule fillRule) { | 79 WindRule fillRule) { |
80 return wrapUnique(new PolygonShape(std::move(vertices), fillRule)); | 80 return WTF::wrapUnique(new PolygonShape(std::move(vertices), fillRule)); |
81 } | 81 } |
82 | 82 |
83 static inline FloatRect physicalRectToLogical(const FloatRect& rect, | 83 static inline FloatRect physicalRectToLogical(const FloatRect& rect, |
84 float logicalBoxHeight, | 84 float logicalBoxHeight, |
85 WritingMode writingMode) { | 85 WritingMode writingMode) { |
86 if (isHorizontalWritingMode(writingMode)) | 86 if (isHorizontalWritingMode(writingMode)) |
87 return rect; | 87 return rect; |
88 if (isFlippedBlocksWritingMode(writingMode)) | 88 if (isFlippedBlocksWritingMode(writingMode)) |
89 return FloatRect(rect.y(), logicalBoxHeight - rect.maxX(), rect.height(), | 89 return FloatRect(rect.y(), logicalBoxHeight - rect.maxX(), rect.height(), |
90 rect.width()); | 90 rect.width()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 shape = createEllipseShape(logicalCenter, FloatSize(radiusX, radiusY)); | 150 shape = createEllipseShape(logicalCenter, FloatSize(radiusX, radiusY)); |
151 break; | 151 break; |
152 } | 152 } |
153 | 153 |
154 case BasicShape::BasicShapePolygonType: { | 154 case BasicShape::BasicShapePolygonType: { |
155 const BasicShapePolygon* polygon = toBasicShapePolygon(basicShape); | 155 const BasicShapePolygon* polygon = toBasicShapePolygon(basicShape); |
156 const Vector<Length>& values = polygon->values(); | 156 const Vector<Length>& values = polygon->values(); |
157 size_t valuesSize = values.size(); | 157 size_t valuesSize = values.size(); |
158 ASSERT(!(valuesSize % 2)); | 158 ASSERT(!(valuesSize % 2)); |
159 std::unique_ptr<Vector<FloatPoint>> vertices = | 159 std::unique_ptr<Vector<FloatPoint>> vertices = |
160 wrapUnique(new Vector<FloatPoint>(valuesSize / 2)); | 160 WTF::wrapUnique(new Vector<FloatPoint>(valuesSize / 2)); |
161 for (unsigned i = 0; i < valuesSize; i += 2) { | 161 for (unsigned i = 0; i < valuesSize; i += 2) { |
162 FloatPoint vertex(floatValueForLength(values.at(i), boxWidth), | 162 FloatPoint vertex(floatValueForLength(values.at(i), boxWidth), |
163 floatValueForLength(values.at(i + 1), boxHeight)); | 163 floatValueForLength(values.at(i + 1), boxHeight)); |
164 (*vertices)[i / 2] = physicalPointToLogical( | 164 (*vertices)[i / 2] = physicalPointToLogical( |
165 vertex, logicalBoxSize.height().toFloat(), writingMode); | 165 vertex, logicalBoxSize.height().toFloat(), writingMode); |
166 } | 166 } |
167 shape = createPolygonShape(std::move(vertices), polygon->getWindRule()); | 167 shape = createPolygonShape(std::move(vertices), polygon->getWindRule()); |
168 break; | 168 break; |
169 } | 169 } |
170 | 170 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 shape->m_writingMode = writingMode; | 207 shape->m_writingMode = writingMode; |
208 shape->m_margin = margin; | 208 shape->m_margin = margin; |
209 | 209 |
210 return shape; | 210 return shape; |
211 } | 211 } |
212 | 212 |
213 std::unique_ptr<Shape> Shape::createEmptyRasterShape(WritingMode writingMode, | 213 std::unique_ptr<Shape> Shape::createEmptyRasterShape(WritingMode writingMode, |
214 float margin) { | 214 float margin) { |
215 std::unique_ptr<RasterShapeIntervals> intervals = | 215 std::unique_ptr<RasterShapeIntervals> intervals = |
216 makeUnique<RasterShapeIntervals>(0, 0); | 216 WTF::makeUnique<RasterShapeIntervals>(0, 0); |
217 std::unique_ptr<RasterShape> rasterShape = | 217 std::unique_ptr<RasterShape> rasterShape = |
218 wrapUnique(new RasterShape(std::move(intervals), IntSize())); | 218 WTF::wrapUnique(new RasterShape(std::move(intervals), IntSize())); |
219 rasterShape->m_writingMode = writingMode; | 219 rasterShape->m_writingMode = writingMode; |
220 rasterShape->m_margin = margin; | 220 rasterShape->m_margin = margin; |
221 return std::move(rasterShape); | 221 return std::move(rasterShape); |
222 } | 222 } |
223 | 223 |
224 std::unique_ptr<Shape> Shape::createRasterShape(Image* image, | 224 std::unique_ptr<Shape> Shape::createRasterShape(Image* image, |
225 float threshold, | 225 float threshold, |
226 const LayoutRect& imageR, | 226 const LayoutRect& imageR, |
227 const LayoutRect& marginR, | 227 const LayoutRect& marginR, |
228 WritingMode writingMode, | 228 WritingMode writingMode, |
229 float margin) { | 229 float margin) { |
230 IntRect imageRect = pixelSnappedIntRect(imageR); | 230 IntRect imageRect = pixelSnappedIntRect(imageR); |
231 IntRect marginRect = pixelSnappedIntRect(marginR); | 231 IntRect marginRect = pixelSnappedIntRect(marginR); |
232 | 232 |
233 std::unique_ptr<RasterShapeIntervals> intervals = wrapUnique( | 233 std::unique_ptr<RasterShapeIntervals> intervals = WTF::wrapUnique( |
234 new RasterShapeIntervals(marginRect.height(), -marginRect.y())); | 234 new RasterShapeIntervals(marginRect.height(), -marginRect.y())); |
235 std::unique_ptr<ImageBuffer> imageBuffer = | 235 std::unique_ptr<ImageBuffer> imageBuffer = |
236 ImageBuffer::create(imageRect.size()); | 236 ImageBuffer::create(imageRect.size()); |
237 | 237 |
238 if (image && imageBuffer) { | 238 if (image && imageBuffer) { |
239 // FIXME: This is not totally correct but it is needed to prevent shapes | 239 // FIXME: This is not totally correct but it is needed to prevent shapes |
240 // that loads SVG Images during paint invalidations to mark layoutObjects | 240 // that loads SVG Images during paint invalidations to mark layoutObjects |
241 // for layout, which is not allowed. See https://crbug.com/429346 | 241 // for layout, which is not allowed. See https://crbug.com/429346 |
242 ImageObserverDisabler disabler(image); | 242 ImageObserverDisabler disabler(image); |
243 SkPaint paint; | 243 SkPaint paint; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 intervals->intervalAt(y + imageRect.y()) | 276 intervals->intervalAt(y + imageRect.y()) |
277 .unite(IntShapeInterval(startX + imageRect.x(), | 277 .unite(IntShapeInterval(startX + imageRect.x(), |
278 endX + imageRect.x())); | 278 endX + imageRect.x())); |
279 startX = -1; | 279 startX = -1; |
280 } | 280 } |
281 } | 281 } |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 std::unique_ptr<RasterShape> rasterShape = | 285 std::unique_ptr<RasterShape> rasterShape = |
286 wrapUnique(new RasterShape(std::move(intervals), marginRect.size())); | 286 WTF::wrapUnique(new RasterShape(std::move(intervals), marginRect.size())); |
287 rasterShape->m_writingMode = writingMode; | 287 rasterShape->m_writingMode = writingMode; |
288 rasterShape->m_margin = margin; | 288 rasterShape->m_margin = margin; |
289 return std::move(rasterShape); | 289 return std::move(rasterShape); |
290 } | 290 } |
291 | 291 |
292 std::unique_ptr<Shape> Shape::createLayoutBoxShape( | 292 std::unique_ptr<Shape> Shape::createLayoutBoxShape( |
293 const FloatRoundedRect& roundedRect, | 293 const FloatRoundedRect& roundedRect, |
294 WritingMode writingMode, | 294 WritingMode writingMode, |
295 float margin) { | 295 float margin) { |
296 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height()); | 296 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height()); |
297 FloatRoundedRect bounds(rect, roundedRect.getRadii()); | 297 FloatRoundedRect bounds(rect, roundedRect.getRadii()); |
298 std::unique_ptr<Shape> shape = createInsetShape(bounds); | 298 std::unique_ptr<Shape> shape = createInsetShape(bounds); |
299 shape->m_writingMode = writingMode; | 299 shape->m_writingMode = writingMode; |
300 shape->m_margin = margin; | 300 shape->m_margin = margin; |
301 | 301 |
302 return shape; | 302 return shape; |
303 } | 303 } |
304 | 304 |
305 } // namespace blink | 305 } // namespace blink |
OLD | NEW |