| 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_->index_count_y_; | 
 |   56     } | 
 |   57  | 
 |   58     inline int index_x() { | 
 |   59       return index_x_ + bundle_->index_offset_x_; | 
 |   60     } | 
 |   61     inline int index_y() { | 
 |   62       return index_y_ + bundle_->index_offset_y_; | 
 |   63     } | 
 |   64  | 
 |   65     TilePriority priority(WhichTree tree) const { | 
 |   66       return bundle_->GetPriority(tree); | 
 |   67     } | 
 |   68  | 
 |   69    private: | 
 |   70     bool InitializeNewTile(); | 
 |   71  | 
 |   72     TileBundle* bundle_; | 
 |   73     Tile* current_tile_; | 
 |   74     int index_x_; | 
 |   75     int index_y_; | 
 |   76     WhichTree current_tree_; | 
 |   77  | 
 |   78     WhichTree min_tree_; | 
 |   79     WhichTree max_tree_; | 
 |   80   }; | 
 |   81  | 
 |   82  private: | 
 |   83   friend class TileManager; | 
 |   84   friend class Iterator; | 
 |   85  | 
 |   86   TileBundle(TileManager* tile_manager, | 
 |   87              int offset_x, | 
 |   88              int offset_y, | 
 |   89              int width, | 
 |   90              int height); | 
 |   91   ~TileBundle(); | 
 |   92  | 
 |   93   void UpdateToLocalIndex(int* index_x, int* index_y); | 
 |   94   Tile* TileAtLocalIndex(WhichTree tree, int x, int y); | 
 |   95  | 
 |   96   TileManager* tile_manager_; | 
 |   97  | 
 |   98   TileGrid tiles_[NUM_TREES]; | 
 |   99   int index_offset_x_; | 
 |  100   int index_offset_y_; | 
 |  101   int index_count_x_; | 
 |  102   int index_count_y_; | 
 |  103  | 
 |  104   TilePriority priority_[NUM_TREES]; | 
 |  105   size_t conservative_count_; | 
 |  106   bool needs_tile_swap_; | 
 |  107  | 
 |  108   Id id_; | 
 |  109   static Id s_next_id_; | 
 |  110 }; | 
 |  111  | 
 |  112 }  // namespace cc | 
 |  113  | 
 |  114 #endif  // CC_RESOURCES_TILE_BUNDLE_H_ | 
| OLD | NEW |