Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: cc/resources/tiling_set_raster_queue_required.cc

Issue 816453008: cc: Split tiling set raster queues into all and required. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/tiling_set_raster_queue_required.h ('k') | cc/test/fake_tile_manager_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "cc/resources/tiling_set_raster_queue_required.h"
6
7 #include <utility>
8
9 #include "cc/resources/picture_layer_tiling_set.h"
10 #include "cc/resources/tile.h"
11 #include "cc/resources/tile_priority.h"
12
13 namespace cc {
14
15 TilingSetRasterQueueRequired::TilingSetRasterQueueRequired(
16 PictureLayerTilingSet* tiling_set,
17 RasterTilePriorityQueue::Type type)
18 : type_(type) {
19 DCHECK_NE(static_cast<int>(type),
20 static_cast<int>(RasterTilePriorityQueue::Type::ALL));
21
22 // Any type of required tile would only come from a high resolution tiling.
23 // The functions that determine this value is
24 // PictureLayerTiling::IsTileRequiredFor*, which all return false if the
25 // resolution is not HIGH_RESOLUTION.
26 PictureLayerTiling* tiling =
27 tiling_set->FindTilingWithResolution(HIGH_RESOLUTION);
28 DCHECK(tiling);
29 iterator_ = TilingIterator(tiling, &tiling->tiling_data_);
30 while (!iterator_.done() && !IsTileRequired(*iterator_))
31 ++iterator_;
32 }
33
34 TilingSetRasterQueueRequired::~TilingSetRasterQueueRequired() {
35 }
36
37 bool TilingSetRasterQueueRequired::IsEmpty() const {
38 return iterator_.done();
39 }
40
41 void TilingSetRasterQueueRequired::Pop() {
42 DCHECK(!IsEmpty());
43 ++iterator_;
44 while (!iterator_.done() && !IsTileRequired(*iterator_))
45 ++iterator_;
46 }
47
48 Tile* TilingSetRasterQueueRequired::Top() {
49 DCHECK(!IsEmpty());
50 return *iterator_;
51 }
52
53 const Tile* TilingSetRasterQueueRequired::Top() const {
54 DCHECK(!IsEmpty());
55 return *iterator_;
56 }
57
58 bool TilingSetRasterQueueRequired::IsTileRequired(const Tile* tile) const {
59 return (type_ == RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION &&
60 tile->required_for_activation()) ||
61 (type_ == RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW &&
62 tile->required_for_draw());
63 }
64
65 TilingSetRasterQueueRequired::TilingIterator::TilingIterator()
66 : tiling_(nullptr), current_tile_(nullptr) {
67 }
68
69 TilingSetRasterQueueRequired::TilingIterator::TilingIterator(
70 PictureLayerTiling* tiling,
71 TilingData* tiling_data)
72 : tiling_(tiling), tiling_data_(tiling_data), current_tile_(nullptr) {
73 if (!tiling_->has_visible_rect_tiles()) {
74 // Verify that if we would create the iterator, then it would be empty (ie
75 // it would return false when evaluated as a bool).
76 DCHECK(!TilingData::Iterator(tiling_data_, tiling->current_visible_rect(),
77 false));
78 return;
79 }
80
81 visible_iterator_ =
82 TilingData::Iterator(tiling_data_, tiling_->current_visible_rect(),
83 false /* include_borders */);
84 if (!visible_iterator_)
85 return;
86
87 current_tile_ =
88 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y());
89
90 // If this is a valid tile, return it. Note that we have to use a tiling check
91 // for occlusion, since the tile's internal state has not yet been updated.
92 if (current_tile_ && current_tile_->NeedsRaster() &&
93 !tiling_->IsTileOccluded(current_tile_)) {
94 tiling_->UpdateTileAndTwinPriority(current_tile_);
95 return;
96 }
97 ++(*this);
98 }
99
100 TilingSetRasterQueueRequired::TilingIterator::~TilingIterator() {
101 }
102
103 TilingSetRasterQueueRequired::TilingIterator&
104 TilingSetRasterQueueRequired::TilingIterator::
105 operator++() {
106 while (true) {
107 ++visible_iterator_;
108 if (!visible_iterator_) {
109 current_tile_ = nullptr;
110 return *this;
111 }
112 std::pair<int, int> next_index = visible_iterator_.index();
113 current_tile_ = tiling_->TileAt(next_index.first, next_index.second);
114 // If the tile doesn't exist or if it exists but doesn't need raster work,
115 // we can move on to the next tile.
116 if (!current_tile_ || !current_tile_->NeedsRaster())
117 continue;
118
119 // If the tile is occluded, we also can skip it. Note that we use the tiling
120 // check for occlusion, since tile's internal state has not yet been updated
121 // (by UpdateTileAndTwinPriority). The tiling check does not rely on tile's
122 // internal state (it is, in fact, used to determine the tile's state).
123 if (tiling_->IsTileOccluded(current_tile_))
124 continue;
125
126 // If we get here, that means we have a valid tile that needs raster and is
127 // in the NOW bin, which means that it can be required.
128 break;
129 }
130
131 if (current_tile_)
132 tiling_->UpdateTileAndTwinPriority(current_tile_);
133 return *this;
134 }
135
136 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tiling_set_raster_queue_required.h ('k') | cc/test/fake_tile_manager_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698