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
3 // found in the LICENSE file.
5 #ifndef CC_TILING_DATA_H_
6 #define CC_TILING_DATA_H_
8 #include "base/basictypes.h"
9 #include "base/logging.h"
10 #include "cc/cc_export.h"
11 #include "ui/gfx/size.h"
20 class CC_EXPORT TilingData
{
22 TilingData(gfx::Size max_texture_size
, gfx::Size total_size
, bool has_border_texels
);
25 gfx::Size
total_size() const { return total_size_
; }
26 void SetTotalSize(const gfx::Size total_size
);
28 gfx::Size
max_texture_size() const { return max_texture_size_
; }
29 void SetMaxTextureSize(gfx::Size max_texture_size
);
31 int border_texels() const { return border_texels_
; }
32 void SetHasBorderTexels(bool has_border_texels
);
34 bool has_empty_bounds() const { return !num_tiles_x_
|| !num_tiles_y_
; }
35 int num_tiles_x() const { return num_tiles_x_
; }
36 int num_tiles_y() const { return num_tiles_y_
; }
37 int TileXIndexFromSrcCoord(int src_position
) const;
38 int TileYIndexFromSrcCoord(int src_position
) const;
40 gfx::Rect
TileBounds(int i
, int j
) const;
41 gfx::Rect
TileBoundsWithBorder(int i
, int j
) const;
42 int TilePositionX(int x_index
) const;
43 int TilePositionY(int y_index
) const;
44 int TileSizeX(int x_index
) const;
45 int TileSizeY(int y_index
) const;
47 // Difference between TileBound's and TileBoundWithBorder's origin().
48 gfx::Vector2d
TextureOffset(int x_index
, int y_index
) const;
51 void AssertTile(int i
, int j
) const {
53 DCHECK_LT(i
, num_tiles_x_
);
55 DCHECK_LT(j
, num_tiles_y_
);
58 void RecomputeNumTiles();
60 gfx::Size max_texture_size_
;
61 gfx::Size total_size_
;
62 // This value is always 0 or 1.
65 // These are computed values.
72 #endif // CC_TILING_DATA_H_