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