| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 ideal_page_scale_(0.f), | 54 ideal_page_scale_(0.f), |
| 55 ideal_device_scale_(0.f), | 55 ideal_device_scale_(0.f), |
| 56 ideal_source_scale_(0.f), | 56 ideal_source_scale_(0.f), |
| 57 ideal_contents_scale_(0.f), | 57 ideal_contents_scale_(0.f), |
| 58 raster_page_scale_(0.f), | 58 raster_page_scale_(0.f), |
| 59 raster_device_scale_(0.f), | 59 raster_device_scale_(0.f), |
| 60 raster_source_scale_(0.f), | 60 raster_source_scale_(0.f), |
| 61 raster_contents_scale_(0.f), | 61 raster_contents_scale_(0.f), |
| 62 low_res_raster_contents_scale_(0.f), | 62 low_res_raster_contents_scale_(0.f), |
| 63 raster_source_scale_is_fixed_(false), | 63 raster_source_scale_is_fixed_(false), |
| 64 was_animating_transform_to_screen_(false), | 64 was_screen_space_transform_animating_(false), |
| 65 needs_post_commit_initialization_(true), | 65 needs_post_commit_initialization_(true), |
| 66 should_update_tile_priorities_(false) { | 66 should_update_tile_priorities_(false) { |
| 67 layer_tree_impl()->RegisterPictureLayerImpl(this); | 67 layer_tree_impl()->RegisterPictureLayerImpl(this); |
| 68 } | 68 } |
| 69 | 69 |
| 70 PictureLayerImpl::~PictureLayerImpl() { | 70 PictureLayerImpl::~PictureLayerImpl() { |
| 71 layer_tree_impl()->UnregisterPictureLayerImpl(this); | 71 layer_tree_impl()->UnregisterPictureLayerImpl(this); |
| 72 } | 72 } |
| 73 | 73 |
| 74 const char* PictureLayerImpl::LayerTypeAsString() const { | 74 const char* PictureLayerImpl::LayerTypeAsString() const { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 on_demand_missing_tile_count); | 380 on_demand_missing_tile_count); |
| 381 } | 381 } |
| 382 | 382 |
| 383 // Aggressively remove any tilings that are not seen to save memory. Note | 383 // Aggressively remove any tilings that are not seen to save memory. Note |
| 384 // that this is at the expense of doing cause more frequent re-painting. A | 384 // that this is at the expense of doing cause more frequent re-painting. A |
| 385 // better scheme would be to maintain a tighter visible_content_rect for the | 385 // better scheme would be to maintain a tighter visible_content_rect for the |
| 386 // finer tilings. | 386 // finer tilings. |
| 387 CleanUpTilingsOnActiveLayer(seen_tilings); | 387 CleanUpTilingsOnActiveLayer(seen_tilings); |
| 388 } | 388 } |
| 389 | 389 |
| 390 void PictureLayerImpl::UpdateTilePriorities() { | 390 void PictureLayerImpl::UpdateTiles() { |
| 391 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); | 391 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTiles"); |
| 392 | 392 |
| 393 DoPostCommitInitializationIfNeeded(); | 393 DoPostCommitInitializationIfNeeded(); |
| 394 | 394 |
| 395 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { | 395 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { |
| 396 visible_rect_for_tile_priority_ = visible_content_rect(); | 396 visible_rect_for_tile_priority_ = visible_content_rect(); |
| 397 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 397 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); |
| 398 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 398 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
| 399 } | 399 } |
| 400 | 400 |
| 401 if (!CanHaveTilings()) { | 401 if (!CanHaveTilings()) { |
| 402 ideal_page_scale_ = 0.f; | 402 ideal_page_scale_ = 0.f; |
| 403 ideal_device_scale_ = 0.f; | 403 ideal_device_scale_ = 0.f; |
| 404 ideal_contents_scale_ = 0.f; | 404 ideal_contents_scale_ = 0.f; |
| 405 ideal_source_scale_ = 0.f; | 405 ideal_source_scale_ = 0.f; |
| 406 SanityCheckTilingState(); | 406 SanityCheckTilingState(); |
| 407 return; | 407 return; |
| 408 } | 408 } |
| 409 | 409 |
| 410 UpdateIdealScales(); |
| 411 |
| 412 DCHECK(tilings_->num_tilings() > 0 || raster_contents_scale_ == 0.f) |
| 413 << "A layer with no tilings shouldn't have valid raster scales"; |
| 414 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) { |
| 415 RecalculateRasterScales(); |
| 416 AddTilingsForRasterScale(); |
| 417 } |
| 418 |
| 419 DCHECK(raster_page_scale_); |
| 420 DCHECK(raster_device_scale_); |
| 421 DCHECK(raster_source_scale_); |
| 422 DCHECK(raster_contents_scale_); |
| 423 DCHECK(low_res_raster_contents_scale_); |
| 424 |
| 425 was_screen_space_transform_animating_ = |
| 426 draw_properties().screen_space_transform_is_animating; |
| 427 |
| 410 // TODO(sohanjg): Avoid needlessly update priorities when syncing to a | 428 // TODO(sohanjg): Avoid needlessly update priorities when syncing to a |
| 411 // non-updated tree which will then be updated immediately afterwards. | 429 // non-updated tree which will then be updated immediately afterwards. |
| 412 should_update_tile_priorities_ = true; | 430 should_update_tile_priorities_ = true; |
| 413 | 431 |
| 414 UpdateIdealScales(); | 432 UpdateTilePriorities(); |
| 415 ManageTilings(draw_properties().screen_space_transform_is_animating, | |
| 416 draw_properties().maximum_animation_contents_scale); | |
| 417 | 433 |
| 418 if (!tilings_->num_tilings()) | 434 if (layer_tree_impl()->IsPendingTree()) |
| 419 return; | 435 MarkVisibleResourcesAsRequired(); |
| 436 } |
| 437 |
| 438 void PictureLayerImpl::UpdateTilePriorities() { |
| 439 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); |
| 420 | 440 |
| 421 double current_frame_time_in_seconds = | 441 double current_frame_time_in_seconds = |
| 422 (layer_tree_impl()->CurrentFrameTimeTicks() - | 442 (layer_tree_impl()->CurrentFrameTimeTicks() - |
| 423 base::TimeTicks()).InSecondsF(); | 443 base::TimeTicks()).InSecondsF(); |
| 424 | 444 |
| 425 bool tiling_needs_update = false; | 445 bool tiling_needs_update = false; |
| 426 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 446 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 427 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( | 447 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( |
| 428 current_frame_time_in_seconds)) { | 448 current_frame_time_in_seconds)) { |
| 429 tiling_needs_update = true; | 449 tiling_needs_update = true; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 444 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 464 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 445 screen_to_layer, gfx::Rect(viewport_size_for_tile_priority_))); | 465 screen_to_layer, gfx::Rect(viewport_size_for_tile_priority_))); |
| 446 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); | 466 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); |
| 447 } | 467 } |
| 448 } | 468 } |
| 449 | 469 |
| 450 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | 470 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( |
| 451 visible_rect_in_content_space, 1.f / contents_scale_x()); | 471 visible_rect_in_content_space, 1.f / contents_scale_x()); |
| 452 WhichTree tree = | 472 WhichTree tree = |
| 453 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 473 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
| 454 // TODO(sohanjg): Passing MaximumContentsScale as layer contents scale | 474 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 455 // in UpdateTilePriorities is wrong and should be ideal contents scale. | 475 // TODO(sohanjg): Passing MaximumContentsScale as layer contents scale |
| 456 tilings_->UpdateTilePriorities(tree, | 476 // in UpdateTilePriorities is wrong and should be ideal contents scale. |
| 457 visible_layer_rect, | 477 tilings_->tiling_at(i)->UpdateTilePriorities(tree, |
| 458 MaximumTilingContentsScale(), | 478 visible_layer_rect, |
| 459 current_frame_time_in_seconds); | 479 MaximumTilingContentsScale(), |
| 460 | 480 current_frame_time_in_seconds); |
| 461 if (layer_tree_impl()->IsPendingTree()) | 481 } |
| 462 MarkVisibleResourcesAsRequired(); | |
| 463 | 482 |
| 464 // Tile priorities were modified. | 483 // Tile priorities were modified. |
| 465 layer_tree_impl()->DidModifyTilePriorities(); | 484 layer_tree_impl()->DidModifyTilePriorities(); |
| 466 } | 485 } |
| 467 | 486 |
| 468 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { | 487 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { |
| 469 if (layer_tree_impl()->IsActiveTree()) { | 488 if (layer_tree_impl()->IsActiveTree()) { |
| 470 gfx::RectF layer_damage_rect = | 489 gfx::RectF layer_damage_rect = |
| 471 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); | 490 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); |
| 472 AddDamageRect(layer_damage_rect); | 491 AddDamageRect(layer_damage_rect); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 iter->GetTileVersionForDrawing(); | 738 iter->GetTileVersionForDrawing(); |
| 720 if (!tile_version.IsReadyToDraw() || | 739 if (!tile_version.IsReadyToDraw() || |
| 721 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) | 740 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) |
| 722 return 0; | 741 return 0; |
| 723 | 742 |
| 724 return tile_version.get_resource_id(); | 743 return tile_version.get_resource_id(); |
| 725 } | 744 } |
| 726 | 745 |
| 727 void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { | 746 void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { |
| 728 DCHECK(layer_tree_impl()->IsPendingTree()); | 747 DCHECK(layer_tree_impl()->IsPendingTree()); |
| 729 DCHECK(!layer_tree_impl()->needs_update_draw_properties()); | |
| 730 DCHECK(ideal_contents_scale_); | 748 DCHECK(ideal_contents_scale_); |
| 731 DCHECK_GT(tilings_->num_tilings(), 0u); | 749 DCHECK_GT(tilings_->num_tilings(), 0u); |
| 732 | 750 |
| 733 // The goal of this function is to find the minimum set of tiles that need to | 751 // The goal of this function is to find the minimum set of tiles that need to |
| 734 // be ready to draw in order to activate without flashing content from a | 752 // be ready to draw in order to activate without flashing content from a |
| 735 // higher res on the active tree to a lower res on the pending tree. | 753 // higher res on the active tree to a lower res on the pending tree. |
| 736 | 754 |
| 737 // First, early out for layers with no visible content. | 755 // First, early out for layers with no visible content. |
| 738 if (visible_content_rect().IsEmpty()) | 756 if (visible_content_rect().IsEmpty()) |
| 739 return; | 757 return; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 namespace { | 951 namespace { |
| 934 | 952 |
| 935 inline float PositiveRatio(float float1, float float2) { | 953 inline float PositiveRatio(float float1, float float2) { |
| 936 DCHECK_GT(float1, 0); | 954 DCHECK_GT(float1, 0); |
| 937 DCHECK_GT(float2, 0); | 955 DCHECK_GT(float2, 0); |
| 938 return float1 > float2 ? float1 / float2 : float2 / float1; | 956 return float1 > float2 ? float1 / float2 : float2 / float1; |
| 939 } | 957 } |
| 940 | 958 |
| 941 } // namespace | 959 } // namespace |
| 942 | 960 |
| 943 void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen, | 961 void PictureLayerImpl::AddTilingsForRasterScale() { |
| 944 float maximum_animation_contents_scale) { | |
| 945 DCHECK(ideal_contents_scale_); | |
| 946 DCHECK(ideal_page_scale_); | |
| 947 DCHECK(ideal_device_scale_); | |
| 948 DCHECK(ideal_source_scale_); | |
| 949 DCHECK(CanHaveTilings()); | |
| 950 DCHECK(!needs_post_commit_initialization_); | |
| 951 | |
| 952 bool change_target_tiling = | |
| 953 raster_page_scale_ == 0.f || | |
| 954 raster_device_scale_ == 0.f || | |
| 955 raster_source_scale_ == 0.f || | |
| 956 raster_contents_scale_ == 0.f || | |
| 957 low_res_raster_contents_scale_ == 0.f || | |
| 958 ShouldAdjustRasterScale(animating_transform_to_screen); | |
| 959 | |
| 960 if (tilings_->num_tilings() == 0) { | |
| 961 DCHECK(change_target_tiling) | |
| 962 << "A layer with no tilings shouldn't have valid raster scales"; | |
| 963 } | |
| 964 | |
| 965 if (change_target_tiling) { | |
| 966 RecalculateRasterScales(animating_transform_to_screen, | |
| 967 maximum_animation_contents_scale); | |
| 968 } | |
| 969 | |
| 970 was_animating_transform_to_screen_ = animating_transform_to_screen; | |
| 971 | |
| 972 if (!change_target_tiling) | |
| 973 return; | |
| 974 | |
| 975 PictureLayerTiling* high_res = NULL; | 962 PictureLayerTiling* high_res = NULL; |
| 976 PictureLayerTiling* low_res = NULL; | 963 PictureLayerTiling* low_res = NULL; |
| 977 | 964 |
| 978 PictureLayerTiling* previous_low_res = NULL; | 965 PictureLayerTiling* previous_low_res = NULL; |
| 979 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 966 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 980 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 967 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
| 981 if (tiling->contents_scale() == raster_contents_scale_) | 968 if (tiling->contents_scale() == raster_contents_scale_) |
| 982 high_res = tiling; | 969 high_res = tiling; |
| 983 if (tiling->contents_scale() == low_res_raster_contents_scale_) | 970 if (tiling->contents_scale() == low_res_raster_contents_scale_) |
| 984 low_res = tiling; | 971 low_res = tiling; |
| 985 if (tiling->resolution() == LOW_RESOLUTION) | 972 if (tiling->resolution() == LOW_RESOLUTION) |
| 986 previous_low_res = tiling; | 973 previous_low_res = tiling; |
| 987 | 974 |
| 988 // Reset all tilings to non-ideal until the end of this function. | 975 // Reset all tilings to non-ideal until the end of this function. |
| 989 tiling->set_resolution(NON_IDEAL_RESOLUTION); | 976 tiling->set_resolution(NON_IDEAL_RESOLUTION); |
| 990 } | 977 } |
| 991 | 978 |
| 992 if (!high_res) { | 979 if (!high_res) { |
| 993 high_res = AddTiling(raster_contents_scale_); | 980 high_res = AddTiling(raster_contents_scale_); |
| 994 if (raster_contents_scale_ == low_res_raster_contents_scale_) | 981 if (raster_contents_scale_ == low_res_raster_contents_scale_) |
| 995 low_res = high_res; | 982 low_res = high_res; |
| 996 } | 983 } |
| 997 | 984 |
| 998 // Only create new low res tilings when the transform is static. This | 985 // Only create new low res tilings when the transform is static. This |
| 999 // prevents wastefully creating a paired low res tiling for every new high res | 986 // prevents wastefully creating a paired low res tiling for every new high res |
| 1000 // tiling during a pinch or a CSS animation. | 987 // tiling during a pinch or a CSS animation. |
| 1001 bool is_pinching = layer_tree_impl()->PinchGestureActive(); | 988 bool is_pinching = layer_tree_impl()->PinchGestureActive(); |
| 1002 if (layer_tree_impl()->create_low_res_tiling() && !is_pinching && | 989 if (layer_tree_impl()->create_low_res_tiling() && !is_pinching && |
| 1003 !animating_transform_to_screen && !low_res && low_res != high_res) | 990 !draw_properties().screen_space_transform_is_animating && !low_res && |
| 991 low_res != high_res) |
| 1004 low_res = AddTiling(low_res_raster_contents_scale_); | 992 low_res = AddTiling(low_res_raster_contents_scale_); |
| 1005 | 993 |
| 1006 // Set low-res if we have one. | 994 // Set low-res if we have one. |
| 1007 if (!low_res) | 995 if (!low_res) |
| 1008 low_res = previous_low_res; | 996 low_res = previous_low_res; |
| 1009 if (low_res && low_res != high_res) | 997 if (low_res && low_res != high_res) |
| 1010 low_res->set_resolution(LOW_RESOLUTION); | 998 low_res->set_resolution(LOW_RESOLUTION); |
| 1011 | 999 |
| 1012 // Make sure we always have one high-res (even if high == low). | 1000 // Make sure we always have one high-res (even if high == low). |
| 1013 high_res->set_resolution(HIGH_RESOLUTION); | 1001 high_res->set_resolution(HIGH_RESOLUTION); |
| 1014 | 1002 |
| 1015 SanityCheckTilingState(); | 1003 SanityCheckTilingState(); |
| 1016 } | 1004 } |
| 1017 | 1005 |
| 1018 bool PictureLayerImpl::ShouldAdjustRasterScale( | 1006 bool PictureLayerImpl::ShouldAdjustRasterScale() const { |
| 1019 bool animating_transform_to_screen) const { | 1007 if (was_screen_space_transform_animating_ != |
| 1020 if (was_animating_transform_to_screen_ != animating_transform_to_screen) | 1008 draw_properties().screen_space_transform_is_animating) |
| 1021 return true; | 1009 return true; |
| 1022 | 1010 |
| 1023 bool is_pinching = layer_tree_impl()->PinchGestureActive(); | 1011 bool is_pinching = layer_tree_impl()->PinchGestureActive(); |
| 1024 if (is_pinching && raster_page_scale_) { | 1012 if (is_pinching && raster_page_scale_) { |
| 1025 // We change our raster scale when it is: | 1013 // We change our raster scale when it is: |
| 1026 // - Higher than ideal (need a lower-res tiling available) | 1014 // - Higher than ideal (need a lower-res tiling available) |
| 1027 // - Too far from ideal (need a higher-res tiling available) | 1015 // - Too far from ideal (need a higher-res tiling available) |
| 1028 float ratio = ideal_page_scale_ / raster_page_scale_; | 1016 float ratio = ideal_page_scale_ / raster_page_scale_; |
| 1029 if (raster_page_scale_ > ideal_page_scale_ || | 1017 if (raster_page_scale_ > ideal_page_scale_ || |
| 1030 ratio > kMaxScaleRatioDuringPinch) | 1018 ratio > kMaxScaleRatioDuringPinch) |
| 1031 return true; | 1019 return true; |
| 1032 } | 1020 } |
| 1033 | 1021 |
| 1034 if (!is_pinching) { | 1022 if (!is_pinching) { |
| 1035 // When not pinching, match the ideal page scale factor. | 1023 // When not pinching, match the ideal page scale factor. |
| 1036 if (raster_page_scale_ != ideal_page_scale_) | 1024 if (raster_page_scale_ != ideal_page_scale_) |
| 1037 return true; | 1025 return true; |
| 1038 } | 1026 } |
| 1039 | 1027 |
| 1040 // Always match the ideal device scale factor. | 1028 // Always match the ideal device scale factor. |
| 1041 if (raster_device_scale_ != ideal_device_scale_) | 1029 if (raster_device_scale_ != ideal_device_scale_) |
| 1042 return true; | 1030 return true; |
| 1043 | 1031 |
| 1044 // When the source scale changes we want to match it, but not when animating | 1032 // When the source scale changes we want to match it, but not when animating |
| 1045 // or when we've fixed the scale in place. | 1033 // or when we've fixed the scale in place. |
| 1046 if (!animating_transform_to_screen && !raster_source_scale_is_fixed_ && | 1034 if (!draw_properties().screen_space_transform_is_animating && |
| 1035 !raster_source_scale_is_fixed_ && |
| 1047 raster_source_scale_ != ideal_source_scale_) | 1036 raster_source_scale_ != ideal_source_scale_) |
| 1048 return true; | 1037 return true; |
| 1049 | 1038 |
| 1050 return false; | 1039 return false; |
| 1051 } | 1040 } |
| 1052 | 1041 |
| 1053 float PictureLayerImpl::SnappedContentsScale(float scale) { | 1042 float PictureLayerImpl::SnappedContentsScale(float scale) { |
| 1054 // If a tiling exists within the max snapping ratio, snap to its scale. | 1043 // If a tiling exists within the max snapping ratio, snap to its scale. |
| 1055 float snapped_contents_scale = scale; | 1044 float snapped_contents_scale = scale; |
| 1056 float snapped_ratio = kSnapToExistingTilingRatio; | 1045 float snapped_ratio = kSnapToExistingTilingRatio; |
| 1057 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 1046 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 1058 float tiling_contents_scale = tilings_->tiling_at(i)->contents_scale(); | 1047 float tiling_contents_scale = tilings_->tiling_at(i)->contents_scale(); |
| 1059 float ratio = PositiveRatio(tiling_contents_scale, scale); | 1048 float ratio = PositiveRatio(tiling_contents_scale, scale); |
| 1060 if (ratio < snapped_ratio) { | 1049 if (ratio < snapped_ratio) { |
| 1061 snapped_contents_scale = tiling_contents_scale; | 1050 snapped_contents_scale = tiling_contents_scale; |
| 1062 snapped_ratio = ratio; | 1051 snapped_ratio = ratio; |
| 1063 } | 1052 } |
| 1064 } | 1053 } |
| 1065 return snapped_contents_scale; | 1054 return snapped_contents_scale; |
| 1066 } | 1055 } |
| 1067 | 1056 |
| 1068 void PictureLayerImpl::RecalculateRasterScales( | 1057 void PictureLayerImpl::RecalculateRasterScales() { |
| 1069 bool animating_transform_to_screen, | |
| 1070 float maximum_animation_contents_scale) { | |
| 1071 float old_raster_contents_scale = raster_contents_scale_; | 1058 float old_raster_contents_scale = raster_contents_scale_; |
| 1072 float old_raster_page_scale = raster_page_scale_; | 1059 float old_raster_page_scale = raster_page_scale_; |
| 1073 float old_raster_source_scale = raster_source_scale_; | 1060 float old_raster_source_scale = raster_source_scale_; |
| 1074 | 1061 |
| 1075 raster_device_scale_ = ideal_device_scale_; | 1062 raster_device_scale_ = ideal_device_scale_; |
| 1076 raster_page_scale_ = ideal_page_scale_; | 1063 raster_page_scale_ = ideal_page_scale_; |
| 1077 raster_source_scale_ = ideal_source_scale_; | 1064 raster_source_scale_ = ideal_source_scale_; |
| 1078 raster_contents_scale_ = ideal_contents_scale_; | 1065 raster_contents_scale_ = ideal_contents_scale_; |
| 1079 | 1066 |
| 1080 // If we're not animating, or leaving an animation, and the | 1067 // If we're not animating, or leaving an animation, and the |
| 1081 // ideal_source_scale_ changes, then things are unpredictable, and we fix | 1068 // ideal_source_scale_ changes, then things are unpredictable, and we fix |
| 1082 // the raster_source_scale_ in place. | 1069 // the raster_source_scale_ in place. |
| 1083 if (old_raster_source_scale && !animating_transform_to_screen && | 1070 if (old_raster_source_scale && |
| 1084 !was_animating_transform_to_screen_ && | 1071 !draw_properties().screen_space_transform_is_animating && |
| 1072 !was_screen_space_transform_animating_ && |
| 1085 old_raster_source_scale != ideal_source_scale_) | 1073 old_raster_source_scale != ideal_source_scale_) |
| 1086 raster_source_scale_is_fixed_ = true; | 1074 raster_source_scale_is_fixed_ = true; |
| 1087 | 1075 |
| 1088 // TODO(danakj): Adjust raster source scale closer to ideal source scale at | 1076 // TODO(danakj): Adjust raster source scale closer to ideal source scale at |
| 1089 // a throttled rate. Possibly make use of invalidation_.IsEmpty() on pending | 1077 // a throttled rate. Possibly make use of invalidation_.IsEmpty() on pending |
| 1090 // tree. This will allow CSS scale changes to get re-rastered at an | 1078 // tree. This will allow CSS scale changes to get re-rastered at an |
| 1091 // appropriate rate. | 1079 // appropriate rate. |
| 1092 if (raster_source_scale_is_fixed_) { | 1080 if (raster_source_scale_is_fixed_) { |
| 1093 raster_contents_scale_ /= raster_source_scale_; | 1081 raster_contents_scale_ /= raster_source_scale_; |
| 1094 raster_source_scale_ = 1.f; | 1082 raster_source_scale_ = 1.f; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1110 raster_page_scale_ = | 1098 raster_page_scale_ = |
| 1111 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; | 1099 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; |
| 1112 } | 1100 } |
| 1113 | 1101 |
| 1114 raster_contents_scale_ = | 1102 raster_contents_scale_ = |
| 1115 std::max(raster_contents_scale_, MinimumContentsScale()); | 1103 std::max(raster_contents_scale_, MinimumContentsScale()); |
| 1116 | 1104 |
| 1117 // Since we're not re-rasterizing during animation, rasterize at the maximum | 1105 // Since we're not re-rasterizing during animation, rasterize at the maximum |
| 1118 // scale that will occur during the animation, if the maximum scale is | 1106 // scale that will occur during the animation, if the maximum scale is |
| 1119 // known. | 1107 // known. |
| 1120 if (animating_transform_to_screen) { | 1108 if (draw_properties().screen_space_transform_is_animating) { |
| 1121 if (maximum_animation_contents_scale > 0.f) { | 1109 if (draw_properties().maximum_animation_contents_scale > 0.f) { |
| 1122 raster_contents_scale_ = | 1110 raster_contents_scale_ = |
| 1123 std::max(raster_contents_scale_, maximum_animation_contents_scale); | 1111 std::max(raster_contents_scale_, |
| 1112 draw_properties().maximum_animation_contents_scale); |
| 1124 } else { | 1113 } else { |
| 1125 raster_contents_scale_ = | 1114 raster_contents_scale_ = |
| 1126 std::max(raster_contents_scale_, | 1115 std::max(raster_contents_scale_, |
| 1127 1.f * ideal_page_scale_ * ideal_device_scale_); | 1116 1.f * ideal_page_scale_ * ideal_device_scale_); |
| 1128 } | 1117 } |
| 1129 } | 1118 } |
| 1130 | 1119 |
| 1131 // If this layer would only create one tile at this content scale, | 1120 // If this layer would only create one tile at this content scale, |
| 1132 // don't create a low res tiling. | 1121 // don't create a low res tiling. |
| 1133 gfx::Size content_bounds = | 1122 gfx::Size content_bounds = |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1624 return iterator_index_ < iterators_.size(); | 1613 return iterator_index_ < iterators_.size(); |
| 1625 } | 1614 } |
| 1626 | 1615 |
| 1627 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1616 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
| 1628 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1617 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
| 1629 return it->get_type() == iteration_stage_ && | 1618 return it->get_type() == iteration_stage_ && |
| 1630 (**it)->required_for_activation() == required_for_activation_; | 1619 (**it)->required_for_activation() == required_for_activation_; |
| 1631 } | 1620 } |
| 1632 | 1621 |
| 1633 } // namespace cc | 1622 } // namespace cc |
| OLD | NEW |