Chromium Code Reviews| 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::NOT_MASK || |
| 698 // Layer::LayerMaskType::NOT_MASK | 700 (layer_tree_impl()->settings().enable_mask_tiling && |
| 699 // || (layer_tree_impl()->settings().enable_mask_tiling && mask_type == | 701 mask_type_ == Layer::LayerMaskType::MULTI_TEXTURE_MASK)) |
|
enne (OOO)
2017/02/10 22:24:34
Maybe setting the mask type should just ignore thi
trchen
2017/02/11 00:21:16
+1 to enne@
I think it is cleaner to change layer
sunxd
2017/02/13 18:13:42
Yeah I think it looks better, if mask tiling is di
| |
| 700 // Layer::LayerMaskType::MULTI_TEXTURE_MASK)). | |
| 701 if (mask_type_ == Layer::LayerMaskType::NOT_MASK) | |
| 702 flags = Tile::USE_PICTURE_ANALYSIS; | 702 flags = Tile::USE_PICTURE_ANALYSIS; |
| 703 | 703 |
| 704 if (contents_opaque()) | 704 if (contents_opaque()) |
| 705 flags |= Tile::IS_OPAQUE; | 705 flags |= Tile::IS_OPAQUE; |
| 706 | 706 |
| 707 return layer_tree_impl()->tile_manager()->CreateTile( | 707 return layer_tree_impl()->tile_manager()->CreateTile( |
| 708 info, id(), layer_tree_impl()->source_frame_number(), flags); | 708 info, id(), layer_tree_impl()->source_frame_number(), flags); |
| 709 } | 709 } |
| 710 | 710 |
| 711 const Region* PictureLayerImpl::GetPendingInvalidation() { | 711 const Region* PictureLayerImpl::GetPendingInvalidation() { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 733 | 733 |
| 734 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const { | 734 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const { |
| 735 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale()); | 735 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale()); |
| 736 } | 736 } |
| 737 | 737 |
| 738 gfx::Size PictureLayerImpl::CalculateTileSize( | 738 gfx::Size PictureLayerImpl::CalculateTileSize( |
| 739 const gfx::Size& content_bounds) const { | 739 const gfx::Size& content_bounds) const { |
| 740 int max_texture_size = | 740 int max_texture_size = |
| 741 layer_tree_impl()->resource_provider()->max_texture_size(); | 741 layer_tree_impl()->resource_provider()->max_texture_size(); |
| 742 | 742 |
| 743 // TODO(sunxd): the condition should be mask_type_ == Layer::LayerMaskType:: | 743 if (mask_type_ == Layer::LayerMaskType::SINGLE_TEXTURE_MASK || |
| 744 // SINGLE_TEXTURE_MASK || (mask_type_ == | 744 (mask_type_ == Layer::LayerMaskType::MULTI_TEXTURE_MASK && |
| 745 // Layer::LayerMaskType::MULTI_TEXTURE_MASK && | 745 !layer_tree_impl()->settings().enable_mask_tiling)) { |
| 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, | 746 // 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. | 747 // we shouldn't have such a tiling at all. |
| 750 DCHECK_LE(content_bounds.width(), max_texture_size); | 748 DCHECK_LE(content_bounds.width(), max_texture_size); |
| 751 DCHECK_LE(content_bounds.height(), max_texture_size); | 749 DCHECK_LE(content_bounds.height(), max_texture_size); |
| 752 return content_bounds; | 750 return content_bounds; |
| 753 } | 751 } |
| 754 | 752 |
| 755 int default_tile_width = 0; | 753 int default_tile_width = 0; |
| 756 int default_tile_height = 0; | 754 int default_tile_height = 0; |
| 757 if (layer_tree_impl()->use_gpu_rasterization()) { | 755 if (layer_tree_impl()->use_gpu_rasterization()) { |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1171 // this from happening. | 1169 // this from happening. |
| 1172 int min_dimension = std::min(raster_source_->GetSize().width(), | 1170 int min_dimension = std::min(raster_source_->GetSize().width(), |
| 1173 raster_source_->GetSize().height()); | 1171 raster_source_->GetSize().height()); |
| 1174 if (!min_dimension) | 1172 if (!min_dimension) |
| 1175 return setting_min; | 1173 return setting_min; |
| 1176 | 1174 |
| 1177 return std::max(1.f / min_dimension, setting_min); | 1175 return std::max(1.f / min_dimension, setting_min); |
| 1178 } | 1176 } |
| 1179 | 1177 |
| 1180 float PictureLayerImpl::MaximumContentsScale() const { | 1178 float PictureLayerImpl::MaximumContentsScale() const { |
| 1181 // Masks can not have tilings that would become larger than the | 1179 // 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 | 1180 // have tilings that would become larger than the max_texture_size since they |
| 1183 // tiling. Other layers can have tilings such that dimension * scale | 1181 // use a single tile for the entire tiling. Other layers can have tilings such |
| 1184 // does not overflow. | 1182 // 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>( | 1183 float max_dimension = static_cast<float>( |
| 1190 mask_type_ != Layer::LayerMaskType::NOT_MASK | 1184 mask_type_ == Layer::LayerMaskType::SINGLE_TEXTURE_MASK || |
| 1185 (mask_type_ == Layer::LayerMaskType::MULTI_TEXTURE_MASK && | |
| 1186 !layer_tree_impl()->settings().enable_mask_tiling) | |
| 1191 ? layer_tree_impl()->resource_provider()->max_texture_size() | 1187 ? layer_tree_impl()->resource_provider()->max_texture_size() |
| 1192 : std::numeric_limits<int>::max()); | 1188 : std::numeric_limits<int>::max()); |
| 1193 float max_scale_width = max_dimension / bounds().width(); | 1189 float max_scale_width = max_dimension / bounds().width(); |
| 1194 float max_scale_height = max_dimension / bounds().height(); | 1190 float max_scale_height = max_dimension / bounds().height(); |
| 1195 float max_scale = std::min(max_scale_width, max_scale_height); | 1191 float max_scale = std::min(max_scale_width, max_scale_height); |
| 1196 | 1192 |
| 1197 // We require that multiplying the layer size by the contents scale and | 1193 // We require that multiplying the layer size by the contents scale and |
| 1198 // ceiling produces a value <= |max_dimension|. Because for large layer | 1194 // ceiling produces a value <= |max_dimension|. Because for large layer |
| 1199 // sizes floating point ambiguity may crop up, making the result larger or | 1195 // 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 | 1196 // smaller than expected, we use a slightly smaller floating point value for |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1374 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1370 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
| 1375 return !layer_tree_impl()->IsRecycleTree(); | 1371 return !layer_tree_impl()->IsRecycleTree(); |
| 1376 } | 1372 } |
| 1377 | 1373 |
| 1378 bool PictureLayerImpl::HasValidTilePriorities() const { | 1374 bool PictureLayerImpl::HasValidTilePriorities() const { |
| 1379 return IsOnActiveOrPendingTree() && | 1375 return IsOnActiveOrPendingTree() && |
| 1380 is_drawn_render_surface_layer_list_member(); | 1376 is_drawn_render_surface_layer_list_member(); |
| 1381 } | 1377 } |
| 1382 | 1378 |
| 1383 } // namespace cc | 1379 } // namespace cc |
| OLD | NEW |