Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: cc/base/tiling_data.h

Issue 2352393002: cc: Detach spiral iterator implementation to separate file. (Closed)
Patch Set: win build break Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/reverse_spiral_iterator.h"
14 #include "cc/base/spiral_iterator.h"
13 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
15 17
16 namespace gfx { 18 namespace gfx {
17 class Vector2d; 19 class Vector2d;
18 } 20 }
19 21
20 namespace cc { 22 namespace cc {
21 23
22 class CC_EXPORT TilingData { 24 class CC_EXPORT TilingData {
(...skipping 21 matching lines...) Expand all
44 int num_tiles_y() const { return num_tiles_y_; } 46 int num_tiles_y() const { return num_tiles_y_; }
45 // Return the tile index whose non-border texels include src_position. 47 // Return the tile index whose non-border texels include src_position.
46 int TileXIndexFromSrcCoord(int src_position) const; 48 int TileXIndexFromSrcCoord(int src_position) const;
47 int TileYIndexFromSrcCoord(int src_position) const; 49 int TileYIndexFromSrcCoord(int src_position) const;
48 // Return the lowest tile index whose border texels include src_position. 50 // Return the lowest tile index whose border texels include src_position.
49 int FirstBorderTileXIndexFromSrcCoord(int src_position) const; 51 int FirstBorderTileXIndexFromSrcCoord(int src_position) const;
50 int FirstBorderTileYIndexFromSrcCoord(int src_position) const; 52 int FirstBorderTileYIndexFromSrcCoord(int src_position) const;
51 // Return the highest tile index whose border texels include src_position. 53 // Return the highest tile index whose border texels include src_position.
52 int LastBorderTileXIndexFromSrcCoord(int src_position) const; 54 int LastBorderTileXIndexFromSrcCoord(int src_position) const;
53 int LastBorderTileYIndexFromSrcCoord(int src_position) const; 55 int LastBorderTileYIndexFromSrcCoord(int src_position) const;
56 // Return the tile indices around the given rect.
57 IndexRect TileAroundIndexRect(const gfx::Rect& center_rect) const;
54 58
55 gfx::Rect ExpandRectIgnoringBordersToTileBounds(const gfx::Rect& rect) const; 59 gfx::Rect ExpandRectIgnoringBordersToTileBounds(const gfx::Rect& rect) const;
56 gfx::Rect ExpandRectToTileBounds(const gfx::Rect& rect) const; 60 gfx::Rect ExpandRectToTileBounds(const gfx::Rect& rect) const;
57 61
58 gfx::Rect TileBounds(int i, int j) const; 62 gfx::Rect TileBounds(int i, int j) const;
59 gfx::Rect TileBoundsWithBorder(int i, int j) const; 63 gfx::Rect TileBoundsWithBorder(int i, int j) const;
60 int TilePositionX(int x_index) const; 64 int TilePositionX(int x_index) const;
61 int TilePositionY(int y_index) const; 65 int TilePositionY(int y_index) const;
62 int TileSizeX(int x_index) const; 66 int TileSizeX(int x_index) const;
63 int TileSizeY(int y_index) const; 67 int TileSizeY(int y_index) const;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 class CC_EXPORT SpiralDifferenceIterator : public BaseDifferenceIterator { 133 class CC_EXPORT SpiralDifferenceIterator : public BaseDifferenceIterator {
130 public: 134 public:
131 SpiralDifferenceIterator(); 135 SpiralDifferenceIterator();
132 SpiralDifferenceIterator(const TilingData* tiling_data, 136 SpiralDifferenceIterator(const TilingData* tiling_data,
133 const gfx::Rect& consider_rect, 137 const gfx::Rect& consider_rect,
134 const gfx::Rect& ignore_rect, 138 const gfx::Rect& ignore_rect,
135 const gfx::Rect& center_rect); 139 const gfx::Rect& center_rect);
136 SpiralDifferenceIterator& operator++(); 140 SpiralDifferenceIterator& operator++();
137 141
138 private: 142 private:
139 int current_step_count() const { 143 SpiralIterator spiral_iterator_;
140 return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_
141 : horizontal_step_count_;
142 }
143
144 bool needs_direction_switch() const;
145 void switch_direction();
146
147 enum Direction { UP, LEFT, DOWN, RIGHT };
148
149 Direction direction_;
150 int delta_x_;
151 int delta_y_;
152 int current_step_;
153 int horizontal_step_count_;
154 int vertical_step_count_;
155 }; 144 };
156 145
157 class CC_EXPORT ReverseSpiralDifferenceIterator 146 class CC_EXPORT ReverseSpiralDifferenceIterator
vmpstr 2016/09/22 17:43:42 Can we remove this class and have the SpiralIterat
prashant.n 2016/09/23 01:52:34 1. Basically this class provides around_index_rect
158 : public BaseDifferenceIterator { 147 : public BaseDifferenceIterator {
159 public: 148 public:
160 ReverseSpiralDifferenceIterator(); 149 ReverseSpiralDifferenceIterator();
161 ReverseSpiralDifferenceIterator(const TilingData* tiling_data, 150 ReverseSpiralDifferenceIterator(const TilingData* tiling_data,
162 const gfx::Rect& consider_rect, 151 const gfx::Rect& consider_rect,
163 const gfx::Rect& ignore_rect, 152 const gfx::Rect& ignore_rect,
164 const gfx::Rect& center_rect); 153 const gfx::Rect& center_rect);
165 ReverseSpiralDifferenceIterator& operator++(); 154 ReverseSpiralDifferenceIterator& operator++();
166 155
167 private: 156 private:
168 int current_step_count() const { 157 ReverseSpiralIterator reverse_spiral_iterator_;
169 return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_
170 : horizontal_step_count_;
171 }
172
173 bool needs_direction_switch() const;
174 void switch_direction();
175
176 IndexRect around_index_rect_;
177
178 enum Direction { LEFT, UP, RIGHT, DOWN };
179
180 Direction direction_;
181 int delta_x_;
182 int delta_y_;
183 int current_step_;
184 int horizontal_step_count_;
185 int vertical_step_count_;
186 }; 158 };
187 159
188 private: 160 private:
189 void AssertTile(int i, int j) const { 161 void AssertTile(int i, int j) const {
190 DCHECK_GE(i, 0); 162 DCHECK_GE(i, 0);
191 DCHECK_LT(i, num_tiles_x_); 163 DCHECK_LT(i, num_tiles_x_);
192 DCHECK_GE(j, 0); 164 DCHECK_GE(j, 0);
193 DCHECK_LT(j, num_tiles_y_); 165 DCHECK_LT(j, num_tiles_y_);
194 } 166 }
195 167
196 void RecomputeNumTiles(); 168 void RecomputeNumTiles();
197 169
198 gfx::Size max_texture_size_; 170 gfx::Size max_texture_size_;
199 gfx::Size tiling_size_; 171 gfx::Size tiling_size_;
200 int border_texels_; 172 int border_texels_;
201 173
202 // These are computed values. 174 // These are computed values.
203 int num_tiles_x_; 175 int num_tiles_x_;
204 int num_tiles_y_; 176 int num_tiles_y_;
205 }; 177 };
206 178
207 } // namespace cc 179 } // namespace cc
208 180
209 #endif // CC_BASE_TILING_DATA_H_ 181 #endif // CC_BASE_TILING_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698