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

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

Issue 2295343005: Improve PictureLayerTiling::CoverageIterator to handle rounding more precisely (Closed)
Patch Set: remove the 1.5 Created 4 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
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/tiles/picture_layer_tiling.h » ('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 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 high_tiles); 1922 high_tiles);
1923 1923
1924 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); 1924 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
1925 AppendQuadsData data; 1925 AppendQuadsData data;
1926 active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); 1926 active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1927 active_layer()->AppendQuads(render_pass.get(), &data); 1927 active_layer()->AppendQuads(render_pass.get(), &data);
1928 active_layer()->DidDraw(nullptr); 1928 active_layer()->DidDraw(nullptr);
1929 1929
1930 // All high res tiles drew, and the one ideal res tile drew. 1930 // All high res tiles drew, and the one ideal res tile drew.
1931 ASSERT_GT(render_pass->quad_list.size(), 9u); 1931 ASSERT_GT(render_pass->quad_list.size(), 9u);
1932 EXPECT_EQ(gfx::SizeF(99.f, 99.f), 1932 EXPECT_EQ(gfx::Rect(0, 0, 99, 99), render_pass->quad_list.front()->rect);
1933 EXPECT_EQ(gfx::RectF(0.f, 0.f, 99.f, 99.f),
1933 TileDrawQuad::MaterialCast(render_pass->quad_list.front()) 1934 TileDrawQuad::MaterialCast(render_pass->quad_list.front())
1934 ->tex_coord_rect.size()); 1935 ->tex_coord_rect);
1935 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f), 1936 EXPECT_EQ(gfx::Rect(99, 0, 100, 99),
1937 render_pass->quad_list.ElementAt(1)->rect);
1938 EXPECT_EQ(gfx::RectF(49.5f, 0.f, 50.f, 49.5f),
1936 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1)) 1939 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1))
1937 ->tex_coord_rect.size()); 1940 ->tex_coord_rect);
1938 1941
1939 // Neither the high res nor the ideal tiles were considered as incomplete. 1942 // Neither the high res nor the ideal tiles were considered as incomplete.
1940 EXPECT_EQ(0u, data.num_missing_tiles); 1943 EXPECT_EQ(0u, data.num_missing_tiles);
1941 EXPECT_EQ(0u, data.num_incomplete_tiles); 1944 EXPECT_EQ(0u, data.num_incomplete_tiles);
1942 EXPECT_FALSE(active_layer()->only_used_low_res_last_append_quads()); 1945 EXPECT_FALSE(active_layer()->only_used_low_res_last_append_quads());
1943 } 1946 }
1944 1947
1945 TEST_F(PictureLayerImplTest, AppendQuadsDataForCheckerboard) { 1948 TEST_F(PictureLayerImplTest, AppendQuadsDataForCheckerboard) {
1946 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1949 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1947 1950
(...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after
4122 4125
4123 EXPECT_EQ(1u, pending_layer()->num_tilings()); 4126 EXPECT_EQ(1u, pending_layer()->num_tilings());
4124 EXPECT_EQ(2u, active_layer()->num_tilings()); 4127 EXPECT_EQ(2u, active_layer()->num_tilings());
4125 4128
4126 RebuildPropertyTreesOnPendingTree(); 4129 RebuildPropertyTreesOnPendingTree();
4127 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4130 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4128 // UpdateDrawProperties with the occluding layer. 4131 // UpdateDrawProperties with the occluding layer.
4129 bool update_lcd_text = false; 4132 bool update_lcd_text = false;
4130 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); 4133 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text);
4131 4134
4135 float dest_scale = std::max(active_layer()->MaximumTilingContentsScale(),
4136 pending_layer()->MaximumTilingContentsScale());
4137 gfx::Rect dest_layer_bounds =
4138 gfx::ScaleToEnclosingRect(gfx::Rect(layer_bounds), dest_scale);
4139 gfx::Rect dest_invalidation_rect =
4140 gfx::ScaleToEnclosingRect(invalidation_rect, dest_scale);
4141
4132 // The expected number of occluded tiles on each of the 2 tilings for each of 4142 // The expected number of occluded tiles on each of the 2 tilings for each of
4133 // the 3 tree priorities. 4143 // the 3 tree priorities.
4134 size_t expected_occluded_tile_count_on_pending[] = {4u, 0u}; 4144 size_t expected_occluded_tile_count_on_pending[] = {4u, 0u};
4135 size_t expected_occluded_tile_count_on_active[] = {12u, 3u}; 4145 size_t expected_occluded_tile_count_on_active[] = {12u, 3u};
4136 size_t total_expected_occluded_tile_count_on_trees[] = {15u, 4u}; 4146 size_t total_expected_occluded_tile_count_on_trees[] = {15u, 4u};
4137 4147
4138 // Verify number of occluded tiles on the pending layer for each tiling. 4148 // Verify number of occluded tiles on the pending layer for each tiling.
4139 for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { 4149 for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) {
4140 PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); 4150 PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i);
4141 auto prioritized_tiles = 4151 auto prioritized_tiles =
4142 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); 4152 tiling->UpdateAndGetAllPrioritizedTilesForTesting();
4143 4153
4144 size_t occluded_tile_count_on_pending = 0u; 4154 size_t occluded_tile_count_on_pending = 0u;
4145 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, 4155 for (PictureLayerTiling::CoverageIterator iter(tiling, dest_scale,
4146 gfx::Rect(layer_bounds)); 4156 dest_layer_bounds);
4147 iter; ++iter) { 4157 iter; ++iter) {
4148 Tile* tile = *iter; 4158 Tile* tile = *iter;
4149 4159
4150 if (invalidation_rect.Intersects(iter.geometry_rect())) 4160 if (dest_invalidation_rect.Intersects(iter.geometry_rect()))
4151 EXPECT_TRUE(tile); 4161 EXPECT_TRUE(tile);
4152 else 4162 else
4153 EXPECT_FALSE(tile); 4163 EXPECT_FALSE(tile);
4154 4164
4155 if (!tile) 4165 if (!tile)
4156 continue; 4166 continue;
4157 if (prioritized_tiles[tile].is_occluded()) 4167 if (prioritized_tiles[tile].is_occluded())
4158 occluded_tile_count_on_pending++; 4168 occluded_tile_count_on_pending++;
4159 } 4169 }
4160 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], 4170 EXPECT_EQ(expected_occluded_tile_count_on_pending[i],
4161 occluded_tile_count_on_pending) 4171 occluded_tile_count_on_pending)
4162 << tiling->contents_scale(); 4172 << tiling->contents_scale();
4163 } 4173 }
4164 4174
4165 // Verify number of occluded tiles on the active layer for each tiling. 4175 // Verify number of occluded tiles on the active layer for each tiling.
4166 for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { 4176 for (size_t i = 0; i < active_layer()->num_tilings(); ++i) {
4167 PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); 4177 PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i);
4168 auto prioritized_tiles = 4178 auto prioritized_tiles =
4169 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); 4179 tiling->UpdateAndGetAllPrioritizedTilesForTesting();
4170 4180
4171 size_t occluded_tile_count_on_active = 0u; 4181 size_t occluded_tile_count_on_active = 0u;
4172 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, 4182 for (PictureLayerTiling::CoverageIterator iter(tiling, dest_scale,
4173 gfx::Rect(layer_bounds)); 4183 dest_layer_bounds);
4174 iter; ++iter) { 4184 iter; ++iter) {
4175 Tile* tile = *iter; 4185 Tile* tile = *iter;
4176 4186
4177 if (!tile) 4187 if (!tile)
4178 continue; 4188 continue;
4179 if (prioritized_tiles[tile].is_occluded()) 4189 if (prioritized_tiles[tile].is_occluded())
4180 occluded_tile_count_on_active++; 4190 occluded_tile_count_on_active++;
4181 } 4191 }
4182 EXPECT_EQ(expected_occluded_tile_count_on_active[i], 4192 EXPECT_EQ(expected_occluded_tile_count_on_active[i],
4183 occluded_tile_count_on_active) 4193 occluded_tile_count_on_active)
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
4962 EXPECT_FLOAT_EQ(expected_contents_scale, 4972 EXPECT_FLOAT_EQ(expected_contents_scale,
4963 pending_layer_ptr->picture_layer_tiling_set() 4973 pending_layer_ptr->picture_layer_tiling_set()
4964 ->FindTilingWithResolution(HIGH_RESOLUTION) 4974 ->FindTilingWithResolution(HIGH_RESOLUTION)
4965 ->contents_scale()) 4975 ->contents_scale())
4966 << "ideal_contents_scale: " << ideal_contents_scale; 4976 << "ideal_contents_scale: " << ideal_contents_scale;
4967 } 4977 }
4968 } 4978 }
4969 4979
4970 } // namespace 4980 } // namespace
4971 } // namespace cc 4981 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/tiles/picture_layer_tiling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698