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/point_conversions.h" | 9 #include "ui/gfx/point_conversions.h" |
9 #include "ui/gfx/rect_conversions.h" | 10 #include "ui/gfx/rect_conversions.h" |
10 #include "ui/gfx/safe_integer_conversions.h" | 11 #include "ui/gfx/safe_integer_conversions.h" |
11 #include "ui/gfx/size_conversions.h" | 12 #include "ui/gfx/size_conversions.h" |
12 | 13 |
13 namespace cc { | 14 namespace cc { |
14 | 15 |
15 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 16 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
16 float contents_scale, | 17 float contents_scale, |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 gfx::Size last_layer_bounds, | 329 gfx::Size last_layer_bounds, |
329 gfx::Size current_layer_bounds, | 330 gfx::Size current_layer_bounds, |
330 gfx::Size last_layer_content_bounds, | 331 gfx::Size last_layer_content_bounds, |
331 gfx::Size current_layer_content_bounds, | 332 gfx::Size current_layer_content_bounds, |
332 float last_layer_contents_scale, | 333 float last_layer_contents_scale, |
333 float current_layer_contents_scale, | 334 float current_layer_contents_scale, |
334 const gfx::Transform& last_screen_transform, | 335 const gfx::Transform& last_screen_transform, |
335 const gfx::Transform& current_screen_transform, | 336 const gfx::Transform& current_screen_transform, |
336 int current_source_frame_number, | 337 int current_source_frame_number, |
337 double current_frame_time) { | 338 double current_frame_time) { |
| 339 TRACE_EVENT0("cc", "PictureLayerTiling::UpdateTilePriorities"); |
338 gfx::Rect content_rect = ContentRect(); | 340 gfx::Rect content_rect = ContentRect(); |
339 if (content_rect.IsEmpty()) | 341 if (content_rect.IsEmpty()) |
340 return; | 342 return; |
341 | 343 |
342 bool first_update_in_new_source_frame = | 344 bool first_update_in_new_source_frame = |
343 current_source_frame_number != last_source_frame_number_; | 345 current_source_frame_number != last_source_frame_number_; |
344 | 346 |
345 bool first_update_in_new_impl_frame = | 347 bool first_update_in_new_impl_frame = |
346 current_frame_time != last_impl_frame_time_; | 348 current_frame_time != last_impl_frame_time_; |
347 | 349 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | 420 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); |
419 gfx::RectF current_screen_rect = gfx::ScaleRect( | 421 gfx::RectF current_screen_rect = gfx::ScaleRect( |
420 tile_bounds, | 422 tile_bounds, |
421 current_scale, | 423 current_scale, |
422 current_scale) + current_offset; | 424 current_scale) + current_offset; |
423 gfx::RectF last_screen_rect = gfx::ScaleRect( | 425 gfx::RectF last_screen_rect = gfx::ScaleRect( |
424 tile_bounds, | 426 tile_bounds, |
425 last_scale, | 427 last_scale, |
426 last_scale) + last_offset; | 428 last_scale) + last_offset; |
427 | 429 |
| 430 float distance_to_visible_in_pixels = |
| 431 TilePriority::manhattanDistance(current_screen_rect, view_rect); |
| 432 |
428 float time_to_visible_in_seconds = | 433 float time_to_visible_in_seconds = |
429 TilePriority::TimeForBoundsToIntersect( | 434 TilePriority::TimeForBoundsToIntersect( |
430 last_screen_rect, current_screen_rect, time_delta, view_rect); | 435 last_screen_rect, current_screen_rect, time_delta, view_rect); |
431 float distance_to_visible_in_pixels = | |
432 TilePriority::manhattanDistance(current_screen_rect, view_rect); | |
433 | |
434 TilePriority priority( | 436 TilePriority priority( |
435 resolution_, | 437 resolution_, |
436 time_to_visible_in_seconds, | 438 time_to_visible_in_seconds, |
437 distance_to_visible_in_pixels); | 439 distance_to_visible_in_pixels); |
438 tile->set_priority(tree, priority); | 440 tile->set_priority(tree, priority); |
439 } | 441 } |
440 } | 442 } |
441 else | 443 else |
442 { | 444 { |
443 for (TilingData::Iterator iter(&tiling_data_, inflated_rect); | 445 for (TilingData::Iterator iter(&tiling_data_, inflated_rect); |
(...skipping 11 matching lines...) Expand all Loading... |
455 current_scale); | 457 current_scale); |
456 gfx::RectF current_screen_rect = MathUtil::mapClippedRect( | 458 gfx::RectF current_screen_rect = MathUtil::mapClippedRect( |
457 current_screen_transform, current_layer_content_rect); | 459 current_screen_transform, current_layer_content_rect); |
458 gfx::RectF last_layer_content_rect = gfx::ScaleRect( | 460 gfx::RectF last_layer_content_rect = gfx::ScaleRect( |
459 tile_bounds, | 461 tile_bounds, |
460 last_scale, | 462 last_scale, |
461 last_scale); | 463 last_scale); |
462 gfx::RectF last_screen_rect = MathUtil::mapClippedRect( | 464 gfx::RectF last_screen_rect = MathUtil::mapClippedRect( |
463 last_screen_transform, last_layer_content_rect); | 465 last_screen_transform, last_layer_content_rect); |
464 | 466 |
| 467 float distance_to_visible_in_pixels = |
| 468 TilePriority::manhattanDistance(current_screen_rect, view_rect); |
| 469 |
465 float time_to_visible_in_seconds = | 470 float time_to_visible_in_seconds = |
466 TilePriority::TimeForBoundsToIntersect( | 471 TilePriority::TimeForBoundsToIntersect( |
467 last_screen_rect, current_screen_rect, time_delta, view_rect); | 472 last_screen_rect, current_screen_rect, time_delta, view_rect); |
468 float distance_to_visible_in_pixels = | |
469 TilePriority::manhattanDistance(current_screen_rect, view_rect); | |
470 | 473 |
471 TilePriority priority( | 474 TilePriority priority( |
472 resolution_, | 475 resolution_, |
473 time_to_visible_in_seconds, | 476 time_to_visible_in_seconds, |
474 distance_to_visible_in_pixels); | 477 distance_to_visible_in_pixels); |
475 tile->set_priority(tree, priority); | 478 tile->set_priority(tree, priority); |
476 } | 479 } |
477 } | 480 } |
478 | 481 |
479 last_source_frame_number_ = current_source_frame_number; | 482 last_source_frame_number_ = current_source_frame_number; |
480 last_impl_frame_time_ = current_frame_time; | 483 last_impl_frame_time_ = current_frame_time; |
481 } | 484 } |
482 | 485 |
483 void PictureLayerTiling::DidBecomeActive() { | 486 void PictureLayerTiling::DidBecomeActive() { |
484 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 487 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
485 it->second->set_priority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); | 488 it->second->set_priority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); |
486 it->second->set_priority(PENDING_TREE, TilePriority()); | 489 it->second->set_priority(PENDING_TREE, TilePriority()); |
487 | 490 |
488 // Tile holds a ref onto a picture pile. If the tile never gets invalidated | 491 // Tile holds a ref onto a picture pile. If the tile never gets invalidated |
489 // and recreated, then that picture pile ref could exist indefinitely. To | 492 // and recreated, then that picture pile ref could exist indefinitely. To |
490 // prevent this, ask the client to update the pile to its own ref. This | 493 // prevent this, ask the client to update the pile to its own ref. This |
491 // will cause PicturePileImpls and their clones to get deleted once the | 494 // will cause PicturePileImpls and their clones to get deleted once the |
492 // corresponding PictureLayerImpl and any in flight raster jobs go out of | 495 // corresponding PictureLayerImpl and any in flight raster jobs go out of |
493 // scope. | 496 // scope. |
494 client_->UpdatePile(it->second); | 497 client_->UpdatePile(it->second); |
495 } | 498 } |
496 } | 499 } |
497 | 500 |
498 } // namespace cc | 501 } // namespace cc |
OLD | NEW |