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 "cc/base/cc_export.h"
     11 #include "cc/resources/managed_tile_state.h"
     12 
     13 namespace cc {
     14 class Tile;
     15 
     16 class CC_EXPORT PrioritizedTileSet {
     17  public:
     18   PrioritizedTileSet();
     19   ~PrioritizedTileSet();
     20 
     21   void InsertTile(Tile* tile, ManagedTileBin bin);
     22   void Clear();
     23 
     24   class CC_EXPORT Iterator {
     25    public:
     26     Iterator(PrioritizedTileSet* set, bool use_priority_ordering);
     27 
     28     ~Iterator();
     29 
     30     void DisablePriorityOrdering();
     31 
     32     Iterator& 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<Tile*>::iterator iterator_;
     45     bool use_priority_ordering_;
     46   };
     47 
     48  private:
     49   friend class Iterator;
     50 
     51   void SortBinIfNeeded(ManagedTileBin bin);
     52 
     53   std::vector<Tile*> tiles_[NUM_BINS];
     54   bool bin_sorted_[NUM_BINS];
     55 };
     56 
     57 }  // namespace cc
     58 
     59 #endif  // CC_RESOURCES_PRIORITIZED_TILE_SET_H_
     60