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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 // TODO(danakj): We should always get an occlusion tracker when we are using | 392 // TODO(danakj): We should always get an occlusion tracker when we are using |
393 // occlusion, so update this check when we don't use a pending tree in the | 393 // occlusion, so update this check when we don't use a pending tree in the |
394 // browser compositor. | 394 // browser compositor. |
395 DCHECK(!occlusion_tracker || | 395 DCHECK(!occlusion_tracker || |
396 layer_tree_impl()->settings().use_occlusion_for_tile_prioritization); | 396 layer_tree_impl()->settings().use_occlusion_for_tile_prioritization); |
397 | 397 |
398 // Transforms and viewport are invalid for tile management inside a | 398 // Transforms and viewport are invalid for tile management inside a |
399 // resourceless software draw, so don't update them. | 399 // resourceless software draw, so don't update them. |
400 if (!layer_tree_impl()->resourceless_software_draw()) { | 400 if (!layer_tree_impl()->resourceless_software_draw()) { |
401 visible_rect_for_tile_priority_ = visible_content_rect(); | 401 visible_rect_for_tile_priority_ = visible_content_rect(); |
402 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 402 viewport_rect_for_tile_priority_ = |
| 403 layer_tree_impl()->ViewportRectForTilePriority(); |
403 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 404 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
404 } | 405 } |
405 | 406 |
406 if (!CanHaveTilings()) { | 407 if (!CanHaveTilings()) { |
407 ideal_page_scale_ = 0.f; | 408 ideal_page_scale_ = 0.f; |
408 ideal_device_scale_ = 0.f; | 409 ideal_device_scale_ = 0.f; |
409 ideal_contents_scale_ = 0.f; | 410 ideal_contents_scale_ = 0.f; |
410 ideal_source_scale_ = 0.f; | 411 ideal_source_scale_ = 0.f; |
411 SanityCheckTilingState(); | 412 SanityCheckTilingState(); |
412 return; | 413 return; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 451 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
451 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( | 452 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( |
452 current_frame_time_in_seconds)) { | 453 current_frame_time_in_seconds)) { |
453 tiling_needs_update = true; | 454 tiling_needs_update = true; |
454 break; | 455 break; |
455 } | 456 } |
456 } | 457 } |
457 if (!tiling_needs_update) | 458 if (!tiling_needs_update) |
458 return; | 459 return; |
459 | 460 |
460 // Use visible_content_rect, unless it's empty. If it's empty, then | 461 // If visible_rect_for_tile_priority_ is empty or |
461 // try to inverse project the viewport into layer space and use that. | 462 // LayerTreeImpl::ExternalTilingRect is set to be different from the device |
| 463 // viewport, try to inverse project the viewport into layer space and use |
| 464 // that. Otherwise just use visible_rect_for_tile_priority_ |
462 gfx::Rect visible_rect_in_content_space = visible_rect_for_tile_priority_; | 465 gfx::Rect visible_rect_in_content_space = visible_rect_for_tile_priority_; |
463 if (visible_rect_in_content_space.IsEmpty()) { | 466 if (visible_rect_in_content_space.IsEmpty() || |
464 gfx::Transform screen_to_layer(gfx::Transform::kSkipInitialization); | 467 layer_tree_impl()->DeviceViewport() != viewport_rect_for_tile_priority_) { |
465 if (screen_space_transform_for_tile_priority_.GetInverse( | 468 gfx::Transform view_to_layer(gfx::Transform::kSkipInitialization); |
466 &screen_to_layer)) { | 469 |
| 470 if (screen_space_transform_for_tile_priority_.GetInverse(&view_to_layer)) { |
| 471 // Transform from view space to content space. |
467 visible_rect_in_content_space = | 472 visible_rect_in_content_space = |
468 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 473 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
469 screen_to_layer, gfx::Rect(viewport_size_for_tile_priority_))); | 474 view_to_layer, viewport_rect_for_tile_priority_)); |
| 475 |
470 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); | 476 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); |
471 } | 477 } |
472 } | 478 } |
473 | 479 |
474 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | 480 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( |
475 visible_rect_in_content_space, 1.f / contents_scale_x()); | 481 visible_rect_in_content_space, 1.f / contents_scale_x()); |
476 WhichTree tree = | 482 WhichTree tree = |
477 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 483 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
478 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 484 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
479 tilings_->tiling_at(i)->UpdateTilePriorities(tree, | 485 tilings_->tiling_at(i)->UpdateTilePriorities(tree, |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1635 return iterator_index_ < iterators_.size(); | 1641 return iterator_index_ < iterators_.size(); |
1636 } | 1642 } |
1637 | 1643 |
1638 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1644 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1639 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1645 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1640 return it->get_type() == iteration_stage_ && | 1646 return it->get_type() == iteration_stage_ && |
1641 (**it)->required_for_activation() == required_for_activation_; | 1647 (**it)->required_for_activation() == required_for_activation_; |
1642 } | 1648 } |
1643 | 1649 |
1644 } // namespace cc | 1650 } // namespace cc |
OLD | NEW |