OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 | 5 |
6 #ifndef CCLayerTilingData_h | 6 #ifndef CCLayerTilingData_h |
7 #define CCLayerTilingData_h | 7 #define CCLayerTilingData_h |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "cc/hash_pair.h" | 11 #include "cc/hash_pair.h" |
12 #include "cc/scoped_ptr_hash_map.h" | 12 #include "cc/scoped_ptr_hash_map.h" |
13 #include "IntRect.h" | 13 #include "IntRect.h" |
14 #include "Region.h" | 14 #include "Region.h" |
15 #include "TilingData.h" | 15 #include "TilingData.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 class CCLayerTilingData { | 19 class LayerTilingData { |
20 public: | 20 public: |
21 enum BorderTexelOption { HasBorderTexels, NoBorderTexels }; | 21 enum BorderTexelOption { HasBorderTexels, NoBorderTexels }; |
22 | 22 |
23 ~CCLayerTilingData(); | 23 ~LayerTilingData(); |
24 | 24 |
25 static scoped_ptr<CCLayerTilingData> create(const IntSize& tileSize, BorderT
exelOption); | 25 static scoped_ptr<LayerTilingData> create(const IntSize& tileSize, BorderTex
elOption); |
26 | 26 |
27 bool hasEmptyBounds() const { return m_tilingData.hasEmptyBounds(); } | 27 bool hasEmptyBounds() const { return m_tilingData.hasEmptyBounds(); } |
28 int numTilesX() const { return m_tilingData.numTilesX(); } | 28 int numTilesX() const { return m_tilingData.numTilesX(); } |
29 int numTilesY() const { return m_tilingData.numTilesY(); } | 29 int numTilesY() const { return m_tilingData.numTilesY(); } |
30 IntRect tileBounds(int i, int j) const { return m_tilingData.tileBounds(i, j
); } | 30 IntRect tileBounds(int i, int j) const { return m_tilingData.tileBounds(i, j
); } |
31 IntPoint textureOffset(int xIndex, int yIndex) const { return m_tilingData.t
extureOffset(xIndex, yIndex); } | 31 IntPoint textureOffset(int xIndex, int yIndex) const { return m_tilingData.t
extureOffset(xIndex, yIndex); } |
32 | 32 |
33 // Change the tile size. This may invalidate all the existing tiles. | 33 // Change the tile size. This may invalidate all the existing tiles. |
34 void setTileSize(const IntSize&); | 34 void setTileSize(const IntSize&); |
35 IntSize tileSize() const; | 35 IntSize tileSize() const; |
36 // Change the border texel setting. This may invalidate all existing tiles. | 36 // Change the border texel setting. This may invalidate all existing tiles. |
37 void setBorderTexelOption(BorderTexelOption); | 37 void setBorderTexelOption(BorderTexelOption); |
38 bool hasBorderTexels() const { return m_tilingData.borderTexels(); } | 38 bool hasBorderTexels() const { return m_tilingData.borderTexels(); } |
39 | 39 |
40 bool isEmpty() const { return hasEmptyBounds() || !tiles().size(); } | 40 bool isEmpty() const { return hasEmptyBounds() || !tiles().size(); } |
41 | 41 |
42 const CCLayerTilingData& operator=(const CCLayerTilingData&); | 42 const LayerTilingData& operator=(const LayerTilingData&); |
43 | 43 |
44 class Tile { | 44 class Tile { |
45 public: | 45 public: |
46 Tile() : m_i(-1), m_j(-1) { } | 46 Tile() : m_i(-1), m_j(-1) { } |
47 virtual ~Tile() { } | 47 virtual ~Tile() { } |
48 | 48 |
49 int i() const { return m_i; } | 49 int i() const { return m_i; } |
50 int j() const { return m_j; } | 50 int j() const { return m_j; } |
51 void moveTo(int i, int j) { m_i = i; m_j = j; } | 51 void moveTo(int i, int j) { m_i = i; m_j = j; } |
52 | 52 |
(...skipping 17 matching lines...) Expand all Loading... |
70 IntSize bounds() const; | 70 IntSize bounds() const; |
71 | 71 |
72 void contentRectToTileIndices(const IntRect&, int &left, int &top, int &righ
t, int &bottom) const; | 72 void contentRectToTileIndices(const IntRect&, int &left, int &top, int &righ
t, int &bottom) const; |
73 IntRect tileRect(const Tile*) const; | 73 IntRect tileRect(const Tile*) const; |
74 | 74 |
75 Region opaqueRegionInContentRect(const IntRect&) const; | 75 Region opaqueRegionInContentRect(const IntRect&) const; |
76 | 76 |
77 void reset(); | 77 void reset(); |
78 | 78 |
79 protected: | 79 protected: |
80 CCLayerTilingData(const IntSize& tileSize, BorderTexelOption); | 80 LayerTilingData(const IntSize& tileSize, BorderTexelOption); |
81 | 81 |
82 TileMap m_tiles; | 82 TileMap m_tiles; |
83 TilingData m_tilingData; | 83 TilingData m_tilingData; |
84 }; | 84 }; |
85 | 85 |
86 } | 86 } |
87 | 87 |
88 #endif | 88 #endif |
OLD | NEW |