Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 | 219 |
| 220 // 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 |
| 221 // 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 |
| 222 // dropped. | 222 // dropped. |
| 223 // If the recording will be replaced below, just invalidate newly exposed | 223 // If the recording will be replaced below, just invalidate newly exposed |
| 224 // 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 |
| 225 // there is new recording to display. | 225 // there is new recording to display. |
| 226 gfx::Rect old_tiling_rect_over_tiles = | 226 gfx::Rect old_tiling_rect_over_tiles = |
| 227 tiling_.ExpandRectToTileBounds(gfx::Rect(old_tiling_size)); | 227 tiling_.ExpandRectToTileBounds(gfx::Rect(old_tiling_size)); |
| 228 if (min_toss_x < tiling_.num_tiles_x()) { | 228 if (min_toss_x < tiling_.num_tiles_x()) { |
| 229 int unrecorded_left = std::max(tiling_.TilePositionX(min_toss_x), | 229 // The bounds which we want to invalidate are the tiles along the old |
| 230 interest_rect_over_tiles.right()); | 230 // edge of the pile. In the picture below, it would be the bounding box |
| 231 // of tiles {h,i,j}. | |
| 232 // | |
| 233 // old pile edge-v new pile edge-v | |
| 234 // ---------------+ - - - - - - - -+ | |
| 235 // mmppssvvyybbeeh|h . | |
|
enne (OOO)
2014/08/25 17:48:47
If I'm reading this diagram correctly, min_toss_x
danakj
2014/08/25 18:03:39
The old pile edge was in the middle of the h tile
enne (OOO)
2014/08/25 18:08:13
...so you're agreeing with me?
danakj
2014/08/25 18:13:35
Ya, but for clarify min_toss_x would be == h not b
| |
| 236 // mmppssvvyybbeeh|h . | |
| 237 // nnqqttwwzzccffi|i . | |
| 238 // nnqqttwwzzccffi|i . | |
| 239 // oorruuxxaaddggj|j . | |
| 240 // oorruuxxaaddggj|j . | |
| 241 // ---------------+ - - - - - - - -+ <- old pile edge | |
| 242 // . | |
| 243 // - - - - - - - - - - - - - - - -+ <- new pile edge | |
| 244 // | |
| 245 // If you were to slide a vertical beam from the left edge of the | |
| 246 // invalidation rect toward the right, it would either hit the right edge | |
| 247 // of the invalidation rect, or the interest rect (expanded to the bounds | |
| 248 // of the tiles it touches). | |
| 249 // +--------------------------------------+ | |
| 250 // |===> INVALIDATION RECT | | |
|
enne (OOO)
2014/08/25 17:48:47
This bit took me a while to understand. Can you i
danakj
2014/08/25 18:03:39
Sure, this rect is no longer the entire pile, this
| |
| 251 // |===> | | |
| 252 // |===>+-----------------+ | | |
| 253 // |===>| INTEREST RECT | | | |
|
enne (OOO)
2014/08/25 17:48:47
This may just be the coffee speaking, but I think
danakj
2014/08/25 18:03:39
Outside of the interest rect we invalidate the ent
enne (OOO)
2014/08/25 18:08:13
What do you mean by "impl can keep around recordin
danakj
2014/08/25 18:13:35
If a raster tile used some of the old pixels on on
enne (OOO)
2014/08/25 18:24:17
Something still doesn't seem right here to me. I
danakj
2014/08/25 18:29:55
There are 2 possible outcomes for each tile on the
| |
| 254 // +----|-----------------|---------------+ | |
| 255 // We want to invalidate everything between the top and bottom of the | |
| 256 // invalidation rect from the left edge, until the first point where | |
| 257 // either the interest rect or the other end of the invalidation rect | |
| 258 // is reached. The |left_until| variable is this point. | |
| 259 // | |
| 260 // Repeat this for each of the four edges of the invalidation rect. In the | |
| 261 // picture above, the beam from the bottom would produce no invalidation | |
| 262 // since it would immediately hit the interest rect. | |
| 263 // | |
| 264 // Lastly, we need to consider tiles that do intersect the interest rect. | |
| 265 // For those tiles, we want to invalidate exactly the newly exposed | |
| 266 // pixels. In the picture below, the left and bottom edges touch the | |
| 267 // interest rect, so no invalidation would be added from those edges. | |
| 268 // However everyting to the right of the old pile edge are newly visible | |
| 269 // pixels and should be invalidated. The last step is to add that entire | |
| 270 // rect to the invalidation. This will overlap, or even be contained | |
| 271 // within the four rects previously added, if the interest rect intersects | |
| 272 // any tiles within the bounds of the invalidation rect. | |
| 273 // | |
| 274 // v-old pile edge v-new pile edge | |
| 275 // +--.-----------------------------------+ | |
| 276 // | .===> INVALIDATION RECT | | |
| 277 // | .===> | | |
| 278 // ---.===>---------------+ | | |
| 279 // | .===> INTEREST RECT | | | |
| 280 // +--.-------------------|---------------+ | |
| 281 | |
| 282 int left = tiling_.TilePositionX(min_toss_x); | |
| 283 int right = left + tiling_.TileSizeX(min_toss_x); | |
| 284 int top = old_tiling_rect_over_tiles.y(); | |
| 285 int bottom = old_tiling_rect_over_tiles.bottom(); | |
| 286 | |
| 287 int left_until = std::min(interest_rect_over_tiles.x(), right); | |
| 288 int right_until = std::max(interest_rect_over_tiles.right(), left); | |
| 289 int top_until = std::min(interest_rect_over_tiles.y(), bottom); | |
| 290 int bottom_until = std::max(interest_rect_over_tiles.bottom(), top); | |
| 291 | |
| 231 int exposed_left = old_tiling_size.width(); | 292 int exposed_left = old_tiling_size.width(); |
| 232 int left = std::min(unrecorded_left, exposed_left); | 293 int exposed_left_until = right; |
| 233 int tile_right = | 294 DCHECK_GE(exposed_left, left); |
| 234 tiling_.TilePositionX(min_toss_x) + tiling_.TileSizeX(min_toss_x); | 295 |
| 235 int exposed_right = tiling_size().width(); | 296 gfx::Rect left_rect(left, top, left_until - left, bottom - top); |
| 236 int right = std::min(tile_right, exposed_right); | 297 gfx::Rect right_rect(right_until, top, right - right_until, bottom - top); |
| 237 gfx::Rect right_side(left, | 298 gfx::Rect top_rect(left, top, right - left, top_until - top); |
| 238 old_tiling_rect_over_tiles.y(), | 299 gfx::Rect bottom_rect( |
| 239 right - left, | 300 left, bottom_until, right - left, bottom - bottom_until); |
| 240 old_tiling_rect_over_tiles.height()); | 301 gfx::Rect exposed_rect( |
| 241 resize_invalidation.Union(right_side); | 302 exposed_left, top, exposed_left_until - exposed_left, bottom - top); |
| 303 resize_invalidation.Union(left_rect); | |
| 304 resize_invalidation.Union(right_rect); | |
| 305 resize_invalidation.Union(top_rect); | |
| 306 resize_invalidation.Union(bottom_rect); | |
| 307 resize_invalidation.Union(exposed_rect); | |
| 242 } | 308 } |
| 243 if (min_toss_y < tiling_.num_tiles_y()) { | 309 if (min_toss_y < tiling_.num_tiles_y()) { |
| 244 int unrecorded_top = std::max(tiling_.TilePositionY(min_toss_y), | 310 // The same thing occurs here as in the case above, but the invalidation |
| 245 interest_rect_over_tiles.bottom()); | 311 // rect is the bounding box around the bottom row of tiles in the old |
| 312 // pile. This would be tiles {o,r,u,x,a,d,g,j} in the above picture. | |
| 313 | |
| 314 int top = tiling_.TilePositionY(min_toss_y); | |
| 315 int bottom = top + tiling_.TileSizeY(min_toss_y); | |
| 316 int left = old_tiling_rect_over_tiles.x(); | |
| 317 int right = old_tiling_rect_over_tiles.right(); | |
| 318 | |
| 319 int top_until = std::min(interest_rect_over_tiles.y(), bottom); | |
| 320 int bottom_until = std::max(interest_rect_over_tiles.bottom(), top); | |
| 321 int left_until = std::min(interest_rect_over_tiles.x(), right); | |
| 322 int right_until = std::max(interest_rect_over_tiles.right(), left); | |
| 323 | |
| 246 int exposed_top = old_tiling_size.height(); | 324 int exposed_top = old_tiling_size.height(); |
| 247 int top = std::min(unrecorded_top, exposed_top); | 325 int exposed_top_until = bottom; |
| 248 int tile_bottom = | 326 DCHECK_GE(exposed_top, top); |
| 249 tiling_.TilePositionY(min_toss_y) + tiling_.TileSizeY(min_toss_y); | 327 |
| 250 int exposed_bottom = tiling_size().height(); | 328 gfx::Rect left_rect(left, top, left_until - left, bottom - top); |
| 251 int bottom = std::min(tile_bottom, exposed_bottom); | 329 gfx::Rect right_rect(right_until, top, right - right_until, bottom - top); |
| 252 gfx::Rect bottom_side(old_tiling_rect_over_tiles.x(), | 330 gfx::Rect top_rect(left, top, right - left, top_until - top); |
| 253 top, | 331 gfx::Rect bottom_rect( |
| 254 old_tiling_rect_over_tiles.width(), | 332 left, bottom_until, right - left, bottom - bottom_until); |
| 255 bottom - top); | 333 gfx::Rect exposed_rect( |
| 256 resize_invalidation.Union(bottom_side); | 334 left, exposed_top, right - left, exposed_top_until - exposed_top); |
| 335 resize_invalidation.Union(left_rect); | |
| 336 resize_invalidation.Union(right_rect); | |
| 337 resize_invalidation.Union(top_rect); | |
| 338 resize_invalidation.Union(bottom_rect); | |
| 339 resize_invalidation.Union(exposed_rect); | |
| 257 } | 340 } |
| 258 } | 341 } |
| 259 | 342 |
| 260 Region invalidation_expanded_to_full_tiles; | 343 Region invalidation_expanded_to_full_tiles; |
| 261 for (Region::Iterator i(*invalidation); i.has_rect(); i.next()) { | 344 for (Region::Iterator i(*invalidation); i.has_rect(); i.next()) { |
| 262 gfx::Rect invalid_rect = i.rect(); | 345 gfx::Rect invalid_rect = i.rect(); |
| 263 | 346 |
| 264 // Expand invalidation that is outside tiles that intersect the interest | 347 // Expand invalidation that is outside tiles that intersect the interest |
| 265 // rect. These tiles are no longer valid and should be considerered fully | 348 // rect. These tiles are no longer valid and should be considerered fully |
| 266 // invalid, so we can know to not keep around raster tiles that intersect | 349 // invalid, so we can know to not keep around raster tiles that intersect |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 } | 484 } |
| 402 | 485 |
| 403 void PicturePile::SetEmptyBounds() { | 486 void PicturePile::SetEmptyBounds() { |
| 404 tiling_.SetTilingSize(gfx::Size()); | 487 tiling_.SetTilingSize(gfx::Size()); |
| 405 picture_map_.clear(); | 488 picture_map_.clear(); |
| 406 has_any_recordings_ = false; | 489 has_any_recordings_ = false; |
| 407 recorded_viewport_ = gfx::Rect(); | 490 recorded_viewport_ = gfx::Rect(); |
| 408 } | 491 } |
| 409 | 492 |
| 410 } // namespace cc | 493 } // namespace cc |
| OLD | NEW |