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

Side by Side Diff: cc/tiling_data.h

Issue 11887027: cc: Add iterator and big border support to TilingData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CC_EXPORT for Win Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/tiling_data.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_TILING_DATA_H_ 5 #ifndef CC_TILING_DATA_H_
6 #define CC_TILING_DATA_H_ 6 #define CC_TILING_DATA_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "cc/cc_export.h" 10 #include "cc/cc_export.h"
11 #include "ui/gfx/rect.h"
11 #include "ui/gfx/size.h" 12 #include "ui/gfx/size.h"
12 13
13 namespace gfx { 14 namespace gfx {
14 class Rect;
15 class Vector2d; 15 class Vector2d;
16 } 16 }
17 17
18 namespace cc { 18 namespace cc {
19 19
20 class CC_EXPORT TilingData { 20 class CC_EXPORT TilingData {
21 public: 21 public:
22 TilingData(gfx::Size max_texture_size, gfx::Size total_size, bool has_border_t exels); 22 TilingData(
23 ~TilingData(); 23 gfx::Size max_texture_size,
24 gfx::Size total_size,
25 bool has_border_texels);
26 TilingData(
27 gfx::Size max_texture_size,
28 gfx::Size total_size,
29 int border_texels);
24 30
25 gfx::Size total_size() const { return total_size_; } 31 gfx::Size total_size() const { return total_size_; }
26 void SetTotalSize(const gfx::Size total_size); 32 void SetTotalSize(const gfx::Size total_size);
27 33
28 gfx::Size max_texture_size() const { return max_texture_size_; } 34 gfx::Size max_texture_size() const { return max_texture_size_; }
29 void SetMaxTextureSize(gfx::Size max_texture_size); 35 void SetMaxTextureSize(gfx::Size max_texture_size);
30 36
31 int border_texels() const { return border_texels_; } 37 int border_texels() const { return border_texels_; }
32 void SetHasBorderTexels(bool has_border_texels); 38 void SetHasBorderTexels(bool has_border_texels);
39 void SetBorderTexels(int border_texels);
33 40
34 bool has_empty_bounds() const { return !num_tiles_x_ || !num_tiles_y_; } 41 bool has_empty_bounds() const { return !num_tiles_x_ || !num_tiles_y_; }
35 int num_tiles_x() const { return num_tiles_x_; } 42 int num_tiles_x() const { return num_tiles_x_; }
36 int num_tiles_y() const { return num_tiles_y_; } 43 int num_tiles_y() const { return num_tiles_y_; }
44 // Return the tile coordinate whose non-border texels include src_position.
37 int TileXIndexFromSrcCoord(int src_position) const; 45 int TileXIndexFromSrcCoord(int src_position) const;
38 int TileYIndexFromSrcCoord(int src_position) const; 46 int TileYIndexFromSrcCoord(int src_position) const;
47 // Return the lowest tile coordinate whose border texels include src_position.
48 int BorderTileXIndexFromSrcCoord(int src_position) const;
49 int BorderTileYIndexFromSrcCoord(int src_position) const;
39 50
40 gfx::Rect TileBounds(int i, int j) const; 51 gfx::Rect TileBounds(int i, int j) const;
41 gfx::Rect TileBoundsWithBorder(int i, int j) const; 52 gfx::Rect TileBoundsWithBorder(int i, int j) const;
42 int TilePositionX(int x_index) const; 53 int TilePositionX(int x_index) const;
43 int TilePositionY(int y_index) const; 54 int TilePositionY(int y_index) const;
44 int TileSizeX(int x_index) const; 55 int TileSizeX(int x_index) const;
45 int TileSizeY(int y_index) const; 56 int TileSizeY(int y_index) const;
46 57
47 // Difference between TileBound's and TileBoundWithBorder's origin(). 58 // Difference between TileBound's and TileBoundWithBorder's origin().
48 gfx::Vector2d TextureOffset(int x_index, int y_index) const; 59 gfx::Vector2d TextureOffset(int x_index, int y_index) const;
49 60
61 // Iterate through all indices whose bounds + border intersect with this rect.
62 class CC_EXPORT Iterator {
63 public:
64 Iterator(const TilingData* tiling_data, gfx::Rect rect);
65 Iterator& operator++();
66 operator bool() const;
67
68 int index_x() const { return index_x_; }
69 int index_y() const { return index_y_; }
70
71 private:
72 void done();
73
74 const TilingData* tiling_data_;
75 gfx::Rect rect_;
76 int index_x_;
77 int index_y_;
78 };
79
50 private: 80 private:
51 void AssertTile(int i, int j) const { 81 void AssertTile(int i, int j) const {
52 DCHECK_GE(i, 0); 82 DCHECK_GE(i, 0);
53 DCHECK_LT(i, num_tiles_x_); 83 DCHECK_LT(i, num_tiles_x_);
54 DCHECK_GE(j, 0); 84 DCHECK_GE(j, 0);
55 DCHECK_LT(j, num_tiles_y_); 85 DCHECK_LT(j, num_tiles_y_);
56 } 86 }
57 87
58 void RecomputeNumTiles(); 88 void RecomputeNumTiles();
59 89
60 gfx::Size max_texture_size_; 90 gfx::Size max_texture_size_;
61 gfx::Size total_size_; 91 gfx::Size total_size_;
62 // This value is always 0 or 1.
63 int border_texels_; 92 int border_texels_;
64 93
65 // These are computed values. 94 // These are computed values.
66 int num_tiles_x_; 95 int num_tiles_x_;
67 int num_tiles_y_; 96 int num_tiles_y_;
68 }; 97 };
69 98
70 } // namespace cc 99 } // namespace cc
71 100
72 #endif // CC_TILING_DATA_H_ 101 #endif // CC_TILING_DATA_H_
OLDNEW
« no previous file with comments | « no previous file | cc/tiling_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698