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