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

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

Issue 2688673003: cc: Distinguish single texture mask from normal masks (Closed)
Patch Set: 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
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 bool is_mask,
96 bool is_single_texture_mask)
96 : LayerImpl(tree_impl, id), 97 : LayerImpl(tree_impl, id),
97 twin_layer_(nullptr), 98 twin_layer_(nullptr),
98 tilings_(CreatePictureLayerTilingSet()), 99 tilings_(CreatePictureLayerTilingSet()),
99 ideal_page_scale_(0.f), 100 ideal_page_scale_(0.f),
100 ideal_device_scale_(0.f), 101 ideal_device_scale_(0.f),
101 ideal_source_scale_(0.f), 102 ideal_source_scale_(0.f),
102 ideal_contents_scale_(0.f), 103 ideal_contents_scale_(0.f),
103 raster_page_scale_(0.f), 104 raster_page_scale_(0.f),
104 raster_device_scale_(0.f), 105 raster_device_scale_(0.f),
105 raster_source_scale_(0.f), 106 raster_source_scale_(0.f),
106 raster_contents_scale_(0.f), 107 raster_contents_scale_(0.f),
107 low_res_raster_contents_scale_(0.f), 108 low_res_raster_contents_scale_(0.f),
108 was_screen_space_transform_animating_(false), 109 was_screen_space_transform_animating_(false),
109 only_used_low_res_last_append_quads_(false), 110 only_used_low_res_last_append_quads_(false),
110 is_mask_(is_mask), 111 is_mask_(is_mask),
112 is_single_texture_mask_(is_single_texture_mask),
111 nearest_neighbor_(false), 113 nearest_neighbor_(false),
112 is_directly_composited_image_(false) { 114 is_directly_composited_image_(false) {
113 layer_tree_impl()->RegisterPictureLayerImpl(this); 115 layer_tree_impl()->RegisterPictureLayerImpl(this);
114 } 116 }
115 117
116 PictureLayerImpl::~PictureLayerImpl() { 118 PictureLayerImpl::~PictureLayerImpl() {
117 if (twin_layer_) 119 if (twin_layer_)
118 twin_layer_->twin_layer_ = nullptr; 120 twin_layer_->twin_layer_ = nullptr;
119 layer_tree_impl()->UnregisterPictureLayerImpl(this); 121 layer_tree_impl()->UnregisterPictureLayerImpl(this);
120 } 122 }
121 123
122 const char* PictureLayerImpl::LayerTypeAsString() const { 124 const char* PictureLayerImpl::LayerTypeAsString() const {
123 return "cc::PictureLayerImpl"; 125 return "cc::PictureLayerImpl";
124 } 126 }
125 127
126 std::unique_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( 128 std::unique_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl(
127 LayerTreeImpl* tree_impl) { 129 LayerTreeImpl* tree_impl) {
128 return PictureLayerImpl::Create(tree_impl, id(), is_mask_); 130 return PictureLayerImpl::Create(tree_impl, id(), is_mask_,
131 is_single_texture_mask_);
129 } 132 }
130 133
131 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { 134 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
132 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); 135 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
133 DCHECK_EQ(layer_impl->is_mask_, is_mask_); 136 DCHECK_EQ(layer_impl->is_mask_, is_mask_);
137 DCHECK_EQ(layer_impl->is_single_texture_mask_, is_single_texture_mask_);
134 138
135 LayerImpl::PushPropertiesTo(base_layer); 139 LayerImpl::PushPropertiesTo(base_layer);
136 140
137 // Twin relationships should never change once established. 141 // Twin relationships should never change once established.
138 DCHECK(!twin_layer_ || twin_layer_ == layer_impl); 142 DCHECK(!twin_layer_ || twin_layer_ == layer_impl);
139 DCHECK(!twin_layer_ || layer_impl->twin_layer_ == this); 143 DCHECK(!twin_layer_ || layer_impl->twin_layer_ == this);
140 // The twin relationship does not need to exist before the first 144 // The twin relationship does not need to exist before the first
141 // PushPropertiesTo from pending to active layer since before that the active 145 // 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 146 // layer can not have a pile or tilings, it has only been created and inserted
143 // into the tree at that point. 147 // into the tree at that point.
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 // representation of what was invalidated that is cleared after drawing. 693 // representation of what was invalidated that is cleared after drawing.
690 return IntersectRegions(invalidation_, update_rect()); 694 return IntersectRegions(invalidation_, update_rect());
691 } 695 }
692 696
693 std::unique_ptr<Tile> PictureLayerImpl::CreateTile( 697 std::unique_ptr<Tile> PictureLayerImpl::CreateTile(
694 const Tile::CreateInfo& info) { 698 const Tile::CreateInfo& info) {
695 int flags = 0; 699 int flags = 0;
696 700
697 // We don't handle solid color masks, so we shouldn't bother analyzing those. 701 // We don't handle solid color masks, so we shouldn't bother analyzing those.
698 // Otherwise, always analyze to maximize memory savings. 702 // Otherwise, always analyze to maximize memory savings.
699 if (!is_mask_) 703 if (!is_mask_ && !is_single_texture_mask_)
700 flags = Tile::USE_PICTURE_ANALYSIS; 704 flags = Tile::USE_PICTURE_ANALYSIS;
701 705
702 if (contents_opaque()) 706 if (contents_opaque())
703 flags |= Tile::IS_OPAQUE; 707 flags |= Tile::IS_OPAQUE;
704 708
705 return layer_tree_impl()->tile_manager()->CreateTile( 709 return layer_tree_impl()->tile_manager()->CreateTile(
706 info, id(), layer_tree_impl()->source_frame_number(), flags); 710 info, id(), layer_tree_impl()->source_frame_number(), flags);
707 } 711 }
708 712
709 const Region* PictureLayerImpl::GetPendingInvalidation() { 713 const Region* PictureLayerImpl::GetPendingInvalidation() {
(...skipping 21 matching lines...) Expand all
731 735
732 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const { 736 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const {
733 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale()); 737 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale());
734 } 738 }
735 739
736 gfx::Size PictureLayerImpl::CalculateTileSize( 740 gfx::Size PictureLayerImpl::CalculateTileSize(
737 const gfx::Size& content_bounds) const { 741 const gfx::Size& content_bounds) const {
738 int max_texture_size = 742 int max_texture_size =
739 layer_tree_impl()->resource_provider()->max_texture_size(); 743 layer_tree_impl()->resource_provider()->max_texture_size();
740 744
741 if (is_mask_) { 745 if (is_mask_ || is_single_texture_mask_) {
742 // 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,
743 // we shouldn't have such a tiling at all. 747 // we shouldn't have such a tiling at all.
744 DCHECK_LE(content_bounds.width(), max_texture_size); 748 DCHECK_LE(content_bounds.width(), max_texture_size);
745 DCHECK_LE(content_bounds.height(), max_texture_size); 749 DCHECK_LE(content_bounds.height(), max_texture_size);
746 return content_bounds; 750 return content_bounds;
747 } 751 }
748 752
749 int default_tile_width = 0; 753 int default_tile_width = 0;
750 int default_tile_height = 0; 754 int default_tile_height = 0;
751 if (layer_tree_impl()->use_gpu_rasterization()) { 755 if (layer_tree_impl()->use_gpu_rasterization()) {
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 1174
1171 return std::max(1.f / min_dimension, setting_min); 1175 return std::max(1.f / min_dimension, setting_min);
1172 } 1176 }
1173 1177
1174 float PictureLayerImpl::MaximumContentsScale() const { 1178 float PictureLayerImpl::MaximumContentsScale() const {
1175 // Masks can not have tilings that would become larger than the 1179 // Masks can not have tilings that would become larger than the
1176 // max_texture_size since they use a single tile for the entire 1180 // max_texture_size since they use a single tile for the entire
1177 // tiling. Other layers can have tilings such that dimension * scale 1181 // tiling. Other layers can have tilings such that dimension * scale
1178 // does not overflow. 1182 // does not overflow.
1179 float max_dimension = static_cast<float>( 1183 float max_dimension = static_cast<float>(
1180 is_mask_ ? layer_tree_impl()->resource_provider()->max_texture_size() 1184 is_mask_ || is_single_texture_mask_
1181 : std::numeric_limits<int>::max()); 1185 ? layer_tree_impl()->resource_provider()->max_texture_size()
1186 : std::numeric_limits<int>::max());
1182 float max_scale_width = max_dimension / bounds().width(); 1187 float max_scale_width = max_dimension / bounds().width();
1183 float max_scale_height = max_dimension / bounds().height(); 1188 float max_scale_height = max_dimension / bounds().height();
1184 float max_scale = std::min(max_scale_width, max_scale_height); 1189 float max_scale = std::min(max_scale_width, max_scale_height);
1185 1190
1186 // We require that multiplying the layer size by the contents scale and 1191 // We require that multiplying the layer size by the contents scale and
1187 // ceiling produces a value <= |max_dimension|. Because for large layer 1192 // ceiling produces a value <= |max_dimension|. Because for large layer
1188 // sizes floating point ambiguity may crop up, making the result larger or 1193 // sizes floating point ambiguity may crop up, making the result larger or
1189 // smaller than expected, we use a slightly smaller floating point value for 1194 // smaller than expected, we use a slightly smaller floating point value for
1190 // the scale, to help ensure that the resulting content bounds will never end 1195 // the scale, to help ensure that the resulting content bounds will never end
1191 // up larger than |max_dimension|. 1196 // up larger than |max_dimension|.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { 1368 bool PictureLayerImpl::IsOnActiveOrPendingTree() const {
1364 return !layer_tree_impl()->IsRecycleTree(); 1369 return !layer_tree_impl()->IsRecycleTree();
1365 } 1370 }
1366 1371
1367 bool PictureLayerImpl::HasValidTilePriorities() const { 1372 bool PictureLayerImpl::HasValidTilePriorities() const {
1368 return IsOnActiveOrPendingTree() && 1373 return IsOnActiveOrPendingTree() &&
1369 is_drawn_render_surface_layer_list_member(); 1374 is_drawn_render_surface_layer_list_member();
1370 } 1375 }
1371 1376
1372 } // namespace cc 1377 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698