Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 2688673003: cc: Distinguish single texture mask from normal masks (Closed)
Patch Set: Rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/test/fake_picture_layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 return gfx::Rect(rx, ry, static_cast<int>(rr - rx), 85 return gfx::Rect(rx, ry, static_cast<int>(rr - rx),
86 static_cast<int>(rb - ry)); 86 static_cast<int>(rb - ry));
87 } 87 }
88 88
89 } // namespace 89 } // namespace
90 90
91 namespace cc { 91 namespace cc {
92 92
93 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, 93 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl,
94 int id, 94 int id,
95 bool is_mask) 95 Layer::LayerMaskType mask_type)
96 : LayerImpl(tree_impl, id), 96 : LayerImpl(tree_impl, id),
97 twin_layer_(nullptr), 97 twin_layer_(nullptr),
98 tilings_(CreatePictureLayerTilingSet()), 98 tilings_(CreatePictureLayerTilingSet()),
99 ideal_page_scale_(0.f), 99 ideal_page_scale_(0.f),
100 ideal_device_scale_(0.f), 100 ideal_device_scale_(0.f),
101 ideal_source_scale_(0.f), 101 ideal_source_scale_(0.f),
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 is_mask_(is_mask), 110 mask_type_(mask_type),
111 nearest_neighbor_(false), 111 nearest_neighbor_(false),
112 is_directly_composited_image_(false) { 112 is_directly_composited_image_(false) {
113 layer_tree_impl()->RegisterPictureLayerImpl(this); 113 layer_tree_impl()->RegisterPictureLayerImpl(this);
114 } 114 }
115 115
116 PictureLayerImpl::~PictureLayerImpl() { 116 PictureLayerImpl::~PictureLayerImpl() {
117 if (twin_layer_) 117 if (twin_layer_)
118 twin_layer_->twin_layer_ = nullptr; 118 twin_layer_->twin_layer_ = nullptr;
119 layer_tree_impl()->UnregisterPictureLayerImpl(this); 119 layer_tree_impl()->UnregisterPictureLayerImpl(this);
120 } 120 }
121 121
122 const char* PictureLayerImpl::LayerTypeAsString() const { 122 const char* PictureLayerImpl::LayerTypeAsString() const {
123 return "cc::PictureLayerImpl"; 123 return "cc::PictureLayerImpl";
124 } 124 }
125 125
126 std::unique_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( 126 std::unique_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl(
127 LayerTreeImpl* tree_impl) { 127 LayerTreeImpl* tree_impl) {
128 return PictureLayerImpl::Create(tree_impl, id(), is_mask_); 128 return PictureLayerImpl::Create(tree_impl, id(), mask_type());
129 } 129 }
130 130
131 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { 131 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
132 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); 132 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
133 DCHECK_EQ(layer_impl->is_mask_, is_mask_); 133 DCHECK_EQ(layer_impl->mask_type_, mask_type_);
134 134
135 LayerImpl::PushPropertiesTo(base_layer); 135 LayerImpl::PushPropertiesTo(base_layer);
136 136
137 // Twin relationships should never change once established. 137 // Twin relationships should never change once established.
138 DCHECK(!twin_layer_ || twin_layer_ == layer_impl); 138 DCHECK(!twin_layer_ || twin_layer_ == layer_impl);
139 DCHECK(!twin_layer_ || layer_impl->twin_layer_ == this); 139 DCHECK(!twin_layer_ || layer_impl->twin_layer_ == this);
140 // The twin relationship does not need to exist before the first 140 // The twin relationship does not need to exist before the first
141 // PushPropertiesTo from pending to active layer since before that the active 141 // 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 142 // layer can not have a pile or tilings, it has only been created and inserted
143 // into the tree at that point. 143 // into the tree at that point.
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, so we shouldn't bother analyzing those.
696 // Otherwise, always analyze to maximize memory savings. 696 // Otherwise, always analyze to maximize memory savings.
697 if (!is_mask_) 697 // TODO(sunxd): the condition should be (mask_type_ ==
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)
698 flags = Tile::USE_PICTURE_ANALYSIS; 702 flags = Tile::USE_PICTURE_ANALYSIS;
699 703
700 if (contents_opaque()) 704 if (contents_opaque())
701 flags |= Tile::IS_OPAQUE; 705 flags |= Tile::IS_OPAQUE;
702 706
703 return layer_tree_impl()->tile_manager()->CreateTile( 707 return layer_tree_impl()->tile_manager()->CreateTile(
704 info, id(), layer_tree_impl()->source_frame_number(), flags); 708 info, id(), layer_tree_impl()->source_frame_number(), flags);
705 } 709 }
706 710
707 const Region* PictureLayerImpl::GetPendingInvalidation() { 711 const Region* PictureLayerImpl::GetPendingInvalidation() {
(...skipping 21 matching lines...) Expand all
729 733
730 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const { 734 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const {
731 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale()); 735 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale());
732 } 736 }
733 737
734 gfx::Size PictureLayerImpl::CalculateTileSize( 738 gfx::Size PictureLayerImpl::CalculateTileSize(
735 const gfx::Size& content_bounds) const { 739 const gfx::Size& content_bounds) const {
736 int max_texture_size = 740 int max_texture_size =
737 layer_tree_impl()->resource_provider()->max_texture_size(); 741 layer_tree_impl()->resource_provider()->max_texture_size();
738 742
739 if (is_mask_) { 743 // TODO(sunxd): the condition should be mask_type_ == Layer::LayerMaskType::
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) {
740 // Masks are not tiled, so if we can't cover the whole mask with one tile, 748 // Masks are not tiled, so if we can't cover the whole mask with one tile,
741 // we shouldn't have such a tiling at all. 749 // we shouldn't have such a tiling at all.
742 DCHECK_LE(content_bounds.width(), max_texture_size); 750 DCHECK_LE(content_bounds.width(), max_texture_size);
743 DCHECK_LE(content_bounds.height(), max_texture_size); 751 DCHECK_LE(content_bounds.height(), max_texture_size);
744 return content_bounds; 752 return content_bounds;
745 } 753 }
746 754
747 int default_tile_width = 0; 755 int default_tile_width = 0;
748 int default_tile_height = 0; 756 int default_tile_height = 0;
749 if (layer_tree_impl()->use_gpu_rasterization()) { 757 if (layer_tree_impl()->use_gpu_rasterization()) {
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 return setting_min; 1175 return setting_min;
1168 1176
1169 return std::max(1.f / min_dimension, setting_min); 1177 return std::max(1.f / min_dimension, setting_min);
1170 } 1178 }
1171 1179
1172 float PictureLayerImpl::MaximumContentsScale() const { 1180 float PictureLayerImpl::MaximumContentsScale() const {
1173 // Masks can not have tilings that would become larger than the 1181 // Masks can not have tilings that would become larger than the
1174 // max_texture_size since they use a single tile for the entire 1182 // max_texture_size since they use a single tile for the entire
1175 // tiling. Other layers can have tilings such that dimension * scale 1183 // tiling. Other layers can have tilings such that dimension * scale
1176 // does not overflow. 1184 // 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)
1177 float max_dimension = static_cast<float>( 1189 float max_dimension = static_cast<float>(
1178 is_mask_ ? layer_tree_impl()->resource_provider()->max_texture_size() 1190 mask_type_ != Layer::LayerMaskType::NOT_MASK
1179 : std::numeric_limits<int>::max()); 1191 ? layer_tree_impl()->resource_provider()->max_texture_size()
1192 : std::numeric_limits<int>::max());
1180 float max_scale_width = max_dimension / bounds().width(); 1193 float max_scale_width = max_dimension / bounds().width();
1181 float max_scale_height = max_dimension / bounds().height(); 1194 float max_scale_height = max_dimension / bounds().height();
1182 float max_scale = std::min(max_scale_width, max_scale_height); 1195 float max_scale = std::min(max_scale_width, max_scale_height);
1183 1196
1184 // We require that multiplying the layer size by the contents scale and 1197 // We require that multiplying the layer size by the contents scale and
1185 // ceiling produces a value <= |max_dimension|. Because for large layer 1198 // ceiling produces a value <= |max_dimension|. Because for large layer
1186 // sizes floating point ambiguity may crop up, making the result larger or 1199 // sizes floating point ambiguity may crop up, making the result larger or
1187 // smaller than expected, we use a slightly smaller floating point value for 1200 // smaller than expected, we use a slightly smaller floating point value for
1188 // the scale, to help ensure that the resulting content bounds will never end 1201 // the scale, to help ensure that the resulting content bounds will never end
1189 // up larger than |max_dimension|. 1202 // up larger than |max_dimension|.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { 1374 bool PictureLayerImpl::IsOnActiveOrPendingTree() const {
1362 return !layer_tree_impl()->IsRecycleTree(); 1375 return !layer_tree_impl()->IsRecycleTree();
1363 } 1376 }
1364 1377
1365 bool PictureLayerImpl::HasValidTilePriorities() const { 1378 bool PictureLayerImpl::HasValidTilePriorities() const {
1366 return IsOnActiveOrPendingTree() && 1379 return IsOnActiveOrPendingTree() &&
1367 is_drawn_render_surface_layer_list_member(); 1380 is_drawn_render_surface_layer_list_member();
1368 } 1381 }
1369 1382
1370 } // namespace cc 1383 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/test/fake_picture_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698