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

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: review 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..e194e7bee10ce9f820a9556157596bdf1ec9be3c
--- /dev/null
+++ b/cc/resources/tile_bundle.h
@@ -0,0 +1,119 @@
+// 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 <vector>
+
+#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 PictureLayerTiling;
+class CC_EXPORT TileBundle : public RefCountedManaged<TileBundle> {
+ public:
+ typedef uint64 Id;
+ typedef std::vector<scoped_refptr<Tile> > TileVector;
+ typedef std::vector<TileVector> TileGrid;
+
+ inline Id id() const { return id_; }
+
+ Tile* TileAt(WhichTree tree, int index_x, int index_y);
+ bool RemoveTileAt(WhichTree tree, int index_x, int index_y);
+ void AddTileAt(WhichTree tree,
+ int index_x,
+ int index_y,
+ scoped_refptr<Tile> tile);
+ inline bool IsEmpty() const { return conservative_count_ == 0; }
+
+ void DidBecomeRecycled();
+ void DidBecomeActive();
+
+ void SetPriority(WhichTree tree, const TilePriority& priority);
+ TilePriority GetPriority(WhichTree tree) const;
+
+ void SwapTilesIfRequired();
+
+ class Iterator {
+ public:
+ explicit Iterator(TileBundle* bundle);
+ ~Iterator();
+
+ Iterator& operator++();
+
+ inline Tile* operator*() { return current_tile_; }
+ inline Tile* operator->() { return current_tile_; }
+ inline operator bool() const {
+ return index_y_ < bundle_->bundle_rect_.height();
+ }
+
+ inline int index_x() {
+ return index_x_ + bundle_->bundle_rect_.x();
+ }
+ inline int index_y() {
+ return index_y_ + bundle_->bundle_rect_.y();
+ }
+
+ TilePriority active_priority() const {
+ return priority_[ACTIVE_TREE] ? *priority_[ACTIVE_TREE]
+ : TilePriority();
+ }
+
+ TilePriority pending_priority() const {
+ return priority_[PENDING_TREE] ? *priority_[PENDING_TREE]
+ : TilePriority();
+ }
+
+ bool active_tree_only_tile() {
+ return active_tree_only_tile_;
+ }
+ bool pending_tree_only_tile() {
+ return pending_tree_only_tile_;
+ }
+
+ private:
+ bool InitializeNewTileForTree(WhichTree tree);
+
+ TileBundle* bundle_;
+ Tile* current_tile_;
+ TilePriority* priority_[NUM_TREES];
+ int index_x_;
+ int index_y_;
+ WhichTree current_tree_;
+ bool active_tree_only_tile_;
+ bool pending_tree_only_tile_;
+ };
+
+ private:
+ friend class TileManager;
+ friend class Iterator;
+
+ TileBundle(TileManager* tile_manager, gfx::Rect bundle_rect);
+ ~TileBundle();
+
+ void UpdateToLocalIndex(int* index_x, int* index_y);
+ Tile* TileAtLocalIndex(WhichTree tree, int x, int y);
+
+ TileManager* tile_manager_;
+
+ TileGrid tiles_[NUM_TREES];
+ gfx::Rect bundle_rect_;
+
+ TilePriority priority_[NUM_TREES];
+ size_t conservative_count_;
+ bool needs_tile_swap_;
+
+ Id id_;
+ static Id s_next_id_;
+};
+
+} // namespace cc
+
+#endif // CC_RESOURCES_TILE_BUNDLE_H_

Powered by Google App Engine
This is Rietveld 408576698