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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 const Region& invalidation) { | 166 const Region& invalidation) { |
167 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = | 167 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = |
168 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 168 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
169 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = | 169 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = |
170 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 170 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
171 | 171 |
172 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, | 172 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, |
173 tile_size, invalidation); | 173 tile_size, invalidation); |
174 } | 174 } |
175 | 175 |
176 void SetupTrees(scoped_refptr<RasterSource> pending_raster_source, | 176 void SetupTrees(scoped_refptr<DisplayListRasterSource> pending_raster_source, |
177 scoped_refptr<RasterSource> active_raster_source) { | 177 scoped_refptr<DisplayListRasterSource> active_raster_source) { |
178 SetupPendingTree(active_raster_source); | 178 SetupPendingTree(active_raster_source); |
179 ActivateTree(); | 179 ActivateTree(); |
180 SetupPendingTreeInternal(pending_raster_source, gfx::Size(), Region()); | 180 SetupPendingTreeInternal(pending_raster_source, gfx::Size(), Region()); |
181 } | 181 } |
182 | 182 |
183 void SetupTreesWithInvalidation( | 183 void SetupTreesWithInvalidation( |
184 scoped_refptr<RasterSource> pending_raster_source, | 184 scoped_refptr<DisplayListRasterSource> pending_raster_source, |
185 scoped_refptr<RasterSource> active_raster_source, | 185 scoped_refptr<DisplayListRasterSource> active_raster_source, |
186 const Region& pending_invalidation) { | 186 const Region& pending_invalidation) { |
187 SetupPendingTreeInternal(active_raster_source, gfx::Size(), Region()); | 187 SetupPendingTreeInternal(active_raster_source, gfx::Size(), Region()); |
188 ActivateTree(); | 188 ActivateTree(); |
189 SetupPendingTreeInternal(pending_raster_source, gfx::Size(), | 189 SetupPendingTreeInternal(pending_raster_source, gfx::Size(), |
190 pending_invalidation); | 190 pending_invalidation); |
191 } | 191 } |
192 | 192 |
193 void SetupTreesWithFixedTileSize( | 193 void SetupTreesWithFixedTileSize( |
194 scoped_refptr<RasterSource> pending_raster_source, | 194 scoped_refptr<DisplayListRasterSource> pending_raster_source, |
195 scoped_refptr<RasterSource> active_raster_source, | 195 scoped_refptr<DisplayListRasterSource> active_raster_source, |
196 const gfx::Size& tile_size, | 196 const gfx::Size& tile_size, |
197 const Region& pending_invalidation) { | 197 const Region& pending_invalidation) { |
198 SetupPendingTreeInternal(active_raster_source, tile_size, Region()); | 198 SetupPendingTreeInternal(active_raster_source, tile_size, Region()); |
199 ActivateTree(); | 199 ActivateTree(); |
200 SetupPendingTreeInternal(pending_raster_source, tile_size, | 200 SetupPendingTreeInternal(pending_raster_source, tile_size, |
201 pending_invalidation); | 201 pending_invalidation); |
202 } | 202 } |
203 | 203 |
204 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { | 204 void SetupPendingTree(scoped_refptr<DisplayListRasterSource> raster_source) { |
205 SetupPendingTreeInternal(raster_source, gfx::Size(), Region()); | 205 SetupPendingTreeInternal(raster_source, gfx::Size(), Region()); |
206 } | 206 } |
207 | 207 |
208 void SetupPendingTreeWithInvalidation( | 208 void SetupPendingTreeWithInvalidation( |
209 scoped_refptr<RasterSource> raster_source, | 209 scoped_refptr<DisplayListRasterSource> raster_source, |
210 const Region& invalidation) { | 210 const Region& invalidation) { |
211 SetupPendingTreeInternal(raster_source, gfx::Size(), invalidation); | 211 SetupPendingTreeInternal(raster_source, gfx::Size(), invalidation); |
212 } | 212 } |
213 | 213 |
214 void SetupPendingTreeWithFixedTileSize( | 214 void SetupPendingTreeWithFixedTileSize( |
215 scoped_refptr<RasterSource> raster_source, | 215 scoped_refptr<DisplayListRasterSource> raster_source, |
216 const gfx::Size& tile_size, | 216 const gfx::Size& tile_size, |
217 const Region& invalidation) { | 217 const Region& invalidation) { |
218 SetupPendingTreeInternal(raster_source, tile_size, invalidation); | 218 SetupPendingTreeInternal(raster_source, tile_size, invalidation); |
219 } | 219 } |
220 | 220 |
221 void SetupPendingTreeInternal(scoped_refptr<RasterSource> raster_source, | 221 void SetupPendingTreeInternal( |
222 const gfx::Size& tile_size, | 222 scoped_refptr<DisplayListRasterSource> raster_source, |
223 const Region& invalidation) { | 223 const gfx::Size& tile_size, |
| 224 const Region& invalidation) { |
224 host_impl_.CreatePendingTree(); | 225 host_impl_.CreatePendingTree(); |
225 host_impl_.pending_tree()->PushPageScaleFromMainThread(1.f, 0.00001f, | 226 host_impl_.pending_tree()->PushPageScaleFromMainThread(1.f, 0.00001f, |
226 100000.f); | 227 100000.f); |
227 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 228 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
228 pending_tree->SetDeviceScaleFactor( | 229 pending_tree->SetDeviceScaleFactor( |
229 host_impl_.active_tree()->device_scale_factor()); | 230 host_impl_.active_tree()->device_scale_factor()); |
230 | 231 |
231 // Steal from the recycled tree if possible. | 232 // Steal from the recycled tree if possible. |
232 scoped_ptr<LayerImpl> pending_root = pending_tree->DetachLayerTree(); | 233 scoped_ptr<LayerImpl> pending_root = pending_tree->DetachLayerTree(); |
233 scoped_ptr<FakePictureLayerImpl> pending_layer; | 234 scoped_ptr<FakePictureLayerImpl> pending_layer; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 maximum_animation_contents_scale; | 280 maximum_animation_contents_scale; |
280 layer->draw_properties().starting_animation_contents_scale = | 281 layer->draw_properties().starting_animation_contents_scale = |
281 starting_animation_contents_scale; | 282 starting_animation_contents_scale; |
282 layer->draw_properties().screen_space_transform_is_animating = | 283 layer->draw_properties().screen_space_transform_is_animating = |
283 animating_transform_to_screen; | 284 animating_transform_to_screen; |
284 bool resourceless_software_draw = false; | 285 bool resourceless_software_draw = false; |
285 layer->UpdateTiles(resourceless_software_draw); | 286 layer->UpdateTiles(resourceless_software_draw); |
286 } | 287 } |
287 static void VerifyAllPrioritizedTilesExistAndHaveRasterSource( | 288 static void VerifyAllPrioritizedTilesExistAndHaveRasterSource( |
288 const PictureLayerTiling* tiling, | 289 const PictureLayerTiling* tiling, |
289 RasterSource* raster_source) { | 290 DisplayListRasterSource* raster_source) { |
290 auto prioritized_tiles = | 291 auto prioritized_tiles = |
291 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 292 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
292 for (PictureLayerTiling::CoverageIterator iter( | 293 for (PictureLayerTiling::CoverageIterator iter( |
293 tiling, | 294 tiling, |
294 tiling->contents_scale(), | 295 tiling->contents_scale(), |
295 gfx::Rect(tiling->tiling_size())); | 296 gfx::Rect(tiling->tiling_size())); |
296 iter; | 297 iter; |
297 ++iter) { | 298 ++iter) { |
298 EXPECT_TRUE(*iter); | 299 EXPECT_TRUE(*iter); |
299 EXPECT_EQ(raster_source, prioritized_tiles[*iter].raster_source()); | 300 EXPECT_EQ(raster_source, prioritized_tiles[*iter].raster_source()); |
(...skipping 4190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4490 | 4491 |
4491 int frame_number = 0; | 4492 int frame_number = 0; |
4492 | 4493 |
4493 client.set_fill_with_nonsolid_color(!test_for_solid); | 4494 client.set_fill_with_nonsolid_color(!test_for_solid); |
4494 | 4495 |
4495 Region invalidation(layer_rect); | 4496 Region invalidation(layer_rect); |
4496 recording_source->UpdateAndExpandInvalidation( | 4497 recording_source->UpdateAndExpandInvalidation( |
4497 &client, &invalidation, layer_bounds, layer_rect, frame_number++, | 4498 &client, &invalidation, layer_bounds, layer_rect, frame_number++, |
4498 DisplayListRecordingSource::RECORD_NORMALLY); | 4499 DisplayListRecordingSource::RECORD_NORMALLY); |
4499 | 4500 |
4500 scoped_refptr<RasterSource> pending_raster_source = | 4501 scoped_refptr<DisplayListRasterSource> pending_raster_source = |
4501 recording_source->CreateRasterSource(true); | 4502 recording_source->CreateRasterSource(true); |
4502 | 4503 |
4503 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 4504 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
4504 ActivateTree(); | 4505 ActivateTree(); |
4505 | 4506 |
4506 if (test_for_solid) { | 4507 if (test_for_solid) { |
4507 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4508 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
4508 } else { | 4509 } else { |
4509 ASSERT_TRUE(active_layer_->tilings()); | 4510 ASSERT_TRUE(active_layer_->tilings()); |
4510 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); | 4511 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4554 | 4555 |
4555 int frame_number = 0; | 4556 int frame_number = 0; |
4556 | 4557 |
4557 client.set_fill_with_nonsolid_color(true); | 4558 client.set_fill_with_nonsolid_color(true); |
4558 | 4559 |
4559 Region invalidation1(layer_rect); | 4560 Region invalidation1(layer_rect); |
4560 recording_source->UpdateAndExpandInvalidation( | 4561 recording_source->UpdateAndExpandInvalidation( |
4561 &client, &invalidation1, layer_bounds, layer_rect, frame_number++, | 4562 &client, &invalidation1, layer_bounds, layer_rect, frame_number++, |
4562 DisplayListRecordingSource::RECORD_NORMALLY); | 4563 DisplayListRecordingSource::RECORD_NORMALLY); |
4563 | 4564 |
4564 scoped_refptr<RasterSource> raster_source1 = | 4565 scoped_refptr<DisplayListRasterSource> raster_source1 = |
4565 recording_source->CreateRasterSource(true); | 4566 recording_source->CreateRasterSource(true); |
4566 | 4567 |
4567 SetupPendingTree(raster_source1); | 4568 SetupPendingTree(raster_source1); |
4568 ActivateTree(); | 4569 ActivateTree(); |
4569 bool update_lcd_text = false; | 4570 bool update_lcd_text = false; |
4570 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); | 4571 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); |
4571 | 4572 |
4572 // We've started with a solid layer that contains some tilings. | 4573 // We've started with a solid layer that contains some tilings. |
4573 ASSERT_TRUE(active_layer_->tilings()); | 4574 ASSERT_TRUE(active_layer_->tilings()); |
4574 EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); | 4575 EXPECT_NE(0u, active_layer_->tilings()->num_tilings()); |
4575 | 4576 |
4576 client.set_fill_with_nonsolid_color(false); | 4577 client.set_fill_with_nonsolid_color(false); |
4577 | 4578 |
4578 Region invalidation2(layer_rect); | 4579 Region invalidation2(layer_rect); |
4579 recording_source->UpdateAndExpandInvalidation( | 4580 recording_source->UpdateAndExpandInvalidation( |
4580 &client, &invalidation2, layer_bounds, layer_rect, frame_number++, | 4581 &client, &invalidation2, layer_bounds, layer_rect, frame_number++, |
4581 DisplayListRecordingSource::RECORD_NORMALLY); | 4582 DisplayListRecordingSource::RECORD_NORMALLY); |
4582 | 4583 |
4583 scoped_refptr<RasterSource> raster_source2 = | 4584 scoped_refptr<DisplayListRasterSource> raster_source2 = |
4584 recording_source->CreateRasterSource(true); | 4585 recording_source->CreateRasterSource(true); |
4585 | 4586 |
4586 SetupPendingTree(raster_source2); | 4587 SetupPendingTree(raster_source2); |
4587 ActivateTree(); | 4588 ActivateTree(); |
4588 | 4589 |
4589 // We've switched to a solid color, so we should end up with no tilings. | 4590 // We've switched to a solid color, so we should end up with no tilings. |
4590 ASSERT_TRUE(active_layer_->tilings()); | 4591 ASSERT_TRUE(active_layer_->tilings()); |
4591 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4592 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
4592 } | 4593 } |
4593 | 4594 |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5025 // New low res tiling. | 5026 // New low res tiling. |
5026 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); | 5027 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); |
5027 | 5028 |
5028 // This tiling will be high res now, it won't contain low res content since it | 5029 // This tiling will be high res now, it won't contain low res content since it |
5029 // was all destroyed. | 5030 // was all destroyed. |
5030 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); | 5031 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); |
5031 } | 5032 } |
5032 | 5033 |
5033 } // namespace | 5034 } // namespace |
5034 } // namespace cc | 5035 } // namespace cc |
OLD | NEW |