| 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 // cleared once the invalidation is drawn, which is useful for debugging | 685 // cleared once the invalidation is drawn, which is useful for debugging |
| 686 // visualizations. This method intersects the two to give a more exact | 686 // visualizations. This method intersects the two to give a more exact |
| 687 // representation of what was invalidated that is cleared after drawing. | 687 // representation of what was invalidated that is cleared after drawing. |
| 688 return IntersectRegions(invalidation_, update_rect()); | 688 return IntersectRegions(invalidation_, update_rect()); |
| 689 } | 689 } |
| 690 | 690 |
| 691 std::unique_ptr<Tile> PictureLayerImpl::CreateTile( | 691 std::unique_ptr<Tile> PictureLayerImpl::CreateTile( |
| 692 const Tile::CreateInfo& info) { | 692 const Tile::CreateInfo& info) { |
| 693 int flags = 0; | 693 int flags = 0; |
| 694 | 694 |
| 695 // We don't handle solid color masks, so we shouldn't bother analyzing those. | 695 // We don't handle solid color masks if mask tiling is disabled, we also don't |
| 696 // handle solid color single texture masks if the flag is enabled, so we |
| 697 // shouldn't bother analyzing those. |
| 696 // Otherwise, always analyze to maximize memory savings. | 698 // Otherwise, always analyze to maximize memory savings. |
| 697 // TODO(sunxd): the condition should be (mask_type_ == | 699 if (mask_type_ != Layer::LayerMaskType::SINGLE_TEXTURE_MASK) |
| 698 // Layer::LayerMaskType::NOT_MASK | |
| 699 // || (layer_tree_impl()->settings().enable_mask_tiling && mask_type == | |
| 700 // Layer::LayerMaskType::MULTI_TEXTURE_MASK)). | |
| 701 if (mask_type_ == Layer::LayerMaskType::NOT_MASK) | |
| 702 flags = Tile::USE_PICTURE_ANALYSIS; | 700 flags = Tile::USE_PICTURE_ANALYSIS; |
| 703 | 701 |
| 704 if (contents_opaque()) | 702 if (contents_opaque()) |
| 705 flags |= Tile::IS_OPAQUE; | 703 flags |= Tile::IS_OPAQUE; |
| 706 | 704 |
| 707 return layer_tree_impl()->tile_manager()->CreateTile( | 705 return layer_tree_impl()->tile_manager()->CreateTile( |
| 708 info, id(), layer_tree_impl()->source_frame_number(), flags); | 706 info, id(), layer_tree_impl()->source_frame_number(), flags); |
| 709 } | 707 } |
| 710 | 708 |
| 711 const Region* PictureLayerImpl::GetPendingInvalidation() { | 709 const Region* PictureLayerImpl::GetPendingInvalidation() { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 733 | 731 |
| 734 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const { | 732 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const { |
| 735 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale()); | 733 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale()); |
| 736 } | 734 } |
| 737 | 735 |
| 738 gfx::Size PictureLayerImpl::CalculateTileSize( | 736 gfx::Size PictureLayerImpl::CalculateTileSize( |
| 739 const gfx::Size& content_bounds) const { | 737 const gfx::Size& content_bounds) const { |
| 740 int max_texture_size = | 738 int max_texture_size = |
| 741 layer_tree_impl()->resource_provider()->max_texture_size(); | 739 layer_tree_impl()->resource_provider()->max_texture_size(); |
| 742 | 740 |
| 743 // TODO(sunxd): the condition should be mask_type_ == Layer::LayerMaskType:: | 741 if (mask_type_ == Layer::LayerMaskType::SINGLE_TEXTURE_MASK) { |
| 744 // SINGLE_TEXTURE_MASK || (mask_type_ == | |
| 745 // Layer::LayerMaskType::MULTI_TEXTURE_MASK && | |
| 746 // !layer_tree_impl()->settings().enable_mask_tiling) | |
| 747 if (mask_type_ != Layer::LayerMaskType::NOT_MASK) { | |
| 748 // Masks are not tiled, so if we can't cover the whole mask with one tile, | 742 // Masks are not tiled, so if we can't cover the whole mask with one tile, |
| 749 // we shouldn't have such a tiling at all. | 743 // we shouldn't have such a tiling at all. |
| 750 DCHECK_LE(content_bounds.width(), max_texture_size); | 744 DCHECK_LE(content_bounds.width(), max_texture_size); |
| 751 DCHECK_LE(content_bounds.height(), max_texture_size); | 745 DCHECK_LE(content_bounds.height(), max_texture_size); |
| 752 return content_bounds; | 746 return content_bounds; |
| 753 } | 747 } |
| 754 | 748 |
| 755 int default_tile_width = 0; | 749 int default_tile_width = 0; |
| 756 int default_tile_height = 0; | 750 int default_tile_height = 0; |
| 757 if (layer_tree_impl()->use_gpu_rasterization()) { | 751 if (layer_tree_impl()->use_gpu_rasterization()) { |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 // this from happening. | 1165 // this from happening. |
| 1172 int min_dimension = std::min(raster_source_->GetSize().width(), | 1166 int min_dimension = std::min(raster_source_->GetSize().width(), |
| 1173 raster_source_->GetSize().height()); | 1167 raster_source_->GetSize().height()); |
| 1174 if (!min_dimension) | 1168 if (!min_dimension) |
| 1175 return setting_min; | 1169 return setting_min; |
| 1176 | 1170 |
| 1177 return std::max(1.f / min_dimension, setting_min); | 1171 return std::max(1.f / min_dimension, setting_min); |
| 1178 } | 1172 } |
| 1179 | 1173 |
| 1180 float PictureLayerImpl::MaximumContentsScale() const { | 1174 float PictureLayerImpl::MaximumContentsScale() const { |
| 1181 // Masks can not have tilings that would become larger than the | 1175 // When mask tiling is disabled or the mask is single textured, masks can not |
| 1182 // max_texture_size since they use a single tile for the entire | 1176 // have tilings that would become larger than the max_texture_size since they |
| 1183 // tiling. Other layers can have tilings such that dimension * scale | 1177 // use a single tile for the entire tiling. Other layers can have tilings such |
| 1184 // does not overflow. | 1178 // that dimension * scale does not overflow. |
| 1185 // TODO(sunxd): the condition should be: | |
| 1186 // mask_type_ == Layer::LayerMaskType::SINGLE_TEXTURE_MASK || (mask_type_ == | |
| 1187 // Layer::LayerMaskType::MULTI_TEXTURE_MASK && !layer_tree_impl()->settings(). | |
| 1188 // enable_mask_tiling) | |
| 1189 float max_dimension = static_cast<float>( | 1179 float max_dimension = static_cast<float>( |
| 1190 mask_type_ != Layer::LayerMaskType::NOT_MASK | 1180 mask_type_ == Layer::LayerMaskType::SINGLE_TEXTURE_MASK |
| 1191 ? layer_tree_impl()->resource_provider()->max_texture_size() | 1181 ? layer_tree_impl()->resource_provider()->max_texture_size() |
| 1192 : std::numeric_limits<int>::max()); | 1182 : std::numeric_limits<int>::max()); |
| 1193 float max_scale_width = max_dimension / bounds().width(); | 1183 float max_scale_width = max_dimension / bounds().width(); |
| 1194 float max_scale_height = max_dimension / bounds().height(); | 1184 float max_scale_height = max_dimension / bounds().height(); |
| 1195 float max_scale = std::min(max_scale_width, max_scale_height); | 1185 float max_scale = std::min(max_scale_width, max_scale_height); |
| 1196 | 1186 |
| 1197 // We require that multiplying the layer size by the contents scale and | 1187 // We require that multiplying the layer size by the contents scale and |
| 1198 // ceiling produces a value <= |max_dimension|. Because for large layer | 1188 // ceiling produces a value <= |max_dimension|. Because for large layer |
| 1199 // sizes floating point ambiguity may crop up, making the result larger or | 1189 // sizes floating point ambiguity may crop up, making the result larger or |
| 1200 // smaller than expected, we use a slightly smaller floating point value for | 1190 // smaller than expected, we use a slightly smaller floating point value for |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 } | 1387 } |
| 1398 | 1388 |
| 1399 invalidation_.Union(invalidation); | 1389 invalidation_.Union(invalidation); |
| 1400 tilings_->UpdateTilingsForImplSideInvalidation(invalidation); | 1390 tilings_->UpdateTilingsForImplSideInvalidation(invalidation); |
| 1401 SetNeedsPushProperties(); | 1391 SetNeedsPushProperties(); |
| 1402 TRACE_EVENT_END1("cc", "PictureLayerImpl::InvalidateRegionForImages", | 1392 TRACE_EVENT_END1("cc", "PictureLayerImpl::InvalidateRegionForImages", |
| 1403 "Invalidation", invalidation.ToString()); | 1393 "Invalidation", invalidation.ToString()); |
| 1404 } | 1394 } |
| 1405 | 1395 |
| 1406 } // namespace cc | 1396 } // namespace cc |
| OLD | NEW |