1// Copyright 2014 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_RASTER_TILE_PRIORITY_QUEUE_H_
6#define CC_RESOURCES_RASTER_TILE_PRIORITY_QUEUE_H_
7
8#include <set>
9#include <utility>
10#include <vector>
11
12#include "cc/base/cc_export.h"
13#include "cc/layers/picture_layer_impl.h"
14#include "cc/resources/tile_priority.h"
15
16namespace cc {
17
18class CC_EXPORT RasterTilePriorityQueue {
19 public:
20  struct PairedPictureLayerQueue {
21    PairedPictureLayerQueue();
22    PairedPictureLayerQueue(const PictureLayerImpl::Pair& layer_pair,
23                            TreePriority tree_priority);
24    ~PairedPictureLayerQueue();
25
26    bool IsEmpty() const;
27    Tile* Top(TreePriority tree_priority);
28    void Pop(TreePriority tree_priority);
29
30    WhichTree NextTileIteratorTree(TreePriority tree_priority) const;
31
32    PictureLayerImpl::LayerRasterTileIterator active_iterator;
33    PictureLayerImpl::LayerRasterTileIterator pending_iterator;
34    bool has_both_layers;
35
36    // Set of returned tiles (excluding the current one) for DCHECKing.
37    std::set<const Tile*> returned_tiles_for_debug;
38  };
39
40  RasterTilePriorityQueue();
41  ~RasterTilePriorityQueue();
42
43  void Build(const std::vector<PictureLayerImpl::Pair>& paired_layers,
44             TreePriority tree_priority);
45  void Reset();
46
47  bool IsEmpty() const;
48  Tile* Top();
49  void Pop();
50
51 private:
52  // TODO(vmpstr): This is potentially unnecessary if it becomes the case that
53  // PairedPictureLayerQueue is fast enough to copy. In that case, we can use
54  // objects directly (ie std::vector<PairedPictureLayerQueue>.
55  ScopedPtrVector<PairedPictureLayerQueue> paired_queues_;
56  TreePriority tree_priority_;
57
58  DISALLOW_COPY_AND_ASSIGN(RasterTilePriorityQueue);
59};
60
61}  // namespace cc
62
63#endif  // CC_RESOURCES_RASTER_TILE_PRIORITY_QUEUE_H_
64