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

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: . 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
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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 } 638 }
639 639
640 int PictureLayerImpl::GetSkewportExtrapolationLimitInContentPixels() const { 640 int PictureLayerImpl::GetSkewportExtrapolationLimitInContentPixels() const {
641 return layer_tree_impl() 641 return layer_tree_impl()
642 ->settings() 642 ->settings()
643 .skewport_extrapolation_limit_in_content_pixels; 643 .skewport_extrapolation_limit_in_content_pixels;
644 } 644 }
645 645
646 gfx::Size PictureLayerImpl::CalculateTileSize( 646 gfx::Size PictureLayerImpl::CalculateTileSize(
647 const gfx::Size& content_bounds) const { 647 const gfx::Size& content_bounds) const {
648 if (is_mask_) {
649 int max_size = layer_tree_impl()->MaxTextureSize();
650 return gfx::Size(
651 std::min(max_size, content_bounds.width()),
652 std::min(max_size, content_bounds.height()));
653 }
654
655 int max_texture_size = 648 int max_texture_size =
656 layer_tree_impl()->resource_provider()->max_texture_size(); 649 layer_tree_impl()->resource_provider()->max_texture_size();
vmpstr 2014/09/05 17:44:57 Is this max_texture_size the same as layer_tree_im
danakj 2014/09/05 22:09:52 Ya. RendererCaps is set based on the value from Re
657 650
651 if (is_mask_) {
652 if (content_bounds.width() > max_texture_size ||
vmpstr 2014/09/05 17:44:57 Can you please drop a comment here saying that "bl
danakj 2014/09/05 22:09:51 Done.
653 content_bounds.height() > max_texture_size)
654 return gfx::Size();
655 return content_bounds;
656 }
657
658 gfx::Size default_tile_size = layer_tree_impl()->settings().default_tile_size; 658 gfx::Size default_tile_size = layer_tree_impl()->settings().default_tile_size;
659 if (layer_tree_impl()->use_gpu_rasterization()) { 659 if (layer_tree_impl()->use_gpu_rasterization()) {
660 // TODO(ernstm) crbug.com/365877: We need a unified way to override the 660 // TODO(ernstm) crbug.com/365877: We need a unified way to override the
661 // default-tile-size. 661 // default-tile-size.
662 default_tile_size = 662 default_tile_size =
663 gfx::Size(layer_tree_impl()->device_viewport_size().width(), 663 gfx::Size(layer_tree_impl()->device_viewport_size().width(),
664 layer_tree_impl()->device_viewport_size().height() / 4); 664 layer_tree_impl()->device_viewport_size().height() / 4);
665 } 665 }
666 default_tile_size.SetToMin(gfx::Size(max_texture_size, max_texture_size)); 666 default_tile_size.SetToMin(gfx::Size(max_texture_size, max_texture_size));
667 667
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 gfx::Rect content_rect(content_bounds()); 768 gfx::Rect content_rect(content_bounds());
769 float scale = MaximumTilingContentsScale(); 769 float scale = MaximumTilingContentsScale();
770 PictureLayerTilingSet::CoverageIterator iter( 770 PictureLayerTilingSet::CoverageIterator iter(
771 tilings_.get(), scale, content_rect, ideal_contents_scale_); 771 tilings_.get(), scale, content_rect, ideal_contents_scale_);
772 772
773 // Mask resource not ready yet. 773 // Mask resource not ready yet.
774 if (!iter || !*iter) 774 if (!iter || !*iter)
775 return 0; 775 return 0;
776 776
777 // Masks only supported if they fit on exactly one tile. 777 // Masks only supported if they fit on exactly one tile.
778 if (iter.geometry_rect() != content_rect) 778 DCHECK(iter.geometry_rect() == content_rect)
779 return 0; 779 << "iter rect " << iter.geometry_rect().ToString() << " content rect "
780 << content_rect.ToString();
780 781
781 const ManagedTileState::TileVersion& tile_version = 782 const ManagedTileState::TileVersion& tile_version =
782 iter->GetTileVersionForDrawing(); 783 iter->GetTileVersionForDrawing();
783 if (!tile_version.IsReadyToDraw() || 784 if (!tile_version.IsReadyToDraw() ||
784 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) 785 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE)
785 return 0; 786 return 0;
786 787
787 return tile_version.get_resource_id(); 788 return tile_version.get_resource_id();
788 } 789 }
789 790
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 raster_contents_scale_ = 1186 raster_contents_scale_ =
1186 std::max(raster_contents_scale_, 1187 std::max(raster_contents_scale_,
1187 draw_properties().maximum_animation_contents_scale); 1188 draw_properties().maximum_animation_contents_scale);
1188 } else { 1189 } else {
1189 raster_contents_scale_ = 1190 raster_contents_scale_ =
1190 std::max(raster_contents_scale_, 1191 std::max(raster_contents_scale_,
1191 1.f * ideal_page_scale_ * ideal_device_scale_); 1192 1.f * ideal_page_scale_ * ideal_device_scale_);
1192 } 1193 }
1193 } 1194 }
1194 1195
1195 // If this layer would only create one tile at this content scale, 1196 // If this layer would create zero or one tiles at this content scale,
1196 // don't create a low res tiling. 1197 // don't create a low res tiling.
1197 gfx::Size content_bounds = 1198 gfx::Size content_bounds =
1198 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), raster_contents_scale_)); 1199 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), raster_contents_scale_));
1199 gfx::Size tile_size = CalculateTileSize(content_bounds); 1200 gfx::Size tile_size = CalculateTileSize(content_bounds);
1200 if (tile_size.width() >= content_bounds.width() && 1201 bool tile_covers_bounds = tile_size.width() >= content_bounds.width() &&
1201 tile_size.height() >= content_bounds.height()) { 1202 tile_size.height() >= content_bounds.height();
1203 if (tile_size.IsEmpty() || tile_covers_bounds) {
1202 low_res_raster_contents_scale_ = raster_contents_scale_; 1204 low_res_raster_contents_scale_ = raster_contents_scale_;
1203 return; 1205 return;
1204 } 1206 }
1205 1207
1206 float low_res_factor = 1208 float low_res_factor =
1207 layer_tree_impl()->settings().low_res_contents_scale_factor; 1209 layer_tree_impl()->settings().low_res_contents_scale_factor;
1208 low_res_raster_contents_scale_ = std::max( 1210 low_res_raster_contents_scale_ = std::max(
1209 raster_contents_scale_ * low_res_factor, 1211 raster_contents_scale_ * low_res_factor,
1210 MinimumContentsScale()); 1212 MinimumContentsScale());
1211 } 1213 }
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); 1774 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange();
1773 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; 1775 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start;
1774 return tiling_range.end - 1 - current_tiling_range_offset; 1776 return tiling_range.end - 1 - current_tiling_range_offset;
1775 } 1777 }
1776 } 1778 }
1777 NOTREACHED(); 1779 NOTREACHED();
1778 return 0; 1780 return 0;
1779 } 1781 }
1780 1782
1781 } // namespace cc 1783 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layers/picture_layer_impl_unittest.cc » ('j') | cc/layers/picture_layer_impl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698