Chromium Code Reviews| Index: cc/resources/tile_bundle.h |
| diff --git a/cc/resources/tile_bundle.h b/cc/resources/tile_bundle.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b619a56341df08b594ed80eb58394ecccb7d2af5 |
| --- /dev/null |
| +++ b/cc/resources/tile_bundle.h |
| @@ -0,0 +1,122 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CC_RESOURCES_TILE_BUNDLE_H_ |
| +#define CC_RESOURCES_TILE_BUNDLE_H_ |
| + |
| +#include <utility> |
| + |
| +#include "base/containers/hash_tables.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "cc/base/ref_counted_managed.h" |
| +#include "cc/resources/tile_priority.h" |
| + |
| +namespace cc { |
| + |
| +class TileManager; |
| +class Tile; |
| +class PictureLayerTilingClient; |
| +class PictureLayerTiling; |
| +class CC_EXPORT TileBundle : public RefCountedManaged<TileBundle> { |
| + public: |
| + typedef uint64 Id; |
| + typedef std::pair<int, int> TileMapKey; |
| + typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; |
| + |
| + inline Id id() const { return id_; } |
| + |
| + Tile* TileAt(int index_x, int index_y); |
| + bool RemoveTileAt(int index_x, int index_y); |
| + void AddTileAt(int index_x, |
| + int index_y, |
| + scoped_refptr<Tile> tile); |
| + size_t TileCount() const; |
| + |
| + void DidBecomeRecycled(); |
| + void DidBecomeActive(); |
| + |
| + TileBundle* GetTwinBundle(); |
| + bool IsRecycled() const; |
| + bool IsActive() const; |
| + bool IsPending() const; |
| + |
| + |
| + void SetClient(PictureLayerTilingClient* client) { |
| + client_ = client; |
| + } |
| + |
| + void SetTiling(PictureLayerTiling* tiling) { |
| + tiling_ = tiling; |
| + } |
| + |
| + void MarkRequiredForActivation() { |
| + priority_.required_for_activation = true; |
| + } |
| + |
| + void SetPriority(const TilePriority& priority) { |
| + priority_ = priority; |
| + } |
| + |
| + TilePriority GetPriority() const { |
| + return priority_; |
| + } |
| + |
| + class Iterator { |
| + public: |
| + explicit Iterator(TileBundle* bundle); |
| + ~Iterator(); |
| + |
| + inline Iterator& operator++() { |
| + DCHECK(iterator_ != bundle_->tiles_.end()); |
| + ++iterator_; |
| + return *this; |
| + } |
| + |
| + inline Tile* operator*() { return iterator_->second.get(); } |
| + inline Tile* operator->() { return iterator_->second.get(); } |
| + inline operator bool() const { return iterator_ != bundle_->tiles_.end(); } |
| + |
| + inline int index_x() { |
| + return iterator_->first.first + bundle_->offset_x_; |
| + } |
| + inline int index_y() { |
| + return iterator_->first.second + bundle_->offset_y_; |
| + } |
| + |
| + private: |
| + TileBundle* bundle_; |
| + TileBundle::TileMap::const_iterator iterator_; |
| + }; |
| + |
| + private: |
| + friend class TileManager; |
| + friend class Iterator; |
| + |
| + TileBundle(TileManager* tile_manager, |
| + int width, |
| + int height, |
| + int offset_x, |
| + int offset_y); |
| + ~TileBundle(); |
| + |
| + TileMapKey ComputeLocalIndex(int index_x, int index_y); |
| + |
| + PictureLayerTiling* tiling_; |
| + |
| + TileMap tiles_; |
|
enne (OOO)
2013/11/20 21:20:30
I wonder if there's a way to do this generally but
|
| + int width_; |
|
enne (OOO)
2013/11/20 21:20:30
Do bundles need their width/height/offset explicit
|
| + int height_; |
| + int offset_x_; |
| + int offset_y_; |
| + |
| + TilePriority priority_; |
| + PictureLayerTilingClient* client_; |
|
enne (OOO)
2013/11/20 21:20:30
I wish this wasn't necessary.
|
| + |
| + Id id_; |
| + static Id s_next_id_; |
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_RESOURCES_TILE_BUNDLE_H_ |