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

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

Issue 547463002: cc: Don't make tiles for mask layers that are too big for a texture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hugemasks: rebase-past-mask-analysis Created 6 years, 3 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/layers/picture_layer_impl_unittest.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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 : active(active_layer), pending(pending_layer) { 55 : active(active_layer), pending(pending_layer) {
56 } 56 }
57 57
58 PictureLayerImpl::Pair::~Pair() { 58 PictureLayerImpl::Pair::~Pair() {
59 } 59 }
60 60
61 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) 61 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id)
62 : LayerImpl(tree_impl, id), 62 : LayerImpl(tree_impl, id),
63 twin_layer_(NULL), 63 twin_layer_(NULL),
64 pile_(PicturePileImpl::Create()), 64 pile_(PicturePileImpl::Create()),
65 is_mask_(false),
66 ideal_page_scale_(0.f), 65 ideal_page_scale_(0.f),
67 ideal_device_scale_(0.f), 66 ideal_device_scale_(0.f),
68 ideal_source_scale_(0.f), 67 ideal_source_scale_(0.f),
69 ideal_contents_scale_(0.f), 68 ideal_contents_scale_(0.f),
70 raster_page_scale_(0.f), 69 raster_page_scale_(0.f),
71 raster_device_scale_(0.f), 70 raster_device_scale_(0.f),
72 raster_source_scale_(0.f), 71 raster_source_scale_(0.f),
73 raster_contents_scale_(0.f), 72 raster_contents_scale_(0.f),
74 low_res_raster_contents_scale_(0.f), 73 low_res_raster_contents_scale_(0.f),
75 raster_source_scale_is_fixed_(false), 74 raster_source_scale_is_fixed_(false),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (layer_impl->tilings_) 106 if (layer_impl->tilings_)
108 layer_impl->tilings_->DidBecomeRecycled(); 107 layer_impl->tilings_->DidBecomeRecycled();
109 108
110 LayerImpl::PushPropertiesTo(base_layer); 109 LayerImpl::PushPropertiesTo(base_layer);
111 110
112 // When the pending tree pushes to the active tree, the pending twin 111 // When the pending tree pushes to the active tree, the pending twin
113 // becomes recycled. 112 // becomes recycled.
114 layer_impl->twin_layer_ = NULL; 113 layer_impl->twin_layer_ = NULL;
115 twin_layer_ = NULL; 114 twin_layer_ = NULL;
116 115
117 layer_impl->SetIsMask(is_mask_);
118 layer_impl->pile_ = pile_; 116 layer_impl->pile_ = pile_;
119 117
120 // Tilings would be expensive to push, so we swap. 118 // Tilings would be expensive to push, so we swap.
121 layer_impl->tilings_.swap(tilings_); 119 layer_impl->tilings_.swap(tilings_);
122 layer_impl->tilings_->SetClient(layer_impl); 120 layer_impl->tilings_->SetClient(layer_impl);
123 if (tilings_) 121 if (tilings_)
124 tilings_->SetClient(this); 122 tilings_->SetClient(this);
125 123
126 // Remove invalidated tiles from what will become a recycle tree. 124 // Remove invalidated tiles from what will become a recycle tree.
127 if (tilings_) 125 if (tilings_)
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 return scoped_refptr<Tile>(); 581 return scoped_refptr<Tile>();
584 582
585 int flags = 0; 583 int flags = 0;
586 584
587 // TODO(vmpstr): Revisit this. For now, enabling analysis means that we get as 585 // TODO(vmpstr): Revisit this. For now, enabling analysis means that we get as
588 // much savings on memory as we can. However, for some cases like ganesh or 586 // much savings on memory as we can. However, for some cases like ganesh or
589 // small layers, the amount of time we spend analyzing might not justify 587 // small layers, the amount of time we spend analyzing might not justify
590 // memory savings that we can get. Note that we don't handle solid color 588 // memory savings that we can get. Note that we don't handle solid color
591 // masks, so we shouldn't bother analyzing those. 589 // masks, so we shouldn't bother analyzing those.
592 // Bugs: crbug.com/397198, crbug.com/396908 590 // Bugs: crbug.com/397198, crbug.com/396908
593 if (!is_mask_) 591 if (!pile_->is_mask())
594 flags = Tile::USE_PICTURE_ANALYSIS; 592 flags = Tile::USE_PICTURE_ANALYSIS;
595 593
596 return layer_tree_impl()->tile_manager()->CreateTile( 594 return layer_tree_impl()->tile_manager()->CreateTile(
597 pile_.get(), 595 pile_.get(),
598 content_rect.size(), 596 content_rect.size(),
599 content_rect, 597 content_rect,
600 contents_opaque() ? content_rect : gfx::Rect(), 598 contents_opaque() ? content_rect : gfx::Rect(),
601 tiling->contents_scale(), 599 tiling->contents_scale(),
602 id(), 600 id(),
603 layer_tree_impl()->source_frame_number(), 601 layer_tree_impl()->source_frame_number(),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 } 640 }
643 641
644 int PictureLayerImpl::GetSkewportExtrapolationLimitInContentPixels() const { 642 int PictureLayerImpl::GetSkewportExtrapolationLimitInContentPixels() const {
645 return layer_tree_impl() 643 return layer_tree_impl()
646 ->settings() 644 ->settings()
647 .skewport_extrapolation_limit_in_content_pixels; 645 .skewport_extrapolation_limit_in_content_pixels;
648 } 646 }
649 647
650 gfx::Size PictureLayerImpl::CalculateTileSize( 648 gfx::Size PictureLayerImpl::CalculateTileSize(
651 const gfx::Size& content_bounds) const { 649 const gfx::Size& content_bounds) const {
652 if (is_mask_) {
653 int max_size = layer_tree_impl()->MaxTextureSize();
654 return gfx::Size(
655 std::min(max_size, content_bounds.width()),
656 std::min(max_size, content_bounds.height()));
657 }
658
659 int max_texture_size = 650 int max_texture_size =
660 layer_tree_impl()->resource_provider()->max_texture_size(); 651 layer_tree_impl()->resource_provider()->max_texture_size();
661 652
653 if (pile_->is_mask()) {
654 // Masks are not tiled, so if we can't cover the whole mask with one tile,
655 // don't make any tiles at all. Returning an empty size signals this.
656 if (content_bounds.width() > max_texture_size ||
657 content_bounds.height() > max_texture_size)
658 return gfx::Size();
659 return content_bounds;
660 }
661
662 gfx::Size default_tile_size = layer_tree_impl()->settings().default_tile_size; 662 gfx::Size default_tile_size = layer_tree_impl()->settings().default_tile_size;
663 if (layer_tree_impl()->use_gpu_rasterization()) { 663 if (layer_tree_impl()->use_gpu_rasterization()) {
664 // TODO(ernstm) crbug.com/365877: We need a unified way to override the 664 // TODO(ernstm) crbug.com/365877: We need a unified way to override the
665 // default-tile-size. 665 // default-tile-size.
666 default_tile_size = 666 default_tile_size =
667 gfx::Size(layer_tree_impl()->device_viewport_size().width(), 667 gfx::Size(layer_tree_impl()->device_viewport_size().width(),
668 layer_tree_impl()->device_viewport_size().height() / 4); 668 layer_tree_impl()->device_viewport_size().height() / 4);
669 } 669 }
670 default_tile_size.SetToMin(gfx::Size(max_texture_size, max_texture_size)); 670 default_tile_size.SetToMin(gfx::Size(max_texture_size, max_texture_size));
671 671
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 if (!layer_tree_impl()->needs_update_draw_properties() && 753 if (!layer_tree_impl()->needs_update_draw_properties() &&
754 should_update_tile_priorities_) { 754 should_update_tile_priorities_) {
755 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking 755 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking
756 // when we stop using the pending tree in the browser compositor. If we want 756 // when we stop using the pending tree in the browser compositor. If we want
757 // to support occlusion tracking here, we need to dirty the draw properties 757 // to support occlusion tracking here, we need to dirty the draw properties
758 // or save occlusion as a draw property. 758 // or save occlusion as a draw property.
759 UpdateTilePriorities(NULL); 759 UpdateTilePriorities(NULL);
760 } 760 }
761 } 761 }
762 762
763 void PictureLayerImpl::SetIsMask(bool is_mask) {
764 if (is_mask_ == is_mask)
765 return;
766 is_mask_ = is_mask;
767 if (tilings_)
768 tilings_->RemoveAllTiles();
769 }
770
771 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { 763 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const {
772 gfx::Rect content_rect(content_bounds()); 764 gfx::Rect content_rect(content_bounds());
773 float scale = MaximumTilingContentsScale(); 765 float scale = MaximumTilingContentsScale();
774 PictureLayerTilingSet::CoverageIterator iter( 766 PictureLayerTilingSet::CoverageIterator iter(
775 tilings_.get(), scale, content_rect, ideal_contents_scale_); 767 tilings_.get(), scale, content_rect, ideal_contents_scale_);
776 768
777 // Mask resource not ready yet. 769 // Mask resource not ready yet.
778 if (!iter || !*iter) 770 if (!iter || !*iter)
779 return 0; 771 return 0;
780 772
781 // Masks only supported if they fit on exactly one tile. 773 // Masks only supported if they fit on exactly one tile.
782 if (iter.geometry_rect() != content_rect) 774 DCHECK(iter.geometry_rect() == content_rect)
783 return 0; 775 << "iter rect " << iter.geometry_rect().ToString() << " content rect "
776 << content_rect.ToString();
784 777
785 const ManagedTileState::TileVersion& tile_version = 778 const ManagedTileState::TileVersion& tile_version =
786 iter->GetTileVersionForDrawing(); 779 iter->GetTileVersionForDrawing();
787 if (!tile_version.IsReadyToDraw() || 780 if (!tile_version.IsReadyToDraw() ||
788 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) 781 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE)
789 return 0; 782 return 0;
790 783
791 return tile_version.get_resource_id(); 784 return tile_version.get_resource_id();
792 } 785 }
793 786
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 raster_contents_scale_ = 1182 raster_contents_scale_ =
1190 std::max(raster_contents_scale_, 1183 std::max(raster_contents_scale_,
1191 draw_properties().maximum_animation_contents_scale); 1184 draw_properties().maximum_animation_contents_scale);
1192 } else { 1185 } else {
1193 raster_contents_scale_ = 1186 raster_contents_scale_ =
1194 std::max(raster_contents_scale_, 1187 std::max(raster_contents_scale_,
1195 1.f * ideal_page_scale_ * ideal_device_scale_); 1188 1.f * ideal_page_scale_ * ideal_device_scale_);
1196 } 1189 }
1197 } 1190 }
1198 1191
1199 // If this layer would only create one tile at this content scale, 1192 // If this layer would create zero or one tiles at this content scale,
1200 // don't create a low res tiling. 1193 // don't create a low res tiling.
1201 gfx::Size content_bounds = 1194 gfx::Size content_bounds =
1202 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), raster_contents_scale_)); 1195 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), raster_contents_scale_));
1203 gfx::Size tile_size = CalculateTileSize(content_bounds); 1196 gfx::Size tile_size = CalculateTileSize(content_bounds);
1204 if (tile_size.width() >= content_bounds.width() && 1197 bool tile_covers_bounds = tile_size.width() >= content_bounds.width() &&
1205 tile_size.height() >= content_bounds.height()) { 1198 tile_size.height() >= content_bounds.height();
1199 if (tile_size.IsEmpty() || tile_covers_bounds) {
1206 low_res_raster_contents_scale_ = raster_contents_scale_; 1200 low_res_raster_contents_scale_ = raster_contents_scale_;
1207 return; 1201 return;
1208 } 1202 }
1209 1203
1210 float low_res_factor = 1204 float low_res_factor =
1211 layer_tree_impl()->settings().low_res_contents_scale_factor; 1205 layer_tree_impl()->settings().low_res_contents_scale_factor;
1212 low_res_raster_contents_scale_ = std::max( 1206 low_res_raster_contents_scale_ = std::max(
1213 raster_contents_scale_ * low_res_factor, 1207 raster_contents_scale_ * low_res_factor,
1214 MinimumContentsScale()); 1208 MinimumContentsScale());
1215 } 1209 }
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); 1770 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange();
1777 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; 1771 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start;
1778 return tiling_range.end - 1 - current_tiling_range_offset; 1772 return tiling_range.end - 1 - current_tiling_range_offset;
1779 } 1773 }
1780 } 1774 }
1781 NOTREACHED(); 1775 NOTREACHED();
1782 return 0; 1776 return 0;
1783 } 1777 }
1784 1778
1785 } // namespace cc 1779 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698