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

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

Issue 330003003: cc: Pass ideal contents scale to PictureLayerTiling UpdateTilePriorities. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated test Created 6 years, 6 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.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include <utility> 10 #include <utility>
(...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 tilings.begin(); 1977 tilings.begin();
1978 tiling_iterator != tilings.end(); 1978 tiling_iterator != tilings.end();
1979 ++tiling_iterator) { 1979 ++tiling_iterator) {
1980 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); 1980 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting();
1981 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); 1981 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles));
1982 } 1982 }
1983 1983
1984 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); 1984 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end());
1985 1985
1986 bool mark_required = false; 1986 bool mark_required = false;
1987 for (std::vector<Tile*>::iterator it = all_tiles.begin(); 1987 for (size_t i = 0; i < tilings.size(); ++i) {
1988 it != all_tiles.end(); 1988 PictureLayerTiling* tiling = tilings.at(i);
1989 ++it) { 1989 for (PictureLayerTiling::CoverageIterator iter(
1990 Tile* tile = *it; 1990 tiling,
1991 if (mark_required) 1991 pending_layer_->contents_scale_x(),
1992 tile->MarkRequiredForActivation(); 1992 pending_layer_->visible_content_rect());
1993 mark_required = !mark_required; 1993 iter;
1994 ++iter) {
1995 if (mark_required)
1996 iter->MarkRequiredForActivation();
1997 mark_required = !mark_required;
1998 }
sohanjg 2014/06/20 13:35:20 I think we shouldnt be iterating over all the tile
enne (OOO) 2014/06/25 18:33:07 I think that's an ok change. This is just a test,
vmpstr 2014/06/25 21:08:52 I agree with this change. I was considering making
sohanjg 2014/06/26 08:30:51 Done.
1994 } 1999 }
1995 2000
1996 // Sanity checks. 2001 // Sanity checks.
1997 EXPECT_EQ(91u, all_tiles.size()); 2002 EXPECT_EQ(91u, all_tiles.size());
1998 EXPECT_EQ(91u, all_tiles_set.size()); 2003 EXPECT_EQ(91u, all_tiles_set.size());
1999 2004
2000 // Empty iterator. 2005 // Empty iterator.
2001 PictureLayerImpl::LayerEvictionTileIterator it; 2006 PictureLayerImpl::LayerEvictionTileIterator it;
2002 EXPECT_FALSE(it); 2007 EXPECT_FALSE(it);
2003 2008
(...skipping 27 matching lines...) Expand all
2031 last_tile = tile; 2036 last_tile = tile;
2032 break; 2037 break;
2033 } 2038 }
2034 2039
2035 if (reached_required) { 2040 if (reached_required) {
2036 EXPECT_TRUE(tile->required_for_activation()); 2041 EXPECT_TRUE(tile->required_for_activation());
2037 } else if (tile->required_for_activation()) { 2042 } else if (tile->required_for_activation()) {
2038 reached_required = true; 2043 reached_required = true;
2039 scale_index = 0; 2044 scale_index = 0;
2040 } 2045 }
2041 2046
sohanjg 2014/06/20 13:35:20 This check becomes redundant now, because the tile
enne (OOO) 2014/06/25 18:33:07 I don't understand why this is redundant.
sohanjg 2014/06/25 20:17:53 Because none of the tiles iterated over by layerev
enne (OOO) 2014/06/25 20:20:05 The iterator above is marking some of the tiles as
vmpstr 2014/06/25 21:08:52 This part of the loop break out as soon as a now b
sohanjg 2014/06/26 08:30:51 Done.
2042 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > 2047 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) >
2043 std::numeric_limits<float>::epsilon()) { 2048 std::numeric_limits<float>::epsilon()) {
2044 ++scale_index; 2049 ++scale_index;
2045 ASSERT_LT(scale_index, arraysize(expected_scales)); 2050 ASSERT_LT(scale_index, arraysize(expected_scales));
2046 } 2051 }
2047 2052
2048 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); 2053 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]);
2049 unique_tiles.insert(tile); 2054 unique_tiles.insert(tile);
2050 2055
2051 // If the tile is the same rough bin as last tile (same activation, bin, and 2056 // If the tile is the same rough bin as last tile (same activation, bin, and
2052 // scale), then distance should be decreasing. 2057 // scale), then distance should be decreasing.
2053 if (tile->required_for_activation() == 2058 if (tile->required_for_activation() ==
2054 last_tile->required_for_activation() && 2059 last_tile->required_for_activation() &&
2055 priority.priority_bin == 2060 priority.priority_bin ==
2056 last_tile->priority(PENDING_TREE).priority_bin && 2061 last_tile->priority(PENDING_TREE).priority_bin &&
2057 std::abs(tile->contents_scale() - last_tile->contents_scale()) < 2062 std::abs(tile->contents_scale() - last_tile->contents_scale()) <
2058 std::numeric_limits<float>::epsilon()) { 2063 std::numeric_limits<float>::epsilon()) {
2059 EXPECT_LE(priority.distance_to_visible, 2064 EXPECT_LE(priority.distance_to_visible,
2060 last_tile->priority(PENDING_TREE).distance_to_visible); 2065 last_tile->priority(PENDING_TREE).distance_to_visible);
2061 } 2066 }
2062 2067
2063 last_tile = tile; 2068 last_tile = tile;
2064 } 2069 }
2065 2070
2066 EXPECT_TRUE(reached_visible); 2071 EXPECT_TRUE(reached_visible);
2067 EXPECT_TRUE(reached_required);
sohanjg 2014/06/20 13:35:20 As mentioned above, this check is not required.
enne (OOO) 2014/06/25 18:33:07 This still seems valid to me. I don't understand.
2068 EXPECT_EQ(65u, unique_tiles.size()); 2072 EXPECT_EQ(65u, unique_tiles.size());
2069 2073
2070 scale_index = 0; 2074 scale_index = 0;
2071 reached_required = false; 2075 reached_required = false;
2072 for (; it; ++it) { 2076 for (; it; ++it) {
2073 Tile* tile = *it; 2077 Tile* tile = *it;
2074 EXPECT_TRUE(tile); 2078 EXPECT_TRUE(tile);
2075 2079
2076 TilePriority priority = tile->priority(PENDING_TREE); 2080 TilePriority priority = tile->priority(PENDING_TREE);
2077 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); 2081 EXPECT_EQ(TilePriority::NOW, priority.priority_bin);
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2804 2808
2805 host_impl_.pending_tree()->SetRootLayer(root.Pass()); 2809 host_impl_.pending_tree()->SetRootLayer(root.Pass());
2806 2810
2807 EXPECT_FALSE(pending_mask_content->tilings()); 2811 EXPECT_FALSE(pending_mask_content->tilings());
2808 host_impl_.pending_tree()->UpdateDrawProperties(); 2812 host_impl_.pending_tree()->UpdateDrawProperties();
2809 EXPECT_NE(0u, pending_mask_content->num_tilings()); 2813 EXPECT_NE(0u, pending_mask_content->num_tilings());
2810 } 2814 }
2811 2815
2812 } // namespace 2816 } // namespace
2813 } // namespace cc 2817 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698