OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 CC_BASE_TILING_DATA_H_ | 5 #ifndef CC_BASE_TILING_DATA_H_ |
6 #define CC_BASE_TILING_DATA_H_ | 6 #define CC_BASE_TILING_DATA_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "cc/base/cc_export.h" | 11 #include "cc/base/base_export.h" |
12 #include "cc/base/index_rect.h" | 12 #include "cc/base/index_rect.h" |
13 #include "cc/base/reverse_spiral_iterator.h" | 13 #include "cc/base/reverse_spiral_iterator.h" |
14 #include "cc/base/spiral_iterator.h" | 14 #include "cc/base/spiral_iterator.h" |
15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
16 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
17 | 17 |
18 namespace gfx { | 18 namespace gfx { |
19 class RectF; | 19 class RectF; |
20 class Vector2d; | 20 class Vector2d; |
21 } | 21 } |
22 | 22 |
23 namespace cc { | 23 namespace cc { |
24 | 24 |
25 class CC_EXPORT TilingData { | 25 class CC_BASE_EXPORT TilingData { |
26 public: | 26 public: |
27 TilingData(); | 27 TilingData(); |
28 TilingData(const gfx::Size& max_texture_size, | 28 TilingData(const gfx::Size& max_texture_size, |
29 const gfx::Size& tiling_size, | 29 const gfx::Size& tiling_size, |
30 bool has_border_texels); | 30 bool has_border_texels); |
31 TilingData(const gfx::Size& max_texture_size, | 31 TilingData(const gfx::Size& max_texture_size, |
32 const gfx::Size& tiling_size, | 32 const gfx::Size& tiling_size, |
33 int border_texels); | 33 int border_texels); |
34 | 34 |
35 gfx::Size tiling_size() const { return tiling_size_; } | 35 gfx::Size tiling_size() const { return tiling_size_; } |
(...skipping 29 matching lines...) Expand all Loading... |
65 int TilePositionX(int x_index) const; | 65 int TilePositionX(int x_index) const; |
66 int TilePositionY(int y_index) const; | 66 int TilePositionY(int y_index) const; |
67 int TileSizeX(int x_index) const; | 67 int TileSizeX(int x_index) const; |
68 int TileSizeY(int y_index) const; | 68 int TileSizeY(int y_index) const; |
69 | 69 |
70 gfx::RectF TexelExtent(int i, int j) const; | 70 gfx::RectF TexelExtent(int i, int j) const; |
71 | 71 |
72 // Difference between TileBound's and TileBoundWithBorder's origin(). | 72 // Difference between TileBound's and TileBoundWithBorder's origin(). |
73 gfx::Vector2d TextureOffset(int x_index, int y_index) const; | 73 gfx::Vector2d TextureOffset(int x_index, int y_index) const; |
74 | 74 |
75 class CC_EXPORT BaseIterator { | 75 class CC_BASE_EXPORT BaseIterator { |
76 public: | 76 public: |
77 operator bool() const { return index_x_ != -1 && index_y_ != -1; } | 77 operator bool() const { return index_x_ != -1 && index_y_ != -1; } |
78 | 78 |
79 int index_x() const { return index_x_; } | 79 int index_x() const { return index_x_; } |
80 int index_y() const { return index_y_; } | 80 int index_y() const { return index_y_; } |
81 std::pair<int, int> index() const { | 81 std::pair<int, int> index() const { |
82 return std::make_pair(index_x_, index_y_); | 82 return std::make_pair(index_x_, index_y_); |
83 } | 83 } |
84 | 84 |
85 protected: | 85 protected: |
86 BaseIterator(); | 86 BaseIterator(); |
87 void done() { | 87 void done() { |
88 index_x_ = -1; | 88 index_x_ = -1; |
89 index_y_ = -1; | 89 index_y_ = -1; |
90 } | 90 } |
91 | 91 |
92 int index_x_; | 92 int index_x_; |
93 int index_y_; | 93 int index_y_; |
94 }; | 94 }; |
95 | 95 |
96 // Iterate through tiles whose bounds + optional border intersect with |rect|. | 96 // Iterate through tiles whose bounds + optional border intersect with |rect|. |
97 class CC_EXPORT Iterator : public BaseIterator { | 97 class CC_BASE_EXPORT Iterator : public BaseIterator { |
98 public: | 98 public: |
99 Iterator(); | 99 Iterator(); |
100 Iterator(const TilingData* tiling_data, | 100 Iterator(const TilingData* tiling_data, |
101 const gfx::Rect& consider_rect, | 101 const gfx::Rect& consider_rect, |
102 bool include_borders); | 102 bool include_borders); |
103 Iterator& operator++(); | 103 Iterator& operator++(); |
104 | 104 |
105 private: | 105 private: |
106 IndexRect index_rect_; | 106 IndexRect index_rect_; |
107 }; | 107 }; |
108 | 108 |
109 class CC_EXPORT BaseDifferenceIterator : public BaseIterator { | 109 class CC_BASE_EXPORT BaseDifferenceIterator : public BaseIterator { |
110 protected: | 110 protected: |
111 BaseDifferenceIterator(); | 111 BaseDifferenceIterator(); |
112 BaseDifferenceIterator(const TilingData* tiling_data, | 112 BaseDifferenceIterator(const TilingData* tiling_data, |
113 const gfx::Rect& consider_rect, | 113 const gfx::Rect& consider_rect, |
114 const gfx::Rect& ignore_rect); | 114 const gfx::Rect& ignore_rect); |
115 | 115 |
116 bool HasConsiderRect() const; | 116 bool HasConsiderRect() const; |
117 | 117 |
118 IndexRect consider_index_rect_; | 118 IndexRect consider_index_rect_; |
119 IndexRect ignore_index_rect_; | 119 IndexRect ignore_index_rect_; |
120 }; | 120 }; |
121 | 121 |
122 // Iterate through all indices whose bounds (not including borders) intersect | 122 // Iterate through all indices whose bounds (not including borders) intersect |
123 // with |consider| but which also do not intersect with |ignore|. | 123 // with |consider| but which also do not intersect with |ignore|. |
124 class CC_EXPORT DifferenceIterator : public BaseDifferenceIterator { | 124 class CC_BASE_EXPORT DifferenceIterator : public BaseDifferenceIterator { |
125 public: | 125 public: |
126 DifferenceIterator(); | 126 DifferenceIterator(); |
127 DifferenceIterator(const TilingData* tiling_data, | 127 DifferenceIterator(const TilingData* tiling_data, |
128 const gfx::Rect& consider_rect, | 128 const gfx::Rect& consider_rect, |
129 const gfx::Rect& ignore_rect); | 129 const gfx::Rect& ignore_rect); |
130 DifferenceIterator& operator++(); | 130 DifferenceIterator& operator++(); |
131 }; | 131 }; |
132 | 132 |
133 // Iterate through all indices whose bounds + border intersect with | 133 // Iterate through all indices whose bounds + border intersect with |
134 // |consider| but which also do not intersect with |ignore|. The iterator | 134 // |consider| but which also do not intersect with |ignore|. The iterator |
135 // order is a counterclockwise spiral around the given center. | 135 // order is a counterclockwise spiral around the given center. |
136 class CC_EXPORT SpiralDifferenceIterator : public BaseDifferenceIterator { | 136 class CC_BASE_EXPORT SpiralDifferenceIterator |
| 137 : public BaseDifferenceIterator { |
137 public: | 138 public: |
138 SpiralDifferenceIterator(); | 139 SpiralDifferenceIterator(); |
139 SpiralDifferenceIterator(const TilingData* tiling_data, | 140 SpiralDifferenceIterator(const TilingData* tiling_data, |
140 const gfx::Rect& consider_rect, | 141 const gfx::Rect& consider_rect, |
141 const gfx::Rect& ignore_rect, | 142 const gfx::Rect& ignore_rect, |
142 const gfx::Rect& center_rect); | 143 const gfx::Rect& center_rect); |
143 SpiralDifferenceIterator& operator++(); | 144 SpiralDifferenceIterator& operator++(); |
144 | 145 |
145 private: | 146 private: |
146 SpiralIterator spiral_iterator_; | 147 SpiralIterator spiral_iterator_; |
147 }; | 148 }; |
148 | 149 |
149 class CC_EXPORT ReverseSpiralDifferenceIterator | 150 class CC_BASE_EXPORT ReverseSpiralDifferenceIterator |
150 : public BaseDifferenceIterator { | 151 : public BaseDifferenceIterator { |
151 public: | 152 public: |
152 ReverseSpiralDifferenceIterator(); | 153 ReverseSpiralDifferenceIterator(); |
153 ReverseSpiralDifferenceIterator(const TilingData* tiling_data, | 154 ReverseSpiralDifferenceIterator(const TilingData* tiling_data, |
154 const gfx::Rect& consider_rect, | 155 const gfx::Rect& consider_rect, |
155 const gfx::Rect& ignore_rect, | 156 const gfx::Rect& ignore_rect, |
156 const gfx::Rect& center_rect); | 157 const gfx::Rect& center_rect); |
157 ReverseSpiralDifferenceIterator& operator++(); | 158 ReverseSpiralDifferenceIterator& operator++(); |
158 | 159 |
159 private: | 160 private: |
(...skipping 15 matching lines...) Expand all Loading... |
175 int border_texels_; | 176 int border_texels_; |
176 | 177 |
177 // These are computed values. | 178 // These are computed values. |
178 int num_tiles_x_; | 179 int num_tiles_x_; |
179 int num_tiles_y_; | 180 int num_tiles_y_; |
180 }; | 181 }; |
181 | 182 |
182 } // namespace cc | 183 } // namespace cc |
183 | 184 |
184 #endif // CC_BASE_TILING_DATA_H_ | 185 #endif // CC_BASE_TILING_DATA_H_ |
OLD | NEW |