OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NinePieceImageGrid_h | 5 #ifndef NinePieceImageGrid_h |
6 #define NinePieceImageGrid_h | 6 #define NinePieceImageGrid_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "platform/geometry/FloatRect.h" | 9 #include "platform/geometry/FloatRect.h" |
10 #include "platform/geometry/FloatSize.h" | 10 #include "platform/geometry/FloatSize.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // | 59 // |
60 // it generates drawing information for the nine border pieces. | 60 // it generates drawing information for the nine border pieces. |
61 class CORE_EXPORT NinePieceImageGrid { | 61 class CORE_EXPORT NinePieceImageGrid { |
62 STACK_ALLOCATED(); | 62 STACK_ALLOCATED(); |
63 | 63 |
64 public: | 64 public: |
65 NinePieceImageGrid(const NinePieceImage&, IntSize imageSize, IntRect borderI
mageArea, | 65 NinePieceImageGrid(const NinePieceImage&, IntSize imageSize, IntRect borderI
mageArea, |
66 const IntRectOutsets& borderWidths); | 66 const IntRectOutsets& borderWidths); |
67 | 67 |
68 struct CORE_EXPORT NinePieceDrawInfo { | 68 struct CORE_EXPORT NinePieceDrawInfo { |
| 69 STACK_ALLOCATED(); |
69 bool isDrawable; | 70 bool isDrawable; |
70 bool isCornerPiece; | 71 bool isCornerPiece; |
71 FloatRect destination; | 72 FloatRect destination; |
72 FloatRect source; | 73 FloatRect source; |
73 | 74 |
74 // tileScale and tileRule are only useful for non-corners, i.e. edge and
center pieces. | 75 // tileScale and tileRule are only useful for non-corners, i.e. edge and
center pieces. |
75 FloatSize tileScale; | 76 FloatSize tileScale; |
76 struct { | 77 struct { |
77 Image::TileRule horizontal; | 78 Image::TileRule horizontal; |
78 Image::TileRule vertical; | 79 Image::TileRule vertical; |
79 } tileRule; | 80 } tileRule; |
80 }; | 81 }; |
81 NinePieceDrawInfo getNinePieceDrawInfo(NinePiece) const; | 82 NinePieceDrawInfo getNinePieceDrawInfo(NinePiece) const; |
82 | 83 |
83 struct Edge { | 84 struct Edge { |
| 85 DISALLOW_ALLOCATION(); |
84 bool isDrawable() const { return slice > 0 && width > 0; } | 86 bool isDrawable() const { return slice > 0 && width > 0; } |
85 float scale() const { return isDrawable() ? (float)width / slice : 1; } | 87 float scale() const { return isDrawable() ? (float)width / slice : 1; } |
86 int slice; | 88 int slice; |
87 int width; | 89 int width; |
88 }; | 90 }; |
89 | 91 |
90 private: | 92 private: |
91 void setDrawInfoCorner(NinePieceDrawInfo&, NinePiece) const; | 93 void setDrawInfoCorner(NinePieceDrawInfo&, NinePiece) const; |
92 void setDrawInfoEdge(NinePieceDrawInfo&, NinePiece) const; | 94 void setDrawInfoEdge(NinePieceDrawInfo&, NinePiece) const; |
93 void setDrawInfoMiddle(NinePieceDrawInfo&) const; | 95 void setDrawInfoMiddle(NinePieceDrawInfo&) const; |
94 | 96 |
95 IntRect m_borderImageArea; | 97 IntRect m_borderImageArea; |
96 IntSize m_imageSize; | 98 IntSize m_imageSize; |
97 Image::TileRule m_horizontalTileRule; | 99 Image::TileRule m_horizontalTileRule; |
98 Image::TileRule m_verticalTileRule; | 100 Image::TileRule m_verticalTileRule; |
99 bool m_fill; | 101 bool m_fill; |
100 | 102 |
101 Edge m_top; | 103 Edge m_top; |
102 Edge m_right; | 104 Edge m_right; |
103 Edge m_bottom; | 105 Edge m_bottom; |
104 Edge m_left; | 106 Edge m_left; |
105 }; | 107 }; |
106 | 108 |
107 } // namespace blink | 109 } // namespace blink |
108 | 110 |
109 #endif // NinePieceImageGrid_h | 111 #endif // NinePieceImageGrid_h |
OLD | NEW |