| 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  | 
 |   21 class CC_EXPORT TileBundle : public RefCountedManaged<TileBundle> { | 
 |   22  public: | 
 |   23   typedef uint64 Id; | 
 |   24   typedef std::vector<scoped_refptr<Tile> > TileVector; | 
 |   25   typedef std::vector<TileVector> TileGrid; | 
 |   26  | 
 |   27   inline Id id() const { return id_; } | 
 |   28  | 
 |   29   Tile* TileAt(WhichTree tree, int index_x, int index_y); | 
 |   30   bool RemoveTileAt(WhichTree tree, int index_x, int index_y); | 
 |   31   void AddTileAt(WhichTree tree, | 
 |   32                  int index_x, | 
 |   33                  int index_y, | 
 |   34                  scoped_refptr<Tile> tile); | 
 |   35   bool IsEmpty() const { return conservative_tile_count_ == 0; } | 
 |   36  | 
 |   37   void DidBecomeRecycled(); | 
 |   38   void DidBecomeActive(); | 
 |   39  | 
 |   40   void SetPriority(WhichTree tree, const TilePriority& priority); | 
 |   41   TilePriority GetPriority(WhichTree tree) const; | 
 |   42  | 
 |   43   void SwapTilesIfRequired(); | 
 |   44  | 
 |   45   class CC_EXPORT Iterator { | 
 |   46    public: | 
 |   47     explicit Iterator(TileBundle* bundle); | 
 |   48     Iterator(TileBundle* bundle, WhichTree tree); | 
 |   49     ~Iterator(); | 
 |   50  | 
 |   51     Iterator& operator++(); | 
 |   52  | 
 |   53     inline Tile* operator*() { return current_tile_; } | 
 |   54     inline Tile* operator->() { return current_tile_; } | 
 |   55     inline operator bool() const { | 
 |   56       return index_y_ < bundle_->index_count_y_; | 
 |   57     } | 
 |   58  | 
 |   59     inline int index_x() { | 
 |   60       return index_x_ + bundle_->index_offset_x_; | 
 |   61     } | 
 |   62     inline int index_y() { | 
 |   63       return index_y_ + bundle_->index_offset_y_; | 
 |   64     } | 
 |   65  | 
 |   66     TilePriority priority(WhichTree tree) const { | 
 |   67       return bundle_->GetPriority(tree); | 
 |   68     } | 
 |   69  | 
 |   70    private: | 
 |   71     bool InitializeNewTile(); | 
 |   72  | 
 |   73     TileBundle* bundle_; | 
 |   74     Tile* current_tile_; | 
 |   75     int index_x_; | 
 |   76     int index_y_; | 
 |   77     WhichTree current_tree_; | 
 |   78  | 
 |   79     WhichTree min_tree_; | 
 |   80     WhichTree max_tree_; | 
 |   81   }; | 
 |   82  | 
 |   83  private: | 
 |   84   friend class TileManager; | 
 |   85   friend class Iterator; | 
 |   86  | 
 |   87   TileBundle(TileManager* tile_manager, | 
 |   88              int offset_x, | 
 |   89              int offset_y, | 
 |   90              int width, | 
 |   91              int height); | 
 |   92   ~TileBundle(); | 
 |   93  | 
 |   94   void UpdateToLocalIndex(int* index_x, int* index_y); | 
 |   95   Tile* TileAtLocalIndex(WhichTree tree, int x, int y); | 
 |   96  | 
 |   97   TileManager* tile_manager_; | 
 |   98  | 
 |   99   TileGrid tiles_[NUM_TREES]; | 
 |  100   int index_offset_x_; | 
 |  101   int index_offset_y_; | 
 |  102   int index_count_x_; | 
 |  103   int index_count_y_; | 
 |  104  | 
 |  105   TilePriority priority_[NUM_TREES]; | 
 |  106   int conservative_tile_count_; | 
 |  107   bool needs_tile_swap_; | 
 |  108  | 
 |  109   Id id_; | 
 |  110   static Id s_next_id_; | 
 |  111 }; | 
 |  112  | 
 |  113 }  // namespace cc | 
 |  114  | 
 |  115 #endif  // CC_RESOURCES_TILE_BUNDLE_H_ | 
| OLD | NEW |