| 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 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 on_demand_missing_tile_count); | 412 on_demand_missing_tile_count); |
| 413 } | 413 } |
| 414 | 414 |
| 415 // Aggressively remove any tilings that are not seen to save memory. Note | 415 // Aggressively remove any tilings that are not seen to save memory. Note |
| 416 // that this is at the expense of doing cause more frequent re-painting. A | 416 // that this is at the expense of doing cause more frequent re-painting. A |
| 417 // better scheme would be to maintain a tighter visible_content_rect for the | 417 // better scheme would be to maintain a tighter visible_content_rect for the |
| 418 // finer tilings. | 418 // finer tilings. |
| 419 CleanUpTilingsOnActiveLayer(seen_tilings); | 419 CleanUpTilingsOnActiveLayer(seen_tilings); |
| 420 } | 420 } |
| 421 | 421 |
| 422 void PictureLayerImpl::UpdateTiles( | 422 void PictureLayerImpl::UpdateTiles(const Occlusion& occlusion_in_layer_space) { |
| 423 const OcclusionTracker<LayerImpl>* occlusion_tracker) { | |
| 424 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTiles"); | 423 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTiles"); |
| 425 | 424 |
| 426 DoPostCommitInitializationIfNeeded(); | 425 DoPostCommitInitializationIfNeeded(); |
| 427 | 426 |
| 428 // TODO(danakj): We should always get an occlusion tracker when we are using | |
| 429 // occlusion, so update this check when we don't use a pending tree in the | |
| 430 // browser compositor. | |
| 431 DCHECK(!occlusion_tracker || | |
| 432 layer_tree_impl()->settings().use_occlusion_for_tile_prioritization); | |
| 433 | |
| 434 visible_rect_for_tile_priority_ = visible_content_rect(); | 427 visible_rect_for_tile_priority_ = visible_content_rect(); |
| 435 viewport_rect_for_tile_priority_ = | 428 viewport_rect_for_tile_priority_ = |
| 436 layer_tree_impl()->ViewportRectForTilePriority(); | 429 layer_tree_impl()->ViewportRectForTilePriority(); |
| 437 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 430 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
| 438 | 431 |
| 439 if (!CanHaveTilings()) { | 432 if (!CanHaveTilings()) { |
| 440 ideal_page_scale_ = 0.f; | 433 ideal_page_scale_ = 0.f; |
| 441 ideal_device_scale_ = 0.f; | 434 ideal_device_scale_ = 0.f; |
| 442 ideal_contents_scale_ = 0.f; | 435 ideal_contents_scale_ = 0.f; |
| 443 ideal_source_scale_ = 0.f; | 436 ideal_source_scale_ = 0.f; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 458 DCHECK(raster_device_scale_); | 451 DCHECK(raster_device_scale_); |
| 459 DCHECK(raster_source_scale_); | 452 DCHECK(raster_source_scale_); |
| 460 DCHECK(raster_contents_scale_); | 453 DCHECK(raster_contents_scale_); |
| 461 DCHECK(low_res_raster_contents_scale_); | 454 DCHECK(low_res_raster_contents_scale_); |
| 462 | 455 |
| 463 was_screen_space_transform_animating_ = | 456 was_screen_space_transform_animating_ = |
| 464 draw_properties().screen_space_transform_is_animating; | 457 draw_properties().screen_space_transform_is_animating; |
| 465 | 458 |
| 466 should_update_tile_priorities_ = true; | 459 should_update_tile_priorities_ = true; |
| 467 | 460 |
| 468 UpdateTilePriorities(occlusion_tracker); | 461 UpdateTilePriorities(occlusion_in_layer_space); |
| 469 | 462 |
| 470 if (layer_tree_impl()->IsPendingTree()) | 463 if (layer_tree_impl()->IsPendingTree()) |
| 471 MarkVisibleResourcesAsRequired(); | 464 MarkVisibleResourcesAsRequired(); |
| 472 } | 465 } |
| 473 | 466 |
| 474 void PictureLayerImpl::UpdateTilePriorities( | 467 void PictureLayerImpl::UpdateTilePriorities( |
| 475 const OcclusionTracker<LayerImpl>* occlusion_tracker) { | 468 const Occlusion& occlusion_in_layer_space) { |
| 476 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); | 469 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); |
| 477 | 470 |
| 478 double current_frame_time_in_seconds = | 471 double current_frame_time_in_seconds = |
| 479 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - | 472 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - |
| 480 base::TimeTicks()).InSecondsF(); | 473 base::TimeTicks()).InSecondsF(); |
| 481 | 474 |
| 482 bool tiling_needs_update = false; | 475 bool tiling_needs_update = false; |
| 483 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 476 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 484 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( | 477 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( |
| 485 current_frame_time_in_seconds)) { | 478 current_frame_time_in_seconds)) { |
| 486 tiling_needs_update = true; | 479 tiling_needs_update = true; |
| 487 break; | 480 break; |
| 488 } | 481 } |
| 489 } | 482 } |
| 490 if (!tiling_needs_update) | 483 if (!tiling_needs_update) |
| 491 return; | 484 return; |
| 492 | 485 |
| 493 gfx::Rect visible_rect_in_content_space( | 486 gfx::Rect visible_rect_in_content_space( |
| 494 GetViewportForTilePriorityInContentSpace()); | 487 GetViewportForTilePriorityInContentSpace()); |
| 495 visible_rect_in_content_space.Intersect(visible_content_rect()); | 488 visible_rect_in_content_space.Intersect(visible_content_rect()); |
| 496 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | 489 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( |
| 497 visible_rect_in_content_space, 1.f / contents_scale_x()); | 490 visible_rect_in_content_space, 1.f / contents_scale_x()); |
| 498 WhichTree tree = | 491 WhichTree tree = |
| 499 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 492 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
| 500 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 493 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 501 tilings_->tiling_at(i)->UpdateTilePriorities(tree, | 494 tilings_->tiling_at(i)->UpdateTilePriorities(tree, |
| 502 visible_layer_rect, | 495 visible_layer_rect, |
| 503 ideal_contents_scale_, | 496 ideal_contents_scale_, |
| 504 current_frame_time_in_seconds, | 497 current_frame_time_in_seconds, |
| 505 occlusion_tracker, | 498 occlusion_in_layer_space); |
| 506 render_target(), | |
| 507 draw_transform()); | |
| 508 } | 499 } |
| 509 | 500 |
| 510 // Tile priorities were modified. | 501 // Tile priorities were modified. |
| 511 layer_tree_impl()->DidModifyTilePriorities(); | 502 layer_tree_impl()->DidModifyTilePriorities(); |
| 512 } | 503 } |
| 513 | 504 |
| 514 gfx::Rect PictureLayerImpl::GetViewportForTilePriorityInContentSpace() const { | 505 gfx::Rect PictureLayerImpl::GetViewportForTilePriorityInContentSpace() const { |
| 515 // If visible_rect_for_tile_priority_ is empty or | 506 // If visible_rect_for_tile_priority_ is empty or |
| 516 // viewport_rect_for_tile_priority_ is set to be different from the device | 507 // viewport_rect_for_tile_priority_ is set to be different from the device |
| 517 // viewport, try to inverse project the viewport into layer space and use | 508 // viewport, try to inverse project the viewport into layer space and use |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 // If this tree needs update draw properties, then the tiling will | 740 // If this tree needs update draw properties, then the tiling will |
| 750 // get updated prior to drawing or activation. If this tree does not | 741 // get updated prior to drawing or activation. If this tree does not |
| 751 // need update draw properties, then its transforms are up to date and | 742 // need update draw properties, then its transforms are up to date and |
| 752 // we can create tiles for this tiling immediately. | 743 // we can create tiles for this tiling immediately. |
| 753 if (!layer_tree_impl()->needs_update_draw_properties() && | 744 if (!layer_tree_impl()->needs_update_draw_properties() && |
| 754 should_update_tile_priorities_) { | 745 should_update_tile_priorities_) { |
| 755 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking | 746 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking |
| 756 // when we stop using the pending tree in the browser compositor. If we want | 747 // when we stop using the pending tree in the browser compositor. If we want |
| 757 // to support occlusion tracking here, we need to dirty the draw properties | 748 // to support occlusion tracking here, we need to dirty the draw properties |
| 758 // or save occlusion as a draw property. | 749 // or save occlusion as a draw property. |
| 759 UpdateTilePriorities(NULL); | 750 UpdateTilePriorities(Occlusion()); |
| 760 } | 751 } |
| 761 } | 752 } |
| 762 | 753 |
| 763 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 754 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
| 764 gfx::Rect content_rect(content_bounds()); | 755 gfx::Rect content_rect(content_bounds()); |
| 765 float scale = MaximumTilingContentsScale(); | 756 float scale = MaximumTilingContentsScale(); |
| 766 PictureLayerTilingSet::CoverageIterator iter( | 757 PictureLayerTilingSet::CoverageIterator iter( |
| 767 tilings_.get(), scale, content_rect, ideal_contents_scale_); | 758 tilings_.get(), scale, content_rect, ideal_contents_scale_); |
| 768 | 759 |
| 769 // Mask resource not ready yet. | 760 // Mask resource not ready yet. |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1761 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
| 1771 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1762 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
| 1772 return tiling_range.end - 1 - current_tiling_range_offset; | 1763 return tiling_range.end - 1 - current_tiling_range_offset; |
| 1773 } | 1764 } |
| 1774 } | 1765 } |
| 1775 NOTREACHED(); | 1766 NOTREACHED(); |
| 1776 return 0; | 1767 return 0; |
| 1777 } | 1768 } |
| 1778 | 1769 |
| 1779 } // namespace cc | 1770 } // namespace cc |
| OLD | NEW |