| OLD | NEW |
| 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 | 9 |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 int max_size = layer_tree_impl()->MaxTextureSize(); | 566 int max_size = layer_tree_impl()->MaxTextureSize(); |
| 567 return gfx::Size( | 567 return gfx::Size( |
| 568 std::min(max_size, content_bounds.width()), | 568 std::min(max_size, content_bounds.width()), |
| 569 std::min(max_size, content_bounds.height())); | 569 std::min(max_size, content_bounds.height())); |
| 570 } | 570 } |
| 571 | 571 |
| 572 int max_texture_size = | 572 int max_texture_size = |
| 573 layer_tree_impl()->resource_provider()->max_texture_size(); | 573 layer_tree_impl()->resource_provider()->max_texture_size(); |
| 574 | 574 |
| 575 gfx::Size default_tile_size = layer_tree_impl()->settings().default_tile_size; | 575 gfx::Size default_tile_size = layer_tree_impl()->settings().default_tile_size; |
| 576 if (ShouldUseGpuRasterization()) { |
| 577 // TODO(ernstm) crbug.com/365877: We need a unified way to override the |
| 578 // default-tile-size. |
| 579 default_tile_size = |
| 580 gfx::Size(layer_tree_impl()->device_viewport_size().width(), |
| 581 layer_tree_impl()->device_viewport_size().height() / 4); |
| 582 } |
| 576 default_tile_size.SetToMin(gfx::Size(max_texture_size, max_texture_size)); | 583 default_tile_size.SetToMin(gfx::Size(max_texture_size, max_texture_size)); |
| 577 | 584 |
| 578 gfx::Size max_untiled_content_size = | 585 gfx::Size max_untiled_content_size = |
| 579 layer_tree_impl()->settings().max_untiled_layer_size; | 586 layer_tree_impl()->settings().max_untiled_layer_size; |
| 580 max_untiled_content_size.SetToMin( | 587 max_untiled_content_size.SetToMin( |
| 581 gfx::Size(max_texture_size, max_texture_size)); | 588 gfx::Size(max_texture_size, max_texture_size)); |
| 582 | 589 |
| 583 bool any_dimension_too_large = | 590 bool any_dimension_too_large = |
| 584 content_bounds.width() > max_untiled_content_size.width() || | 591 content_bounds.width() > max_untiled_content_size.width() || |
| 585 content_bounds.height() > max_untiled_content_size.height(); | 592 content_bounds.height() > max_untiled_content_size.height(); |
| 586 | 593 |
| 587 bool any_dimension_one_tile = | 594 bool any_dimension_one_tile = |
| 588 content_bounds.width() <= default_tile_size.width() || | 595 content_bounds.width() <= default_tile_size.width() || |
| 589 content_bounds.height() <= default_tile_size.height(); | 596 content_bounds.height() <= default_tile_size.height(); |
| 590 | 597 |
| 591 // If long and skinny, tile at the max untiled content size, and clamp | 598 // If long and skinny, tile at the max untiled content size, and clamp |
| 592 // the smaller dimension to the content size, e.g. 1000x12 layer with | 599 // the smaller dimension to the content size, e.g. 1000x12 layer with |
| 593 // 500x500 max untiled size would get 500x12 tiles. Also do this | 600 // 500x500 max untiled size would get 500x12 tiles. Also do this |
| 594 // if the layer is small. | 601 // if the layer is small. |
| 595 if (any_dimension_one_tile || !any_dimension_too_large) { | 602 if (any_dimension_one_tile || !any_dimension_too_large) { |
| 596 int width = | 603 int width = std::min( |
| 597 std::min(max_untiled_content_size.width(), content_bounds.width()); | 604 std::max(max_untiled_content_size.width(), default_tile_size.width()), |
| 598 int height = | 605 content_bounds.width()); |
| 599 std::min(max_untiled_content_size.height(), content_bounds.height()); | 606 int height = std::min( |
| 607 std::max(max_untiled_content_size.height(), default_tile_size.height()), |
| 608 content_bounds.height()); |
| 600 // Round width and height up to the closest multiple of 64, or 56 if | 609 // Round width and height up to the closest multiple of 64, or 56 if |
| 601 // we should avoid power-of-two textures. This helps reduce the number | 610 // we should avoid power-of-two textures. This helps reduce the number |
| 602 // of different textures sizes to help recycling, and also keeps all | 611 // of different textures sizes to help recycling, and also keeps all |
| 603 // textures multiple-of-eight, which is preferred on some drivers (IMG). | 612 // textures multiple-of-eight, which is preferred on some drivers (IMG). |
| 604 bool avoid_pow2 = | 613 bool avoid_pow2 = |
| 605 layer_tree_impl()->GetRendererCapabilities().avoid_pow2_textures; | 614 layer_tree_impl()->GetRendererCapabilities().avoid_pow2_textures; |
| 606 int round_up_to = avoid_pow2 ? 56 : 64; | 615 int round_up_to = avoid_pow2 ? 56 : 64; |
| 607 width = RoundUp(width, round_up_to); | 616 width = RoundUp(width, round_up_to); |
| 608 height = RoundUp(height, round_up_to); | 617 height = RoundUp(height, round_up_to); |
| 609 return gfx::Size(width, height); | 618 return gfx::Size(width, height); |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 return iterator_index_ < iterators_.size(); | 1517 return iterator_index_ < iterators_.size(); |
| 1509 } | 1518 } |
| 1510 | 1519 |
| 1511 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1520 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
| 1512 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1521 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
| 1513 return it->get_type() == iteration_stage_ && | 1522 return it->get_type() == iteration_stage_ && |
| 1514 (**it)->required_for_activation() == required_for_activation_; | 1523 (**it)->required_for_activation() == required_for_activation_; |
| 1515 } | 1524 } |
| 1516 | 1525 |
| 1517 } // namespace cc | 1526 } // namespace cc |
| OLD | NEW |