Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Unified Diff: cc/resources/shared_tile_bundle.h

Issue 62283012: cc: Added tile bundles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698