Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CC_RESOURCES_TILE_BUNDLE_H_ | |
| 6 #define CC_RESOURCES_TILE_BUNDLE_H_ | |
| 7 | |
| 8 #include <utility> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "cc/base/ref_counted_managed.h" | |
| 13 #include "cc/resources/tile_priority.h" | |
| 14 | |
| 15 namespace cc { | |
| 16 | |
| 17 class TileManager; | |
| 18 class Tile; | |
| 19 class PictureLayerTiling; | |
| 20 class CC_EXPORT TileBundle : public RefCountedManaged<TileBundle> { | |
| 21 public: | |
| 22 typedef uint64 Id; | |
| 23 typedef std::vector<scoped_refptr<Tile> > TileVector; | |
| 24 typedef std::vector<TileVector> TileGrid; | |
| 25 | |
| 26 inline Id id() const { return id_; } | |
| 27 | |
| 28 Tile* TileAt(WhichTree tree, int index_x, int index_y); | |
| 29 bool RemoveTileAt(WhichTree tree, int index_x, int index_y); | |
| 30 void AddTileAt(WhichTree tree, | |
| 31 int index_x, | |
| 32 int index_y, | |
| 33 scoped_refptr<Tile> tile); | |
| 34 inline bool IsEmpty() const { return conservative_count_ == 0; } | |
| 35 | |
| 36 void DidBecomeRecycled(); | |
| 37 void DidBecomeActive(); | |
| 38 | |
| 39 void SetPriority(WhichTree tree, const TilePriority& priority); | |
| 40 TilePriority GetPriority(WhichTree tree) const; | |
| 41 | |
| 42 void SwapTilesIfRequired(); | |
| 43 | |
| 44 class Iterator { | |
| 45 public: | |
| 46 explicit Iterator(TileBundle* bundle); | |
| 47 Iterator(TileBundle* bundle, WhichTree tree); | |
| 48 ~Iterator(); | |
| 49 | |
| 50 Iterator& operator++(); | |
| 51 | |
| 52 inline Tile* operator*() { return current_tile_; } | |
| 53 inline Tile* operator->() { return current_tile_; } | |
| 54 inline operator bool() const { | |
| 55 return index_y_ < bundle_->height_; | |
| 56 } | |
| 57 | |
| 58 inline int index_x() { | |
| 59 return index_x_ + bundle_->offset_x_; | |
| 60 } | |
| 61 inline int index_y() { | |
| 62 return index_y_ + bundle_->offset_y_; | |
| 63 } | |
| 64 | |
| 65 TilePriority active_priority() const { | |
| 66 return priority_[ACTIVE_TREE] ? *priority_[ACTIVE_TREE] | |
| 67 : TilePriority(); | |
| 68 } | |
| 69 | |
| 70 TilePriority pending_priority() const { | |
| 71 return priority_[PENDING_TREE] ? *priority_[PENDING_TREE] | |
| 72 : TilePriority(); | |
| 73 } | |
| 74 | |
| 75 bool active_tree_only_tile() { | |
|
enne (OOO)
2013/11/27 22:21:15
This is unused now, yeah?
vmpstr
2013/11/27 23:31:57
Oh yeah! Done.
| |
| 76 return active_tree_only_tile_; | |
| 77 } | |
| 78 bool pending_tree_only_tile() { | |
| 79 return pending_tree_only_tile_; | |
| 80 } | |
| 81 | |
| 82 private: | |
| 83 bool InitializeNewTileForTree(WhichTree tree); | |
| 84 | |
| 85 TileBundle* bundle_; | |
| 86 Tile* current_tile_; | |
| 87 TilePriority* priority_[NUM_TREES]; | |
|
enne (OOO)
2013/11/27 22:21:15
Why does this need to be stored? Can you just ask
vmpstr
2013/11/27 23:31:57
I think that's a leftover from some previous itera
| |
| 88 int index_x_; | |
| 89 int index_y_; | |
| 90 WhichTree current_tree_; | |
| 91 bool active_tree_only_tile_; | |
| 92 bool pending_tree_only_tile_; | |
| 93 | |
| 94 std::vector<WhichTree> trees_to_iterate_; | |
| 95 }; | |
| 96 | |
| 97 private: | |
| 98 friend class TileManager; | |
| 99 friend class Iterator; | |
| 100 | |
| 101 TileBundle(TileManager* tile_manager, | |
| 102 int offset_x, | |
| 103 int offset_y, | |
| 104 int width, | |
| 105 int height); | |
| 106 ~TileBundle(); | |
| 107 | |
| 108 void UpdateToLocalIndex(int* index_x, int* index_y); | |
| 109 Tile* TileAtLocalIndex(WhichTree tree, int x, int y); | |
| 110 | |
| 111 TileManager* tile_manager_; | |
| 112 | |
| 113 TileGrid tiles_[NUM_TREES]; | |
| 114 int offset_x_; | |
| 115 int offset_y_; | |
| 116 int width_; | |
| 117 int height_; | |
| 118 | |
| 119 TilePriority priority_[NUM_TREES]; | |
| 120 size_t conservative_count_; | |
| 121 bool needs_tile_swap_; | |
| 122 | |
| 123 Id id_; | |
| 124 static Id s_next_id_; | |
| 125 }; | |
| 126 | |
| 127 } // namespace cc | |
| 128 | |
| 129 #endif // CC_RESOURCES_TILE_BUNDLE_H_ | |
| OLD | NEW |