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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1750 host_impl_.SetCurrentBeginFrameArgs( | 1750 host_impl_.SetCurrentBeginFrameArgs( |
1751 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1751 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1752 pending_layer_->UpdateTiles(resourceless_software_draw); | 1752 pending_layer_->UpdateTiles(resourceless_software_draw); |
1753 | 1753 |
1754 int num_visible = 0; | 1754 int num_visible = 0; |
1755 int num_offscreen = 0; | 1755 int num_offscreen = 0; |
1756 | 1756 |
1757 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 1757 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
1758 pending_layer_->picture_layer_tiling_set(), false)); | 1758 pending_layer_->picture_layer_tiling_set(), false)); |
1759 for (; !queue->IsEmpty(); queue->Pop()) { | 1759 for (; !queue->IsEmpty(); queue->Pop()) { |
1760 const Tile* tile = queue->Top(); | 1760 PrioritizedTile prioritized_tile = queue->Top(); |
vmpstr
2015/05/08 18:11:06
minor (because this is test) nit: const ref
hendrikw
2015/05/08 19:21:02
Done.
| |
1761 DCHECK(tile); | 1761 DCHECK(prioritized_tile.tile()); |
1762 if (tile->priority().distance_to_visible == 0.f) { | 1762 if (prioritized_tile.priority().distance_to_visible == 0.f) { |
1763 EXPECT_TRUE(tile->required_for_activation()); | 1763 EXPECT_TRUE(prioritized_tile.tile()->required_for_activation()); |
1764 num_visible++; | 1764 num_visible++; |
1765 } else { | 1765 } else { |
1766 EXPECT_FALSE(tile->required_for_activation()); | 1766 EXPECT_FALSE(prioritized_tile.tile()->required_for_activation()); |
1767 num_offscreen++; | 1767 num_offscreen++; |
1768 } | 1768 } |
1769 } | 1769 } |
1770 | 1770 |
1771 EXPECT_GT(num_visible, 0); | 1771 EXPECT_GT(num_visible, 0); |
1772 EXPECT_GT(num_offscreen, 0); | 1772 EXPECT_GT(num_offscreen, 0); |
1773 } | 1773 } |
1774 | 1774 |
1775 TEST_F(NoLowResPictureLayerImplTest, | 1775 TEST_F(NoLowResPictureLayerImplTest, |
1776 TileOutsideOfViewportForTilePriorityNotRequired) { | 1776 TileOutsideOfViewportForTilePriorityNotRequired) { |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2064 gfx::Size layer_bounds(400, 400); | 2064 gfx::Size layer_bounds(400, 400); |
2065 gfx::Size tile_size(100, 100); | 2065 gfx::Size tile_size(100, 100); |
2066 | 2066 |
2067 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, | 2067 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, |
2068 gfx::Rect(layer_bounds)); | 2068 gfx::Rect(layer_bounds)); |
2069 | 2069 |
2070 active_layer_->SetAllTilesReady(); | 2070 active_layer_->SetAllTilesReady(); |
2071 | 2071 |
2072 // All active tiles ready, so pending can only activate with all high res | 2072 // All active tiles ready, so pending can only activate with all high res |
2073 // tiles. | 2073 // tiles. |
2074 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2074 pending_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
vmpstr
2015/05/08 18:11:06
I think what you're using here is required_for_act
hendrikw
2015/05/08 19:21:02
Done.
| |
2075 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2075 pending_layer_->LowResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2076 | 2076 |
2077 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2077 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
2078 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2078 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2079 } | 2079 } |
2080 | 2080 |
2081 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { | 2081 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { |
2082 gfx::Size layer_bounds(400, 400); | 2082 gfx::Size layer_bounds(400, 400); |
2083 gfx::Size tile_size(100, 100); | 2083 gfx::Size tile_size(100, 100); |
2084 | 2084 |
2085 // No invalidation. | 2085 // No invalidation. |
2086 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 2086 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
2087 | 2087 |
2088 // Verify active tree not ready. | 2088 // Verify active tree not ready. |
2089 Tile* some_active_tile = | 2089 Tile* some_active_tile = |
2090 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2090 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
2091 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2091 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
2092 | 2092 |
2093 // When high res are required, all tiles in active high res tiling should be | 2093 // When high res are required, all tiles in active high res tiling should be |
2094 // required for activation. | 2094 // required for activation. |
2095 host_impl_.SetRequiresHighResToDraw(); | 2095 host_impl_.SetRequiresHighResToDraw(); |
2096 | 2096 |
2097 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2097 pending_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2098 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2098 pending_layer_->LowResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2099 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2099 active_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2100 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2100 active_layer_->LowResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2101 | 2101 |
2102 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); | 2102 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
2103 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); | 2103 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
2104 AssertAllTilesRequired(active_layer_->HighResTiling()); | 2104 AssertAllTilesRequired(active_layer_->HighResTiling()); |
2105 AssertNoTilesRequired(active_layer_->LowResTiling()); | 2105 AssertNoTilesRequired(active_layer_->LowResTiling()); |
2106 } | 2106 } |
2107 | 2107 |
2108 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { | 2108 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { |
2109 gfx::Size layer_bounds(400, 400); | 2109 gfx::Size layer_bounds(400, 400); |
2110 gfx::Size tile_size(100, 100); | 2110 gfx::Size tile_size(100, 100); |
2111 | 2111 |
2112 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 2112 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
2113 | 2113 |
2114 Tile* some_active_tile = | 2114 Tile* some_active_tile = |
2115 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2115 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
2116 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2116 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
2117 | 2117 |
2118 // Since there are no invalidations, pending tree should have no tiles. | 2118 // Since there are no invalidations, pending tree should have no tiles. |
2119 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); | 2119 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
2120 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); | 2120 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
2121 | 2121 |
2122 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2122 active_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2123 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2123 active_layer_->LowResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2124 | 2124 |
2125 AssertAllTilesRequired(active_layer_->HighResTiling()); | 2125 AssertAllTilesRequired(active_layer_->HighResTiling()); |
2126 AssertNoTilesRequired(active_layer_->LowResTiling()); | 2126 AssertNoTilesRequired(active_layer_->LowResTiling()); |
2127 } | 2127 } |
2128 | 2128 |
2129 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { | 2129 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { |
2130 gfx::Size layer_bounds(400, 400); | 2130 gfx::Size layer_bounds(400, 400); |
2131 gfx::Size tile_size(100, 100); | 2131 gfx::Size tile_size(100, 100); |
2132 | 2132 |
2133 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 2133 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
2134 | 2134 |
2135 Tile* some_active_tile = | 2135 Tile* some_active_tile = |
2136 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2136 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
2137 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2137 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
2138 | 2138 |
2139 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); | 2139 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
2140 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); | 2140 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
2141 active_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); | 2141 active_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); |
2142 active_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); | 2142 active_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); |
2143 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); | 2143 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); |
2144 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); | 2144 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); |
2145 | 2145 |
2146 // If we disallow required for activation, no tiles can be required. | 2146 // If we disallow required for activation, no tiles can be required. |
2147 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2147 active_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2148 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2148 active_layer_->LowResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2149 | 2149 |
2150 AssertNoTilesRequired(active_layer_->HighResTiling()); | 2150 AssertNoTilesRequired(active_layer_->HighResTiling()); |
2151 AssertNoTilesRequired(active_layer_->LowResTiling()); | 2151 AssertNoTilesRequired(active_layer_->LowResTiling()); |
2152 } | 2152 } |
2153 | 2153 |
2154 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 2154 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
2155 gfx::Size layer_bounds(400, 400); | 2155 gfx::Size layer_bounds(400, 400); |
2156 gfx::Size tile_size(100, 100); | 2156 gfx::Size tile_size(100, 100); |
2157 | 2157 |
2158 scoped_refptr<FakePicturePileImpl> pending_pile = | 2158 scoped_refptr<FakePicturePileImpl> pending_pile = |
2159 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2159 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
2160 // This pile will create tilings, but has no recordings so will not create any | 2160 // This pile will create tilings, but has no recordings so will not create any |
2161 // tiles. This is attempting to simulate scrolling past the end of recorded | 2161 // tiles. This is attempting to simulate scrolling past the end of recorded |
2162 // content on the active layer, where the recordings are so far away that | 2162 // content on the active layer, where the recordings are so far away that |
2163 // no tiles are created. | 2163 // no tiles are created. |
2164 bool is_solid_color = false; | 2164 bool is_solid_color = false; |
2165 scoped_refptr<FakePicturePileImpl> active_pile = | 2165 scoped_refptr<FakePicturePileImpl> active_pile = |
2166 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 2166 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
2167 tile_size, layer_bounds, is_solid_color); | 2167 tile_size, layer_bounds, is_solid_color); |
2168 | 2168 |
2169 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); | 2169 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
2170 | 2170 |
2171 // Active layer has tilings, but no tiles due to missing recordings. | 2171 // Active layer has tilings, but no tiles due to missing recordings. |
2172 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 2172 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
2173 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); | 2173 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); |
2174 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 2174 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
2175 | 2175 |
2176 // Since the active layer has no tiles at all, the pending layer doesn't | 2176 // Since the active layer has no tiles at all, the pending layer doesn't |
2177 // need content in order to activate. | 2177 // need content in order to activate. |
2178 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2178 pending_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2179 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2179 pending_layer_->LowResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2180 | 2180 |
2181 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 2181 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
2182 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2182 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2183 } | 2183 } |
2184 | 2184 |
2185 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { | 2185 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { |
2186 gfx::Size layer_bounds(400, 400); | 2186 gfx::Size layer_bounds(400, 400); |
2187 gfx::Size tile_size(100, 100); | 2187 gfx::Size tile_size(100, 100); |
2188 | 2188 |
2189 scoped_refptr<FakePicturePileImpl> pending_pile = | 2189 scoped_refptr<FakePicturePileImpl> pending_pile = |
2190 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2190 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
2191 scoped_refptr<FakePicturePileImpl> active_pile = | 2191 scoped_refptr<FakePicturePileImpl> active_pile = |
2192 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 2192 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
2193 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); | 2193 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
2194 | 2194 |
2195 // Active layer can't have tiles. | 2195 // Active layer can't have tiles. |
2196 EXPECT_FALSE(active_layer_->CanHaveTilings()); | 2196 EXPECT_FALSE(active_layer_->CanHaveTilings()); |
2197 | 2197 |
2198 // All high res tiles required. This should be considered identical | 2198 // All high res tiles required. This should be considered identical |
2199 // to the case where there is no active layer, to avoid flashing content. | 2199 // to the case where there is no active layer, to avoid flashing content. |
2200 // This can happen if a layer exists for a while and switches from | 2200 // This can happen if a layer exists for a while and switches from |
2201 // not being able to have content to having content. | 2201 // not being able to have content to having content. |
2202 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2202 pending_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2203 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2203 pending_layer_->LowResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2204 | 2204 |
2205 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2205 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
2206 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2206 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2207 } | 2207 } |
2208 | 2208 |
2209 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { | 2209 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { |
2210 gfx::Size pending_layer_bounds(400, 400); | 2210 gfx::Size pending_layer_bounds(400, 400); |
2211 gfx::Size active_layer_bounds(200, 200); | 2211 gfx::Size active_layer_bounds(200, 200); |
2212 gfx::Size tile_size(100, 100); | 2212 gfx::Size tile_size(100, 100); |
2213 | 2213 |
2214 scoped_refptr<FakePicturePileImpl> pending_pile = | 2214 scoped_refptr<FakePicturePileImpl> pending_pile = |
2215 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds); | 2215 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds); |
2216 scoped_refptr<FakePicturePileImpl> active_pile = | 2216 scoped_refptr<FakePicturePileImpl> active_pile = |
2217 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); | 2217 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); |
2218 | 2218 |
2219 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); | 2219 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
2220 | 2220 |
2221 // Since the active layer has different bounds, the pending layer needs all | 2221 // Since the active layer has different bounds, the pending layer needs all |
2222 // high res tiles in order to activate. | 2222 // high res tiles in order to activate. |
2223 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2223 pending_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2224 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2224 pending_layer_->LowResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2225 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2225 active_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2226 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2226 active_layer_->LowResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2227 | 2227 |
2228 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2228 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
2229 AssertAllTilesRequired(active_layer_->HighResTiling()); | 2229 AssertAllTilesRequired(active_layer_->HighResTiling()); |
2230 AssertNoTilesRequired(active_layer_->LowResTiling()); | 2230 AssertNoTilesRequired(active_layer_->LowResTiling()); |
2231 // Since the test doesn't invalidate the resized region, we expect that the | 2231 // Since the test doesn't invalidate the resized region, we expect that the |
2232 // same low res tile would exist (which means we don't create a new one of the | 2232 // same low res tile would exist (which means we don't create a new one of the |
2233 // pending tree). | 2233 // pending tree). |
2234 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); | 2234 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
2235 } | 2235 } |
2236 | 2236 |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2546 gfx::Size viewport_size(1000, 1000); | 2546 gfx::Size viewport_size(1000, 1000); |
2547 host_impl_.SetViewportSize(viewport_size); | 2547 host_impl_.SetViewportSize(viewport_size); |
2548 | 2548 |
2549 gfx::Size layer_bounds(4000, 4000); | 2549 gfx::Size layer_bounds(4000, 4000); |
2550 SetupDefaultTrees(layer_bounds); | 2550 SetupDefaultTrees(layer_bounds); |
2551 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); | 2551 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); |
2552 | 2552 |
2553 // Should only have the high-res tiling. | 2553 // Should only have the high-res tiling. |
2554 EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); | 2554 EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); |
2555 | 2555 |
2556 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2556 active_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
2557 | 2557 |
2558 // High res tiling should have 64 tiles (4x16 tile grid). | 2558 // High res tiling should have 64 tiles (4x16 tile grid). |
2559 EXPECT_EQ(64u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | 2559 EXPECT_EQ(64u, active_layer_->HighResTiling()->AllTilesForTesting().size()); |
2560 | 2560 |
2561 // Visible viewport should be covered by 4 tiles. No other | 2561 // Visible viewport should be covered by 4 tiles. No other |
2562 // tiles should be required for activation. | 2562 // tiles should be required for activation. |
2563 EXPECT_EQ(4u, NumberOfTilesRequired(active_layer_->HighResTiling())); | 2563 EXPECT_EQ(4u, NumberOfTilesRequired(active_layer_->HighResTiling())); |
2564 } | 2564 } |
2565 | 2565 |
2566 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { | 2566 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2915 | 2915 |
2916 std::set<Tile*> unique_tiles; | 2916 std::set<Tile*> unique_tiles; |
2917 bool reached_prepaint = false; | 2917 bool reached_prepaint = false; |
2918 int non_ideal_tile_count = 0u; | 2918 int non_ideal_tile_count = 0u; |
2919 int low_res_tile_count = 0u; | 2919 int low_res_tile_count = 0u; |
2920 int high_res_tile_count = 0u; | 2920 int high_res_tile_count = 0u; |
2921 int high_res_now_tiles = 0u; | 2921 int high_res_now_tiles = 0u; |
2922 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 2922 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
2923 pending_layer_->picture_layer_tiling_set(), false)); | 2923 pending_layer_->picture_layer_tiling_set(), false)); |
2924 while (!queue->IsEmpty()) { | 2924 while (!queue->IsEmpty()) { |
2925 Tile* tile = queue->Top(); | 2925 PrioritizedTile prioritized_tile = queue->Top(); |
2926 TilePriority priority = tile->priority(); | 2926 TilePriority priority = prioritized_tile.priority(); |
2927 | 2927 |
2928 EXPECT_TRUE(tile); | 2928 EXPECT_TRUE(prioritized_tile.tile()); |
2929 | 2929 |
2930 // Non-high res tiles only get visible tiles. Also, prepaint should only | 2930 // Non-high res tiles only get visible tiles. Also, prepaint should only |
2931 // come at the end of the iteration. | 2931 // come at the end of the iteration. |
2932 if (priority.resolution != HIGH_RESOLUTION) { | 2932 if (priority.resolution != HIGH_RESOLUTION) { |
2933 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 2933 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
2934 } else if (reached_prepaint) { | 2934 } else if (reached_prepaint) { |
2935 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 2935 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
2936 } else { | 2936 } else { |
2937 reached_prepaint = priority.priority_bin != TilePriority::NOW; | 2937 reached_prepaint = priority.priority_bin != TilePriority::NOW; |
2938 if (!reached_prepaint) | 2938 if (!reached_prepaint) |
2939 ++high_res_now_tiles; | 2939 ++high_res_now_tiles; |
2940 } | 2940 } |
2941 | 2941 |
2942 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; | 2942 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; |
2943 low_res_tile_count += priority.resolution == LOW_RESOLUTION; | 2943 low_res_tile_count += priority.resolution == LOW_RESOLUTION; |
2944 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; | 2944 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; |
2945 | 2945 |
2946 unique_tiles.insert(tile); | 2946 unique_tiles.insert(prioritized_tile.tile()); |
2947 queue->Pop(); | 2947 queue->Pop(); |
2948 } | 2948 } |
2949 | 2949 |
2950 EXPECT_TRUE(reached_prepaint); | 2950 EXPECT_TRUE(reached_prepaint); |
2951 EXPECT_EQ(0, non_ideal_tile_count); | 2951 EXPECT_EQ(0, non_ideal_tile_count); |
2952 EXPECT_EQ(0, low_res_tile_count); | 2952 EXPECT_EQ(0, low_res_tile_count); |
2953 | 2953 |
2954 // With layer size being 1000x1000 and default tile size 256x256, we expect to | 2954 // With layer size being 1000x1000 and default tile size 256x256, we expect to |
2955 // see 4 now tiles out of 16 total high res tiles. | 2955 // see 4 now tiles out of 16 total high res tiles. |
2956 EXPECT_EQ(16, high_res_tile_count); | 2956 EXPECT_EQ(16, high_res_tile_count); |
2957 EXPECT_EQ(4, high_res_now_tiles); | 2957 EXPECT_EQ(4, high_res_now_tiles); |
2958 EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count, | 2958 EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count, |
2959 static_cast<int>(unique_tiles.size())); | 2959 static_cast<int>(unique_tiles.size())); |
2960 | 2960 |
2961 scoped_ptr<TilingSetRasterQueueRequired> required_queue( | 2961 scoped_ptr<TilingSetRasterQueueRequired> required_queue( |
2962 new TilingSetRasterQueueRequired( | 2962 new TilingSetRasterQueueRequired( |
2963 pending_layer_->picture_layer_tiling_set(), | 2963 pending_layer_->picture_layer_tiling_set(), |
2964 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); | 2964 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); |
2965 EXPECT_TRUE(required_queue->IsEmpty()); | 2965 EXPECT_TRUE(required_queue->IsEmpty()); |
2966 | 2966 |
2967 required_queue.reset(new TilingSetRasterQueueRequired( | 2967 required_queue.reset(new TilingSetRasterQueueRequired( |
2968 pending_layer_->picture_layer_tiling_set(), | 2968 pending_layer_->picture_layer_tiling_set(), |
2969 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 2969 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
2970 EXPECT_FALSE(required_queue->IsEmpty()); | 2970 EXPECT_FALSE(required_queue->IsEmpty()); |
2971 int required_for_activation_count = 0; | 2971 int required_for_activation_count = 0; |
2972 while (!required_queue->IsEmpty()) { | 2972 while (!required_queue->IsEmpty()) { |
2973 Tile* tile = required_queue->Top(); | 2973 PrioritizedTile prioritized_tile = required_queue->Top(); |
2974 EXPECT_TRUE(tile->required_for_activation()); | 2974 EXPECT_TRUE(prioritized_tile.tile()->required_for_activation()); |
2975 EXPECT_FALSE(tile->IsReadyToDraw()); | 2975 EXPECT_FALSE(prioritized_tile.tile()->IsReadyToDraw()); |
2976 ++required_for_activation_count; | 2976 ++required_for_activation_count; |
2977 required_queue->Pop(); | 2977 required_queue->Pop(); |
2978 } | 2978 } |
2979 | 2979 |
2980 // All of the high res tiles should be required for activation, since there is | 2980 // All of the high res tiles should be required for activation, since there is |
2981 // no active twin. | 2981 // no active twin. |
2982 EXPECT_EQ(high_res_now_tiles, required_for_activation_count); | 2982 EXPECT_EQ(high_res_now_tiles, required_for_activation_count); |
2983 | 2983 |
2984 // No NOW tiles. | 2984 // No NOW tiles. |
2985 time_ticks += base::TimeDelta::FromMilliseconds(200); | 2985 time_ticks += base::TimeDelta::FromMilliseconds(200); |
2986 host_impl_.SetCurrentBeginFrameArgs( | 2986 host_impl_.SetCurrentBeginFrameArgs( |
2987 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 2987 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
2988 | 2988 |
2989 pending_layer_->draw_properties().visible_content_rect = | 2989 pending_layer_->draw_properties().visible_content_rect = |
2990 gfx::Rect(1100, 1100, 500, 500); | 2990 gfx::Rect(1100, 1100, 500, 500); |
2991 bool resourceless_software_draw = false; | 2991 bool resourceless_software_draw = false; |
2992 pending_layer_->UpdateTiles(resourceless_software_draw); | 2992 pending_layer_->UpdateTiles(resourceless_software_draw); |
2993 | 2993 |
2994 unique_tiles.clear(); | 2994 unique_tiles.clear(); |
2995 high_res_tile_count = 0u; | 2995 high_res_tile_count = 0u; |
2996 queue.reset(new TilingSetRasterQueueAll( | 2996 queue.reset(new TilingSetRasterQueueAll( |
2997 pending_layer_->picture_layer_tiling_set(), false)); | 2997 pending_layer_->picture_layer_tiling_set(), false)); |
2998 while (!queue->IsEmpty()) { | 2998 while (!queue->IsEmpty()) { |
2999 Tile* tile = queue->Top(); | 2999 PrioritizedTile prioritized_tile = queue->Top(); |
3000 TilePriority priority = tile->priority(); | 3000 TilePriority priority = prioritized_tile.priority(); |
3001 | 3001 |
3002 EXPECT_TRUE(tile); | 3002 EXPECT_TRUE(prioritized_tile.tile()); |
3003 | 3003 |
3004 // Non-high res tiles only get visible tiles. | 3004 // Non-high res tiles only get visible tiles. |
3005 EXPECT_EQ(HIGH_RESOLUTION, priority.resolution); | 3005 EXPECT_EQ(HIGH_RESOLUTION, priority.resolution); |
3006 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 3006 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
3007 | 3007 |
3008 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; | 3008 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; |
3009 | 3009 |
3010 unique_tiles.insert(tile); | 3010 unique_tiles.insert(prioritized_tile.tile()); |
3011 queue->Pop(); | 3011 queue->Pop(); |
3012 } | 3012 } |
3013 | 3013 |
3014 EXPECT_EQ(16, high_res_tile_count); | 3014 EXPECT_EQ(16, high_res_tile_count); |
3015 EXPECT_EQ(high_res_tile_count, static_cast<int>(unique_tiles.size())); | 3015 EXPECT_EQ(high_res_tile_count, static_cast<int>(unique_tiles.size())); |
3016 | 3016 |
3017 time_ticks += base::TimeDelta::FromMilliseconds(200); | 3017 time_ticks += base::TimeDelta::FromMilliseconds(200); |
3018 host_impl_.SetCurrentBeginFrameArgs( | 3018 host_impl_.SetCurrentBeginFrameArgs( |
3019 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3019 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
3020 | 3020 |
(...skipping 10 matching lines...) Expand all Loading... | |
3031 TileDrawInfo& draw_info = tile->draw_info(); | 3031 TileDrawInfo& draw_info = tile->draw_info(); |
3032 draw_info.SetSolidColorForTesting(SK_ColorRED); | 3032 draw_info.SetSolidColorForTesting(SK_ColorRED); |
3033 } | 3033 } |
3034 | 3034 |
3035 non_ideal_tile_count = 0; | 3035 non_ideal_tile_count = 0; |
3036 low_res_tile_count = 0; | 3036 low_res_tile_count = 0; |
3037 high_res_tile_count = 0; | 3037 high_res_tile_count = 0; |
3038 queue.reset(new TilingSetRasterQueueAll( | 3038 queue.reset(new TilingSetRasterQueueAll( |
3039 pending_layer_->picture_layer_tiling_set(), true)); | 3039 pending_layer_->picture_layer_tiling_set(), true)); |
3040 while (!queue->IsEmpty()) { | 3040 while (!queue->IsEmpty()) { |
3041 Tile* tile = queue->Top(); | 3041 PrioritizedTile prioritized_tile = queue->Top(); |
3042 TilePriority priority = tile->priority(); | 3042 TilePriority priority = prioritized_tile.priority(); |
3043 | 3043 |
3044 EXPECT_TRUE(tile); | 3044 EXPECT_TRUE(prioritized_tile.tile()); |
3045 | 3045 |
3046 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; | 3046 non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION; |
3047 low_res_tile_count += priority.resolution == LOW_RESOLUTION; | 3047 low_res_tile_count += priority.resolution == LOW_RESOLUTION; |
3048 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; | 3048 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; |
3049 queue->Pop(); | 3049 queue->Pop(); |
3050 } | 3050 } |
3051 | 3051 |
3052 EXPECT_EQ(0, non_ideal_tile_count); | 3052 EXPECT_EQ(0, non_ideal_tile_count); |
3053 EXPECT_EQ(1, low_res_tile_count); | 3053 EXPECT_EQ(1, low_res_tile_count); |
3054 EXPECT_EQ(0, high_res_tile_count); | 3054 EXPECT_EQ(0, high_res_tile_count); |
(...skipping 16 matching lines...) Expand all Loading... | |
3071 SetupPendingTree(pending_pile); | 3071 SetupPendingTree(pending_pile); |
3072 ActivateTree(); | 3072 ActivateTree(); |
3073 EXPECT_EQ(2u, active_layer_->num_tilings()); | 3073 EXPECT_EQ(2u, active_layer_->num_tilings()); |
3074 | 3074 |
3075 scoped_ptr<TilingSetRasterQueueRequired> queue( | 3075 scoped_ptr<TilingSetRasterQueueRequired> queue( |
3076 new TilingSetRasterQueueRequired( | 3076 new TilingSetRasterQueueRequired( |
3077 active_layer_->picture_layer_tiling_set(), | 3077 active_layer_->picture_layer_tiling_set(), |
3078 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); | 3078 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); |
3079 EXPECT_FALSE(queue->IsEmpty()); | 3079 EXPECT_FALSE(queue->IsEmpty()); |
3080 while (!queue->IsEmpty()) { | 3080 while (!queue->IsEmpty()) { |
3081 Tile* tile = queue->Top(); | 3081 PrioritizedTile prioritized_tile = queue->Top(); |
3082 EXPECT_TRUE(tile->required_for_draw()); | 3082 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw()); |
3083 EXPECT_FALSE(tile->IsReadyToDraw()); | 3083 EXPECT_FALSE(prioritized_tile.tile()->IsReadyToDraw()); |
3084 queue->Pop(); | 3084 queue->Pop(); |
3085 } | 3085 } |
3086 | 3086 |
3087 queue.reset(new TilingSetRasterQueueRequired( | 3087 queue.reset(new TilingSetRasterQueueRequired( |
3088 active_layer_->picture_layer_tiling_set(), | 3088 active_layer_->picture_layer_tiling_set(), |
3089 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 3089 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
3090 EXPECT_TRUE(queue->IsEmpty()); | 3090 EXPECT_TRUE(queue->IsEmpty()); |
3091 } | 3091 } |
3092 | 3092 |
3093 TEST_F(PictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) { | 3093 TEST_F(PictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3166 scoped_ptr<TilingSetEvictionQueue> queue( | 3166 scoped_ptr<TilingSetEvictionQueue> queue( |
3167 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set())); | 3167 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set())); |
3168 EXPECT_TRUE(queue->IsEmpty()); | 3168 EXPECT_TRUE(queue->IsEmpty()); |
3169 | 3169 |
3170 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 3170 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
3171 | 3171 |
3172 std::set<Tile*> unique_tiles; | 3172 std::set<Tile*> unique_tiles; |
3173 float expected_scales[] = {low_res_factor, 1.f}; | 3173 float expected_scales[] = {low_res_factor, 1.f}; |
3174 size_t scale_index = 0; | 3174 size_t scale_index = 0; |
3175 bool reached_visible = false; | 3175 bool reached_visible = false; |
3176 Tile* last_tile = nullptr; | 3176 PrioritizedTile last_tile; |
3177 size_t distance_decreasing = 0; | 3177 size_t distance_decreasing = 0; |
3178 size_t distance_increasing = 0; | 3178 size_t distance_increasing = 0; |
3179 queue.reset( | 3179 queue.reset( |
3180 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set())); | 3180 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set())); |
3181 while (!queue->IsEmpty()) { | 3181 while (!queue->IsEmpty()) { |
3182 Tile* tile = queue->Top(); | 3182 PrioritizedTile prioritized_tile = queue->Top(); |
3183 if (!last_tile) | 3183 Tile* tile = prioritized_tile.tile(); |
3184 last_tile = tile; | 3184 if (!last_tile.tile()) |
3185 last_tile = prioritized_tile; | |
3185 | 3186 |
3186 EXPECT_TRUE(tile); | 3187 EXPECT_TRUE(tile); |
3187 | 3188 |
3188 TilePriority priority = tile->priority(); | 3189 TilePriority priority = prioritized_tile.priority(); |
3189 | 3190 |
3190 if (priority.priority_bin == TilePriority::NOW) { | 3191 if (priority.priority_bin == TilePriority::NOW) { |
3191 reached_visible = true; | 3192 reached_visible = true; |
3192 last_tile = tile; | 3193 last_tile = prioritized_tile; |
3193 break; | 3194 break; |
3194 } | 3195 } |
3195 | 3196 |
3196 EXPECT_FALSE(tile->required_for_activation()); | 3197 EXPECT_FALSE(tile->required_for_activation()); |
3197 | 3198 |
3198 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > | 3199 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > |
3199 std::numeric_limits<float>::epsilon()) { | 3200 std::numeric_limits<float>::epsilon()) { |
3200 ++scale_index; | 3201 ++scale_index; |
3201 ASSERT_LT(scale_index, arraysize(expected_scales)); | 3202 ASSERT_LT(scale_index, arraysize(expected_scales)); |
3202 } | 3203 } |
3203 | 3204 |
3204 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); | 3205 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); |
3205 unique_tiles.insert(tile); | 3206 unique_tiles.insert(tile); |
3206 | 3207 |
3207 if (tile->required_for_activation() == | 3208 if (tile->required_for_activation() == |
3208 last_tile->required_for_activation() && | 3209 last_tile.tile()->required_for_activation() && |
3209 std::abs(tile->contents_scale() - last_tile->contents_scale()) < | 3210 std::abs(tile->contents_scale() - last_tile.tile()->contents_scale()) < |
3210 std::numeric_limits<float>::epsilon()) { | 3211 std::numeric_limits<float>::epsilon()) { |
3211 if (priority.distance_to_visible <= | 3212 if (priority.distance_to_visible <= |
3212 last_tile->priority().distance_to_visible) | 3213 last_tile.priority().distance_to_visible) |
3213 ++distance_decreasing; | 3214 ++distance_decreasing; |
3214 else | 3215 else |
3215 ++distance_increasing; | 3216 ++distance_increasing; |
3216 } | 3217 } |
3217 | 3218 |
3218 last_tile = tile; | 3219 last_tile = prioritized_tile; |
3219 queue->Pop(); | 3220 queue->Pop(); |
3220 } | 3221 } |
3221 | 3222 |
3222 // 4 high res tiles are inside the viewport, the rest are evicted. | 3223 // 4 high res tiles are inside the viewport, the rest are evicted. |
3223 EXPECT_TRUE(reached_visible); | 3224 EXPECT_TRUE(reached_visible); |
3224 EXPECT_EQ(12u, unique_tiles.size()); | 3225 EXPECT_EQ(12u, unique_tiles.size()); |
3225 EXPECT_EQ(1u, distance_increasing); | 3226 EXPECT_EQ(1u, distance_increasing); |
3226 EXPECT_EQ(11u, distance_decreasing); | 3227 EXPECT_EQ(11u, distance_decreasing); |
3227 | 3228 |
3228 scale_index = 0; | 3229 scale_index = 0; |
3229 bool reached_required = false; | 3230 bool reached_required = false; |
3230 while (!queue->IsEmpty()) { | 3231 while (!queue->IsEmpty()) { |
3231 Tile* tile = queue->Top(); | 3232 PrioritizedTile prioritized_tile = queue->Top(); |
3233 Tile* tile = prioritized_tile.tile(); | |
3232 EXPECT_TRUE(tile); | 3234 EXPECT_TRUE(tile); |
3233 | 3235 |
3234 TilePriority priority = tile->priority(); | 3236 TilePriority priority = prioritized_tile.priority(); |
3235 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 3237 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
3236 | 3238 |
3237 if (reached_required) { | 3239 if (reached_required) { |
3238 EXPECT_TRUE(tile->required_for_activation()); | 3240 EXPECT_TRUE(tile->required_for_activation()); |
3239 } else if (tile->required_for_activation()) { | 3241 } else if (tile->required_for_activation()) { |
3240 reached_required = true; | 3242 reached_required = true; |
3241 scale_index = 0; | 3243 scale_index = 0; |
3242 } | 3244 } |
3243 | 3245 |
3244 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > | 3246 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3566 | 3568 |
3567 Tile* some_active_tile = | 3569 Tile* some_active_tile = |
3568 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 3570 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
3569 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 3571 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
3570 | 3572 |
3571 // Since there is no invalidation, pending tree should have no tiles. | 3573 // Since there is no invalidation, pending tree should have no tiles. |
3572 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); | 3574 EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty()); |
3573 if (host_impl_.settings().create_low_res_tiling) | 3575 if (host_impl_.settings().create_low_res_tiling) |
3574 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); | 3576 EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty()); |
3575 | 3577 |
3576 active_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 3578 active_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
3577 if (host_impl_.settings().create_low_res_tiling) | 3579 if (host_impl_.settings().create_low_res_tiling) |
3578 active_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 3580 active_layer_->LowResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
3579 | 3581 |
3580 AssertAllTilesRequired(active_layer_->HighResTiling()); | 3582 AssertAllTilesRequired(active_layer_->HighResTiling()); |
3581 if (host_impl_.settings().create_low_res_tiling) | 3583 if (host_impl_.settings().create_low_res_tiling) |
3582 AssertNoTilesRequired(active_layer_->LowResTiling()); | 3584 AssertNoTilesRequired(active_layer_->LowResTiling()); |
3583 } | 3585 } |
3584 | 3586 |
3585 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 3587 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
3586 gfx::Size layer_bounds(400, 400); | 3588 gfx::Size layer_bounds(400, 400); |
3587 gfx::Size tile_size(100, 100); | 3589 gfx::Size tile_size(100, 100); |
3588 | 3590 |
(...skipping 11 matching lines...) Expand all Loading... | |
3600 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); | 3602 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
3601 | 3603 |
3602 // Active layer has tilings, but no tiles due to missing recordings. | 3604 // Active layer has tilings, but no tiles due to missing recordings. |
3603 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 3605 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
3604 EXPECT_EQ(active_layer_->tilings()->num_tilings(), | 3606 EXPECT_EQ(active_layer_->tilings()->num_tilings(), |
3605 host_impl_.settings().create_low_res_tiling ? 2u : 1u); | 3607 host_impl_.settings().create_low_res_tiling ? 2u : 1u); |
3606 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 3608 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
3607 | 3609 |
3608 // Since the active layer has no tiles at all, the pending layer doesn't | 3610 // Since the active layer has no tiles at all, the pending layer doesn't |
3609 // need content in order to activate. | 3611 // need content in order to activate. |
3610 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 3612 pending_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
3611 if (host_impl_.settings().create_low_res_tiling) | 3613 if (host_impl_.settings().create_low_res_tiling) |
3612 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 3614 pending_layer_->LowResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
3613 | 3615 |
3614 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 3616 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
3615 if (host_impl_.settings().create_low_res_tiling) | 3617 if (host_impl_.settings().create_low_res_tiling) |
3616 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 3618 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
3617 } | 3619 } |
3618 | 3620 |
3619 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { | 3621 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
3620 base::TimeTicks time_ticks; | 3622 base::TimeTicks time_ticks; |
3621 time_ticks += base::TimeDelta::FromMilliseconds(1); | 3623 time_ticks += base::TimeDelta::FromMilliseconds(1); |
3622 host_impl_.SetCurrentBeginFrameArgs( | 3624 host_impl_.SetCurrentBeginFrameArgs( |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3965 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { | 3967 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { |
3966 public: | 3968 public: |
3967 OcclusionTrackingPictureLayerImplTest() | 3969 OcclusionTrackingPictureLayerImplTest() |
3968 : PictureLayerImplTest(OcclusionTrackingSettings()) {} | 3970 : PictureLayerImplTest(OcclusionTrackingSettings()) {} |
3969 | 3971 |
3970 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, | 3972 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, |
3971 WhichTree tree, | 3973 WhichTree tree, |
3972 size_t expected_occluded_tile_count, | 3974 size_t expected_occluded_tile_count, |
3973 int source_line) { | 3975 int source_line) { |
3974 size_t occluded_tile_count = 0u; | 3976 size_t occluded_tile_count = 0u; |
3975 Tile* last_tile = nullptr; | 3977 PrioritizedTile last_tile; |
3976 | 3978 |
3977 scoped_ptr<TilingSetEvictionQueue> queue( | 3979 scoped_ptr<TilingSetEvictionQueue> queue( |
3978 new TilingSetEvictionQueue(layer->picture_layer_tiling_set())); | 3980 new TilingSetEvictionQueue(layer->picture_layer_tiling_set())); |
3979 while (!queue->IsEmpty()) { | 3981 while (!queue->IsEmpty()) { |
3980 Tile* tile = queue->Top(); | 3982 PrioritizedTile prioritized_tile = queue->Top(); |
3981 if (!last_tile) | 3983 Tile* tile = prioritized_tile.tile(); |
3982 last_tile = tile; | 3984 if (!last_tile.tile()) |
3985 last_tile = prioritized_tile; | |
3983 | 3986 |
3984 // The only way we will encounter an occluded tile after an unoccluded | 3987 // The only way we will encounter an occluded tile after an unoccluded |
3985 // tile is if the priorty bin decreased, the tile is required for | 3988 // tile is if the priorty bin decreased, the tile is required for |
3986 // activation, or the scale changed. | 3989 // activation, or the scale changed. |
3987 bool tile_is_occluded = tile->is_occluded(); | 3990 bool tile_is_occluded = prioritized_tile.is_occluded(); |
3988 if (tile_is_occluded) { | 3991 if (tile_is_occluded) { |
3989 occluded_tile_count++; | 3992 occluded_tile_count++; |
3990 | 3993 |
3991 bool last_tile_is_occluded = last_tile->is_occluded(); | 3994 bool last_tile_is_occluded = last_tile.is_occluded(); |
3992 if (!last_tile_is_occluded) { | 3995 if (!last_tile_is_occluded) { |
3993 TilePriority::PriorityBin tile_priority_bin = | 3996 TilePriority::PriorityBin tile_priority_bin = |
3994 tile->priority().priority_bin; | 3997 prioritized_tile.priority().priority_bin; |
3995 TilePriority::PriorityBin last_tile_priority_bin = | 3998 TilePriority::PriorityBin last_tile_priority_bin = |
3996 last_tile->priority().priority_bin; | 3999 last_tile.priority().priority_bin; |
3997 | 4000 |
3998 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || | 4001 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || |
3999 tile->required_for_activation() || | 4002 tile->required_for_activation() || |
4000 tile->contents_scale() != last_tile->contents_scale()) | 4003 tile->contents_scale() != |
4004 last_tile.tile()->contents_scale()) | |
4001 << "line: " << source_line; | 4005 << "line: " << source_line; |
4002 } | 4006 } |
4003 } | 4007 } |
4004 last_tile = tile; | 4008 last_tile = prioritized_tile; |
4005 queue->Pop(); | 4009 queue->Pop(); |
4006 } | 4010 } |
4007 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count) | 4011 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count) |
4008 << "line: " << source_line; | 4012 << "line: " << source_line; |
4009 } | 4013 } |
4010 }; | 4014 }; |
4011 | 4015 |
4012 TEST_F(OcclusionTrackingPictureLayerImplTest, | 4016 TEST_F(OcclusionTrackingPictureLayerImplTest, |
4013 OccludedTilesSkippedDuringRasterization) { | 4017 OccludedTilesSkippedDuringRasterization) { |
4014 base::TimeTicks time_ticks; | 4018 base::TimeTicks time_ticks; |
(...skipping 10 matching lines...) Expand all Loading... | |
4025 | 4029 |
4026 scoped_refptr<FakePicturePileImpl> pending_pile = | 4030 scoped_refptr<FakePicturePileImpl> pending_pile = |
4027 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4031 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
4028 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); | 4032 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
4029 | 4033 |
4030 // No occlusion. | 4034 // No occlusion. |
4031 int unoccluded_tile_count = 0; | 4035 int unoccluded_tile_count = 0; |
4032 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 4036 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
4033 pending_layer_->picture_layer_tiling_set(), false)); | 4037 pending_layer_->picture_layer_tiling_set(), false)); |
4034 while (!queue->IsEmpty()) { | 4038 while (!queue->IsEmpty()) { |
4035 Tile* tile = queue->Top(); | 4039 PrioritizedTile prioritized_tile = queue->Top(); |
4040 Tile* tile = prioritized_tile.tile(); | |
4036 | 4041 |
4037 // Occluded tiles should not be iterated over. | 4042 // Occluded tiles should not be iterated over. |
4038 EXPECT_FALSE(tile->is_occluded()); | 4043 EXPECT_FALSE(prioritized_tile.is_occluded()); |
4039 | 4044 |
4040 // Some tiles may not be visible (i.e. outside the viewport). The rest are | 4045 // Some tiles may not be visible (i.e. outside the viewport). The rest are |
4041 // visible and at least partially unoccluded, verified by the above expect. | 4046 // visible and at least partially unoccluded, verified by the above expect. |
4042 bool tile_is_visible = | 4047 bool tile_is_visible = |
4043 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 4048 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
4044 if (tile_is_visible) | 4049 if (tile_is_visible) |
4045 unoccluded_tile_count++; | 4050 unoccluded_tile_count++; |
4046 queue->Pop(); | 4051 queue->Pop(); |
4047 } | 4052 } |
4048 EXPECT_EQ(unoccluded_tile_count, 25); | 4053 EXPECT_EQ(unoccluded_tile_count, 25); |
(...skipping 10 matching lines...) Expand all Loading... | |
4059 time_ticks += base::TimeDelta::FromMilliseconds(200); | 4064 time_ticks += base::TimeDelta::FromMilliseconds(200); |
4060 host_impl_.SetCurrentBeginFrameArgs( | 4065 host_impl_.SetCurrentBeginFrameArgs( |
4061 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4066 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4062 bool update_lcd_text = false; | 4067 bool update_lcd_text = false; |
4063 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4068 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
4064 | 4069 |
4065 unoccluded_tile_count = 0; | 4070 unoccluded_tile_count = 0; |
4066 queue.reset(new TilingSetRasterQueueAll( | 4071 queue.reset(new TilingSetRasterQueueAll( |
4067 pending_layer_->picture_layer_tiling_set(), false)); | 4072 pending_layer_->picture_layer_tiling_set(), false)); |
4068 while (!queue->IsEmpty()) { | 4073 while (!queue->IsEmpty()) { |
4069 Tile* tile = queue->Top(); | 4074 PrioritizedTile prioritized_tile = queue->Top(); |
4075 Tile* tile = prioritized_tile.tile(); | |
4070 | 4076 |
4071 EXPECT_FALSE(tile->is_occluded()); | 4077 EXPECT_FALSE(prioritized_tile.is_occluded()); |
4072 | 4078 |
4073 bool tile_is_visible = | 4079 bool tile_is_visible = |
4074 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 4080 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
4075 if (tile_is_visible) | 4081 if (tile_is_visible) |
4076 unoccluded_tile_count++; | 4082 unoccluded_tile_count++; |
4077 queue->Pop(); | 4083 queue->Pop(); |
4078 } | 4084 } |
4079 EXPECT_EQ(20, unoccluded_tile_count); | 4085 EXPECT_EQ(20, unoccluded_tile_count); |
4080 | 4086 |
4081 // Full occlusion. | 4087 // Full occlusion. |
4082 layer1->SetPosition(gfx::Point(0, 0)); | 4088 layer1->SetPosition(gfx::Point(0, 0)); |
4083 | 4089 |
4084 time_ticks += base::TimeDelta::FromMilliseconds(200); | 4090 time_ticks += base::TimeDelta::FromMilliseconds(200); |
4085 host_impl_.SetCurrentBeginFrameArgs( | 4091 host_impl_.SetCurrentBeginFrameArgs( |
4086 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4092 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4087 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4093 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
4088 | 4094 |
4089 unoccluded_tile_count = 0; | 4095 unoccluded_tile_count = 0; |
4090 queue.reset(new TilingSetRasterQueueAll( | 4096 queue.reset(new TilingSetRasterQueueAll( |
4091 pending_layer_->picture_layer_tiling_set(), false)); | 4097 pending_layer_->picture_layer_tiling_set(), false)); |
4092 while (!queue->IsEmpty()) { | 4098 while (!queue->IsEmpty()) { |
4093 Tile* tile = queue->Top(); | 4099 PrioritizedTile prioritized_tile = queue->Top(); |
4100 Tile* tile = prioritized_tile.tile(); | |
4094 | 4101 |
4095 EXPECT_FALSE(tile->is_occluded()); | 4102 EXPECT_FALSE(prioritized_tile.is_occluded()); |
4096 | 4103 |
4097 bool tile_is_visible = | 4104 bool tile_is_visible = |
4098 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 4105 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
4099 if (tile_is_visible) | 4106 if (tile_is_visible) |
4100 unoccluded_tile_count++; | 4107 unoccluded_tile_count++; |
4101 queue->Pop(); | 4108 queue->Pop(); |
4102 } | 4109 } |
4103 EXPECT_EQ(unoccluded_tile_count, 0); | 4110 EXPECT_EQ(unoccluded_tile_count, 0); |
4104 } | 4111 } |
4105 | 4112 |
(...skipping 12 matching lines...) Expand all Loading... | |
4118 host_impl_.SetViewportSize(viewport_size); | 4125 host_impl_.SetViewportSize(viewport_size); |
4119 | 4126 |
4120 scoped_refptr<FakePicturePileImpl> pending_pile = | 4127 scoped_refptr<FakePicturePileImpl> pending_pile = |
4121 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4128 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
4122 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); | 4129 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
4123 | 4130 |
4124 // No occlusion. | 4131 // No occlusion. |
4125 int occluded_tile_count = 0; | 4132 int occluded_tile_count = 0; |
4126 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4133 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4127 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4134 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4128 tiling->UpdateAllTilePrioritiesForTesting(); | 4135 auto prioritized_tiles = |
4136 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | |
4129 | 4137 |
4130 occluded_tile_count = 0; | 4138 occluded_tile_count = 0; |
4131 for (PictureLayerTiling::CoverageIterator iter( | 4139 for (PictureLayerTiling::CoverageIterator iter( |
4132 tiling, | 4140 tiling, |
4133 pending_layer_->contents_scale_x(), | 4141 pending_layer_->contents_scale_x(), |
4134 gfx::Rect(layer_bounds)); | 4142 gfx::Rect(layer_bounds)); |
4135 iter; | 4143 iter; |
4136 ++iter) { | 4144 ++iter) { |
4137 if (!*iter) | 4145 if (!*iter) |
4138 continue; | 4146 continue; |
4139 const Tile* tile = *iter; | 4147 const Tile* tile = *iter; |
4140 | 4148 |
4141 // Fully occluded tiles are not required for activation. | 4149 // Fully occluded tiles are not required for activation. |
4142 if (tile->is_occluded()) { | 4150 if (prioritized_tiles[tile].is_occluded()) { |
4143 EXPECT_FALSE(tile->required_for_activation()); | 4151 EXPECT_FALSE(tile->required_for_activation()); |
4144 occluded_tile_count++; | 4152 occluded_tile_count++; |
4145 } | 4153 } |
4146 } | 4154 } |
4147 EXPECT_EQ(occluded_tile_count, 0); | 4155 EXPECT_EQ(occluded_tile_count, 0); |
4148 } | 4156 } |
4149 | 4157 |
4150 // Partial occlusion. | 4158 // Partial occlusion. |
4151 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 4159 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
4152 LayerImpl* layer1 = pending_layer_->children()[0]; | 4160 LayerImpl* layer1 = pending_layer_->children()[0]; |
4153 layer1->SetBounds(layer_bounds); | 4161 layer1->SetBounds(layer_bounds); |
4154 layer1->SetContentBounds(layer_bounds); | 4162 layer1->SetContentBounds(layer_bounds); |
4155 layer1->SetDrawsContent(true); | 4163 layer1->SetDrawsContent(true); |
4156 layer1->SetContentsOpaque(true); | 4164 layer1->SetContentsOpaque(true); |
4157 layer1->SetPosition(occluding_layer_position); | 4165 layer1->SetPosition(occluding_layer_position); |
4158 | 4166 |
4159 time_ticks += base::TimeDelta::FromMilliseconds(200); | 4167 time_ticks += base::TimeDelta::FromMilliseconds(200); |
4160 host_impl_.SetCurrentBeginFrameArgs( | 4168 host_impl_.SetCurrentBeginFrameArgs( |
4161 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4169 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4162 bool update_lcd_text = false; | 4170 bool update_lcd_text = false; |
4163 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4171 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
4164 | 4172 |
4165 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4173 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4166 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4174 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4167 tiling->UpdateAllTilePrioritiesForTesting(); | 4175 auto prioritized_tiles = |
4176 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | |
4168 | 4177 |
4169 occluded_tile_count = 0; | 4178 occluded_tile_count = 0; |
4170 for (PictureLayerTiling::CoverageIterator iter( | 4179 for (PictureLayerTiling::CoverageIterator iter( |
4171 tiling, | 4180 tiling, |
4172 pending_layer_->contents_scale_x(), | 4181 pending_layer_->contents_scale_x(), |
4173 gfx::Rect(layer_bounds)); | 4182 gfx::Rect(layer_bounds)); |
4174 iter; | 4183 iter; |
4175 ++iter) { | 4184 ++iter) { |
4176 if (!*iter) | 4185 if (!*iter) |
4177 continue; | 4186 continue; |
4178 const Tile* tile = *iter; | 4187 const Tile* tile = *iter; |
4179 | 4188 |
4180 if (tile->is_occluded()) { | 4189 if (prioritized_tiles[tile].is_occluded()) { |
4181 EXPECT_FALSE(tile->required_for_activation()); | 4190 EXPECT_FALSE(tile->required_for_activation()); |
4182 occluded_tile_count++; | 4191 occluded_tile_count++; |
4183 } | 4192 } |
4184 } | 4193 } |
4185 switch (i) { | 4194 switch (i) { |
4186 case 0: | 4195 case 0: |
4187 EXPECT_EQ(occluded_tile_count, 5); | 4196 EXPECT_EQ(occluded_tile_count, 5); |
4188 break; | 4197 break; |
4189 case 1: | 4198 case 1: |
4190 EXPECT_EQ(occluded_tile_count, 2); | 4199 EXPECT_EQ(occluded_tile_count, 2); |
4191 break; | 4200 break; |
4192 default: | 4201 default: |
4193 NOTREACHED(); | 4202 NOTREACHED(); |
4194 } | 4203 } |
4195 } | 4204 } |
4196 | 4205 |
4197 // Full occlusion. | 4206 // Full occlusion. |
4198 layer1->SetPosition(gfx::PointF(0, 0)); | 4207 layer1->SetPosition(gfx::PointF(0, 0)); |
4199 | 4208 |
4200 time_ticks += base::TimeDelta::FromMilliseconds(200); | 4209 time_ticks += base::TimeDelta::FromMilliseconds(200); |
4201 host_impl_.SetCurrentBeginFrameArgs( | 4210 host_impl_.SetCurrentBeginFrameArgs( |
4202 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4211 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4203 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4212 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
4204 | 4213 |
4205 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4214 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4206 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4215 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4207 tiling->UpdateAllTilePrioritiesForTesting(); | 4216 auto prioritized_tiles = |
4217 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | |
4208 | 4218 |
4209 occluded_tile_count = 0; | 4219 occluded_tile_count = 0; |
4210 for (PictureLayerTiling::CoverageIterator iter( | 4220 for (PictureLayerTiling::CoverageIterator iter( |
4211 tiling, | 4221 tiling, |
4212 pending_layer_->contents_scale_x(), | 4222 pending_layer_->contents_scale_x(), |
4213 gfx::Rect(layer_bounds)); | 4223 gfx::Rect(layer_bounds)); |
4214 iter; | 4224 iter; |
4215 ++iter) { | 4225 ++iter) { |
4216 if (!*iter) | 4226 if (!*iter) |
4217 continue; | 4227 continue; |
4218 const Tile* tile = *iter; | 4228 const Tile* tile = *iter; |
4219 | 4229 |
4220 if (tile->is_occluded()) { | 4230 if (prioritized_tiles[tile].is_occluded()) { |
4221 EXPECT_FALSE(tile->required_for_activation()); | 4231 EXPECT_FALSE(tile->required_for_activation()); |
4222 occluded_tile_count++; | 4232 occluded_tile_count++; |
4223 } | 4233 } |
4224 } | 4234 } |
4225 switch (i) { | 4235 switch (i) { |
4226 case 0: | 4236 case 0: |
4227 EXPECT_EQ(25, occluded_tile_count); | 4237 EXPECT_EQ(25, occluded_tile_count); |
4228 break; | 4238 break; |
4229 case 1: | 4239 case 1: |
4230 EXPECT_EQ(4, occluded_tile_count); | 4240 EXPECT_EQ(4, occluded_tile_count); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4275 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 4285 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4276 // UpdateDrawProperties with the occluding layer. | 4286 // UpdateDrawProperties with the occluding layer. |
4277 bool update_lcd_text = false; | 4287 bool update_lcd_text = false; |
4278 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 4288 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
4279 | 4289 |
4280 EXPECT_EQ(5u, pending_layer_->num_tilings()); | 4290 EXPECT_EQ(5u, pending_layer_->num_tilings()); |
4281 | 4291 |
4282 int occluded_tile_count = 0; | 4292 int occluded_tile_count = 0; |
4283 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4293 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4284 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4294 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4285 tiling->UpdateAllTilePrioritiesForTesting(); | 4295 auto prioritized_tiles = |
4296 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | |
4286 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 4297 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
4287 | 4298 |
4288 occluded_tile_count = 0; | 4299 occluded_tile_count = 0; |
4289 for (size_t j = 0; j < tiles.size(); ++j) { | 4300 for (size_t j = 0; j < tiles.size(); ++j) { |
4290 if (tiles[j]->is_occluded()) { | 4301 if (prioritized_tiles[tiles[j]].is_occluded()) { |
4291 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 4302 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
4292 tiles[j]->content_rect(), 1.0f / tiles[j]->contents_scale()); | 4303 tiles[j]->content_rect(), 1.0f / tiles[j]->contents_scale()); |
4293 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); | 4304 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); |
4294 occluded_tile_count++; | 4305 occluded_tile_count++; |
4295 } | 4306 } |
4296 } | 4307 } |
4297 | 4308 |
4298 switch (i) { | 4309 switch (i) { |
4299 case 0: | 4310 case 0: |
4300 EXPECT_EQ(occluded_tile_count, 30); | 4311 EXPECT_EQ(occluded_tile_count, 30); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4336 layer1->SetBounds(layer_bounds); | 4347 layer1->SetBounds(layer_bounds); |
4337 layer1->SetContentBounds(layer_bounds); | 4348 layer1->SetContentBounds(layer_bounds); |
4338 layer1->SetDrawsContent(true); | 4349 layer1->SetDrawsContent(true); |
4339 layer1->SetContentsOpaque(true); | 4350 layer1->SetContentsOpaque(true); |
4340 layer1->SetPosition(occluding_layer_position); | 4351 layer1->SetPosition(occluding_layer_position); |
4341 | 4352 |
4342 ActivateTree(); | 4353 ActivateTree(); |
4343 | 4354 |
4344 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 4355 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
4345 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | 4356 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
4346 tiling->UpdateAllTilePrioritiesForTesting(); | 4357 auto prioritized_tiles = |
4358 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | |
4347 | 4359 |
4348 for ( | 4360 for ( |
4349 PictureLayerTiling::CoverageIterator iter( | 4361 PictureLayerTiling::CoverageIterator iter( |
4350 tiling, active_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); | 4362 tiling, active_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); |
4351 iter; ++iter) { | 4363 iter; ++iter) { |
4352 if (!*iter) | 4364 if (!*iter) |
4353 continue; | 4365 continue; |
4354 const Tile* tile = *iter; | 4366 const Tile* tile = *iter; |
4355 | 4367 |
4356 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 4368 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
4357 tile->content_rect(), 1.0f / tile->contents_scale()); | 4369 tile->content_rect(), 1.0f / tile->contents_scale()); |
4358 // Tiles are occluded on the active tree iff they lie beneath the | 4370 // Tiles are occluded on the active tree iff they lie beneath the |
4359 // occluding layer. | 4371 // occluding layer. |
4360 EXPECT_EQ(tile->is_occluded(), | 4372 EXPECT_EQ(prioritized_tiles[tile].is_occluded(), |
4361 scaled_content_rect.x() >= occluding_layer_position.x()); | 4373 scaled_content_rect.x() >= occluding_layer_position.x()); |
4362 } | 4374 } |
4363 } | 4375 } |
4364 | 4376 |
4365 // Partially invalidate the pending layer. | 4377 // Partially invalidate the pending layer. |
4366 SetupPendingTreeWithInvalidation(pending_pile, invalidation_rect); | 4378 SetupPendingTreeWithInvalidation(pending_pile, invalidation_rect); |
4367 | 4379 |
4368 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 4380 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
4369 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | 4381 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
4370 tiling->UpdateAllTilePrioritiesForTesting(); | 4382 auto prioritized_tiles = |
4383 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | |
4371 | 4384 |
4372 for (PictureLayerTiling::CoverageIterator iter( | 4385 for (PictureLayerTiling::CoverageIterator iter( |
4373 tiling, | 4386 tiling, |
4374 active_layer_->contents_scale_x(), | 4387 active_layer_->contents_scale_x(), |
4375 gfx::Rect(layer_bounds)); | 4388 gfx::Rect(layer_bounds)); |
4376 iter; | 4389 iter; |
4377 ++iter) { | 4390 ++iter) { |
4378 if (!*iter) | 4391 if (!*iter) |
4379 continue; | 4392 continue; |
4380 const Tile* tile = *iter; | 4393 const Tile* tile = *iter; |
4381 | 4394 |
4382 // All tiles are unoccluded, because the pending tree has no occlusion. | 4395 // All tiles are unoccluded, because the pending tree has no occlusion. |
4383 EXPECT_FALSE(tile->is_occluded()); | 4396 EXPECT_FALSE(prioritized_tiles[tile].is_occluded()); |
4384 EXPECT_FALSE(tile->is_occluded()); | |
4385 | 4397 |
4386 Tile* twin_tile = active_layer_->GetPendingOrActiveTwinTiling(tiling) | 4398 Tile* twin_tile = active_layer_->GetPendingOrActiveTwinTiling(tiling) |
4387 ->TileAt(iter.i(), iter.j()); | 4399 ->TileAt(iter.i(), iter.j()); |
4388 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 4400 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
4389 tile->content_rect(), 1.0f / tile->contents_scale()); | 4401 tile->content_rect(), 1.0f / tile->contents_scale()); |
4390 | 4402 |
4391 if (scaled_content_rect.Intersects(invalidation_rect)) { | 4403 if (scaled_content_rect.Intersects(invalidation_rect)) { |
4392 // Tiles inside the invalidation rect exist on both trees. | 4404 // Tiles inside the invalidation rect exist on both trees. |
4393 EXPECT_TRUE(tile); | 4405 EXPECT_TRUE(tile); |
4394 EXPECT_TRUE(twin_tile); | 4406 EXPECT_TRUE(twin_tile); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4462 | 4474 |
4463 // The expected number of occluded tiles on each of the 2 tilings for each of | 4475 // The expected number of occluded tiles on each of the 2 tilings for each of |
4464 // the 3 tree priorities. | 4476 // the 3 tree priorities. |
4465 size_t expected_occluded_tile_count_on_pending[] = {4u, 0u}; | 4477 size_t expected_occluded_tile_count_on_pending[] = {4u, 0u}; |
4466 size_t expected_occluded_tile_count_on_active[] = {12u, 1u}; | 4478 size_t expected_occluded_tile_count_on_active[] = {12u, 1u}; |
4467 size_t total_expected_occluded_tile_count_on_trees[] = {13u, 4u}; | 4479 size_t total_expected_occluded_tile_count_on_trees[] = {13u, 4u}; |
4468 | 4480 |
4469 // Verify number of occluded tiles on the pending layer for each tiling. | 4481 // Verify number of occluded tiles on the pending layer for each tiling. |
4470 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4482 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4471 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4483 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4472 tiling->UpdateAllTilePrioritiesForTesting(); | 4484 auto prioritized_tiles = |
4485 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | |
4473 | 4486 |
4474 size_t occluded_tile_count_on_pending = 0u; | 4487 size_t occluded_tile_count_on_pending = 0u; |
4475 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, | 4488 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, |
4476 gfx::Rect(layer_bounds)); | 4489 gfx::Rect(layer_bounds)); |
4477 iter; ++iter) { | 4490 iter; ++iter) { |
4478 Tile* tile = *iter; | 4491 Tile* tile = *iter; |
4479 | 4492 |
4480 if (invalidation_rect.Intersects(iter.geometry_rect())) | 4493 if (invalidation_rect.Intersects(iter.geometry_rect())) |
4481 EXPECT_TRUE(tile); | 4494 EXPECT_TRUE(tile); |
4482 else | 4495 else |
4483 EXPECT_FALSE(tile); | 4496 EXPECT_FALSE(tile); |
4484 | 4497 |
4485 if (!tile) | 4498 if (!tile) |
4486 continue; | 4499 continue; |
4487 if (tile->is_occluded()) | 4500 if (prioritized_tiles[tile].is_occluded()) |
4488 occluded_tile_count_on_pending++; | 4501 occluded_tile_count_on_pending++; |
4489 } | 4502 } |
4490 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], | 4503 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], |
4491 occluded_tile_count_on_pending) | 4504 occluded_tile_count_on_pending) |
4492 << tiling->contents_scale(); | 4505 << tiling->contents_scale(); |
4493 } | 4506 } |
4494 | 4507 |
4495 // Verify number of occluded tiles on the active layer for each tiling. | 4508 // Verify number of occluded tiles on the active layer for each tiling. |
4496 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 4509 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
4497 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | 4510 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
4498 tiling->UpdateAllTilePrioritiesForTesting(); | 4511 auto prioritized_tiles = |
4512 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | |
4499 | 4513 |
4500 size_t occluded_tile_count_on_active = 0u; | 4514 size_t occluded_tile_count_on_active = 0u; |
4501 for (PictureLayerTiling::CoverageIterator iter( | 4515 for (PictureLayerTiling::CoverageIterator iter( |
4502 tiling, | 4516 tiling, |
4503 pending_layer_->contents_scale_x(), | 4517 pending_layer_->contents_scale_x(), |
4504 gfx::Rect(layer_bounds)); | 4518 gfx::Rect(layer_bounds)); |
4505 iter; | 4519 iter; |
4506 ++iter) { | 4520 ++iter) { |
4507 Tile* tile = *iter; | 4521 Tile* tile = *iter; |
4508 | 4522 |
4509 if (!tile) | 4523 if (!tile) |
4510 continue; | 4524 continue; |
4511 if (tile->is_occluded()) | 4525 if (prioritized_tiles[tile].is_occluded()) |
4512 occluded_tile_count_on_active++; | 4526 occluded_tile_count_on_active++; |
4513 } | 4527 } |
4514 EXPECT_EQ(expected_occluded_tile_count_on_active[i], | 4528 EXPECT_EQ(expected_occluded_tile_count_on_active[i], |
4515 occluded_tile_count_on_active) | 4529 occluded_tile_count_on_active) |
4516 << i; | 4530 << i; |
4517 } | 4531 } |
4518 | 4532 |
4519 std::vector<Tile*> all_tiles; | 4533 std::vector<Tile*> all_tiles; |
4520 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4534 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4521 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4535 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4751 gfx::Rect viewport = gfx::Rect(0, 0, 100, 100); | 4765 gfx::Rect viewport = gfx::Rect(0, 0, 100, 100); |
4752 gfx::Transform transform; | 4766 gfx::Transform transform; |
4753 | 4767 |
4754 host_impl_.SetRequiresHighResToDraw(); | 4768 host_impl_.SetRequiresHighResToDraw(); |
4755 | 4769 |
4756 // Update tiles. | 4770 // Update tiles. |
4757 pending_layer_->draw_properties().visible_content_rect = viewport; | 4771 pending_layer_->draw_properties().visible_content_rect = viewport; |
4758 pending_layer_->draw_properties().screen_space_transform = transform; | 4772 pending_layer_->draw_properties().screen_space_transform = transform; |
4759 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, | 4773 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
4760 false); | 4774 false); |
4761 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 4775 pending_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
4762 | 4776 |
4763 // Ensure we can't activate. | 4777 // Ensure we can't activate. |
4764 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 4778 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
4765 | 4779 |
4766 // Now in the same frame, move the viewport (this can happen during | 4780 // Now in the same frame, move the viewport (this can happen during |
4767 // animation). | 4781 // animation). |
4768 viewport = gfx::Rect(0, 2000, 100, 100); | 4782 viewport = gfx::Rect(0, 2000, 100, 100); |
4769 | 4783 |
4770 // Update tiles. | 4784 // Update tiles. |
4771 pending_layer_->draw_properties().visible_content_rect = viewport; | 4785 pending_layer_->draw_properties().visible_content_rect = viewport; |
4772 pending_layer_->draw_properties().screen_space_transform = transform; | 4786 pending_layer_->draw_properties().screen_space_transform = transform; |
4773 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, | 4787 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
4774 false); | 4788 false); |
4775 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 4789 pending_layer_->HighResTiling()->UpdateAndGetAllPrioritizedTilesForTesting(); |
4776 | 4790 |
4777 // Make sure all viewport tiles (viewport from the tiling) are ready to draw. | 4791 // Make sure all viewport tiles (viewport from the tiling) are ready to draw. |
4778 std::vector<Tile*> tiles; | 4792 std::vector<Tile*> tiles; |
4779 for (PictureLayerTiling::CoverageIterator iter( | 4793 for (PictureLayerTiling::CoverageIterator iter( |
4780 pending_layer_->HighResTiling(), | 4794 pending_layer_->HighResTiling(), |
4781 1.f, | 4795 1.f, |
4782 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); | 4796 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); |
4783 iter; | 4797 iter; |
4784 ++iter) { | 4798 ++iter) { |
4785 if (*iter) | 4799 if (*iter) |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5025 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 5039 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
5026 EXPECT_EQ(result.width(), 448); | 5040 EXPECT_EQ(result.width(), 448); |
5027 EXPECT_EQ(result.height(), 448); | 5041 EXPECT_EQ(result.height(), 448); |
5028 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 5042 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
5029 EXPECT_EQ(result.width(), 512); | 5043 EXPECT_EQ(result.width(), 512); |
5030 EXPECT_EQ(result.height(), 500 + 2); | 5044 EXPECT_EQ(result.height(), 500 + 2); |
5031 } | 5045 } |
5032 | 5046 |
5033 } // namespace | 5047 } // namespace |
5034 } // namespace cc | 5048 } // namespace cc |
OLD | NEW |