| 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 17 matching lines...) Expand all Loading... |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #ifndef RasterShape_h | 30 #ifndef RasterShape_h |
| 31 #define RasterShape_h | 31 #define RasterShape_h |
| 32 | 32 |
| 33 #include "core/layout/shapes/Shape.h" | 33 #include "core/layout/shapes/Shape.h" |
| 34 #include "core/layout/shapes/ShapeInterval.h" | 34 #include "core/layout/shapes/ShapeInterval.h" |
| 35 #include "platform/geometry/FloatRect.h" | 35 #include "platform/geometry/FloatRect.h" |
| 36 #include "wtf/Assertions.h" | 36 #include "wtf/Assertions.h" |
| 37 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
| 38 #include <memory> |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| 41 class RasterShapeIntervals { | 42 class RasterShapeIntervals { |
| 42 USING_FAST_MALLOC(RasterShapeIntervals); | 43 USING_FAST_MALLOC(RasterShapeIntervals); |
| 43 public: | 44 public: |
| 44 RasterShapeIntervals(unsigned size, int offset = 0) | 45 RasterShapeIntervals(unsigned size, int offset = 0) |
| 45 : m_offset(offset) | 46 : m_offset(offset) |
| 46 { | 47 { |
| 47 m_intervals.resize(clampTo<int>(size)); | 48 m_intervals.resize(clampTo<int>(size)); |
| 48 } | 49 } |
| 49 | 50 |
| 50 void initializeBounds(); | 51 void initializeBounds(); |
| 51 const IntRect& bounds() const { return m_bounds; } | 52 const IntRect& bounds() const { return m_bounds; } |
| 52 bool isEmpty() const { return m_bounds.isEmpty(); } | 53 bool isEmpty() const { return m_bounds.isEmpty(); } |
| 53 | 54 |
| 54 IntShapeInterval& intervalAt(int y) | 55 IntShapeInterval& intervalAt(int y) |
| 55 { | 56 { |
| 56 ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_inte
rvals.size()); | 57 ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_inte
rvals.size()); |
| 57 return m_intervals[y + m_offset]; | 58 return m_intervals[y + m_offset]; |
| 58 } | 59 } |
| 59 | 60 |
| 60 const IntShapeInterval& intervalAt(int y) const | 61 const IntShapeInterval& intervalAt(int y) const |
| 61 { | 62 { |
| 62 ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_inte
rvals.size()); | 63 ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_inte
rvals.size()); |
| 63 return m_intervals[y + m_offset]; | 64 return m_intervals[y + m_offset]; |
| 64 } | 65 } |
| 65 | 66 |
| 66 PassOwnPtr<RasterShapeIntervals> computeShapeMarginIntervals(int shapeMargin
) const; | 67 std::unique_ptr<RasterShapeIntervals> computeShapeMarginIntervals(int shapeM
argin) const; |
| 67 | 68 |
| 68 void buildBoundsPath(Path&) const; | 69 void buildBoundsPath(Path&) const; |
| 69 | 70 |
| 70 private: | 71 private: |
| 71 int size() const { return m_intervals.size(); } | 72 int size() const { return m_intervals.size(); } |
| 72 int offset() const { return m_offset; } | 73 int offset() const { return m_offset; } |
| 73 int minY() const { return -m_offset; } | 74 int minY() const { return -m_offset; } |
| 74 int maxY() const { return -m_offset + m_intervals.size(); } | 75 int maxY() const { return -m_offset + m_intervals.size(); } |
| 75 | 76 |
| 76 IntRect m_bounds; | 77 IntRect m_bounds; |
| 77 Vector<IntShapeInterval> m_intervals; | 78 Vector<IntShapeInterval> m_intervals; |
| 78 int m_offset; | 79 int m_offset; |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 class RasterShape final : public Shape { | 82 class RasterShape final : public Shape { |
| 82 WTF_MAKE_NONCOPYABLE(RasterShape); | 83 WTF_MAKE_NONCOPYABLE(RasterShape); |
| 83 public: | 84 public: |
| 84 RasterShape(PassOwnPtr<RasterShapeIntervals> intervals, const IntSize& margi
nRectSize) | 85 RasterShape(std::unique_ptr<RasterShapeIntervals> intervals, const IntSize&
marginRectSize) |
| 85 : m_intervals(std::move(intervals)) | 86 : m_intervals(std::move(intervals)) |
| 86 , m_marginRectSize(marginRectSize) | 87 , m_marginRectSize(marginRectSize) |
| 87 { | 88 { |
| 88 m_intervals->initializeBounds(); | 89 m_intervals->initializeBounds(); |
| 89 } | 90 } |
| 90 | 91 |
| 91 LayoutRect shapeMarginLogicalBoundingBox() const override { return static_ca
st<LayoutRect>(marginIntervals().bounds()); } | 92 LayoutRect shapeMarginLogicalBoundingBox() const override { return static_ca
st<LayoutRect>(marginIntervals().bounds()); } |
| 92 bool isEmpty() const override { return m_intervals->isEmpty(); } | 93 bool isEmpty() const override { return m_intervals->isEmpty(); } |
| 93 LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHei
ght) const override; | 94 LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHei
ght) const override; |
| 94 void buildDisplayPaths(DisplayPaths& paths) const override | 95 void buildDisplayPaths(DisplayPaths& paths) const override |
| 95 { | 96 { |
| 96 m_intervals->buildBoundsPath(paths.shape); | 97 m_intervals->buildBoundsPath(paths.shape); |
| 97 if (shapeMargin()) | 98 if (shapeMargin()) |
| 98 marginIntervals().buildBoundsPath(paths.marginShape); | 99 marginIntervals().buildBoundsPath(paths.marginShape); |
| 99 } | 100 } |
| 100 | 101 |
| 101 private: | 102 private: |
| 102 const RasterShapeIntervals& marginIntervals() const; | 103 const RasterShapeIntervals& marginIntervals() const; |
| 103 | 104 |
| 104 OwnPtr<RasterShapeIntervals> m_intervals; | 105 std::unique_ptr<RasterShapeIntervals> m_intervals; |
| 105 mutable OwnPtr<RasterShapeIntervals> m_marginIntervals; | 106 mutable std::unique_ptr<RasterShapeIntervals> m_marginIntervals; |
| 106 IntSize m_marginRectSize; | 107 IntSize m_marginRectSize; |
| 107 }; | 108 }; |
| 108 | 109 |
| 109 } // namespace blink | 110 } // namespace blink |
| 110 | 111 |
| 111 #endif // RasterShape_h | 112 #endif // RasterShape_h |
| OLD | NEW |