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

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

Issue 12583018: cc: Rename PictureLayerTiling(Set) Iterator to CoverageIterator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/picture_layer_tiling_set.h" 5 #include "cc/resources/picture_layer_tiling_set.h"
6 6
7 namespace cc { 7 namespace cc {
8 8
9 namespace { 9 namespace {
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 void PictureLayerTilingSet::RemoveAllTiles() { 104 void PictureLayerTilingSet::RemoveAllTiles() {
105 for (size_t i = 0; i < tilings_.size(); ++i) 105 for (size_t i = 0; i < tilings_.size(); ++i)
106 tilings_[i]->Reset(); 106 tilings_[i]->Reset();
107 } 107 }
108 108
109 void PictureLayerTilingSet::CreateTilesFromLayerRect(gfx::Rect layer_rect) { 109 void PictureLayerTilingSet::CreateTilesFromLayerRect(gfx::Rect layer_rect) {
110 for (size_t i = 0; i < tilings_.size(); ++i) 110 for (size_t i = 0; i < tilings_.size(); ++i)
111 tilings_[i]->CreateTilesFromLayerRect(layer_rect); 111 tilings_[i]->CreateTilesFromLayerRect(layer_rect);
112 } 112 }
113 113
114 PictureLayerTilingSet::Iterator::Iterator( 114 PictureLayerTilingSet::CoverageIterator::CoverageIterator(
115 const PictureLayerTilingSet* set, 115 const PictureLayerTilingSet* set,
116 float contents_scale, 116 float contents_scale,
117 gfx::Rect content_rect, 117 gfx::Rect content_rect,
118 float ideal_contents_scale) 118 float ideal_contents_scale)
119 : set_(set), 119 : set_(set),
120 contents_scale_(contents_scale), 120 contents_scale_(contents_scale),
121 ideal_contents_scale_(ideal_contents_scale), 121 ideal_contents_scale_(ideal_contents_scale),
122 current_tiling_(-1) { 122 current_tiling_(-1) {
123 missing_region_.Union(content_rect); 123 missing_region_.Union(content_rect);
124 124
125 for (ideal_tiling_ = 0; 125 for (ideal_tiling_ = 0;
126 static_cast<size_t>(ideal_tiling_) < set_->tilings_.size(); 126 static_cast<size_t>(ideal_tiling_) < set_->tilings_.size();
127 ++ideal_tiling_) { 127 ++ideal_tiling_) {
128 PictureLayerTiling* tiling = set_->tilings_[ideal_tiling_]; 128 PictureLayerTiling* tiling = set_->tilings_[ideal_tiling_];
129 if (tiling->contents_scale() < ideal_contents_scale_) { 129 if (tiling->contents_scale() < ideal_contents_scale_) {
130 if (ideal_tiling_ > 0) 130 if (ideal_tiling_ > 0)
131 ideal_tiling_--; 131 ideal_tiling_--;
132 break; 132 break;
133 } 133 }
134 } 134 }
135 135
136 if (ideal_tiling_ == set_->tilings_.size() && ideal_tiling_ > 0) 136 if (ideal_tiling_ == set_->tilings_.size() && ideal_tiling_ > 0)
137 ideal_tiling_--; 137 ideal_tiling_--;
138 138
139 ++(*this); 139 ++(*this);
140 } 140 }
141 141
142 PictureLayerTilingSet::Iterator::~Iterator() { 142 PictureLayerTilingSet::CoverageIterator::~CoverageIterator() {
143 } 143 }
144 144
145 gfx::Rect PictureLayerTilingSet::Iterator::geometry_rect() const { 145 gfx::Rect PictureLayerTilingSet::CoverageIterator::geometry_rect() const {
146 if (!tiling_iter_) { 146 if (!tiling_iter_) {
147 if (!region_iter_.has_rect()) 147 if (!region_iter_.has_rect())
148 return gfx::Rect(); 148 return gfx::Rect();
149 return region_iter_.rect(); 149 return region_iter_.rect();
150 } 150 }
151 return tiling_iter_.geometry_rect(); 151 return tiling_iter_.geometry_rect();
152 } 152 }
153 153
154 gfx::RectF PictureLayerTilingSet::Iterator::texture_rect() const { 154 gfx::RectF PictureLayerTilingSet::CoverageIterator::texture_rect() const {
155 if (!tiling_iter_) 155 if (!tiling_iter_)
156 return gfx::RectF(); 156 return gfx::RectF();
157 return tiling_iter_.texture_rect(); 157 return tiling_iter_.texture_rect();
158 } 158 }
159 159
160 gfx::Size PictureLayerTilingSet::Iterator::texture_size() const { 160 gfx::Size PictureLayerTilingSet::CoverageIterator::texture_size() const {
161 if (!tiling_iter_) 161 if (!tiling_iter_)
162 return gfx::Size(); 162 return gfx::Size();
163 return tiling_iter_.texture_size(); 163 return tiling_iter_.texture_size();
164 } 164 }
165 165
166 Tile* PictureLayerTilingSet::Iterator::operator->() const { 166 Tile* PictureLayerTilingSet::CoverageIterator::operator->() const {
167 if (!tiling_iter_) 167 if (!tiling_iter_)
168 return NULL; 168 return NULL;
169 return *tiling_iter_; 169 return *tiling_iter_;
170 } 170 }
171 171
172 Tile* PictureLayerTilingSet::Iterator::operator*() const { 172 Tile* PictureLayerTilingSet::CoverageIterator::operator*() const {
173 if (!tiling_iter_) 173 if (!tiling_iter_)
174 return NULL; 174 return NULL;
175 return *tiling_iter_; 175 return *tiling_iter_;
176 } 176 }
177 177
178 PictureLayerTiling* PictureLayerTilingSet::Iterator::CurrentTiling() { 178 PictureLayerTiling* PictureLayerTilingSet::CoverageIterator::CurrentTiling() {
179 if (current_tiling_ < 0) 179 if (current_tiling_ < 0)
180 return NULL; 180 return NULL;
181 if (static_cast<size_t>(current_tiling_) >= set_->tilings_.size()) 181 if (static_cast<size_t>(current_tiling_) >= set_->tilings_.size())
182 return NULL; 182 return NULL;
183 return set_->tilings_[current_tiling_]; 183 return set_->tilings_[current_tiling_];
184 } 184 }
185 185
186 int PictureLayerTilingSet::Iterator::NextTiling() const { 186 int PictureLayerTilingSet::CoverageIterator::NextTiling() const {
187 // Order returned by this method is: 187 // Order returned by this method is:
188 // 1. Ideal tiling index 188 // 1. Ideal tiling index
189 // 2. Tiling index < Ideal in decreasing order (higher res than ideal) 189 // 2. Tiling index < Ideal in decreasing order (higher res than ideal)
190 // 3. Tiling index > Ideal in increasing order (lower res than ideal) 190 // 3. Tiling index > Ideal in increasing order (lower res than ideal)
191 // 4. Tiling index > tilings.size() (invalid index) 191 // 4. Tiling index > tilings.size() (invalid index)
192 if (current_tiling_ < 0) 192 if (current_tiling_ < 0)
193 return ideal_tiling_; 193 return ideal_tiling_;
194 else if (current_tiling_ > ideal_tiling_) 194 else if (current_tiling_ > ideal_tiling_)
195 return current_tiling_ + 1; 195 return current_tiling_ + 1;
196 else if (current_tiling_) 196 else if (current_tiling_)
197 return current_tiling_ - 1; 197 return current_tiling_ - 1;
198 else 198 else
199 return ideal_tiling_ + 1; 199 return ideal_tiling_ + 1;
200 } 200 }
201 201
202 PictureLayerTilingSet::Iterator& PictureLayerTilingSet::Iterator::operator++() { 202 PictureLayerTilingSet::CoverageIterator&
203 PictureLayerTilingSet::CoverageIterator::operator++() {
203 bool first_time = current_tiling_ < 0; 204 bool first_time = current_tiling_ < 0;
204 205
205 if (!*this && !first_time) 206 if (!*this && !first_time)
206 return *this; 207 return *this;
207 208
208 if (tiling_iter_) 209 if (tiling_iter_)
209 ++tiling_iter_; 210 ++tiling_iter_;
210 211
211 // Loop until we find a valid place to stop. 212 // Loop until we find a valid place to stop.
212 while (true) { 213 while (true) {
(...skipping 29 matching lines...) Expand all
242 // treated as geometry with null tiles that the caller can checkerboard. 243 // treated as geometry with null tiles that the caller can checkerboard.
243 gfx::Rect last_rect = region_iter_.rect(); 244 gfx::Rect last_rect = region_iter_.rect();
244 region_iter_.next(); 245 region_iter_.next();
245 246
246 // Done, found next checkerboard rect to return. 247 // Done, found next checkerboard rect to return.
247 if (current_tiling_ >= static_cast<int>(set_->tilings_.size())) 248 if (current_tiling_ >= static_cast<int>(set_->tilings_.size()))
248 return *this; 249 return *this;
249 250
250 // Construct a new iterator for the next tiling, but we need to loop 251 // Construct a new iterator for the next tiling, but we need to loop
251 // again until we get to a valid one. 252 // again until we get to a valid one.
252 tiling_iter_ = PictureLayerTiling::Iterator( 253 tiling_iter_ = PictureLayerTiling::CoverageIterator(
253 set_->tilings_[current_tiling_], 254 set_->tilings_[current_tiling_],
254 contents_scale_, 255 contents_scale_,
255 last_rect); 256 last_rect);
256 } 257 }
257 258
258 return *this; 259 return *this;
259 } 260 }
260 261
261 PictureLayerTilingSet::Iterator::operator bool() const { 262 PictureLayerTilingSet::CoverageIterator::operator bool() const {
262 return current_tiling_ < static_cast<int>(set_->tilings_.size()) || 263 return current_tiling_ < static_cast<int>(set_->tilings_.size()) ||
263 region_iter_.has_rect(); 264 region_iter_.has_rect();
264 } 265 }
265 266
266 void PictureLayerTilingSet::UpdateTilePriorities( 267 void PictureLayerTilingSet::UpdateTilePriorities(
267 WhichTree tree, 268 WhichTree tree,
268 gfx::Size device_viewport, 269 gfx::Size device_viewport,
269 gfx::Rect viewport_in_content_space, 270 gfx::Rect viewport_in_content_space,
270 gfx::Size last_layer_bounds, 271 gfx::Size last_layer_bounds,
271 gfx::Size current_layer_bounds, 272 gfx::Size current_layer_bounds,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 307 }
307 308
308 scoped_ptr<base::Value> PictureLayerTilingSet::AsValue() const { 309 scoped_ptr<base::Value> PictureLayerTilingSet::AsValue() const {
309 scoped_ptr<base::ListValue> state(new base::ListValue()); 310 scoped_ptr<base::ListValue> state(new base::ListValue());
310 for (size_t i = 0; i < tilings_.size(); ++i) 311 for (size_t i = 0; i < tilings_.size(); ++i)
311 state->Append(tilings_[i]->AsValue().release()); 312 state->Append(tilings_[i]->AsValue().release());
312 return state.PassAs<base::Value>(); 313 return state.PassAs<base::Value>();
313 } 314 }
314 315
315 } // namespace cc 316 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling_set.h ('k') | cc/resources/picture_layer_tiling_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698