| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 ideal_contents_scale_(0.f), | 102 ideal_contents_scale_(0.f), |
| 103 raster_page_scale_(0.f), | 103 raster_page_scale_(0.f), |
| 104 raster_device_scale_(0.f), | 104 raster_device_scale_(0.f), |
| 105 raster_source_scale_(0.f), | 105 raster_source_scale_(0.f), |
| 106 raster_contents_scale_(0.f), | 106 raster_contents_scale_(0.f), |
| 107 low_res_raster_contents_scale_(0.f), | 107 low_res_raster_contents_scale_(0.f), |
| 108 was_screen_space_transform_animating_(false), | 108 was_screen_space_transform_animating_(false), |
| 109 only_used_low_res_last_append_quads_(false), | 109 only_used_low_res_last_append_quads_(false), |
| 110 mask_type_(mask_type), | 110 mask_type_(mask_type), |
| 111 nearest_neighbor_(false), | 111 nearest_neighbor_(false), |
| 112 use_transformed_rasterization_(false), |
| 112 is_directly_composited_image_(false) { | 113 is_directly_composited_image_(false) { |
| 113 layer_tree_impl()->RegisterPictureLayerImpl(this); | 114 layer_tree_impl()->RegisterPictureLayerImpl(this); |
| 114 } | 115 } |
| 115 | 116 |
| 116 PictureLayerImpl::~PictureLayerImpl() { | 117 PictureLayerImpl::~PictureLayerImpl() { |
| 117 if (twin_layer_) | 118 if (twin_layer_) |
| 118 twin_layer_->twin_layer_ = nullptr; | 119 twin_layer_->twin_layer_ = nullptr; |
| 119 layer_tree_impl()->UnregisterPictureLayerImpl(this); | 120 layer_tree_impl()->UnregisterPictureLayerImpl(this); |
| 120 } | 121 } |
| 121 | 122 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 138 DCHECK(!twin_layer_ || twin_layer_ == layer_impl); | 139 DCHECK(!twin_layer_ || twin_layer_ == layer_impl); |
| 139 DCHECK(!twin_layer_ || layer_impl->twin_layer_ == this); | 140 DCHECK(!twin_layer_ || layer_impl->twin_layer_ == this); |
| 140 // The twin relationship does not need to exist before the first | 141 // The twin relationship does not need to exist before the first |
| 141 // PushPropertiesTo from pending to active layer since before that the active | 142 // PushPropertiesTo from pending to active layer since before that the active |
| 142 // layer can not have a pile or tilings, it has only been created and inserted | 143 // layer can not have a pile or tilings, it has only been created and inserted |
| 143 // into the tree at that point. | 144 // into the tree at that point. |
| 144 twin_layer_ = layer_impl; | 145 twin_layer_ = layer_impl; |
| 145 layer_impl->twin_layer_ = this; | 146 layer_impl->twin_layer_ = this; |
| 146 | 147 |
| 147 layer_impl->SetNearestNeighbor(nearest_neighbor_); | 148 layer_impl->SetNearestNeighbor(nearest_neighbor_); |
| 149 layer_impl->SetUseTransformedRasterization(use_transformed_rasterization_); |
| 148 | 150 |
| 149 // Solid color layers have no tilings. | 151 // Solid color layers have no tilings. |
| 150 DCHECK(!raster_source_->IsSolidColor() || tilings_->num_tilings() == 0); | 152 DCHECK(!raster_source_->IsSolidColor() || tilings_->num_tilings() == 0); |
| 151 // The pending tree should only have a high res (and possibly low res) tiling. | 153 // The pending tree should only have a high res (and possibly low res) tiling. |
| 152 DCHECK_LE(tilings_->num_tilings(), | 154 DCHECK_LE(tilings_->num_tilings(), |
| 153 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u); | 155 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u); |
| 154 | 156 |
| 155 layer_impl->set_gpu_raster_max_texture_size(gpu_raster_max_texture_size_); | 157 layer_impl->set_gpu_raster_max_texture_size(gpu_raster_max_texture_size_); |
| 156 layer_impl->UpdateRasterSource(raster_source_, &invalidation_, | 158 layer_impl->UpdateRasterSource(raster_source_, &invalidation_, |
| 157 tilings_.get()); | 159 tilings_.get()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 width = DebugColors::OOMTileBorderWidth(device_scale_factor); | 270 width = DebugColors::OOMTileBorderWidth(device_scale_factor); |
| 269 } else if (iter->draw_info().has_compressed_resource()) { | 271 } else if (iter->draw_info().has_compressed_resource()) { |
| 270 color = DebugColors::CompressedTileBorderColor(); | 272 color = DebugColors::CompressedTileBorderColor(); |
| 271 width = DebugColors::CompressedTileBorderWidth(device_scale_factor); | 273 width = DebugColors::CompressedTileBorderWidth(device_scale_factor); |
| 272 } else if (iter.resolution() == HIGH_RESOLUTION) { | 274 } else if (iter.resolution() == HIGH_RESOLUTION) { |
| 273 color = DebugColors::HighResTileBorderColor(); | 275 color = DebugColors::HighResTileBorderColor(); |
| 274 width = DebugColors::HighResTileBorderWidth(device_scale_factor); | 276 width = DebugColors::HighResTileBorderWidth(device_scale_factor); |
| 275 } else if (iter.resolution() == LOW_RESOLUTION) { | 277 } else if (iter.resolution() == LOW_RESOLUTION) { |
| 276 color = DebugColors::LowResTileBorderColor(); | 278 color = DebugColors::LowResTileBorderColor(); |
| 277 width = DebugColors::LowResTileBorderWidth(device_scale_factor); | 279 width = DebugColors::LowResTileBorderWidth(device_scale_factor); |
| 278 } else if (iter->contents_scale() > max_contents_scale) { | 280 } else if (iter->contents_scale_key() > max_contents_scale) { |
| 279 color = DebugColors::ExtraHighResTileBorderColor(); | 281 color = DebugColors::ExtraHighResTileBorderColor(); |
| 280 width = DebugColors::ExtraHighResTileBorderWidth(device_scale_factor); | 282 width = DebugColors::ExtraHighResTileBorderWidth(device_scale_factor); |
| 281 } else { | 283 } else { |
| 282 color = DebugColors::ExtraLowResTileBorderColor(); | 284 color = DebugColors::ExtraLowResTileBorderColor(); |
| 283 width = DebugColors::ExtraLowResTileBorderWidth(device_scale_factor); | 285 width = DebugColors::ExtraLowResTileBorderWidth(device_scale_factor); |
| 284 } | 286 } |
| 285 } else { | 287 } else { |
| 286 color = DebugColors::MissingTileBorderColor(); | 288 color = DebugColors::MissingTileBorderColor(); |
| 287 width = DebugColors::MissingTileBorderWidth(device_scale_factor); | 289 width = DebugColors::MissingTileBorderWidth(device_scale_factor); |
| 288 } | 290 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 switch (draw_info.mode()) { | 338 switch (draw_info.mode()) { |
| 337 case TileDrawInfo::RESOURCE_MODE: { | 339 case TileDrawInfo::RESOURCE_MODE: { |
| 338 gfx::RectF texture_rect = iter.texture_rect(); | 340 gfx::RectF texture_rect = iter.texture_rect(); |
| 339 | 341 |
| 340 // The raster_contents_scale_ is the best scale that the layer is | 342 // The raster_contents_scale_ is the best scale that the layer is |
| 341 // trying to produce, even though it may not be ideal. Since that's | 343 // trying to produce, even though it may not be ideal. Since that's |
| 342 // the best the layer can promise in the future, consider those as | 344 // the best the layer can promise in the future, consider those as |
| 343 // complete. But if a tile is ideal scale, we don't want to consider | 345 // complete. But if a tile is ideal scale, we don't want to consider |
| 344 // it incomplete and trying to replace it with a tile at a worse | 346 // it incomplete and trying to replace it with a tile at a worse |
| 345 // scale. | 347 // scale. |
| 346 if (iter->contents_scale() != raster_contents_scale_ && | 348 if (iter->contents_scale_key() != raster_contents_scale_ && |
| 347 iter->contents_scale() != ideal_contents_scale_ && | 349 iter->contents_scale_key() != ideal_contents_scale_ && |
| 348 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { | 350 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { |
| 349 append_quads_data->num_incomplete_tiles++; | 351 append_quads_data->num_incomplete_tiles++; |
| 350 } | 352 } |
| 351 | 353 |
| 352 TileDrawQuad* quad = | 354 TileDrawQuad* quad = |
| 353 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); | 355 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); |
| 354 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, | 356 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, |
| 355 visible_geometry_rect, draw_info.resource_id(), | 357 visible_geometry_rect, draw_info.resource_id(), |
| 356 texture_rect, draw_info.resource_size(), | 358 texture_rect, draw_info.resource_size(), |
| 357 draw_info.contents_swizzled(), nearest_neighbor_); | 359 draw_info.contents_swizzled(), nearest_neighbor_); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 | 639 |
| 638 DCHECK(!RasterSourceUsesLCDText()); | 640 DCHECK(!RasterSourceUsesLCDText()); |
| 639 } | 641 } |
| 640 | 642 |
| 641 bool PictureLayerImpl::RasterSourceUsesLCDText() const { | 643 bool PictureLayerImpl::RasterSourceUsesLCDText() const { |
| 642 return raster_source_ ? raster_source_->CanUseLCDText() | 644 return raster_source_ ? raster_source_->CanUseLCDText() |
| 643 : layer_tree_impl()->settings().can_use_lcd_text; | 645 : layer_tree_impl()->settings().can_use_lcd_text; |
| 644 } | 646 } |
| 645 | 647 |
| 646 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { | 648 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { |
| 647 if (layer_tree_impl()->IsActiveTree()) { | 649 if (layer_tree_impl()->IsActiveTree()) |
| 648 gfx::Rect layer_damage_rect = gfx::ScaleToEnclosingRect( | 650 AddDamageRect(tile->enclosing_layer_rect()); |
| 649 tile->content_rect(), 1.f / tile->contents_scale()); | |
| 650 AddDamageRect(layer_damage_rect); | |
| 651 } | |
| 652 if (tile->draw_info().NeedsRaster()) { | 651 if (tile->draw_info().NeedsRaster()) { |
| 653 PictureLayerTiling* tiling = | 652 PictureLayerTiling* tiling = |
| 654 tilings_->FindTilingWithScaleKey(tile->contents_scale()); | 653 tilings_->FindTilingWithScaleKey(tile->contents_scale_key()); |
| 655 if (tiling) | 654 if (tiling) |
| 656 tiling->set_all_tiles_done(false); | 655 tiling->set_all_tiles_done(false); |
| 657 } | 656 } |
| 658 } | 657 } |
| 659 | 658 |
| 659 SimpleEnclosedRegion PictureLayerImpl::VisibleOpaqueRegion() const { |
| 660 if (use_transformed_rasterization_) |
| 661 return SimpleEnclosedRegion(); |
| 662 return LayerImpl::VisibleOpaqueRegion(); |
| 663 } |
| 664 |
| 660 void PictureLayerImpl::DidBeginTracing() { | 665 void PictureLayerImpl::DidBeginTracing() { |
| 661 raster_source_->DidBeginTracing(); | 666 raster_source_->DidBeginTracing(); |
| 662 } | 667 } |
| 663 | 668 |
| 664 void PictureLayerImpl::ReleaseResources() { | 669 void PictureLayerImpl::ReleaseResources() { |
| 665 // Recreate tilings with new settings, since some of those might change when | 670 // Recreate tilings with new settings, since some of those might change when |
| 666 // we release resources. | 671 // we release resources. |
| 667 tilings_ = nullptr; | 672 tilings_ = nullptr; |
| 668 ResetRasterScale(); | 673 ResetRasterScale(); |
| 669 } | 674 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) | 722 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) |
| 718 return &twin_layer->invalidation_; | 723 return &twin_layer->invalidation_; |
| 719 return nullptr; | 724 return nullptr; |
| 720 } | 725 } |
| 721 | 726 |
| 722 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( | 727 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( |
| 723 const PictureLayerTiling* tiling) const { | 728 const PictureLayerTiling* tiling) const { |
| 724 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); | 729 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); |
| 725 if (!twin_layer) | 730 if (!twin_layer) |
| 726 return nullptr; | 731 return nullptr; |
| 727 return twin_layer->tilings_->FindTilingWithScaleKey(tiling->contents_scale()); | 732 const PictureLayerTiling* twin_tiling = |
| 733 twin_layer->tilings_->FindTilingWithScaleKey( |
| 734 tiling->contents_scale_key()); |
| 735 if (twin_tiling && |
| 736 twin_tiling->raster_transform() == tiling->raster_transform()) |
| 737 return twin_tiling; |
| 738 return nullptr; |
| 728 } | 739 } |
| 729 | 740 |
| 730 bool PictureLayerImpl::RequiresHighResToDraw() const { | 741 bool PictureLayerImpl::RequiresHighResToDraw() const { |
| 731 return layer_tree_impl()->RequiresHighResToDraw(); | 742 return layer_tree_impl()->RequiresHighResToDraw(); |
| 732 } | 743 } |
| 733 | 744 |
| 734 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const { | 745 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const { |
| 735 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale()); | 746 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale()); |
| 736 } | 747 } |
| 737 | 748 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 } | 876 } |
| 866 | 877 |
| 867 void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) { | 878 void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) { |
| 868 if (nearest_neighbor_ == nearest_neighbor) | 879 if (nearest_neighbor_ == nearest_neighbor) |
| 869 return; | 880 return; |
| 870 | 881 |
| 871 nearest_neighbor_ = nearest_neighbor; | 882 nearest_neighbor_ = nearest_neighbor; |
| 872 NoteLayerPropertyChanged(); | 883 NoteLayerPropertyChanged(); |
| 873 } | 884 } |
| 874 | 885 |
| 875 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 886 void PictureLayerImpl::SetUseTransformedRasterization(bool use) { |
| 887 if (use_transformed_rasterization_ == use) |
| 888 return; |
| 889 |
| 890 use_transformed_rasterization_ = use; |
| 891 NoteLayerPropertyChanged(); |
| 892 } |
| 893 |
| 894 PictureLayerTiling* PictureLayerImpl::AddTiling( |
| 895 const ScaleTranslate2d& contents_transform) { |
| 876 DCHECK(CanHaveTilings()); | 896 DCHECK(CanHaveTilings()); |
| 877 DCHECK_GE(contents_scale, MinimumContentsScale()); | 897 DCHECK_GE(contents_transform.scale(), MinimumContentsScale()); |
| 878 DCHECK_LE(contents_scale, MaximumContentsScale()); | 898 DCHECK_LE(contents_transform.scale(), MaximumContentsScale()); |
| 879 DCHECK(raster_source_->HasRecordings()); | 899 DCHECK(raster_source_->HasRecordings()); |
| 880 return tilings_->AddTiling(contents_scale, raster_source_); | 900 return tilings_->AddTiling(contents_transform, raster_source_); |
| 881 } | 901 } |
| 882 | 902 |
| 883 void PictureLayerImpl::RemoveAllTilings() { | 903 void PictureLayerImpl::RemoveAllTilings() { |
| 884 tilings_->RemoveAllTilings(); | 904 tilings_->RemoveAllTilings(); |
| 885 // If there are no tilings, then raster scales are no longer meaningful. | 905 // If there are no tilings, then raster scales are no longer meaningful. |
| 886 ResetRasterScale(); | 906 ResetRasterScale(); |
| 887 } | 907 } |
| 888 | 908 |
| 889 void PictureLayerImpl::AddTilingsForRasterScale() { | 909 void PictureLayerImpl::AddTilingsForRasterScale() { |
| 890 // Reset all resolution enums on tilings, we'll be setting new values in this | 910 // Reset all resolution enums on tilings, we'll be setting new values in this |
| 891 // function. | 911 // function. |
| 892 tilings_->MarkAllTilingsNonIdeal(); | 912 tilings_->MarkAllTilingsNonIdeal(); |
| 893 | 913 |
| 894 PictureLayerTiling* high_res = | 914 PictureLayerTiling* high_res = |
| 895 tilings_->FindTilingWithScaleKey(raster_contents_scale_); | 915 tilings_->FindTilingWithScaleKey(raster_contents_scale_); |
| 916 gfx::Vector2dF raster_translation = |
| 917 CalculateRasterTranslation(raster_contents_scale_); |
| 918 if (high_res && |
| 919 high_res->raster_transform().translation() != raster_translation) { |
| 920 tilings_->Remove(high_res); |
| 921 high_res = nullptr; |
| 922 } |
| 896 if (!high_res) { | 923 if (!high_res) { |
| 897 // We always need a high res tiling, so create one if it doesn't exist. | 924 // We always need a high res tiling, so create one if it doesn't exist. |
| 898 high_res = AddTiling(raster_contents_scale_); | 925 high_res = |
| 926 AddTiling(ScaleTranslate2d(raster_contents_scale_, raster_translation)); |
| 899 } else if (high_res->may_contain_low_resolution_tiles()) { | 927 } else if (high_res->may_contain_low_resolution_tiles()) { |
| 900 // If the tiling we find here was LOW_RESOLUTION previously, it may not be | 928 // If the tiling we find here was LOW_RESOLUTION previously, it may not be |
| 901 // fully rastered, so destroy the old tiles. | 929 // fully rastered, so destroy the old tiles. |
| 902 high_res->Reset(); | 930 high_res->Reset(); |
| 903 // Reset the flag now that we'll make it high res, it will have fully | 931 // Reset the flag now that we'll make it high res, it will have fully |
| 904 // rastered content. | 932 // rastered content. |
| 905 high_res->reset_may_contain_low_resolution_tiles(); | 933 high_res->reset_may_contain_low_resolution_tiles(); |
| 906 } | 934 } |
| 907 high_res->set_resolution(HIGH_RESOLUTION); | 935 high_res->set_resolution(HIGH_RESOLUTION); |
| 908 | 936 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 tilings_->FindTilingWithScaleKey(low_res_raster_contents_scale_); | 1013 tilings_->FindTilingWithScaleKey(low_res_raster_contents_scale_); |
| 986 DCHECK(!low_res || low_res->resolution() != HIGH_RESOLUTION); | 1014 DCHECK(!low_res || low_res->resolution() != HIGH_RESOLUTION); |
| 987 | 1015 |
| 988 // Only create new low res tilings when the transform is static. This | 1016 // Only create new low res tilings when the transform is static. This |
| 989 // prevents wastefully creating a paired low res tiling for every new high | 1017 // prevents wastefully creating a paired low res tiling for every new high |
| 990 // res tiling during a pinch or a CSS animation. | 1018 // res tiling during a pinch or a CSS animation. |
| 991 bool is_pinching = layer_tree_impl()->PinchGestureActive(); | 1019 bool is_pinching = layer_tree_impl()->PinchGestureActive(); |
| 992 bool is_animating = draw_properties().screen_space_transform_is_animating; | 1020 bool is_animating = draw_properties().screen_space_transform_is_animating; |
| 993 if (!is_pinching && !is_animating) { | 1021 if (!is_pinching && !is_animating) { |
| 994 if (!low_res) | 1022 if (!low_res) |
| 995 low_res = AddTiling(low_res_raster_contents_scale_); | 1023 low_res = AddTiling( |
| 1024 ScaleTranslate2d(low_res_raster_contents_scale_, gfx::Vector2dF())); |
| 996 low_res->set_resolution(LOW_RESOLUTION); | 1025 low_res->set_resolution(LOW_RESOLUTION); |
| 997 } | 1026 } |
| 998 } | 1027 } |
| 999 | 1028 |
| 1000 void PictureLayerImpl::RecalculateRasterScales() { | 1029 void PictureLayerImpl::RecalculateRasterScales() { |
| 1001 if (is_directly_composited_image_) { | 1030 if (is_directly_composited_image_) { |
| 1002 if (!raster_source_scale_) | 1031 if (!raster_source_scale_) |
| 1003 raster_source_scale_ = 1.f; | 1032 raster_source_scale_ = 1.f; |
| 1004 | 1033 |
| 1005 float min_scale = MinimumContentsScale(); | 1034 float min_scale = MinimumContentsScale(); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 } | 1180 } |
| 1152 | 1181 |
| 1153 PictureLayerTilingSet* twin_set = twin ? twin->tilings_.get() : nullptr; | 1182 PictureLayerTilingSet* twin_set = twin ? twin->tilings_.get() : nullptr; |
| 1154 tilings_->CleanUpTilings(min_acceptable_high_res_scale, | 1183 tilings_->CleanUpTilings(min_acceptable_high_res_scale, |
| 1155 max_acceptable_high_res_scale, used_tilings, | 1184 max_acceptable_high_res_scale, used_tilings, |
| 1156 twin_set); | 1185 twin_set); |
| 1157 DCHECK_GT(tilings_->num_tilings(), 0u); | 1186 DCHECK_GT(tilings_->num_tilings(), 0u); |
| 1158 SanityCheckTilingState(); | 1187 SanityCheckTilingState(); |
| 1159 } | 1188 } |
| 1160 | 1189 |
| 1190 gfx::Vector2dF PictureLayerImpl::CalculateRasterTranslation( |
| 1191 float raster_scale) { |
| 1192 if (!use_transformed_rasterization_) |
| 1193 return gfx::Vector2dF(); |
| 1194 |
| 1195 DCHECK(!draw_properties().screen_space_transform_is_animating); |
| 1196 gfx::Transform draw_transform = DrawTransform(); |
| 1197 DCHECK(draw_transform.IsScaleOrTranslation()); |
| 1198 |
| 1199 // It is only useful to align the content space to the target space if their |
| 1200 // relative pixel ratio is some small rational number. Currently we only |
| 1201 // align if the relative pixel ratio is 1:1. |
| 1202 // Good match if the maximum alignment error on a layer of size 10000px |
| 1203 // does not exceed 0.001px. |
| 1204 static constexpr float kErrorThreshold = 0.0000001f; |
| 1205 if (std::abs(draw_transform.matrix().getFloat(0, 0) - raster_scale) > |
| 1206 kErrorThreshold || |
| 1207 std::abs(draw_transform.matrix().getFloat(1, 1) - raster_scale) > |
| 1208 kErrorThreshold) |
| 1209 return gfx::Vector2dF(); |
| 1210 |
| 1211 // Extract the fractional part of layer origin in the target space. |
| 1212 float origin_x = draw_transform.matrix().getFloat(0, 3); |
| 1213 float origin_y = draw_transform.matrix().getFloat(1, 3); |
| 1214 return gfx::Vector2dF(origin_x - floorf(origin_x), |
| 1215 origin_y - floorf(origin_y)); |
| 1216 } |
| 1217 |
| 1161 float PictureLayerImpl::MinimumContentsScale() const { | 1218 float PictureLayerImpl::MinimumContentsScale() const { |
| 1162 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; | 1219 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; |
| 1163 | 1220 |
| 1164 // If the contents scale is less than 1 / width (also for height), | 1221 // If the contents scale is less than 1 / width (also for height), |
| 1165 // then it will end up having less than one pixel of content in that | 1222 // then it will end up having less than one pixel of content in that |
| 1166 // dimension. Bump the minimum contents scale up in this case to prevent | 1223 // dimension. Bump the minimum contents scale up in this case to prevent |
| 1167 // this from happening. | 1224 // this from happening. |
| 1168 int min_dimension = std::min(raster_source_->GetSize().width(), | 1225 int min_dimension = std::min(raster_source_->GetSize().width(), |
| 1169 raster_source_->GetSize().height()); | 1226 raster_source_->GetSize().height()); |
| 1170 if (!min_dimension) | 1227 if (!min_dimension) |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 } | 1449 } |
| 1393 | 1450 |
| 1394 invalidation_.Union(invalidation); | 1451 invalidation_.Union(invalidation); |
| 1395 tilings_->UpdateTilingsForImplSideInvalidation(invalidation); | 1452 tilings_->UpdateTilingsForImplSideInvalidation(invalidation); |
| 1396 SetNeedsPushProperties(); | 1453 SetNeedsPushProperties(); |
| 1397 TRACE_EVENT_END1("cc", "PictureLayerImpl::InvalidateRegionForImages", | 1454 TRACE_EVENT_END1("cc", "PictureLayerImpl::InvalidateRegionForImages", |
| 1398 "Invalidation", invalidation.ToString()); | 1455 "Invalidation", invalidation.ToString()); |
| 1399 } | 1456 } |
| 1400 | 1457 |
| 1401 } // namespace cc | 1458 } // namespace cc |
| OLD | NEW |