| 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 "base/debug/trace_event.h" |
| 8 #include "cc/math_util.h" | 8 #include "cc/math_util.h" |
| 9 #include "ui/gfx/point_conversions.h" | 9 #include "ui/gfx/point_conversions.h" |
| 10 #include "ui/gfx/rect_conversions.h" | 10 #include "ui/gfx/rect_conversions.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 const gfx::RectF viewport_in_layer_space, | 333 const gfx::RectF viewport_in_layer_space, |
| 334 gfx::Size last_layer_bounds, | 334 gfx::Size last_layer_bounds, |
| 335 gfx::Size current_layer_bounds, | 335 gfx::Size current_layer_bounds, |
| 336 gfx::Size last_layer_content_bounds, | 336 gfx::Size last_layer_content_bounds, |
| 337 gfx::Size current_layer_content_bounds, | 337 gfx::Size current_layer_content_bounds, |
| 338 float last_layer_contents_scale, | 338 float last_layer_contents_scale, |
| 339 float current_layer_contents_scale, | 339 float current_layer_contents_scale, |
| 340 const gfx::Transform& last_screen_transform, | 340 const gfx::Transform& last_screen_transform, |
| 341 const gfx::Transform& current_screen_transform, | 341 const gfx::Transform& current_screen_transform, |
| 342 int current_source_frame_number, | 342 int current_source_frame_number, |
| 343 double current_frame_time) { | 343 double current_frame_time, |
| 344 bool store_screen_space_quads_on_tiles) { |
| 344 TRACE_EVENT0("cc", "PictureLayerTiling::UpdateTilePriorities"); | 345 TRACE_EVENT0("cc", "PictureLayerTiling::UpdateTilePriorities"); |
| 345 if (ContentRect().IsEmpty()) | 346 if (ContentRect().IsEmpty()) |
| 346 return; | 347 return; |
| 347 | 348 |
| 348 bool first_update_in_new_source_frame = | 349 bool first_update_in_new_source_frame = |
| 349 current_source_frame_number != last_source_frame_number_; | 350 current_source_frame_number != last_source_frame_number_; |
| 350 | 351 |
| 351 bool first_update_in_new_impl_frame = | 352 bool first_update_in_new_impl_frame = |
| 352 current_frame_time != last_impl_frame_time_; | 353 current_frame_time != last_impl_frame_time_; |
| 353 | 354 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 float distance_to_visible_in_pixels = | 437 float distance_to_visible_in_pixels = |
| 437 TilePriority::manhattanDistance(current_screen_rect, view_rect); | 438 TilePriority::manhattanDistance(current_screen_rect, view_rect); |
| 438 | 439 |
| 439 float time_to_visible_in_seconds = | 440 float time_to_visible_in_seconds = |
| 440 TilePriority::TimeForBoundsToIntersect( | 441 TilePriority::TimeForBoundsToIntersect( |
| 441 last_screen_rect, current_screen_rect, time_delta, view_rect); | 442 last_screen_rect, current_screen_rect, time_delta, view_rect); |
| 442 TilePriority priority( | 443 TilePriority priority( |
| 443 resolution_, | 444 resolution_, |
| 444 time_to_visible_in_seconds, | 445 time_to_visible_in_seconds, |
| 445 distance_to_visible_in_pixels); | 446 distance_to_visible_in_pixels); |
| 447 if (store_screen_space_quads_on_tiles) |
| 448 priority.set_current_screen_quad(gfx::QuadF(current_screen_rect)); |
| 446 tile->set_priority(tree, priority); | 449 tile->set_priority(tree, priority); |
| 447 } | 450 } |
| 448 } | 451 } else { |
| 449 else | |
| 450 { | |
| 451 for (TilingData::Iterator iter(&tiling_data_, inflated_rect); | 452 for (TilingData::Iterator iter(&tiling_data_, inflated_rect); |
| 452 iter; ++iter) { | 453 iter; ++iter) { |
| 453 TileMap::iterator find = tiles_.find(iter.index()); | 454 TileMap::iterator find = tiles_.find(iter.index()); |
| 454 if (find == tiles_.end()) | 455 if (find == tiles_.end()) |
| 455 continue; | 456 continue; |
| 456 Tile* tile = find->second.get(); | 457 Tile* tile = find->second.get(); |
| 457 | 458 |
| 458 gfx::Rect tile_bounds = | 459 gfx::Rect tile_bounds = |
| 459 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | 460 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); |
| 460 gfx::RectF current_layer_content_rect = gfx::ScaleRect( | 461 gfx::RectF current_layer_content_rect = gfx::ScaleRect( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 474 TilePriority::manhattanDistance(current_screen_rect, view_rect); | 475 TilePriority::manhattanDistance(current_screen_rect, view_rect); |
| 475 | 476 |
| 476 float time_to_visible_in_seconds = | 477 float time_to_visible_in_seconds = |
| 477 TilePriority::TimeForBoundsToIntersect( | 478 TilePriority::TimeForBoundsToIntersect( |
| 478 last_screen_rect, current_screen_rect, time_delta, view_rect); | 479 last_screen_rect, current_screen_rect, time_delta, view_rect); |
| 479 | 480 |
| 480 TilePriority priority( | 481 TilePriority priority( |
| 481 resolution_, | 482 resolution_, |
| 482 time_to_visible_in_seconds, | 483 time_to_visible_in_seconds, |
| 483 distance_to_visible_in_pixels); | 484 distance_to_visible_in_pixels); |
| 485 if (store_screen_space_quads_on_tiles) { |
| 486 bool clipped; |
| 487 priority.set_current_screen_quad( |
| 488 MathUtil::mapQuad(current_screen_transform, |
| 489 gfx::QuadF(current_layer_content_rect), |
| 490 clipped)); |
| 491 } |
| 484 tile->set_priority(tree, priority); | 492 tile->set_priority(tree, priority); |
| 485 } | 493 } |
| 486 } | 494 } |
| 487 | 495 |
| 488 last_source_frame_number_ = current_source_frame_number; | 496 last_source_frame_number_ = current_source_frame_number; |
| 489 last_impl_frame_time_ = current_frame_time; | 497 last_impl_frame_time_ = current_frame_time; |
| 490 } | 498 } |
| 491 | 499 |
| 492 void PictureLayerTiling::DidBecomeActive() { | 500 void PictureLayerTiling::DidBecomeActive() { |
| 493 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 501 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 494 it->second->set_priority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); | 502 it->second->set_priority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); |
| 495 it->second->set_priority(PENDING_TREE, TilePriority()); | 503 it->second->set_priority(PENDING_TREE, TilePriority()); |
| 496 | 504 |
| 497 // Tile holds a ref onto a picture pile. If the tile never gets invalidated | 505 // Tile holds a ref onto a picture pile. If the tile never gets invalidated |
| 498 // and recreated, then that picture pile ref could exist indefinitely. To | 506 // and recreated, then that picture pile ref could exist indefinitely. To |
| 499 // prevent this, ask the client to update the pile to its own ref. This | 507 // prevent this, ask the client to update the pile to its own ref. This |
| 500 // will cause PicturePileImpls and their clones to get deleted once the | 508 // will cause PicturePileImpls and their clones to get deleted once the |
| 501 // corresponding PictureLayerImpl and any in flight raster jobs go out of | 509 // corresponding PictureLayerImpl and any in flight raster jobs go out of |
| 502 // scope. | 510 // scope. |
| 503 client_->UpdatePile(it->second); | 511 client_->UpdatePile(it->second); |
| 504 } | 512 } |
| 505 } | 513 } |
| 506 | 514 |
| 507 } // namespace cc | 515 } // namespace cc |
| OLD | NEW |