Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 36 #include "wtf/Assertions.h" | 36 #include "wtf/Assertions.h" |
| 37 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
| 38 | 38 |
| 39 namespace WebCore { | 39 namespace WebCore { |
| 40 | 40 |
| 41 class RasterShapeIntervals { | 41 class RasterShapeIntervals { |
| 42 public: | 42 public: |
| 43 RasterShapeIntervals(unsigned size, int offset = 0) | 43 RasterShapeIntervals(unsigned size, int offset = 0) |
| 44 : m_offset(offset) | 44 : m_offset(offset) |
| 45 { | 45 { |
| 46 m_intervalLists.resize(size); | 46 m_intervals.resize(size); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void initializeBounds(); | |
| 49 const IntRect& bounds() const { return m_bounds; } | 50 const IntRect& bounds() const { return m_bounds; } |
| 50 bool isEmpty() const { return m_bounds.isEmpty(); } | 51 bool isEmpty() const { return m_bounds.isEmpty(); } |
| 51 void appendInterval(int y, int x1, int x2); | |
| 52 | 52 |
| 53 void getExcludedIntervals(int y1, int y2, IntShapeIntervals& result) const; | 53 IntShapeInterval& intervalAt(int y) |
| 54 { | |
| 55 ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_inte rvals.size()); | |
|
eseidel
2014/04/02 19:59:11
RELEASE_ASSERT? I guess the Vector already does t
| |
| 56 return m_intervals[y + m_offset]; | |
| 57 } | |
| 58 | |
| 59 const IntShapeInterval& intervalAt(int y) const | |
| 60 { | |
| 61 ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_inte rvals.size()); | |
| 62 return m_intervals[y + m_offset]; | |
| 63 } | |
| 54 | 64 |
| 55 PassOwnPtr<RasterShapeIntervals> computeShapeMarginIntervals(int shapeMargin ) const; | 65 PassOwnPtr<RasterShapeIntervals> computeShapeMarginIntervals(int shapeMargin ) const; |
| 56 | 66 |
| 57 void buildBoundsPath(Path&) const; | 67 void buildBoundsPath(Path&) const; |
| 58 | 68 |
| 59 private: | 69 private: |
| 60 int size() const { return m_intervalLists.size(); } | 70 int size() const { return m_intervals.size(); } |
| 61 int offset() const { return m_offset; } | 71 int offset() const { return m_offset; } |
| 62 int minY() const { return -m_offset; } | 72 int minY() const { return -m_offset; } |
| 63 int maxY() const { return -m_offset + m_intervalLists.size(); } | 73 int maxY() const { return -m_offset + m_intervals.size(); } |
| 64 | 74 |
| 65 IntShapeIntervals& intervalsAt(int y) | |
| 66 { | |
| 67 ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_inte rvalLists.size()); | |
| 68 return m_intervalLists[y + m_offset]; | |
| 69 } | |
| 70 | |
| 71 const IntShapeIntervals& intervalsAt(int y) const | |
| 72 { | |
| 73 ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_inte rvalLists.size()); | |
| 74 return m_intervalLists[y + m_offset]; | |
| 75 } | |
| 76 | |
| 77 IntShapeInterval limitIntervalAt(int y) const | |
| 78 { | |
| 79 const IntShapeIntervals& intervals = intervalsAt(y); | |
| 80 return intervals.size() ? IntShapeInterval(intervals[0].x1(), intervals. last().x2()) : IntShapeInterval(); | |
| 81 } | |
| 82 | |
| 83 bool contains(const IntRect&) const; | |
| 84 bool getIntervalX1Values(int minY, int maxY, int minIntervalWidth, Vector<in t>& result) const; | |
| 85 void uniteMarginInterval(int y, const IntShapeInterval&); | |
| 86 IntRect m_bounds; | 75 IntRect m_bounds; |
| 87 Vector<IntShapeIntervals> m_intervalLists; | 76 Vector<IntShapeInterval> m_intervals; |
| 88 int m_offset; | 77 int m_offset; |
| 89 }; | 78 }; |
| 90 | 79 |
| 91 class RasterShape FINAL : public Shape { | 80 class RasterShape FINAL : public Shape { |
| 92 WTF_MAKE_NONCOPYABLE(RasterShape); | 81 WTF_MAKE_NONCOPYABLE(RasterShape); |
| 93 public: | 82 public: |
| 94 RasterShape(PassOwnPtr<RasterShapeIntervals> intervals, const IntSize& margi nRectSize) | 83 RasterShape(PassOwnPtr<RasterShapeIntervals> intervals, const IntSize& margi nRectSize) |
| 95 : m_intervals(intervals) | 84 : m_intervals(intervals) |
| 96 , m_marginRectSize(marginRectSize) | 85 , m_marginRectSize(marginRectSize) |
| 97 { | 86 { |
| 87 m_intervals->initializeBounds(); | |
| 98 } | 88 } |
| 99 | 89 |
| 100 virtual LayoutRect shapeMarginLogicalBoundingBox() const OVERRIDE { return s tatic_cast<LayoutRect>(marginIntervals().bounds()); } | 90 virtual LayoutRect shapeMarginLogicalBoundingBox() const OVERRIDE { return s tatic_cast<LayoutRect>(marginIntervals().bounds()); } |
| 101 virtual bool isEmpty() const OVERRIDE { return m_intervals->isEmpty(); } | 91 virtual bool isEmpty() const OVERRIDE { return m_intervals->isEmpty(); } |
| 102 virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalH eight, SegmentList&) const OVERRIDE; | 92 virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalH eight, SegmentList&) const OVERRIDE; |
| 103 | 93 |
| 104 private: | 94 private: |
| 105 const RasterShapeIntervals& marginIntervals() const; | 95 const RasterShapeIntervals& marginIntervals() const; |
| 106 | 96 |
| 107 OwnPtr<RasterShapeIntervals> m_intervals; | 97 OwnPtr<RasterShapeIntervals> m_intervals; |
| 108 mutable OwnPtr<RasterShapeIntervals> m_marginIntervals; | 98 mutable OwnPtr<RasterShapeIntervals> m_marginIntervals; |
| 109 IntSize m_marginRectSize; | 99 IntSize m_marginRectSize; |
| 110 }; | 100 }; |
| 111 | 101 |
| 112 } // namespace WebCore | 102 } // namespace WebCore |
| 113 | 103 |
| 114 #endif // RasterShape_h | 104 #endif // RasterShape_h |
| OLD | NEW |