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

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

Issue 1130123003: cc: Separate the priority from the tile and put in new PrioritizedTile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tile too friendly, lets fix that Created 5 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/tiling_set_raster_queue_required.h" 5 #include "cc/resources/tiling_set_raster_queue_required.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "cc/resources/picture_layer_tiling_set.h" 9 #include "cc/resources/picture_layer_tiling_set.h"
10 #include "cc/resources/tile.h" 10 #include "cc/resources/tile.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return iterator_.done(); 63 return iterator_.done();
64 } 64 }
65 65
66 void TilingSetRasterQueueRequired::Pop() { 66 void TilingSetRasterQueueRequired::Pop() {
67 DCHECK(!IsEmpty()); 67 DCHECK(!IsEmpty());
68 ++iterator_; 68 ++iterator_;
69 while (!iterator_.done() && !IsTileRequired(*iterator_)) 69 while (!iterator_.done() && !IsTileRequired(*iterator_))
70 ++iterator_; 70 ++iterator_;
71 } 71 }
72 72
73 Tile* TilingSetRasterQueueRequired::Top() { 73 const PrioritizedTile& TilingSetRasterQueueRequired::Top() const {
74 DCHECK(!IsEmpty()); 74 DCHECK(!IsEmpty());
75 return *iterator_; 75 return *iterator_;
76 } 76 }
77 77
78 const Tile* TilingSetRasterQueueRequired::Top() const { 78 bool TilingSetRasterQueueRequired::IsTileRequired(
79 DCHECK(!IsEmpty()); 79 const PrioritizedTile& prioritized_tile) const {
80 return *iterator_;
81 }
82
83 bool TilingSetRasterQueueRequired::IsTileRequired(const Tile* tile) const {
84 return (type_ == RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION && 80 return (type_ == RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION &&
85 tile->required_for_activation()) || 81 prioritized_tile.tile()->required_for_activation()) ||
86 (type_ == RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW && 82 (type_ == RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW &&
87 tile->required_for_draw()); 83 prioritized_tile.tile()->required_for_draw());
88 } 84 }
89 85
90 TilingSetRasterQueueRequired::TilingIterator::TilingIterator() 86 TilingSetRasterQueueRequired::TilingIterator::TilingIterator()
91 : tiling_(nullptr), current_tile_(nullptr) { 87 : tiling_(nullptr) {
92 } 88 }
93 89
94 TilingSetRasterQueueRequired::TilingIterator::TilingIterator( 90 TilingSetRasterQueueRequired::TilingIterator::TilingIterator(
95 PictureLayerTiling* tiling, 91 PictureLayerTiling* tiling,
96 TilingData* tiling_data, 92 TilingData* tiling_data,
97 const gfx::Rect& rect) 93 const gfx::Rect& rect)
98 : tiling_(tiling), tiling_data_(tiling_data), current_tile_(nullptr) { 94 : tiling_(tiling), tiling_data_(tiling_data) {
99 visible_iterator_ = 95 visible_iterator_ =
100 TilingData::Iterator(tiling_data_, rect, false /* include_borders */); 96 TilingData::Iterator(tiling_data_, rect, false /* include_borders */);
101 if (!visible_iterator_) 97 if (!visible_iterator_)
102 return; 98 return;
103 99
104 current_tile_ = 100 Tile* tile =
105 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); 101 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y());
106
107 // If this is a valid tile, return it. Note that we have to use a tiling check 102 // If this is a valid tile, return it. Note that we have to use a tiling check
108 // for occlusion, since the tile's internal state has not yet been updated. 103 // for occlusion, since the tile's internal state has not yet been updated.
109 if (current_tile_ && current_tile_->NeedsRaster() && 104 if (tile && tile->NeedsRaster() && !tiling_->IsTileOccluded(tile)) {
110 !tiling_->IsTileOccluded(current_tile_)) { 105 current_tile_.UpdateTile(tile, tiling_);
111 tiling_->UpdateTilePriority(current_tile_);
112 return; 106 return;
113 } 107 }
114 ++(*this); 108 ++(*this);
115 } 109 }
116 110
117 TilingSetRasterQueueRequired::TilingIterator::~TilingIterator() { 111 TilingSetRasterQueueRequired::TilingIterator::~TilingIterator() {
118 } 112 }
119 113
120 TilingSetRasterQueueRequired::TilingIterator& 114 TilingSetRasterQueueRequired::TilingIterator&
121 TilingSetRasterQueueRequired::TilingIterator:: 115 TilingSetRasterQueueRequired::TilingIterator::
122 operator++() { 116 operator++() {
117 Tile* tile = nullptr;
123 while (true) { 118 while (true) {
124 ++visible_iterator_; 119 ++visible_iterator_;
125 if (!visible_iterator_) { 120 if (!visible_iterator_) {
126 current_tile_ = nullptr; 121 current_tile_.Invalidate();
127 return *this; 122 return *this;
128 } 123 }
129 std::pair<int, int> next_index = visible_iterator_.index(); 124 std::pair<int, int> next_index = visible_iterator_.index();
130 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); 125 tile = tiling_->TileAt(next_index.first, next_index.second);
131 // If the tile doesn't exist or if it exists but doesn't need raster work, 126 // If the tile doesn't exist or if it exists but doesn't need raster work,
132 // we can move on to the next tile. 127 // we can move on to the next tile.
133 if (!current_tile_ || !current_tile_->NeedsRaster()) 128 if (!tile || !tile->NeedsRaster())
134 continue; 129 continue;
135 130
136 // If the tile is occluded, we also can skip it. Note that we use the tiling 131 // If the tile is occluded, we also can skip it. Note that we use the tiling
137 // check for occlusion, since tile's internal state has not yet been updated 132 // check for occlusion, since tile's internal state has not yet been updated
138 // (by UpdateTilePriority). The tiling check does not rely on tile's 133 // (by UpdateTilePriority). The tiling check does not rely on tile's
139 // internal state (it is, in fact, used to determine the tile's state). 134 // internal state (it is, in fact, used to determine the tile's state).
140 if (tiling_->IsTileOccluded(current_tile_)) 135 if (tiling_->IsTileOccluded(tile))
141 continue; 136 continue;
142 137
143 // If we get here, that means we have a valid tile that needs raster and is 138 // If we get here, that means we have a valid tile that needs raster and is
144 // in the NOW bin, which means that it can be required. 139 // in the NOW bin, which means that it can be required.
145 break; 140 break;
146 } 141 }
147 142
148 if (current_tile_) 143 current_tile_.UpdateTile(tile, tiling_);
149 tiling_->UpdateTilePriority(current_tile_);
150 return *this; 144 return *this;
151 } 145 }
152 146
153 } // namespace cc 147 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698