Chromium Code Reviews| Index: cc/resources/shared_tile_bundle.h | 
| diff --git a/cc/resources/shared_tile_bundle.h b/cc/resources/shared_tile_bundle.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..81fc57283328f73802bef60e8ba92c92c6c3f5a5 | 
| --- /dev/null | 
| +++ b/cc/resources/shared_tile_bundle.h | 
| @@ -0,0 +1,104 @@ | 
| +// 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_SHARED_TILE_BUNDLE_H_ | 
| +#define CC_RESOURCES_SHARED_TILE_BUNDLE_H_ | 
| + | 
| +#include <utility> | 
| + | 
| +#include "base/containers/hash_tables.h" | 
| +#include "cc/resources/tile_bundle.h" | 
| +#include "cc/resources/tile_priority.h" | 
| + | 
| +namespace cc { | 
| + | 
| +class SharedTileBundle { | 
| 
 
enne (OOO)
2013/11/20 21:20:30
I'm not quite sure I'm buying the SharedTileBundle
 
 | 
| + public: | 
| + typedef std::pair<int, int> TileMapKey; | 
| + typedef base::hash_map<TileMapKey, Tile*> TileMap; | 
| + | 
| + SharedTileBundle(); | 
| + SharedTileBundle(const TilePriority& active_priority, | 
| + const TilePriority& pending_priority); | 
| + | 
| + void AddTileAt(int x, int y, Tile* tile); | 
| + | 
| + inline const TilePriority& active_priority() const { | 
| + return active_priority_; | 
| + } | 
| + | 
| + inline const TilePriority& pending_priority() const { | 
| + return pending_priority_; | 
| + } | 
| + | 
| + class Iterator { | 
| + public: | 
| + explicit Iterator(SharedTileBundle* bundle); | 
| + ~Iterator(); | 
| + | 
| + inline Iterator& operator++() { | 
| + DCHECK(iterator_ != bundle_->tiles_.end()); | 
| + ++iterator_; | 
| + return *this; | 
| + } | 
| + | 
| + inline Tile* operator*() { return iterator_->second; } | 
| + inline Tile* operator->() { return iterator_->second; } | 
| + inline operator bool() const { return iterator_ != bundle_->tiles_.end(); } | 
| + | 
| + inline int index_x() { return iterator_->first.first; } | 
| + inline int index_y() { return iterator_->first.second; } | 
| + | 
| + private: | 
| + SharedTileBundle* bundle_; | 
| + SharedTileBundle::TileMap::const_iterator iterator_; | 
| + }; | 
| + | 
| + private: | 
| + TilePriority active_priority_; | 
| + TilePriority pending_priority_; | 
| + | 
| + TileMap tiles_; | 
| +}; | 
| + | 
| +class BundleSetIterator { | 
| + public: | 
| + typedef base::hash_map<TileBundle::Id, TileBundle*> TileBundleMap; | 
| + | 
| + explicit BundleSetIterator(TileBundleMap* bundles); | 
| + ~BundleSetIterator(); | 
| + | 
| + SharedTileBundle* operator*(); | 
| + SharedTileBundle* operator->(); | 
| + operator bool() const; | 
| + | 
| + BundleSetIterator& operator++(); | 
| + | 
| + private: | 
| + enum SharedBundleType { | 
| + eBothPriorities, | 
| 
 
enne (OOO)
2013/11/20 21:20:30
BOTH_PRIORITIES
 
 | 
| + eActivePriorityOnly, | 
| + ePendingPriorityOnly, | 
| + eMaxSharedBundleTypes | 
| + }; | 
| + | 
| + void AdvanceBundleIterator(); | 
| + bool InitializeSharedBundles(); | 
| + bool InitializeSharedBundle(SharedBundleType type); | 
| + void DetermineActivePendingBundles(TileBundle* bundle, TileBundle* twin); | 
| + | 
| + TileBundleMap* bundles_; | 
| + TileBundleMap::iterator current_bundle_iterator_; | 
| + base::hash_set<TileBundle::Id> processed_bundles_; | 
| + | 
| + SharedTileBundle current_bundle_; | 
| + SharedBundleType current_bundle_type_; | 
| + | 
| + TileBundle* active_bundle_; | 
| + TileBundle* pending_bundle_; | 
| +}; | 
| + | 
| +} // namespace cc | 
| + | 
| +#endif // CC_RESOURCES_SHARED_TILE_BUNDLE_H_ |