Home | History | Annotate | Download | only in resources
      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_PRIORITIZED_TILE_SET_H_
      6 #define CC_RESOURCES_PRIORITIZED_TILE_SET_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/memory/ref_counted.h"
     11 #include "base/memory/scoped_ptr.h"
     12 #include "cc/base/cc_export.h"
     13 #include "cc/resources/managed_tile_state.h"
     14 
     15 namespace cc {
     16 class Tile;
     17 
     18 class CC_EXPORT PrioritizedTileSet {
     19  public:
     20   PrioritizedTileSet();
     21   ~PrioritizedTileSet();
     22 
     23   void InsertTile(Tile* tile, ManagedTileBin bin);
     24   void Clear();
     25   void Sort();
     26 
     27   class CC_EXPORT PriorityIterator {
     28    public:
     29     explicit PriorityIterator(PrioritizedTileSet* set);
     30     ~PriorityIterator();
     31 
     32     PriorityIterator& operator++();
     33     Tile* operator->() { return *(*this); }
     34     Tile* operator*();
     35     operator bool() const {
     36       return iterator_ != tile_set_->tiles_[current_bin_].end();
     37     }
     38 
     39    private:
     40     void AdvanceList();
     41 
     42     PrioritizedTileSet* tile_set_;
     43     ManagedTileBin current_bin_;
     44     std::vector<scoped_refptr<Tile> >::iterator iterator_;
     45   };
     46 
     47  private:
     48   friend class PriorityIterator;
     49 
     50   typedef scoped_refptr<Tile> TileRef;
     51   std::vector<TileRef> tiles_[NUM_BINS];
     52 };
     53 
     54 }  // namespace cc
     55 
     56 #endif  // CC_RESOURCES_PRIORITIZED_TILE_SET_H_
     57