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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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( |
423 const OcclusionTracker<LayerImpl>* occlusion_tracker) { | 423 const Occlusion& occlusion_in_content_space) { |
424 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTiles"); | 424 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTiles"); |
425 | 425 |
426 DoPostCommitInitializationIfNeeded(); | 426 DoPostCommitInitializationIfNeeded(); |
427 | 427 |
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(); | 428 visible_rect_for_tile_priority_ = visible_content_rect(); |
435 viewport_rect_for_tile_priority_ = | 429 viewport_rect_for_tile_priority_ = |
436 layer_tree_impl()->ViewportRectForTilePriority(); | 430 layer_tree_impl()->ViewportRectForTilePriority(); |
437 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 431 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
438 | 432 |
439 if (!CanHaveTilings()) { | 433 if (!CanHaveTilings()) { |
440 ideal_page_scale_ = 0.f; | 434 ideal_page_scale_ = 0.f; |
441 ideal_device_scale_ = 0.f; | 435 ideal_device_scale_ = 0.f; |
442 ideal_contents_scale_ = 0.f; | 436 ideal_contents_scale_ = 0.f; |
443 ideal_source_scale_ = 0.f; | 437 ideal_source_scale_ = 0.f; |
(...skipping 14 matching lines...) Expand all Loading... |
458 DCHECK(raster_device_scale_); | 452 DCHECK(raster_device_scale_); |
459 DCHECK(raster_source_scale_); | 453 DCHECK(raster_source_scale_); |
460 DCHECK(raster_contents_scale_); | 454 DCHECK(raster_contents_scale_); |
461 DCHECK(low_res_raster_contents_scale_); | 455 DCHECK(low_res_raster_contents_scale_); |
462 | 456 |
463 was_screen_space_transform_animating_ = | 457 was_screen_space_transform_animating_ = |
464 draw_properties().screen_space_transform_is_animating; | 458 draw_properties().screen_space_transform_is_animating; |
465 | 459 |
466 should_update_tile_priorities_ = true; | 460 should_update_tile_priorities_ = true; |
467 | 461 |
468 UpdateTilePriorities(occlusion_tracker); | 462 UpdateTilePriorities(occlusion_in_content_space); |
469 | 463 |
470 if (layer_tree_impl()->IsPendingTree()) | 464 if (layer_tree_impl()->IsPendingTree()) |
471 MarkVisibleResourcesAsRequired(); | 465 MarkVisibleResourcesAsRequired(); |
472 } | 466 } |
473 | 467 |
474 void PictureLayerImpl::UpdateTilePriorities( | 468 void PictureLayerImpl::UpdateTilePriorities( |
475 const OcclusionTracker<LayerImpl>* occlusion_tracker) { | 469 const Occlusion& occlusion_in_content_space) { |
476 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); | 470 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); |
477 | 471 |
478 double current_frame_time_in_seconds = | 472 double current_frame_time_in_seconds = |
479 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - | 473 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - |
480 base::TimeTicks()).InSecondsF(); | 474 base::TimeTicks()).InSecondsF(); |
481 | 475 |
482 bool tiling_needs_update = false; | 476 bool tiling_needs_update = false; |
483 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 477 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
484 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( | 478 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( |
485 current_frame_time_in_seconds)) { | 479 current_frame_time_in_seconds)) { |
486 tiling_needs_update = true; | 480 tiling_needs_update = true; |
487 break; | 481 break; |
488 } | 482 } |
489 } | 483 } |
490 if (!tiling_needs_update) | 484 if (!tiling_needs_update) |
491 return; | 485 return; |
492 | 486 |
493 gfx::Rect visible_rect_in_content_space( | 487 gfx::Rect visible_rect_in_content_space( |
494 GetViewportForTilePriorityInContentSpace()); | 488 GetViewportForTilePriorityInContentSpace()); |
495 visible_rect_in_content_space.Intersect(visible_content_rect()); | 489 visible_rect_in_content_space.Intersect(visible_content_rect()); |
496 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | 490 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( |
497 visible_rect_in_content_space, 1.f / contents_scale_x()); | 491 visible_rect_in_content_space, 1.f / contents_scale_x()); |
498 WhichTree tree = | 492 WhichTree tree = |
499 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 493 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
500 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 494 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
501 tilings_->tiling_at(i)->UpdateTilePriorities(tree, | 495 tilings_->tiling_at(i)->UpdateTilePriorities(tree, |
502 visible_layer_rect, | 496 visible_layer_rect, |
503 ideal_contents_scale_, | 497 ideal_contents_scale_, |
504 current_frame_time_in_seconds, | 498 current_frame_time_in_seconds, |
505 occlusion_tracker, | 499 occlusion_in_content_space); |
506 render_target(), | |
507 draw_transform()); | |
508 } | 500 } |
509 | 501 |
510 // Tile priorities were modified. | 502 // Tile priorities were modified. |
511 layer_tree_impl()->DidModifyTilePriorities(); | 503 layer_tree_impl()->DidModifyTilePriorities(); |
512 } | 504 } |
513 | 505 |
514 gfx::Rect PictureLayerImpl::GetViewportForTilePriorityInContentSpace() const { | 506 gfx::Rect PictureLayerImpl::GetViewportForTilePriorityInContentSpace() const { |
515 // If visible_rect_for_tile_priority_ is empty or | 507 // If visible_rect_for_tile_priority_ is empty or |
516 // viewport_rect_for_tile_priority_ is set to be different from the device | 508 // 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 | 509 // 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 | 741 // If this tree needs update draw properties, then the tiling will |
750 // get updated prior to drawing or activation. If this tree does not | 742 // 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 | 743 // need update draw properties, then its transforms are up to date and |
752 // we can create tiles for this tiling immediately. | 744 // we can create tiles for this tiling immediately. |
753 if (!layer_tree_impl()->needs_update_draw_properties() && | 745 if (!layer_tree_impl()->needs_update_draw_properties() && |
754 should_update_tile_priorities_) { | 746 should_update_tile_priorities_) { |
755 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking | 747 // 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 | 748 // 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 | 749 // to support occlusion tracking here, we need to dirty the draw properties |
758 // or save occlusion as a draw property. | 750 // or save occlusion as a draw property. |
759 UpdateTilePriorities(NULL); | 751 UpdateTilePriorities(Occlusion()); |
760 } | 752 } |
761 } | 753 } |
762 | 754 |
763 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 755 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
764 gfx::Rect content_rect(content_bounds()); | 756 gfx::Rect content_rect(content_bounds()); |
765 float scale = MaximumTilingContentsScale(); | 757 float scale = MaximumTilingContentsScale(); |
766 PictureLayerTilingSet::CoverageIterator iter( | 758 PictureLayerTilingSet::CoverageIterator iter( |
767 tilings_.get(), scale, content_rect, ideal_contents_scale_); | 759 tilings_.get(), scale, content_rect, ideal_contents_scale_); |
768 | 760 |
769 // Mask resource not ready yet. | 761 // Mask resource not ready yet. |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1766 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1775 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1767 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1776 return tiling_range.end - 1 - current_tiling_range_offset; | 1768 return tiling_range.end - 1 - current_tiling_range_offset; |
1777 } | 1769 } |
1778 } | 1770 } |
1779 NOTREACHED(); | 1771 NOTREACHED(); |
1780 return 0; | 1772 return 0; |
1781 } | 1773 } |
1782 | 1774 |
1783 } // namespace cc | 1775 } // namespace cc |
OLD | NEW |