| 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(); | 
 |   48  | 
 |   49     Iterator& operator++(); | 
 |   50  | 
 |   51     inline Tile* operator*() { return current_tile_; } | 
 |   52     inline Tile* operator->() { return current_tile_; } | 
 |   53     inline operator bool() const { | 
 |   54       return index_y_ < bundle_->bundle_rect_.height(); | 
 |   55     } | 
 |   56  | 
 |   57     inline int index_x() { | 
 |   58       return index_x_ + bundle_->bundle_rect_.x(); | 
 |   59     } | 
 |   60     inline int index_y() { | 
 |   61       return index_y_ + bundle_->bundle_rect_.y(); | 
 |   62     } | 
 |   63  | 
 |   64     TilePriority active_priority() const { | 
 |   65       return priority_[ACTIVE_TREE] ? *priority_[ACTIVE_TREE] | 
 |   66                                     : TilePriority(); | 
 |   67     } | 
 |   68  | 
 |   69     TilePriority pending_priority() const { | 
 |   70       return priority_[PENDING_TREE] ? *priority_[PENDING_TREE] | 
 |   71                                      : TilePriority(); | 
 |   72     } | 
 |   73  | 
 |   74     bool active_tree_only_tile() { | 
 |   75       return active_tree_only_tile_; | 
 |   76     } | 
 |   77     bool pending_tree_only_tile() { | 
 |   78       return pending_tree_only_tile_; | 
 |   79     } | 
 |   80  | 
 |   81    private: | 
 |   82     bool InitializeNewTileForTree(WhichTree tree); | 
 |   83  | 
 |   84     TileBundle* bundle_; | 
 |   85     Tile* current_tile_; | 
 |   86     TilePriority* priority_[NUM_TREES]; | 
 |   87     int index_x_; | 
 |   88     int index_y_; | 
 |   89     WhichTree current_tree_; | 
 |   90     bool active_tree_only_tile_; | 
 |   91     bool pending_tree_only_tile_; | 
 |   92   }; | 
 |   93  | 
 |   94  private: | 
 |   95   friend class TileManager; | 
 |   96   friend class Iterator; | 
 |   97  | 
 |   98   TileBundle(TileManager* tile_manager, gfx::Rect bundle_rect); | 
 |   99   ~TileBundle(); | 
 |  100  | 
 |  101   void UpdateToLocalIndex(int* index_x, int* index_y); | 
 |  102   Tile* TileAtLocalIndex(WhichTree tree, int x, int y); | 
 |  103  | 
 |  104   TileManager* tile_manager_; | 
 |  105  | 
 |  106   TileGrid tiles_[NUM_TREES]; | 
 |  107   gfx::Rect bundle_rect_; | 
 |  108  | 
 |  109   TilePriority priority_[NUM_TREES]; | 
 |  110   size_t conservative_count_; | 
 |  111   bool needs_tile_swap_; | 
 |  112  | 
 |  113   Id id_; | 
 |  114   static Id s_next_id_; | 
 |  115 }; | 
 |  116  | 
 |  117 }  // namespace cc | 
 |  118  | 
 |  119 #endif  // CC_RESOURCES_TILE_BUNDLE_H_ | 
| OLD | NEW |