summaryrefslogtreecommitdiff
path: root/chromium/cc/resources/prioritized_tile_set.h
blob: fe1b2a0a9412faaadff10c79ec8a3eb2f95c2201 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_RESOURCES_PRIORITIZED_TILE_SET_H_
#define CC_RESOURCES_PRIORITIZED_TILE_SET_H_

#include <vector>

#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "cc/base/cc_export.h"
#include "cc/resources/managed_tile_state.h"

namespace cc {
class Tile;

class CC_EXPORT PrioritizedTileSet {
 public:
  PrioritizedTileSet();
  ~PrioritizedTileSet();

  void InsertTile(Tile* tile, ManagedTileBin bin);
  void Clear();
  void Sort();

  class CC_EXPORT PriorityIterator {
   public:
    explicit PriorityIterator(PrioritizedTileSet* set);
    ~PriorityIterator();

    PriorityIterator& operator++();
    Tile* operator->() { return *(*this); }
    Tile* operator*();
    operator bool() const {
      return iterator_ != tile_set_->tiles_[current_bin_].end();
    }

   private:
    void AdvanceList();

    PrioritizedTileSet* tile_set_;
    ManagedTileBin current_bin_;
    std::vector<scoped_refptr<Tile> >::iterator iterator_;
  };

 private:
  friend class PriorityIterator;

  typedef scoped_refptr<Tile> TileRef;
  std::vector<TileRef> tiles_[NUM_BINS];
};

}  // namespace cc

#endif  // CC_RESOURCES_PRIORITIZED_TILE_SET_H_