summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/shapes/RasterShape.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/rendering/shapes/RasterShape.h')
-rw-r--r--Source/WebCore/rendering/shapes/RasterShape.h85
1 files changed, 35 insertions, 50 deletions
diff --git a/Source/WebCore/rendering/shapes/RasterShape.h b/Source/WebCore/rendering/shapes/RasterShape.h
index c04ef15ff..23ddaf4ff 100644
--- a/Source/WebCore/rendering/shapes/RasterShape.h
+++ b/Source/WebCore/rendering/shapes/RasterShape.h
@@ -12,7 +12,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -27,8 +27,7 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef RasterShape_h
-#define RasterShape_h
+#pragma once
#include "FloatRect.h"
#include "Shape.h"
@@ -39,70 +38,59 @@
namespace WebCore {
class RasterShapeIntervals {
+ WTF_MAKE_FAST_ALLOCATED;
public:
- RasterShapeIntervals(unsigned size, unsigned shapeMargin = 0)
- : m_shapeMargin(shapeMargin)
+ RasterShapeIntervals(unsigned size, int offset = 0)
+ : m_offset(offset)
{
- m_intervalLists.resize(size + shapeMargin * 2);
+ m_intervals.resize(clampTo<int>(size));
}
+ void initializeBounds();
const IntRect& bounds() const { return m_bounds; }
bool isEmpty() const { return m_bounds.isEmpty(); }
- void appendInterval(int y, int x1, int x2);
-
- void getIncludedIntervals(int y1, int y2, IntShapeIntervals& result) const;
- void getExcludedIntervals(int y1, int y2, IntShapeIntervals& result) const;
- bool firstIncludedIntervalY(int minY, const IntSize& minSize, LayoutUnit& result) const;
- PassOwnPtr<RasterShapeIntervals> computeShapeMarginIntervals(unsigned shapeMargin) const;
-
- void buildBoundsPath(Path&) const;
-
-private:
- int size() const { return m_intervalLists.size(); }
- IntShapeIntervals& intervalsAt(int y)
+ IntShapeInterval& intervalAt(int y)
{
- ASSERT(static_cast<int>(y + m_shapeMargin) >= 0 && y + m_shapeMargin < m_intervalLists.size());
- return m_intervalLists[y + m_shapeMargin];
+ ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_intervals.size());
+ return m_intervals[y + m_offset];
}
- const IntShapeIntervals& intervalsAt(int y) const
+ const IntShapeInterval& intervalAt(int y) const
{
- ASSERT(static_cast<int>(y + m_shapeMargin) >= 0 && y + m_shapeMargin < m_intervalLists.size());
- return m_intervalLists[y + m_shapeMargin];
+ ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_intervals.size());
+ return m_intervals[y + m_offset];
}
- IntShapeInterval limitIntervalAt(int y) const
- {
- const IntShapeIntervals& intervals = intervalsAt(y);
- return intervals.size() ? IntShapeInterval(intervals[0].x1(), intervals.last().x2()) : IntShapeInterval();
- }
+ std::unique_ptr<RasterShapeIntervals> computeShapeMarginIntervals(int shapeMargin) const;
+ void buildBoundsPath(Path&) const;
+
+private:
+ int size() const { return m_intervals.size(); }
+ int offset() const { return m_offset; }
+ int minY() const { return -m_offset; }
+ int maxY() const { return -m_offset + m_intervals.size(); }
- bool contains(const IntRect&) const;
- bool getIntervalX1Values(int minY, int maxY, int minIntervalWidth, Vector<int>& result) const;
- void uniteMarginInterval(int y, const IntShapeInterval&);
IntRect m_bounds;
- Vector<IntShapeIntervals> m_intervalLists;
- unsigned m_shapeMargin;
+ Vector<IntShapeInterval> m_intervals;
+ int m_offset;
};
-class RasterShape : public Shape {
+class RasterShape final : public Shape {
WTF_MAKE_NONCOPYABLE(RasterShape);
public:
- RasterShape(PassOwnPtr<RasterShapeIntervals> intervals, const IntSize& imageSize)
- : m_intervals(intervals)
- , m_imageSize(imageSize)
+ RasterShape(std::unique_ptr<RasterShapeIntervals> intervals, const IntSize& marginRectSize)
+ : m_intervals(WTFMove(intervals))
+ , m_marginRectSize(marginRectSize)
{
+ m_intervals->initializeBounds();
}
- virtual LayoutRect shapeMarginLogicalBoundingBox() const override { return static_cast<LayoutRect>(marginIntervals().bounds()); }
- virtual LayoutRect shapePaddingLogicalBoundingBox() const override { return static_cast<LayoutRect>(paddingIntervals().bounds()); }
- virtual bool isEmpty() const override { return m_intervals->isEmpty(); }
- virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const override;
- virtual void getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const override;
- virtual bool firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIntervalTop, const FloatSize& minLogicalIntervalSize, LayoutUnit&) const override;
+ LayoutRect shapeMarginLogicalBoundingBox() const override { return static_cast<LayoutRect>(marginIntervals().bounds()); }
+ bool isEmpty() const override { return m_intervals->isEmpty(); }
+ LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const override;
- virtual void buildDisplayPaths(DisplayPaths& paths) const override
+ void buildDisplayPaths(DisplayPaths& paths) const override
{
m_intervals->buildBoundsPath(paths.shape);
if (shapeMargin())
@@ -111,13 +99,10 @@ public:
private:
const RasterShapeIntervals& marginIntervals() const;
- const RasterShapeIntervals& paddingIntervals() const;
- OwnPtr<RasterShapeIntervals> m_intervals;
- mutable OwnPtr<RasterShapeIntervals> m_marginIntervals;
- IntSize m_imageSize;
+ std::unique_ptr<RasterShapeIntervals> m_intervals;
+ mutable std::unique_ptr<RasterShapeIntervals> m_marginIntervals;
+ IntSize m_marginRectSize;
};
} // namespace WebCore
-
-#endif // RasterShape_h