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/cc_export.h" |
12 #include "cc/base/index_rect.h" | 12 #include "cc/base/index_rect.h" |
| 13 #include "cc/base/pyramid_sequence.h" |
13 #include "cc/base/reverse_spiral_iterator.h" | 14 #include "cc/base/reverse_spiral_iterator.h" |
14 #include "cc/base/spiral_iterator.h" | 15 #include "cc/base/spiral_iterator.h" |
15 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
16 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
17 | 18 |
18 namespace gfx { | 19 namespace gfx { |
19 class RectF; | 20 class RectF; |
20 class Vector2d; | 21 class Vector2d; |
21 } | 22 } |
22 | 23 |
(...skipping 30 matching lines...) Expand all Loading... |
53 int TileAbsoluteXIndexFromSrcCoord(int src_position) const; | 54 int TileAbsoluteXIndexFromSrcCoord(int src_position) const; |
54 int TileAbsoluteYIndexFromSrcCoord(int src_position) const; | 55 int TileAbsoluteYIndexFromSrcCoord(int src_position) const; |
55 // Return the lowest tile index whose border texels include src_position. | 56 // Return the lowest tile index whose border texels include src_position. |
56 int FirstBorderTileXIndexFromSrcCoord(int src_position) const; | 57 int FirstBorderTileXIndexFromSrcCoord(int src_position) const; |
57 int FirstBorderTileYIndexFromSrcCoord(int src_position) const; | 58 int FirstBorderTileYIndexFromSrcCoord(int src_position) const; |
58 // Return the highest tile index whose border texels include src_position. | 59 // Return the highest tile index whose border texels include src_position. |
59 int LastBorderTileXIndexFromSrcCoord(int src_position) const; | 60 int LastBorderTileXIndexFromSrcCoord(int src_position) const; |
60 int LastBorderTileYIndexFromSrcCoord(int src_position) const; | 61 int LastBorderTileYIndexFromSrcCoord(int src_position) const; |
61 // Return the tile indices around the given rect. | 62 // Return the tile indices around the given rect. |
62 IndexRect TileAroundIndexRect(const gfx::Rect& center_rect) const; | 63 IndexRect TileAroundIndexRect(const gfx::Rect& center_rect) const; |
| 64 // Return the absolute tile indices around the given rect. |
| 65 IndexRect TileAroundAbsoluteIndexRect(const gfx::Rect& center_rect) const; |
63 | 66 |
64 gfx::Rect ExpandRectIgnoringBordersToTileBounds(const gfx::Rect& rect) const; | 67 gfx::Rect ExpandRectIgnoringBordersToTileBounds(const gfx::Rect& rect) const; |
65 gfx::Rect ExpandRectToTileBounds(const gfx::Rect& rect) const; | 68 gfx::Rect ExpandRectToTileBounds(const gfx::Rect& rect) const; |
66 | 69 |
67 gfx::Rect TileBounds(int i, int j) const; | 70 gfx::Rect TileBounds(int i, int j) const; |
68 gfx::Rect TileBoundsWithBorder(int i, int j) const; | 71 gfx::Rect TileBoundsWithBorder(int i, int j) const; |
69 int TilePositionX(int x_index) const; | 72 int TilePositionX(int x_index) const; |
70 int TilePositionY(int y_index) const; | 73 int TilePositionY(int y_index) const; |
71 int TileSizeX(int x_index) const; | 74 int TileSizeX(int x_index) const; |
72 int TileSizeY(int y_index) const; | 75 int TileSizeY(int y_index) const; |
73 | 76 |
74 gfx::RectF TexelExtent(int i, int j) const; | 77 gfx::RectF TexelExtent(int i, int j) const; |
75 | 78 |
76 // Difference between TileBound's and TileBoundWithBorder's origin(). | 79 // Difference between TileBound's and TileBoundWithBorder's origin(). |
77 gfx::Vector2d TextureOffset(int x_index, int y_index) const; | 80 gfx::Vector2d TextureOffset(int x_index, int y_index) const; |
78 | 81 |
| 82 // Returns true if tiling-iterator is specified as pyramid-sequence. |
| 83 static bool IsPyramidSequenceEnabled(); |
| 84 |
79 class CC_EXPORT BaseIterator { | 85 class CC_EXPORT BaseIterator { |
80 public: | 86 public: |
81 operator bool() const { return index_x_ != -1 && index_y_ != -1; } | 87 operator bool() const { return index_x_ != -1 && index_y_ != -1; } |
82 | 88 |
83 int index_x() const { return index_x_; } | 89 int index_x() const { return index_x_; } |
84 int index_y() const { return index_y_; } | 90 int index_y() const { return index_y_; } |
85 std::pair<int, int> index() const { | 91 std::pair<int, int> index() const { |
86 return std::make_pair(index_x_, index_y_); | 92 return std::make_pair(index_x_, index_y_); |
87 } | 93 } |
88 | 94 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 142 |
137 // Iterate through all indices whose bounds + border intersect with | 143 // Iterate through all indices whose bounds + border intersect with |
138 // |consider| but which also do not intersect with |ignore|. The iterator | 144 // |consider| but which also do not intersect with |ignore|. The iterator |
139 // order is a counterclockwise spiral around the given center. | 145 // order is a counterclockwise spiral around the given center. |
140 class CC_EXPORT SpiralDifferenceIterator : public BaseDifferenceIterator { | 146 class CC_EXPORT SpiralDifferenceIterator : public BaseDifferenceIterator { |
141 public: | 147 public: |
142 SpiralDifferenceIterator(); | 148 SpiralDifferenceIterator(); |
143 SpiralDifferenceIterator(const TilingData* tiling_data, | 149 SpiralDifferenceIterator(const TilingData* tiling_data, |
144 const gfx::Rect& consider_rect, | 150 const gfx::Rect& consider_rect, |
145 const gfx::Rect& ignore_rect, | 151 const gfx::Rect& ignore_rect, |
146 const gfx::Rect& center_rect); | 152 const gfx::Rect& center_rect, |
| 153 const bool use_pyramid_sequence); |
| 154 SpiralDifferenceIterator(const SpiralDifferenceIterator& other); |
| 155 SpiralDifferenceIterator(SpiralDifferenceIterator&& other); |
| 156 ~SpiralDifferenceIterator(); |
| 157 |
| 158 SpiralDifferenceIterator& operator=(const SpiralDifferenceIterator& other); |
| 159 SpiralDifferenceIterator& operator=(SpiralDifferenceIterator&& other); |
| 160 |
147 SpiralDifferenceIterator& operator++(); | 161 SpiralDifferenceIterator& operator++(); |
148 | 162 |
149 private: | 163 private: |
150 SpiralIterator spiral_iterator_; | 164 SpiralIterator spiral_iterator_; |
| 165 bool use_pyramid_sequence_; |
| 166 PyramidSequence pyramid_sequence_; |
| 167 PyramidSequence::Iterator iterator_; |
151 }; | 168 }; |
152 | 169 |
153 class CC_EXPORT ReverseSpiralDifferenceIterator | 170 class CC_EXPORT ReverseSpiralDifferenceIterator |
154 : public BaseDifferenceIterator { | 171 : public BaseDifferenceIterator { |
155 public: | 172 public: |
156 ReverseSpiralDifferenceIterator(); | 173 ReverseSpiralDifferenceIterator(); |
157 ReverseSpiralDifferenceIterator(const TilingData* tiling_data, | 174 ReverseSpiralDifferenceIterator(const TilingData* tiling_data, |
158 const gfx::Rect& consider_rect, | 175 const gfx::Rect& consider_rect, |
159 const gfx::Rect& ignore_rect, | 176 const gfx::Rect& ignore_rect, |
160 const gfx::Rect& center_rect); | 177 const gfx::Rect& center_rect, |
| 178 const bool use_pyramid_sequence); |
| 179 ReverseSpiralDifferenceIterator( |
| 180 const ReverseSpiralDifferenceIterator& other); |
| 181 ReverseSpiralDifferenceIterator(ReverseSpiralDifferenceIterator&& other); |
| 182 ~ReverseSpiralDifferenceIterator(); |
| 183 |
| 184 ReverseSpiralDifferenceIterator& operator=( |
| 185 const ReverseSpiralDifferenceIterator& other); |
| 186 ReverseSpiralDifferenceIterator& operator=( |
| 187 ReverseSpiralDifferenceIterator&& other); |
| 188 |
161 ReverseSpiralDifferenceIterator& operator++(); | 189 ReverseSpiralDifferenceIterator& operator++(); |
162 | 190 |
163 private: | 191 private: |
164 ReverseSpiralIterator reverse_spiral_iterator_; | 192 ReverseSpiralIterator reverse_spiral_iterator_; |
| 193 bool use_pyramid_sequence_; |
| 194 PyramidSequence pyramid_sequence_; |
| 195 PyramidSequence::ReverseIterator reverse_iterator_; |
165 }; | 196 }; |
166 | 197 |
167 private: | 198 private: |
168 void AssertTile(int i, int j) const { | 199 void AssertTile(int i, int j) const { |
169 DCHECK_GE(i, 0); | 200 DCHECK_GE(i, 0); |
170 DCHECK_LT(i, num_tiles_x_); | 201 DCHECK_LT(i, num_tiles_x_); |
171 DCHECK_GE(j, 0); | 202 DCHECK_GE(j, 0); |
172 DCHECK_LT(j, num_tiles_y_); | 203 DCHECK_LT(j, num_tiles_y_); |
173 } | 204 } |
174 | 205 |
175 void RecomputeNumTiles(); | 206 void RecomputeNumTiles(); |
176 | 207 |
177 gfx::Size max_texture_size_; | 208 gfx::Size max_texture_size_; |
178 gfx::Size tiling_size_; | 209 gfx::Size tiling_size_; |
179 int border_texels_; | 210 int border_texels_; |
180 | 211 |
181 // These are computed values. | 212 // These are computed values. |
182 int num_tiles_x_; | 213 int num_tiles_x_; |
183 int num_tiles_y_; | 214 int num_tiles_y_; |
184 }; | 215 }; |
185 | 216 |
186 } // namespace cc | 217 } // namespace cc |
187 | 218 |
188 #endif // CC_BASE_TILING_DATA_H_ | 219 #endif // CC_BASE_TILING_DATA_H_ |
OLD | NEW |