1 // Copyright 2015 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.
5 #include "cc/tiles/raster_tile_priority_queue_required.h"
7 #include "cc/tiles/tiling_set_raster_queue_required.h"
13 void AppendTilingSetRequiredQueues(
14 const std::vector
<PictureLayerImpl
*>& layers
,
15 ScopedPtrVector
<TilingSetRasterQueueRequired
>* queues
) {
16 for (auto* layer
: layers
) {
17 if (!layer
->HasValidTilePriorities())
20 scoped_ptr
<TilingSetRasterQueueRequired
> tiling_set_queue(
21 new TilingSetRasterQueueRequired(
22 layer
->picture_layer_tiling_set(),
23 RasterTilePriorityQueueRequired::Type::REQUIRED_FOR_ACTIVATION
));
24 if (!tiling_set_queue
->IsEmpty())
25 queues
->push_back(tiling_set_queue
.Pass());
31 RasterTilePriorityQueueRequired::RasterTilePriorityQueueRequired() {
34 RasterTilePriorityQueueRequired::~RasterTilePriorityQueueRequired() {
37 void RasterTilePriorityQueueRequired::Build(
38 const std::vector
<PictureLayerImpl
*>& active_layers
,
39 const std::vector
<PictureLayerImpl
*>& pending_layers
,
41 DCHECK_NE(static_cast<int>(type
), static_cast<int>(Type::ALL
));
42 if (type
== Type::REQUIRED_FOR_DRAW
)
43 BuildRequiredForDraw(active_layers
);
45 BuildRequiredForActivation(active_layers
, pending_layers
);
48 void RasterTilePriorityQueueRequired::BuildRequiredForDraw(
49 const std::vector
<PictureLayerImpl
*>& active_layers
) {
50 for (const auto& layer
: active_layers
) {
51 if (!layer
->HasValidTilePriorities())
54 scoped_ptr
<TilingSetRasterQueueRequired
> tiling_set_queue(
55 new TilingSetRasterQueueRequired(layer
->picture_layer_tiling_set(),
56 Type::REQUIRED_FOR_DRAW
));
57 if (!tiling_set_queue
->IsEmpty())
58 tiling_set_queues_
.push_back(tiling_set_queue
.Pass());
62 void RasterTilePriorityQueueRequired::BuildRequiredForActivation(
63 const std::vector
<PictureLayerImpl
*>& active_layers
,
64 const std::vector
<PictureLayerImpl
*>& pending_layers
) {
65 AppendTilingSetRequiredQueues(active_layers
, &tiling_set_queues_
);
66 AppendTilingSetRequiredQueues(pending_layers
, &tiling_set_queues_
);
69 bool RasterTilePriorityQueueRequired::IsEmpty() const {
70 return tiling_set_queues_
.empty();
73 const PrioritizedTile
& RasterTilePriorityQueueRequired::Top() const {
75 return tiling_set_queues_
.back()->Top();
78 void RasterTilePriorityQueueRequired::Pop() {
80 tiling_set_queues_
.back()->Pop();
81 if (tiling_set_queues_
.back()->IsEmpty())
82 tiling_set_queues_
.pop_back();