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/picture_layer_tiling.h" | 5 #include "cc/picture_layer_tiling.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | |
| 7 #include "cc/math_util.h" | 8 #include "cc/math_util.h" |
| 8 #include "ui/gfx/rect_conversions.h" | 9 #include "ui/gfx/rect_conversions.h" |
| 9 #include "ui/gfx/size_conversions.h" | 10 #include "ui/gfx/size_conversions.h" |
| 10 | 11 |
| 11 namespace cc { | 12 namespace cc { |
| 12 | 13 |
| 13 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 14 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
| 14 float contents_scale, | 15 float contents_scale, |
| 15 gfx::Size tile_size) { | 16 gfx::Size tile_size) { |
| 16 return make_scoped_ptr(new PictureLayerTiling(contents_scale, tile_size)); | 17 return make_scoped_ptr(new PictureLayerTiling(contents_scale, tile_size)); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 } | 291 } |
| 291 | 292 |
| 292 void PictureLayerTiling::UpdateTilePriorities( | 293 void PictureLayerTiling::UpdateTilePriorities( |
| 293 WhichTree tree, | 294 WhichTree tree, |
| 294 const gfx::Size& device_viewport, | 295 const gfx::Size& device_viewport, |
| 295 float last_layer_contents_scale, | 296 float last_layer_contents_scale, |
| 296 float current_layer_contents_scale, | 297 float current_layer_contents_scale, |
| 297 const gfx::Transform& last_screen_transform, | 298 const gfx::Transform& last_screen_transform, |
| 298 const gfx::Transform& current_screen_transform, | 299 const gfx::Transform& current_screen_transform, |
| 299 double time_delta) { | 300 double time_delta) { |
| 301 TRACE_EVENT0("cc", "PictureLayerTiling::UpdateTilePriorities"); | |
| 300 gfx::Rect content_rect = ContentRect(); | 302 gfx::Rect content_rect = ContentRect(); |
| 301 if (content_rect.IsEmpty()) | 303 if (content_rect.IsEmpty()) |
| 302 return; | 304 return; |
| 303 | 305 |
| 304 gfx::Rect view_rect(gfx::Point(), device_viewport); | 306 gfx::Rect view_rect(gfx::Point(), device_viewport); |
| 305 float current_scale = current_layer_contents_scale / contents_scale_; | 307 float current_scale = current_layer_contents_scale / contents_scale_; |
| 306 float last_scale = last_layer_contents_scale / contents_scale_; | 308 float last_scale = last_layer_contents_scale / contents_scale_; |
| 307 | 309 |
| 308 if (last_screen_transform.IsIdentityOrTranslation() && | 310 if (last_screen_transform.IsIdentityOrTranslation() && |
| 309 current_screen_transform.IsIdentityOrTranslation()) | 311 current_screen_transform.IsIdentityOrTranslation()) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 324 gfx::Rect tile_bound = tiling_data_.TileBounds(key.first, key.second); | 326 gfx::Rect tile_bound = tiling_data_.TileBounds(key.first, key.second); |
| 325 gfx::RectF current_screen_rect = gfx::ScaleRect( | 327 gfx::RectF current_screen_rect = gfx::ScaleRect( |
| 326 tile_bound, | 328 tile_bound, |
| 327 current_scale, | 329 current_scale, |
| 328 current_scale) + current_offset; | 330 current_scale) + current_offset; |
| 329 gfx::RectF last_screen_rect = gfx::ScaleRect( | 331 gfx::RectF last_screen_rect = gfx::ScaleRect( |
| 330 tile_bound, | 332 tile_bound, |
| 331 last_scale, | 333 last_scale, |
| 332 last_scale) + last_offset; | 334 last_scale) + last_offset; |
| 333 | 335 |
| 336 priority.distance_to_visible_in_pixels = | |
|
enne (OOO)
2013/01/30 06:53:56
Please don't create unnecessary diff churn by movi
whunt
2013/01/30 21:07:33
This is a performance optimization.
enne (OOO)
2013/01/30 21:50:12
Could you explain?
| |
| 337 TilePriority::manhattanDistance(current_screen_rect, view_rect); | |
| 338 | |
| 334 priority.time_to_visible_in_seconds = | 339 priority.time_to_visible_in_seconds = |
| 335 TilePriority::TimeForBoundsToIntersect( | 340 TilePriority::TimeForBoundsToIntersect( |
| 336 last_screen_rect, current_screen_rect, time_delta, view_rect); | 341 last_screen_rect, current_screen_rect, time_delta, view_rect); |
| 337 | 342 |
| 338 priority.distance_to_visible_in_pixels = | |
| 339 TilePriority::manhattanDistance(current_screen_rect, view_rect); | |
| 340 it->second->set_priority(tree, priority); | 343 it->second->set_priority(tree, priority); |
| 341 } | 344 } |
| 342 } | 345 } |
| 343 else | 346 else |
| 344 { | 347 { |
| 345 for (TileMap::const_iterator it = tiles_.begin(); | 348 for (TileMap::const_iterator it = tiles_.begin(); |
| 346 it != tiles_.end(); ++it) { | 349 it != tiles_.end(); ++it) { |
| 347 TileMapKey key = it->first; | 350 TileMapKey key = it->first; |
| 348 TilePriority priority; | 351 TilePriority priority; |
| 349 priority.resolution = resolution_; | 352 priority.resolution = resolution_; |
| 350 | 353 |
| 351 gfx::Rect tile_bound = tiling_data_.TileBounds(key.first, key.second); | 354 gfx::Rect tile_bound = tiling_data_.TileBounds(key.first, key.second); |
| 352 gfx::RectF current_layer_content_rect = gfx::ScaleRect( | 355 gfx::RectF current_layer_content_rect = gfx::ScaleRect( |
| 353 tile_bound, | 356 tile_bound, |
| 354 current_scale, | 357 current_scale, |
| 355 current_scale); | 358 current_scale); |
| 356 gfx::RectF current_screen_rect = MathUtil::mapClippedRect( | 359 gfx::RectF current_screen_rect = MathUtil::mapClippedRect( |
| 357 current_screen_transform, current_layer_content_rect); | 360 current_screen_transform, current_layer_content_rect); |
| 358 gfx::RectF last_layer_content_rect = gfx::ScaleRect( | 361 gfx::RectF last_layer_content_rect = gfx::ScaleRect( |
| 359 tile_bound, | 362 tile_bound, |
| 360 last_scale, | 363 last_scale, |
| 361 last_scale); | 364 last_scale); |
| 362 gfx::RectF last_screen_rect = MathUtil::mapClippedRect( | 365 gfx::RectF last_screen_rect = MathUtil::mapClippedRect( |
| 363 last_screen_transform, last_layer_content_rect); | 366 last_screen_transform, last_layer_content_rect); |
| 364 | 367 |
| 368 priority.distance_to_visible_in_pixels = | |
| 369 TilePriority::manhattanDistance(current_screen_rect, view_rect); | |
| 370 | |
| 365 priority.time_to_visible_in_seconds = | 371 priority.time_to_visible_in_seconds = |
| 366 TilePriority::TimeForBoundsToIntersect( | 372 TilePriority::TimeForBoundsToIntersect( |
| 367 last_screen_rect, current_screen_rect, time_delta, view_rect); | 373 last_screen_rect, current_screen_rect, time_delta, view_rect); |
| 368 | 374 |
| 369 priority.distance_to_visible_in_pixels = | |
| 370 TilePriority::manhattanDistance(current_screen_rect, view_rect); | |
| 371 it->second->set_priority(tree, priority); | 375 it->second->set_priority(tree, priority); |
| 372 } | 376 } |
| 373 } | 377 } |
| 374 } | 378 } |
| 375 | 379 |
| 376 void PictureLayerTiling::DidBecomeActive() { | 380 void PictureLayerTiling::DidBecomeActive() { |
| 377 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 381 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 378 it->second->set_priority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); | 382 it->second->set_priority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); |
| 379 it->second->set_priority(PENDING_TREE, TilePriority()); | 383 it->second->set_priority(PENDING_TREE, TilePriority()); |
| 380 | 384 |
| 381 // Tile holds a ref onto a picture pile. If the tile never gets invalidated | 385 // Tile holds a ref onto a picture pile. If the tile never gets invalidated |
| 382 // and recreated, then that picture pile ref could exist indefinitely. To | 386 // and recreated, then that picture pile ref could exist indefinitely. To |
| 383 // prevent this, ask the client to update the pile to its own ref. This | 387 // prevent this, ask the client to update the pile to its own ref. This |
| 384 // will cause PicturePileImpls and their clones to get deleted once the | 388 // will cause PicturePileImpls and their clones to get deleted once the |
| 385 // corresponding PictureLayerImpl and any in flight raster jobs go out of | 389 // corresponding PictureLayerImpl and any in flight raster jobs go out of |
| 386 // scope. | 390 // scope. |
| 387 client_->UpdatePile(it->second); | 391 client_->UpdatePile(it->second); |
| 388 } | 392 } |
| 389 } | 393 } |
| 390 | 394 |
| 391 } // namespace cc | 395 } // namespace cc |
| OLD | NEW |