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

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

Issue 605773004: CC: Tile-size cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 2 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 | « no previous file | 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 26 matching lines...) Expand all
37 // tiling's scale if the desired scale is within this ratio. 37 // tiling's scale if the desired scale is within this ratio.
38 const float kSnapToExistingTilingRatio = 1.2f; 38 const float kSnapToExistingTilingRatio = 1.2f;
39 39
40 // Estimate skewport 60 frames ahead for pre-rasterization on the CPU. 40 // Estimate skewport 60 frames ahead for pre-rasterization on the CPU.
41 const float kCpuSkewportTargetTimeInFrames = 60.0f; 41 const float kCpuSkewportTargetTimeInFrames = 60.0f;
42 42
43 // Don't pre-rasterize on the GPU (except for kBackflingGuardDistancePixels in 43 // Don't pre-rasterize on the GPU (except for kBackflingGuardDistancePixels in
44 // TileManager::BinFromTilePriority). 44 // TileManager::BinFromTilePriority).
45 const float kGpuSkewportTargetTimeInFrames = 0.0f; 45 const float kGpuSkewportTargetTimeInFrames = 0.0f;
46 46
47 // Even for really wide viewports, at some point GPU raster should use
48 // less than 4 tiles to fill the viewport. This is set to 128 as a
49 // sane minimum for now, but we might want to increase with tuning.
50 const int kMinHeightForGpuRasteredTile = 128;
51
47 } // namespace 52 } // namespace
48 53
49 namespace cc { 54 namespace cc {
50 55
51 PictureLayerImpl::Pair::Pair() : active(NULL), pending(NULL) { 56 PictureLayerImpl::Pair::Pair() : active(NULL), pending(NULL) {
52 } 57 }
53 58
54 PictureLayerImpl::Pair::Pair(PictureLayerImpl* active_layer, 59 PictureLayerImpl::Pair::Pair(PictureLayerImpl* active_layer,
55 PictureLayerImpl* pending_layer) 60 PictureLayerImpl* pending_layer)
56 : active(active_layer), pending(pending_layer) { 61 : active(active_layer), pending(pending_layer) {
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 if (pile_->is_mask()) { 673 if (pile_->is_mask()) {
669 // Masks are not tiled, so if we can't cover the whole mask with one tile, 674 // Masks are not tiled, so if we can't cover the whole mask with one tile,
670 // don't make any tiles at all. Returning an empty size signals this. 675 // don't make any tiles at all. Returning an empty size signals this.
671 if (content_bounds.width() > max_texture_size || 676 if (content_bounds.width() > max_texture_size ||
672 content_bounds.height() > max_texture_size) 677 content_bounds.height() > max_texture_size)
673 return gfx::Size(); 678 return gfx::Size();
674 return content_bounds; 679 return content_bounds;
675 } 680 }
676 681
677 gfx::Size default_tile_size = layer_tree_impl()->settings().default_tile_size; 682 gfx::Size default_tile_size = layer_tree_impl()->settings().default_tile_size;
678 if (layer_tree_impl()->use_gpu_rasterization()) {
679 // TODO(ernstm) crbug.com/365877: We need a unified way to override the
680 // default-tile-size.
681 default_tile_size =
682 gfx::Size(layer_tree_impl()->device_viewport_size().width(),
683 layer_tree_impl()->device_viewport_size().height() / 4);
684 }
685 default_tile_size.SetToMin(gfx::Size(max_texture_size, max_texture_size));
686
687 gfx::Size max_untiled_content_size = 683 gfx::Size max_untiled_content_size =
688 layer_tree_impl()->settings().max_untiled_layer_size; 684 layer_tree_impl()->settings().max_untiled_layer_size;
685
686 // For GPU rasterization, we pick an ideal tile size using the viewport,
687 // so we don't need the above settings.
688 bool use_gpu = layer_tree_impl()->use_gpu_rasterization();
689 if (use_gpu) {
vmpstr 2014/10/09 16:35:43 For complexity thing, maybe just have the two vari
epenner 2014/10/09 18:36:33 I dunno, I think once you see the code you might n
vmpstr 2014/10/09 18:38:18 Fair enough. That's why I'm not really sure how to
690 int width = layer_tree_impl()->device_viewport_size().width();
691 int height = layer_tree_impl()->device_viewport_size().height() / 4;
692 height = std::max(height, kMinHeightForGpuRasteredTile);
693 default_tile_size = gfx::Size(width, height);
694 // Since the width is already expanded to viewport width, we use
695 // double the height as our max untiled size.
696 max_untiled_content_size = gfx::Size(height * 2, height * 2);
697 }
698
699 default_tile_size.SetToMin(gfx::Size(max_texture_size, max_texture_size));
689 max_untiled_content_size.SetToMin( 700 max_untiled_content_size.SetToMin(
690 gfx::Size(max_texture_size, max_texture_size)); 701 gfx::Size(max_texture_size, max_texture_size));
691 702
692 bool any_dimension_too_large = 703 bool both_dimensions_are_small =
693 content_bounds.width() > max_untiled_content_size.width() || 704 content_bounds.width() <= max_untiled_content_size.width() &&
694 content_bounds.height() > max_untiled_content_size.height(); 705 content_bounds.height() <= max_untiled_content_size.height();
695 706
696 bool any_dimension_one_tile = 707 bool long_and_skinny =
697 content_bounds.width() <= default_tile_size.width() || 708 content_bounds.width() <= default_tile_size.width() ||
698 content_bounds.height() <= default_tile_size.height(); 709 content_bounds.height() <= default_tile_size.height();
699 710
711 // Using GPU raster the width is already expanded to the viewport, so we just
712 // use the height to determine if the layer is skinny horizontally.
713 if (use_gpu)
714 long_and_skinny = content_bounds.width() <= default_tile_size.height();
vmpstr 2014/10/09 16:35:43 typo? This should probably compare height with hei
epenner 2014/10/09 18:36:32 This is what I intended. But perhaps I need to imp
715
700 // If long and skinny, tile at the max untiled content size, and clamp 716 // If long and skinny, tile at the max untiled content size, and clamp
701 // the smaller dimension to the content size, e.g. 1000x12 layer with 717 // the smaller dimension to the content size, e.g. 1000x12 layer with
702 // 500x500 max untiled size would get 500x12 tiles. Also do this 718 // 500x500 max untiled size would get 500x12 tiles. Also do this
703 // if the layer is small. 719 // if the layer is small.
704 if (any_dimension_one_tile || !any_dimension_too_large) { 720 if (long_and_skinny || both_dimensions_are_small) {
705 int width = std::min( 721 int width = std::min(
706 std::max(max_untiled_content_size.width(), default_tile_size.width()), 722 std::max(max_untiled_content_size.width(), default_tile_size.width()),
707 content_bounds.width()); 723 content_bounds.width());
708 int height = std::min( 724 int height = std::min(
709 std::max(max_untiled_content_size.height(), default_tile_size.height()), 725 std::max(max_untiled_content_size.height(), default_tile_size.height()),
710 content_bounds.height()); 726 content_bounds.height());
711 // Round up to the closest multiple of 64. This improves recycling and 727 // Round up to the closest multiple of 64. This improves recycling and
712 // avoids odd texture sizes. 728 // avoids odd texture sizes.
713 width = RoundUp(width, 64); 729 width = RoundUp(width, 64);
714 height = RoundUp(height, 64); 730 height = RoundUp(height, 64);
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); 1803 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange();
1788 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; 1804 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start;
1789 return tiling_range.end - 1 - current_tiling_range_offset; 1805 return tiling_range.end - 1 - current_tiling_range_offset;
1790 } 1806 }
1791 } 1807 }
1792 NOTREACHED(); 1808 NOTREACHED();
1793 return 0; 1809 return 0;
1794 } 1810 }
1795 1811
1796 } // namespace cc 1812 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698