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

Unified Diff: cc/resources/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/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_

Powered by Google App Engine
This is Rietveld 408576698