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

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: Add tests. 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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 if (pile_->is_mask()) { 668 if (pile_->is_mask()) {
669 // Masks are not tiled, so if we can't cover the whole mask with one tile, 669 // 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. 670 // don't make any tiles at all. Returning an empty size signals this.
671 if (content_bounds.width() > max_texture_size || 671 if (content_bounds.width() > max_texture_size ||
672 content_bounds.height() > max_texture_size) 672 content_bounds.height() > max_texture_size)
673 return gfx::Size(); 673 return gfx::Size();
674 return content_bounds; 674 return content_bounds;
675 } 675 }
676 676
677 gfx::Size default_tile_size = layer_tree_impl()->settings().default_tile_size; 677 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 = 678 gfx::Size max_untiled_content_size =
688 layer_tree_impl()->settings().max_untiled_layer_size; 679 layer_tree_impl()->settings().max_untiled_layer_size;
680
681 // For GPU rasterization, we pick an ideal tile size using the viewport,
682 // so we don't need the above settings.
683 bool use_gpu = layer_tree_impl()->use_gpu_rasterization();
684 if (use_gpu) {
685 int width = layer_tree_impl()->device_viewport_size().width();
686 int height = layer_tree_impl()->device_viewport_size().height() / 4;
687 height = std::max(height, 128);
vmpstr 2014/10/08 23:30:28 nit: Consider making this a constant.
epennerAtGoogle 2014/10/09 00:29:43 Done.
688 default_tile_size = gfx::Size(width, height);
689 // Since the width is already expanded to viewport width, we use
690 // double the height as our max untiled size.
691 max_untiled_content_size = gfx::Size(height * 2, height * 2);
692 }
693
694 default_tile_size.SetToMin(gfx::Size(max_texture_size, max_texture_size));
689 max_untiled_content_size.SetToMin( 695 max_untiled_content_size.SetToMin(
690 gfx::Size(max_texture_size, max_texture_size)); 696 gfx::Size(max_texture_size, max_texture_size));
691 697
692 bool any_dimension_too_large = 698 bool any_dimension_too_large =
693 content_bounds.width() > max_untiled_content_size.width() || 699 content_bounds.width() > max_untiled_content_size.width() ||
694 content_bounds.height() > max_untiled_content_size.height(); 700 content_bounds.height() > max_untiled_content_size.height();
695 701
696 bool any_dimension_one_tile = 702 bool any_dimension_one_tile =
697 content_bounds.width() <= default_tile_size.width() || 703 !use_gpu && (content_bounds.width() <= default_tile_size.width() ||
vmpstr 2014/10/08 23:30:28 Can you make a comment here or something like that
epennerAtGoogle 2014/10/09 00:29:43 Done. While adding the comment, I realized this c
698 content_bounds.height() <= default_tile_size.height(); 704 content_bounds.height() <= default_tile_size.height());
699 705
700 // If long and skinny, tile at the max untiled content size, and clamp 706 // 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 707 // the smaller dimension to the content size, e.g. 1000x12 layer with
702 // 500x500 max untiled size would get 500x12 tiles. Also do this 708 // 500x500 max untiled size would get 500x12 tiles. Also do this
703 // if the layer is small. 709 // if the layer is small.
704 if (any_dimension_one_tile || !any_dimension_too_large) { 710 if (any_dimension_one_tile || !any_dimension_too_large) {
705 int width = std::min( 711 int width = std::min(
706 std::max(max_untiled_content_size.width(), default_tile_size.width()), 712 std::max(max_untiled_content_size.width(), default_tile_size.width()),
707 content_bounds.width()); 713 content_bounds.width());
708 int height = std::min( 714 int height = std::min(
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); 1793 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange();
1788 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; 1794 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start;
1789 return tiling_range.end - 1 - current_tiling_range_offset; 1795 return tiling_range.end - 1 - current_tiling_range_offset;
1790 } 1796 }
1791 } 1797 }
1792 NOTREACHED(); 1798 NOTREACHED();
1793 return 0; 1799 return 0;
1794 } 1800 }
1795 1801
1796 } // namespace cc 1802 } // 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