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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 // TODO(danakj): We should always get an occlusion tracker when we are using | 407 // TODO(danakj): We should always get an occlusion tracker when we are using |
408 // occlusion, so update this check when we don't use a pending tree in the | 408 // occlusion, so update this check when we don't use a pending tree in the |
409 // browser compositor. | 409 // browser compositor. |
410 DCHECK(!occlusion_tracker || | 410 DCHECK(!occlusion_tracker || |
411 layer_tree_impl()->settings().use_occlusion_for_tile_prioritization); | 411 layer_tree_impl()->settings().use_occlusion_for_tile_prioritization); |
412 | 412 |
413 // Transforms and viewport are invalid for tile management inside a | 413 // Transforms and viewport are invalid for tile management inside a |
414 // resourceless software draw, so don't update them. | 414 // resourceless software draw, so don't update them. |
415 if (!layer_tree_impl()->resourceless_software_draw()) { | 415 if (!layer_tree_impl()->resourceless_software_draw()) { |
416 visible_rect_for_tile_priority_ = visible_content_rect(); | 416 visible_rect_for_tile_priority_ = visible_content_rect(); |
417 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 417 viewport_rect_for_tile_priority_ = |
| 418 layer_tree_impl()->ViewportRectForTilePriority(); |
418 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 419 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
419 } | 420 } |
420 | 421 |
421 if (!CanHaveTilings()) { | 422 if (!CanHaveTilings()) { |
422 ideal_page_scale_ = 0.f; | 423 ideal_page_scale_ = 0.f; |
423 ideal_device_scale_ = 0.f; | 424 ideal_device_scale_ = 0.f; |
424 ideal_contents_scale_ = 0.f; | 425 ideal_contents_scale_ = 0.f; |
425 ideal_source_scale_ = 0.f; | 426 ideal_source_scale_ = 0.f; |
426 SanityCheckTilingState(); | 427 SanityCheckTilingState(); |
427 return; | 428 return; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 466 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
466 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( | 467 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( |
467 current_frame_time_in_seconds)) { | 468 current_frame_time_in_seconds)) { |
468 tiling_needs_update = true; | 469 tiling_needs_update = true; |
469 break; | 470 break; |
470 } | 471 } |
471 } | 472 } |
472 if (!tiling_needs_update) | 473 if (!tiling_needs_update) |
473 return; | 474 return; |
474 | 475 |
475 // Use visible_content_rect, unless it's empty. If it's empty, then | 476 // If visible_rect_for_tile_priority_ is empty or |
476 // try to inverse project the viewport into layer space and use that. | 477 // viewport_rect_for_tile_priority_ is set to be different from the device |
| 478 // viewport, try to inverse project the viewport into layer space and use |
| 479 // that. Otherwise just use visible_rect_for_tile_priority_ |
477 gfx::Rect visible_rect_in_content_space = visible_rect_for_tile_priority_; | 480 gfx::Rect visible_rect_in_content_space = visible_rect_for_tile_priority_; |
478 if (visible_rect_in_content_space.IsEmpty()) { | 481 if (visible_rect_in_content_space.IsEmpty() || |
479 gfx::Transform screen_to_layer(gfx::Transform::kSkipInitialization); | 482 layer_tree_impl()->DeviceViewport() != viewport_rect_for_tile_priority_) { |
480 if (screen_space_transform_for_tile_priority_.GetInverse( | 483 gfx::Transform view_to_layer(gfx::Transform::kSkipInitialization); |
481 &screen_to_layer)) { | 484 |
| 485 if (screen_space_transform_for_tile_priority_.GetInverse(&view_to_layer)) { |
| 486 // Transform from view space to content space. |
482 visible_rect_in_content_space = | 487 visible_rect_in_content_space = |
483 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 488 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
484 screen_to_layer, gfx::Rect(viewport_size_for_tile_priority_))); | 489 view_to_layer, viewport_rect_for_tile_priority_)); |
| 490 |
485 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); | 491 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); |
486 } | 492 } |
487 } | 493 } |
488 | 494 |
489 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | 495 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( |
490 visible_rect_in_content_space, 1.f / contents_scale_x()); | 496 visible_rect_in_content_space, 1.f / contents_scale_x()); |
491 WhichTree tree = | 497 WhichTree tree = |
492 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 498 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
493 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 499 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
494 tilings_->tiling_at(i)->UpdateTilePriorities(tree, | 500 tilings_->tiling_at(i)->UpdateTilePriorities(tree, |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 return iterator_index_ < iterators_.size(); | 1687 return iterator_index_ < iterators_.size(); |
1682 } | 1688 } |
1683 | 1689 |
1684 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1690 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1685 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1691 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1686 return it->get_type() == iteration_stage_ && | 1692 return it->get_type() == iteration_stage_ && |
1687 (**it)->required_for_activation() == required_for_activation_; | 1693 (**it)->required_for_activation() == required_for_activation_; |
1688 } | 1694 } |
1689 | 1695 |
1690 } // namespace cc | 1696 } // namespace cc |
OLD | NEW |