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

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

Issue 389973004: cc: Give TilingData back a Size instead of a Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tilingsize: comments Created 6 years, 5 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
« no previous file with comments | « cc/resources/picture_pile.h ('k') | cc/resources/picture_pile_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_pile.h" 5 #include "cc/resources/picture_pile.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 PicturePile::~PicturePile() { 151 PicturePile::~PicturePile() {
152 } 152 }
153 153
154 bool PicturePile::UpdateAndExpandInvalidation( 154 bool PicturePile::UpdateAndExpandInvalidation(
155 ContentLayerClient* painter, 155 ContentLayerClient* painter,
156 Region* invalidation, 156 Region* invalidation,
157 SkColor background_color, 157 SkColor background_color,
158 bool contents_opaque, 158 bool contents_opaque,
159 bool contents_fill_bounds_completely, 159 bool contents_fill_bounds_completely,
160 const gfx::Rect& layer_bounds_rect, 160 const gfx::Size& layer_size,
161 const gfx::Rect& visible_layer_rect, 161 const gfx::Rect& visible_layer_rect,
162 int frame_number, 162 int frame_number,
163 Picture::RecordingMode recording_mode, 163 Picture::RecordingMode recording_mode,
164 RenderingStatsInstrumentation* stats_instrumentation) { 164 RenderingStatsInstrumentation* stats_instrumentation) {
165 background_color_ = background_color; 165 background_color_ = background_color;
166 contents_opaque_ = contents_opaque; 166 contents_opaque_ = contents_opaque;
167 contents_fill_bounds_completely_ = contents_fill_bounds_completely; 167 contents_fill_bounds_completely_ = contents_fill_bounds_completely;
168 168
169 bool updated = false; 169 bool updated = false;
170 170
171 Region resize_invalidation; 171 Region resize_invalidation;
172 gfx::Rect old_tiling_rect = tiling_rect(); 172 gfx::Size old_tiling_size = tiling_size();
173 if (old_tiling_rect != layer_bounds_rect) { 173 if (old_tiling_size != layer_size) {
174 tiling_.SetTilingRect(layer_bounds_rect); 174 tiling_.SetTilingSize(layer_size);
175 updated = true; 175 updated = true;
176 } 176 }
177 177
178 gfx::Rect interest_rect = visible_layer_rect; 178 gfx::Rect interest_rect = visible_layer_rect;
179 interest_rect.Inset( 179 interest_rect.Inset(
180 -kPixelDistanceToRecord, 180 -kPixelDistanceToRecord,
181 -kPixelDistanceToRecord, 181 -kPixelDistanceToRecord,
182 -kPixelDistanceToRecord, 182 -kPixelDistanceToRecord,
183 -kPixelDistanceToRecord); 183 -kPixelDistanceToRecord);
184 recorded_viewport_ = interest_rect; 184 recorded_viewport_ = interest_rect;
185 recorded_viewport_.Intersect(tiling_rect()); 185 recorded_viewport_.Intersect(gfx::Rect(tiling_size()));
186 186
187 gfx::Rect interest_rect_over_tiles = 187 gfx::Rect interest_rect_over_tiles =
188 tiling_.ExpandRectToTileBounds(interest_rect); 188 tiling_.ExpandRectToTileBounds(interest_rect);
189 189
190 if (old_tiling_rect != layer_bounds_rect) { 190 if (old_tiling_size != layer_size) {
191 has_any_recordings_ = false; 191 has_any_recordings_ = false;
192 192
193 if (tiling_rect().origin() != old_tiling_rect.origin()) { 193 // Drop recordings that are outside the new layer bounds or that changed
194 // If the origin changes we just do something simple. 194 // size.
195 picture_map_.clear(); 195 std::vector<PictureMapKey> to_erase;
196 invalidation->Union(old_tiling_rect); 196 int min_toss_x = tiling_.num_tiles_x();
197 invalidation->Union(tiling_rect()); 197 if (tiling_size().width() > old_tiling_size.width()) {
198 } else { 198 min_toss_x =
199 // Drop recordings that are outside the new layer bounds or that changed 199 tiling_.FirstBorderTileXIndexFromSrcCoord(old_tiling_size.width());
200 // size. 200 }
201 std::vector<PictureMapKey> to_erase; 201 int min_toss_y = tiling_.num_tiles_y();
202 int min_toss_x = tiling_.num_tiles_x(); 202 if (tiling_size().height() > old_tiling_size.height()) {
203 if (tiling_rect().right() > old_tiling_rect.right()) { 203 min_toss_y =
204 min_toss_x = 204 tiling_.FirstBorderTileYIndexFromSrcCoord(old_tiling_size.height());
205 tiling_.FirstBorderTileXIndexFromSrcCoord(old_tiling_rect.right()); 205 }
206 for (PictureMap::const_iterator it = picture_map_.begin();
207 it != picture_map_.end();
208 ++it) {
209 const PictureMapKey& key = it->first;
210 if (key.first < min_toss_x && key.second < min_toss_y) {
211 has_any_recordings_ |= !!it->second.GetPicture();
212 continue;
206 } 213 }
207 int min_toss_y = tiling_.num_tiles_y(); 214 to_erase.push_back(key);
208 if (tiling_rect().bottom() > old_tiling_rect.bottom()) { 215 }
209 min_toss_y =
210 tiling_.FirstBorderTileYIndexFromSrcCoord(old_tiling_rect.bottom());
211 }
212 for (PictureMap::const_iterator it = picture_map_.begin();
213 it != picture_map_.end();
214 ++it) {
215 const PictureMapKey& key = it->first;
216 if (key.first < min_toss_x && key.second < min_toss_y) {
217 has_any_recordings_ |= !!it->second.GetPicture();
218 continue;
219 }
220 to_erase.push_back(key);
221 }
222 216
223 for (size_t i = 0; i < to_erase.size(); ++i) 217 for (size_t i = 0; i < to_erase.size(); ++i)
224 picture_map_.erase(to_erase[i]); 218 picture_map_.erase(to_erase[i]);
225 219
226 // If a recording is dropped and not re-recorded below, invalidate that 220 // If a recording is dropped and not re-recorded below, invalidate that
227 // full recording to cause any raster tiles that would use it to be 221 // full recording to cause any raster tiles that would use it to be
228 // dropped. 222 // dropped.
229 // If the recording will be replaced below, just invalidate newly exposed 223 // If the recording will be replaced below, just invalidate newly exposed
230 // areas to force raster tiles that include the old recording to know 224 // areas to force raster tiles that include the old recording to know
231 // there is new recording to display. 225 // there is new recording to display.
232 gfx::Rect old_tiling_rect_over_tiles = 226 gfx::Rect old_tiling_rect_over_tiles =
233 tiling_.ExpandRectToTileBounds(old_tiling_rect); 227 tiling_.ExpandRectToTileBounds(gfx::Rect(old_tiling_size));
234 if (min_toss_x < tiling_.num_tiles_x()) { 228 if (min_toss_x < tiling_.num_tiles_x()) {
235 int unrecorded_left = std::max(tiling_.TilePositionX(min_toss_x), 229 int unrecorded_left = std::max(tiling_.TilePositionX(min_toss_x),
236 interest_rect_over_tiles.right()); 230 interest_rect_over_tiles.right());
237 int exposed_left = old_tiling_rect.right(); 231 int exposed_left = old_tiling_size.width();
238 int left = std::min(unrecorded_left, exposed_left); 232 int left = std::min(unrecorded_left, exposed_left);
239 int tile_right = 233 int tile_right =
240 tiling_.TilePositionX(min_toss_x) + tiling_.TileSizeX(min_toss_x); 234 tiling_.TilePositionX(min_toss_x) + tiling_.TileSizeX(min_toss_x);
241 int exposed_right = tiling_rect().right(); 235 int exposed_right = tiling_size().width();
242 int right = std::min(tile_right, exposed_right); 236 int right = std::min(tile_right, exposed_right);
243 gfx::Rect right_side(left, 237 gfx::Rect right_side(left,
244 old_tiling_rect_over_tiles.y(), 238 old_tiling_rect_over_tiles.y(),
245 right - left, 239 right - left,
246 old_tiling_rect_over_tiles.height()); 240 old_tiling_rect_over_tiles.height());
247 resize_invalidation.Union(right_side); 241 resize_invalidation.Union(right_side);
248 } 242 }
249 if (min_toss_y < tiling_.num_tiles_y()) { 243 if (min_toss_y < tiling_.num_tiles_y()) {
250 int unrecorded_top = std::max(tiling_.TilePositionY(min_toss_y), 244 int unrecorded_top = std::max(tiling_.TilePositionY(min_toss_y),
251 interest_rect_over_tiles.bottom()); 245 interest_rect_over_tiles.bottom());
252 int exposed_top = old_tiling_rect.bottom(); 246 int exposed_top = old_tiling_size.height();
253 int top = std::min(unrecorded_top, exposed_top); 247 int top = std::min(unrecorded_top, exposed_top);
254 int tile_bottom = 248 int tile_bottom =
255 tiling_.TilePositionY(min_toss_y) + tiling_.TileSizeY(min_toss_y); 249 tiling_.TilePositionY(min_toss_y) + tiling_.TileSizeY(min_toss_y);
256 int exposed_bottom = tiling_rect().bottom(); 250 int exposed_bottom = tiling_size().height();
257 int bottom = std::min(tile_bottom, exposed_bottom); 251 int bottom = std::min(tile_bottom, exposed_bottom);
258 gfx::Rect bottom_side(old_tiling_rect_over_tiles.x(), 252 gfx::Rect bottom_side(old_tiling_rect_over_tiles.x(),
259 top, 253 top,
260 old_tiling_rect_over_tiles.width(), 254 old_tiling_rect_over_tiles.width(),
261 bottom - top); 255 bottom - top);
262 resize_invalidation.Union(bottom_side); 256 resize_invalidation.Union(bottom_side);
263 }
264 } 257 }
265 } 258 }
266 259
267 Region invalidation_expanded_to_full_tiles; 260 Region invalidation_expanded_to_full_tiles;
268 for (Region::Iterator i(*invalidation); i.has_rect(); i.next()) { 261 for (Region::Iterator i(*invalidation); i.has_rect(); i.next()) {
269 gfx::Rect invalid_rect = i.rect(); 262 gfx::Rect invalid_rect = i.rect();
270 263
271 // Expand invalidation that is outside tiles that intersect the interest 264 // Expand invalidation that is outside tiles that intersect the interest
272 // rect. These tiles are no longer valid and should be considerered fully 265 // rect. These tiles are no longer valid and should be considerered fully
273 // invalid, so we can know to not keep around raster tiles that intersect 266 // invalid, so we can know to not keep around raster tiles that intersect
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 395 }
403 DCHECK(found_tile_for_recorded_picture); 396 DCHECK(found_tile_for_recorded_picture);
404 } 397 }
405 398
406 has_any_recordings_ = true; 399 has_any_recordings_ = true;
407 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); 400 DCHECK(CanRasterSlowTileCheck(recorded_viewport_));
408 return true; 401 return true;
409 } 402 }
410 403
411 void PicturePile::SetEmptyBounds() { 404 void PicturePile::SetEmptyBounds() {
412 tiling_.SetTilingRect(gfx::Rect()); 405 tiling_.SetTilingSize(gfx::Size());
413 picture_map_.clear(); 406 picture_map_.clear();
414 has_any_recordings_ = false; 407 has_any_recordings_ = false;
415 recorded_viewport_ = gfx::Rect(); 408 recorded_viewport_ = gfx::Rect();
416 } 409 }
417 410
418 } // namespace cc 411 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_pile.h ('k') | cc/resources/picture_pile_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698