| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 // Temporary forwarding header |
| 6 #ifndef CCLayerTilingData_h | 6 #include "cc/layer_tiling_data.h" |
| 7 #define CCLayerTilingData_h | |
| 8 | |
| 9 #if USE(ACCELERATED_COMPOSITING) | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "IntRect.h" | |
| 13 #include "Region.h" | |
| 14 #include "TilingData.h" | |
| 15 #include <wtf/HashMap.h> | |
| 16 #include <wtf/HashTraits.h> | |
| 17 #include <wtf/PassOwnPtr.h> | |
| 18 | |
| 19 namespace cc { | |
| 20 | |
| 21 class CCLayerTilingData { | |
| 22 public: | |
| 23 enum BorderTexelOption { HasBorderTexels, NoBorderTexels }; | |
| 24 | |
| 25 ~CCLayerTilingData(); | |
| 26 | |
| 27 static PassOwnPtr<CCLayerTilingData> create(const IntSize& tileSize, BorderT
exelOption); | |
| 28 | |
| 29 bool hasEmptyBounds() const { return m_tilingData.hasEmptyBounds(); } | |
| 30 int numTilesX() const { return m_tilingData.numTilesX(); } | |
| 31 int numTilesY() const { return m_tilingData.numTilesY(); } | |
| 32 IntRect tileBounds(int i, int j) const { return m_tilingData.tileBounds(i, j
); } | |
| 33 IntPoint textureOffset(int xIndex, int yIndex) const { return m_tilingData.t
extureOffset(xIndex, yIndex); } | |
| 34 | |
| 35 // Change the tile size. This may invalidate all the existing tiles. | |
| 36 void setTileSize(const IntSize&); | |
| 37 IntSize tileSize() const; | |
| 38 // Change the border texel setting. This may invalidate all existing tiles. | |
| 39 void setBorderTexelOption(BorderTexelOption); | |
| 40 bool hasBorderTexels() const { return m_tilingData.borderTexels(); } | |
| 41 | |
| 42 bool isEmpty() const { return hasEmptyBounds() || !tiles().size(); } | |
| 43 | |
| 44 const CCLayerTilingData& operator=(const CCLayerTilingData&); | |
| 45 | |
| 46 class Tile { | |
| 47 public: | |
| 48 Tile() : m_i(-1), m_j(-1) { } | |
| 49 virtual ~Tile() { } | |
| 50 | |
| 51 int i() const { return m_i; } | |
| 52 int j() const { return m_j; } | |
| 53 void moveTo(int i, int j) { m_i = i; m_j = j; } | |
| 54 | |
| 55 const IntRect& opaqueRect() const { return m_opaqueRect; } | |
| 56 void setOpaqueRect(const IntRect& opaqueRect) { m_opaqueRect = opaqueRec
t; } | |
| 57 private: | |
| 58 int m_i; | |
| 59 int m_j; | |
| 60 IntRect m_opaqueRect; | |
| 61 DISALLOW_COPY_AND_ASSIGN(Tile); | |
| 62 }; | |
| 63 // Default hash key traits for integers disallow 0 and -1 as a key, so | |
| 64 // use a custom hash trait which disallows -1 and -2 instead. | |
| 65 typedef std::pair<int, int> TileMapKey; | |
| 66 struct TileMapKeyTraits : HashTraits<TileMapKey> { | |
| 67 static const bool emptyValueIsZero = false; | |
| 68 static const bool needsDestruction = false; | |
| 69 static TileMapKey emptyValue() { return std::make_pair(-1, -1); } | |
| 70 static void constructDeletedValue(TileMapKey& slot) { slot = std::make_p
air(-2, -2); } | |
| 71 static bool isDeletedValue(TileMapKey value) { return value.first == -2
&& value.second == -2; } | |
| 72 }; | |
| 73 typedef HashMap<TileMapKey, OwnPtr<Tile>, DefaultHash<TileMapKey>::Hash, Til
eMapKeyTraits> TileMap; | |
| 74 | |
| 75 void addTile(PassOwnPtr<Tile>, int, int); | |
| 76 PassOwnPtr<Tile> takeTile(int, int); | |
| 77 Tile* tileAt(int, int) const; | |
| 78 const TileMap& tiles() const { return m_tiles; } | |
| 79 | |
| 80 void setBounds(const IntSize&); | |
| 81 IntSize bounds() const; | |
| 82 | |
| 83 void contentRectToTileIndices(const IntRect&, int &left, int &top, int &righ
t, int &bottom) const; | |
| 84 IntRect tileRect(const Tile*) const; | |
| 85 | |
| 86 Region opaqueRegionInContentRect(const IntRect&) const; | |
| 87 | |
| 88 void reset(); | |
| 89 | |
| 90 protected: | |
| 91 CCLayerTilingData(const IntSize& tileSize, BorderTexelOption); | |
| 92 | |
| 93 TileMap m_tiles; | |
| 94 TilingData m_tilingData; | |
| 95 }; | |
| 96 | |
| 97 } | |
| 98 | |
| 99 #endif // USE(ACCELERATED_COMPOSITING) | |
| 100 | |
| 101 #endif | |
| OLD | NEW |