| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 scoped_ptr<FakePictureLayerImpl> pending_layer = | 133 scoped_ptr<FakePictureLayerImpl> pending_layer = |
| 134 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); | 134 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); |
| 135 pending_layer->SetDrawsContent(true); | 135 pending_layer->SetDrawsContent(true); |
| 136 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); | 136 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); |
| 137 | 137 |
| 138 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 138 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
| 139 host_impl_.pending_tree()->LayerById(id_)); | 139 host_impl_.pending_tree()->LayerById(id_)); |
| 140 pending_layer_->DoPostCommitInitializationIfNeeded(); | 140 pending_layer_->DoPostCommitInitializationIfNeeded(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void SetupDrawPropertiesAndManageTilings( | 143 void SetupDrawPropertiesAndUpdateTiles(FakePictureLayerImpl* layer, |
| 144 FakePictureLayerImpl* layer, | 144 float ideal_contents_scale, |
| 145 float ideal_contents_scale, | 145 float device_scale_factor, |
| 146 float device_scale_factor, | 146 float page_scale_factor, |
| 147 float page_scale_factor, | 147 float maximum_animation_contents_scale, |
| 148 float maximum_animation_contents_scale, | 148 bool animating_transform_to_screen) { |
| 149 bool animating_transform_to_screen) { | |
| 150 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; | 149 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; |
| 151 layer->draw_properties().device_scale_factor = device_scale_factor; | 150 layer->draw_properties().device_scale_factor = device_scale_factor; |
| 152 layer->draw_properties().page_scale_factor = page_scale_factor; | 151 layer->draw_properties().page_scale_factor = page_scale_factor; |
| 153 layer->draw_properties().maximum_animation_contents_scale = | 152 layer->draw_properties().maximum_animation_contents_scale = |
| 154 maximum_animation_contents_scale; | 153 maximum_animation_contents_scale; |
| 155 layer->draw_properties().screen_space_transform_is_animating = | 154 layer->draw_properties().screen_space_transform_is_animating = |
| 156 animating_transform_to_screen; | 155 animating_transform_to_screen; |
| 157 layer->ScaleAndManageTilings(animating_transform_to_screen, | 156 layer->UpdateTiles(); |
| 158 maximum_animation_contents_scale); | |
| 159 } | 157 } |
| 160 static void VerifyAllTilesExistAndHavePile( | 158 static void VerifyAllTilesExistAndHavePile( |
| 161 const PictureLayerTiling* tiling, | 159 const PictureLayerTiling* tiling, |
| 162 PicturePileImpl* pile) { | 160 PicturePileImpl* pile) { |
| 163 for (PictureLayerTiling::CoverageIterator iter( | 161 for (PictureLayerTiling::CoverageIterator iter( |
| 164 tiling, tiling->contents_scale(), tiling->TilingRect()); | 162 tiling, tiling->contents_scale(), tiling->TilingRect()); |
| 165 iter; | 163 iter; |
| 166 ++iter) { | 164 ++iter) { |
| 167 EXPECT_TRUE(*iter); | 165 EXPECT_TRUE(*iter); |
| 168 EXPECT_EQ(pile, iter->picture_pile()); | 166 EXPECT_EQ(pile, iter->picture_pile()); |
| 169 } | 167 } |
| 170 } | 168 } |
| 171 | 169 |
| 172 void SetContentsScaleOnBothLayers(float contents_scale, | 170 void SetContentsScaleOnBothLayers(float contents_scale, |
| 173 float device_scale_factor, | 171 float device_scale_factor, |
| 174 float page_scale_factor, | 172 float page_scale_factor, |
| 175 float maximum_animation_contents_scale, | 173 float maximum_animation_contents_scale, |
| 176 bool animating_transform) { | 174 bool animating_transform) { |
| 177 SetupDrawPropertiesAndManageTilings(pending_layer_, | 175 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 178 contents_scale, | 176 contents_scale, |
| 179 device_scale_factor, | 177 device_scale_factor, |
| 180 page_scale_factor, | 178 page_scale_factor, |
| 181 maximum_animation_contents_scale, | 179 maximum_animation_contents_scale, |
| 182 animating_transform); | 180 animating_transform); |
| 183 | 181 |
| 184 SetupDrawPropertiesAndManageTilings(active_layer_, | 182 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 185 contents_scale, | 183 contents_scale, |
| 186 device_scale_factor, | 184 device_scale_factor, |
| 187 page_scale_factor, | 185 page_scale_factor, |
| 188 maximum_animation_contents_scale, | 186 maximum_animation_contents_scale, |
| 189 animating_transform); | 187 animating_transform); |
| 190 } | 188 } |
| 191 | 189 |
| 192 void ResetTilingsAndRasterScales() { | 190 void ResetTilingsAndRasterScales() { |
| 193 pending_layer_->ReleaseResources(); | 191 pending_layer_->ReleaseResources(); |
| 194 active_layer_->ReleaseResources(); | 192 active_layer_->ReleaseResources(); |
| 195 } | 193 } |
| 196 | 194 |
| 197 void AssertAllTilesRequired(PictureLayerTiling* tiling) { | 195 void AssertAllTilesRequired(PictureLayerTiling* tiling) { |
| 198 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 196 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 199 for (size_t i = 0; i < tiles.size(); ++i) | 197 for (size_t i = 0; i < tiles.size(); ++i) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 216 settings.default_tile_size.width() * 7 / 2, | 214 settings.default_tile_size.width() * 7 / 2, |
| 217 settings.default_tile_size.height() * 7 / 2); | 215 settings.default_tile_size.height() * 7 / 2); |
| 218 | 216 |
| 219 scoped_refptr<FakePicturePileImpl> pending_pile = | 217 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 220 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); | 218 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
| 221 scoped_refptr<FakePicturePileImpl> active_pile = | 219 scoped_refptr<FakePicturePileImpl> active_pile = |
| 222 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); | 220 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
| 223 | 221 |
| 224 SetupTrees(pending_pile, active_pile); | 222 SetupTrees(pending_pile, active_pile); |
| 225 | 223 |
| 226 SetupDrawPropertiesAndManageTilings( | 224 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 227 active_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
| 228 | 225 |
| 229 // Add 1x1 rects at the centers of each tile, then re-record pile contents | 226 // Add 1x1 rects at the centers of each tile, then re-record pile contents |
| 230 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 227 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 231 std::vector<Tile*> tiles = | 228 std::vector<Tile*> tiles = |
| 232 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 229 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
| 233 EXPECT_EQ(16u, tiles.size()); | 230 EXPECT_EQ(16u, tiles.size()); |
| 234 std::vector<SkRect> rects; | 231 std::vector<SkRect> rects; |
| 235 std::vector<Tile*>::const_iterator tile_iter; | 232 std::vector<Tile*>::const_iterator tile_iter; |
| 236 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { | 233 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { |
| 237 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); | 234 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 309 |
| 313 scoped_refptr<FakePicturePileImpl> pending_pile = | 310 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 314 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 311 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 315 scoped_refptr<FakePicturePileImpl> active_pile = | 312 scoped_refptr<FakePicturePileImpl> active_pile = |
| 316 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 313 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 317 | 314 |
| 318 SetupTrees(pending_pile, active_pile); | 315 SetupTrees(pending_pile, active_pile); |
| 319 | 316 |
| 320 Region invalidation; | 317 Region invalidation; |
| 321 AddDefaultTilingsWithInvalidation(invalidation); | 318 AddDefaultTilingsWithInvalidation(invalidation); |
| 322 SetupDrawPropertiesAndManageTilings(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 319 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 323 | 320 |
| 324 // UpdateTilePriorities with valid viewport. Should update tile viewport. | 321 // UpdateTiles with valid viewport. Should update tile viewport. |
| 325 bool valid_for_tile_management = true; | 322 bool valid_for_tile_management = true; |
| 326 gfx::Rect viewport = gfx::Rect(layer_bounds); | 323 gfx::Rect viewport = gfx::Rect(layer_bounds); |
| 327 gfx::Transform transform; | 324 gfx::Transform transform; |
| 328 host_impl_.SetExternalDrawConstraints( | 325 host_impl_.SetExternalDrawConstraints( |
| 329 transform, viewport, viewport, valid_for_tile_management); | 326 transform, viewport, viewport, valid_for_tile_management); |
| 330 active_layer_->draw_properties().visible_content_rect = viewport; | 327 active_layer_->draw_properties().visible_content_rect = viewport; |
| 331 active_layer_->draw_properties().screen_space_transform = transform; | 328 active_layer_->draw_properties().screen_space_transform = transform; |
| 332 active_layer_->UpdateTilePriorities(); | 329 active_layer_->UpdateTiles(); |
| 333 | 330 |
| 334 gfx::Rect visible_rect_for_tile_priority = | 331 gfx::Rect visible_rect_for_tile_priority = |
| 335 active_layer_->visible_rect_for_tile_priority(); | 332 active_layer_->visible_rect_for_tile_priority(); |
| 336 EXPECT_FALSE(visible_rect_for_tile_priority.IsEmpty()); | 333 EXPECT_FALSE(visible_rect_for_tile_priority.IsEmpty()); |
| 337 gfx::Size viewport_size_for_tile_priority = | 334 gfx::Size viewport_size_for_tile_priority = |
| 338 active_layer_->viewport_size_for_tile_priority(); | 335 active_layer_->viewport_size_for_tile_priority(); |
| 339 EXPECT_FALSE(viewport_size_for_tile_priority.IsEmpty()); | 336 EXPECT_FALSE(viewport_size_for_tile_priority.IsEmpty()); |
| 340 gfx::Transform screen_space_transform_for_tile_priority = | 337 gfx::Transform screen_space_transform_for_tile_priority = |
| 341 active_layer_->screen_space_transform_for_tile_priority(); | 338 active_layer_->screen_space_transform_for_tile_priority(); |
| 342 | 339 |
| 343 // Expand viewport and set it as invalid for prioritizing tiles. | 340 // Expand viewport and set it as invalid for prioritizing tiles. |
| 344 // Should not update tile viewport. | 341 // Should not update tile viewport. |
| 345 time_ticks += base::TimeDelta::FromMilliseconds(200); | 342 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 346 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 343 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
| 347 valid_for_tile_management = false; | 344 valid_for_tile_management = false; |
| 348 viewport = gfx::ScaleToEnclosingRect(viewport, 2); | 345 viewport = gfx::ScaleToEnclosingRect(viewport, 2); |
| 349 transform.Translate(1.f, 1.f); | 346 transform.Translate(1.f, 1.f); |
| 350 active_layer_->draw_properties().visible_content_rect = viewport; | 347 active_layer_->draw_properties().visible_content_rect = viewport; |
| 351 active_layer_->draw_properties().screen_space_transform = transform; | 348 active_layer_->draw_properties().screen_space_transform = transform; |
| 352 host_impl_.SetExternalDrawConstraints( | 349 host_impl_.SetExternalDrawConstraints( |
| 353 transform, viewport, viewport, valid_for_tile_management); | 350 transform, viewport, viewport, valid_for_tile_management); |
| 354 active_layer_->UpdateTilePriorities(); | 351 active_layer_->UpdateTiles(); |
| 355 | 352 |
| 356 EXPECT_RECT_EQ(visible_rect_for_tile_priority, | 353 EXPECT_RECT_EQ(visible_rect_for_tile_priority, |
| 357 active_layer_->visible_rect_for_tile_priority()); | 354 active_layer_->visible_rect_for_tile_priority()); |
| 358 EXPECT_SIZE_EQ(viewport_size_for_tile_priority, | 355 EXPECT_SIZE_EQ(viewport_size_for_tile_priority, |
| 359 active_layer_->viewport_size_for_tile_priority()); | 356 active_layer_->viewport_size_for_tile_priority()); |
| 360 EXPECT_TRANSFORMATION_MATRIX_EQ( | 357 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 361 screen_space_transform_for_tile_priority, | 358 screen_space_transform_for_tile_priority, |
| 362 active_layer_->screen_space_transform_for_tile_priority()); | 359 active_layer_->screen_space_transform_for_tile_priority()); |
| 363 | 360 |
| 364 // Keep expanded viewport but mark it valid. Should update tile viewport. | 361 // Keep expanded viewport but mark it valid. Should update tile viewport. |
| 365 time_ticks += base::TimeDelta::FromMilliseconds(200); | 362 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 366 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 363 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
| 367 valid_for_tile_management = true; | 364 valid_for_tile_management = true; |
| 368 host_impl_.SetExternalDrawConstraints( | 365 host_impl_.SetExternalDrawConstraints( |
| 369 transform, viewport, viewport, valid_for_tile_management); | 366 transform, viewport, viewport, valid_for_tile_management); |
| 370 active_layer_->UpdateTilePriorities(); | 367 active_layer_->UpdateTiles(); |
| 371 | 368 |
| 372 EXPECT_FALSE(visible_rect_for_tile_priority == | 369 EXPECT_FALSE(visible_rect_for_tile_priority == |
| 373 active_layer_->visible_rect_for_tile_priority()); | 370 active_layer_->visible_rect_for_tile_priority()); |
| 374 EXPECT_FALSE(viewport_size_for_tile_priority == | 371 EXPECT_FALSE(viewport_size_for_tile_priority == |
| 375 active_layer_->viewport_size_for_tile_priority()); | 372 active_layer_->viewport_size_for_tile_priority()); |
| 376 EXPECT_FALSE(screen_space_transform_for_tile_priority == | 373 EXPECT_FALSE(screen_space_transform_for_tile_priority == |
| 377 active_layer_->screen_space_transform_for_tile_priority()); | 374 active_layer_->screen_space_transform_for_tile_priority()); |
| 378 } | 375 } |
| 379 | 376 |
| 380 TEST_F(PictureLayerImplTest, InvalidViewportAfterReleaseResources) { | 377 TEST_F(PictureLayerImplTest, InvalidViewportAfterReleaseResources) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 397 bool valid_for_tile_management = false; | 394 bool valid_for_tile_management = false; |
| 398 gfx::Rect viewport = gfx::Rect(layer_bounds); | 395 gfx::Rect viewport = gfx::Rect(layer_bounds); |
| 399 host_impl_.SetExternalDrawConstraints( | 396 host_impl_.SetExternalDrawConstraints( |
| 400 gfx::Transform(), viewport, viewport, valid_for_tile_management); | 397 gfx::Transform(), viewport, viewport, valid_for_tile_management); |
| 401 ResetTilingsAndRasterScales(); | 398 ResetTilingsAndRasterScales(); |
| 402 host_impl_.pending_tree()->UpdateDrawProperties(); | 399 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 403 host_impl_.active_tree()->UpdateDrawProperties(); | 400 host_impl_.active_tree()->UpdateDrawProperties(); |
| 404 EXPECT_TRUE(active_layer_->HighResTiling()); | 401 EXPECT_TRUE(active_layer_->HighResTiling()); |
| 405 | 402 |
| 406 size_t num_tilings = active_layer_->num_tilings(); | 403 size_t num_tilings = active_layer_->num_tilings(); |
| 407 active_layer_->UpdateTilePriorities(); | 404 active_layer_->UpdateTiles(); |
| 408 pending_layer_->AddTiling(0.5f); | 405 pending_layer_->AddTiling(0.5f); |
| 409 EXPECT_EQ(num_tilings + 1, active_layer_->num_tilings()); | 406 EXPECT_EQ(num_tilings + 1, active_layer_->num_tilings()); |
| 410 } | 407 } |
| 411 | 408 |
| 412 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { | 409 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { |
| 413 gfx::Size tile_size(100, 100); | 410 gfx::Size tile_size(100, 100); |
| 414 gfx::Size layer_bounds(400, 400); | 411 gfx::Size layer_bounds(400, 400); |
| 415 gfx::Rect layer_invalidation(150, 200, 30, 180); | 412 gfx::Rect layer_invalidation(150, 200, 30, 180); |
| 416 | 413 |
| 417 scoped_refptr<FakePicturePileImpl> pending_pile = | 414 scoped_refptr<FakePicturePileImpl> pending_pile = |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 gfx::Size tile_size(400, 400); | 568 gfx::Size tile_size(400, 400); |
| 572 gfx::Size layer_bounds(1300, 1900); | 569 gfx::Size layer_bounds(1300, 1900); |
| 573 | 570 |
| 574 scoped_refptr<FakePicturePileImpl> pending_pile = | 571 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 575 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 572 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| 576 scoped_refptr<FakePicturePileImpl> active_pile = | 573 scoped_refptr<FakePicturePileImpl> active_pile = |
| 577 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 574 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| 578 | 575 |
| 579 SetupTrees(pending_pile, active_pile); | 576 SetupTrees(pending_pile, active_pile); |
| 580 | 577 |
| 581 SetupDrawPropertiesAndManageTilings( | 578 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 582 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
| 583 | 579 |
| 584 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 580 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 585 } | 581 } |
| 586 | 582 |
| 587 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { | 583 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
| 588 gfx::Size tile_size(400, 400); | 584 gfx::Size tile_size(400, 400); |
| 589 gfx::Size layer_bounds(1300, 1900); | 585 gfx::Size layer_bounds(1300, 1900); |
| 590 | 586 |
| 591 scoped_refptr<FakePicturePileImpl> pending_pile = | 587 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 592 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 588 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 593 scoped_refptr<FakePicturePileImpl> active_pile = | 589 scoped_refptr<FakePicturePileImpl> active_pile = |
| 594 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 590 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 595 | 591 |
| 596 SetupTrees(pending_pile, active_pile); | 592 SetupTrees(pending_pile, active_pile); |
| 597 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 593 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 598 | 594 |
| 599 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 595 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 600 EXPECT_LT(low_res_factor, 1.f); | 596 EXPECT_LT(low_res_factor, 1.f); |
| 601 | 597 |
| 602 SetupDrawPropertiesAndManageTilings(pending_layer_, | 598 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 603 6.f, // ideal contents scale | 599 6.f, // ideal contents scale |
| 604 3.f, // device scale | 600 3.f, // device scale |
| 605 2.f, // page scale | 601 2.f, // page scale |
| 606 1.f, // maximum animation scale | 602 1.f, // maximum animation scale |
| 607 false); | 603 false); |
| 608 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 604 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 609 EXPECT_FLOAT_EQ(6.f, | 605 EXPECT_FLOAT_EQ(6.f, |
| 610 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 606 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 611 EXPECT_FLOAT_EQ(6.f * low_res_factor, | 607 EXPECT_FLOAT_EQ(6.f * low_res_factor, |
| 612 pending_layer_->tilings()->tiling_at(1)->contents_scale()); | 608 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
| 613 | 609 |
| 614 // If we change the page scale factor, then we should get new tilings. | 610 // If we change the page scale factor, then we should get new tilings. |
| 615 SetupDrawPropertiesAndManageTilings(pending_layer_, | 611 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 616 6.6f, // ideal contents scale | 612 6.6f, // ideal contents scale |
| 617 3.f, // device scale | 613 3.f, // device scale |
| 618 2.2f, // page scale | 614 2.2f, // page scale |
| 619 1.f, // maximum animation scale | 615 1.f, // maximum animation scale |
| 620 false); | 616 false); |
| 621 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); | 617 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); |
| 622 EXPECT_FLOAT_EQ(6.6f, | 618 EXPECT_FLOAT_EQ(6.6f, |
| 623 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 619 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 624 EXPECT_FLOAT_EQ(6.6f * low_res_factor, | 620 EXPECT_FLOAT_EQ(6.6f * low_res_factor, |
| 625 pending_layer_->tilings()->tiling_at(2)->contents_scale()); | 621 pending_layer_->tilings()->tiling_at(2)->contents_scale()); |
| 626 | 622 |
| 627 // If we change the device scale factor, then we should get new tilings. | 623 // If we change the device scale factor, then we should get new tilings. |
| 628 SetupDrawPropertiesAndManageTilings(pending_layer_, | 624 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 629 7.26f, // ideal contents scale | 625 7.26f, // ideal contents scale |
| 630 3.3f, // device scale | 626 3.3f, // device scale |
| 631 2.2f, // page scale | 627 2.2f, // page scale |
| 632 1.f, // maximum animation scale | 628 1.f, // maximum animation scale |
| 633 false); | 629 false); |
| 634 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); | 630 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); |
| 635 EXPECT_FLOAT_EQ(7.26f, | 631 EXPECT_FLOAT_EQ(7.26f, |
| 636 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 632 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 637 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 633 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
| 638 pending_layer_->tilings()->tiling_at(3)->contents_scale()); | 634 pending_layer_->tilings()->tiling_at(3)->contents_scale()); |
| 639 | 635 |
| 640 // If we change the device scale factor, but end up at the same total scale | 636 // If we change the device scale factor, but end up at the same total scale |
| 641 // factor somehow, then we don't get new tilings. | 637 // factor somehow, then we don't get new tilings. |
| 642 SetupDrawPropertiesAndManageTilings(pending_layer_, | 638 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 643 7.26f, // ideal contents scale | 639 7.26f, // ideal contents scale |
| 644 2.2f, // device scale | 640 2.2f, // device scale |
| 645 3.3f, // page scale | 641 3.3f, // page scale |
| 646 1.f, // maximum animation scale | 642 1.f, // maximum animation scale |
| 647 false); | 643 false); |
| 648 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); | 644 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); |
| 649 EXPECT_FLOAT_EQ(7.26f, | 645 EXPECT_FLOAT_EQ(7.26f, |
| 650 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 646 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 651 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 647 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
| 652 pending_layer_->tilings()->tiling_at(3)->contents_scale()); | 648 pending_layer_->tilings()->tiling_at(3)->contents_scale()); |
| 653 } | 649 } |
| 654 | 650 |
| 655 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { | 651 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
| 656 // This test makes sure that if a layer can have tilings, then a commit makes | 652 // This test makes sure that if a layer can have tilings, then a commit makes |
| 657 // it not able to have tilings (empty size), and then a future commit that | 653 // it not able to have tilings (empty size), and then a future commit that |
| 658 // makes it valid again should be able to create tilings. | 654 // makes it valid again should be able to create tilings. |
| 659 gfx::Size tile_size(400, 400); | 655 gfx::Size tile_size(400, 400); |
| 660 gfx::Size layer_bounds(1300, 1900); | 656 gfx::Size layer_bounds(1300, 1900); |
| 661 | 657 |
| 662 scoped_refptr<FakePicturePileImpl> empty_pile = | 658 scoped_refptr<FakePicturePileImpl> empty_pile = |
| 663 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 659 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| 664 scoped_refptr<FakePicturePileImpl> valid_pile = | 660 scoped_refptr<FakePicturePileImpl> valid_pile = |
| 665 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 661 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 666 | 662 |
| 667 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 663 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 668 EXPECT_LT(low_res_factor, 1.f); | 664 EXPECT_LT(low_res_factor, 1.f); |
| 669 | 665 |
| 670 float high_res_scale = 1.3f; | 666 float high_res_scale = 1.3f; |
| 671 float low_res_scale = high_res_scale * low_res_factor; | 667 float low_res_scale = high_res_scale * low_res_factor; |
| 672 float device_scale = 1.7f; | 668 float device_scale = 1.7f; |
| 673 float page_scale = 3.2f; | 669 float page_scale = 3.2f; |
| 674 float maximum_animation_scale = 1.f; | 670 float maximum_animation_scale = 1.f; |
| 675 | 671 |
| 676 SetupPendingTree(valid_pile); | 672 SetupPendingTree(valid_pile); |
| 677 SetupDrawPropertiesAndManageTilings(pending_layer_, | 673 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 678 high_res_scale, | 674 high_res_scale, |
| 679 device_scale, | 675 device_scale, |
| 680 page_scale, | 676 page_scale, |
| 681 maximum_animation_scale, | 677 maximum_animation_scale, |
| 682 false); | 678 false); |
| 683 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 679 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 684 EXPECT_FLOAT_EQ(high_res_scale, | 680 EXPECT_FLOAT_EQ(high_res_scale, |
| 685 pending_layer_->HighResTiling()->contents_scale()); | 681 pending_layer_->HighResTiling()->contents_scale()); |
| 686 EXPECT_FLOAT_EQ(low_res_scale, | 682 EXPECT_FLOAT_EQ(low_res_scale, |
| 687 pending_layer_->LowResTiling()->contents_scale()); | 683 pending_layer_->LowResTiling()->contents_scale()); |
| 688 | 684 |
| 689 ActivateTree(); | 685 ActivateTree(); |
| 690 SetupPendingTree(empty_pile); | 686 SetupPendingTree(empty_pile); |
| 691 SetupDrawPropertiesAndManageTilings(pending_layer_, | 687 EXPECT_FALSE(pending_layer_->CanHaveTilings()); |
| 692 high_res_scale, | 688 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 693 device_scale, | 689 high_res_scale, |
| 694 page_scale, | 690 device_scale, |
| 695 maximum_animation_scale, | 691 page_scale, |
| 696 false); | 692 maximum_animation_scale, |
| 693 false); |
| 697 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 694 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 698 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 695 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 699 | 696 |
| 700 ActivateTree(); | 697 ActivateTree(); |
| 701 SetupDrawPropertiesAndManageTilings(active_layer_, | 698 EXPECT_FALSE(active_layer_->CanHaveTilings()); |
| 702 high_res_scale, | 699 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 703 device_scale, | 700 high_res_scale, |
| 704 page_scale, | 701 device_scale, |
| 705 maximum_animation_scale, | 702 page_scale, |
| 706 false); | 703 maximum_animation_scale, |
| 704 false); |
| 707 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); | 705 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 708 | 706 |
| 709 SetupPendingTree(valid_pile); | 707 SetupPendingTree(valid_pile); |
| 710 SetupDrawPropertiesAndManageTilings(pending_layer_, | 708 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 711 high_res_scale, | 709 high_res_scale, |
| 712 device_scale, | 710 device_scale, |
| 713 page_scale, | 711 page_scale, |
| 714 maximum_animation_scale, | 712 maximum_animation_scale, |
| 715 false); | 713 false); |
| 716 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 714 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 717 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); | 715 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 718 EXPECT_FLOAT_EQ(high_res_scale, | 716 EXPECT_FLOAT_EQ(high_res_scale, |
| 719 pending_layer_->HighResTiling()->contents_scale()); | 717 pending_layer_->HighResTiling()->contents_scale()); |
| 720 EXPECT_FLOAT_EQ(low_res_scale, | 718 EXPECT_FLOAT_EQ(low_res_scale, |
| 721 pending_layer_->LowResTiling()->contents_scale()); | 719 pending_layer_->LowResTiling()->contents_scale()); |
| 722 } | 720 } |
| 723 | 721 |
| 724 TEST_F(PictureLayerImplTest, ZoomOutCrash) { | 722 TEST_F(PictureLayerImplTest, ZoomOutCrash) { |
| 725 gfx::Size tile_size(400, 400); | 723 gfx::Size tile_size(400, 400); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 // Now move the ideal scale to 1.0. Our target stays 1.2. | 910 // Now move the ideal scale to 1.0. Our target stays 1.2. |
| 913 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); | 911 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); |
| 914 | 912 |
| 915 // All the tilings are between are target and the ideal, so they are not | 913 // All the tilings are between are target and the ideal, so they are not |
| 916 // removed. | 914 // removed. |
| 917 used_tilings.clear(); | 915 used_tilings.clear(); |
| 918 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 916 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 919 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 917 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 920 | 918 |
| 921 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. | 919 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
| 922 SetupDrawPropertiesAndManageTilings( | 920 SetupDrawPropertiesAndUpdateTiles( |
| 923 active_layer_, 1.1f, device_scale, page_scale, 1.f, false); | 921 active_layer_, 1.1f, device_scale, page_scale, 1.f, false); |
| 924 | 922 |
| 925 // Because the pending layer's ideal scale is still 1.0, our tilings fall | 923 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
| 926 // in the range [1.0,1.2] and are kept. | 924 // in the range [1.0,1.2] and are kept. |
| 927 used_tilings.clear(); | 925 used_tilings.clear(); |
| 928 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 926 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 929 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 927 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 930 | 928 |
| 931 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays | 929 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
| 932 // 1.2 still. | 930 // 1.2 still. |
| 933 SetupDrawPropertiesAndManageTilings( | 931 SetupDrawPropertiesAndUpdateTiles( |
| 934 pending_layer_, 1.1f, device_scale, page_scale, 1.f, false); | 932 pending_layer_, 1.1f, device_scale, page_scale, 1.f, false); |
| 935 | 933 |
| 936 // Our 1.0 tiling now falls outside the range between our ideal scale and our | 934 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
| 937 // target raster scale. But it is in our used tilings set, so nothing is | 935 // target raster scale. But it is in our used tilings set, so nothing is |
| 938 // deleted. | 936 // deleted. |
| 939 used_tilings.clear(); | 937 used_tilings.clear(); |
| 940 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 938 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
| 941 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 939 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 942 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 940 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 943 | 941 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 gfx::Size layer_bounds(1300, 1900); | 1079 gfx::Size layer_bounds(1300, 1900); |
| 1082 | 1080 |
| 1083 scoped_refptr<FakePicturePileImpl> pending_pile = | 1081 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1084 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1082 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1085 scoped_refptr<FakePicturePileImpl> active_pile = | 1083 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1086 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1084 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1087 | 1085 |
| 1088 SetupTrees(pending_pile, active_pile); | 1086 SetupTrees(pending_pile, active_pile); |
| 1089 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1087 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1090 | 1088 |
| 1091 SetupDrawPropertiesAndManageTilings(pending_layer_, | 1089 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 1092 1.3f, // ideal contents scale | 1090 1.3f, // ideal contents scale |
| 1093 2.7f, // device scale | 1091 2.7f, // device scale |
| 1094 3.2f, // page scale | 1092 3.2f, // page scale |
| 1095 1.f, // maximum animation scale | 1093 1.f, // maximum animation scale |
| 1096 false); | 1094 false); |
| 1097 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1095 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1098 | 1096 |
| 1099 // All tilings should be removed when losing output surface. | 1097 // All tilings should be removed when losing output surface. |
| 1100 active_layer_->ReleaseResources(); | 1098 active_layer_->ReleaseResources(); |
| 1101 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 1099 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 1102 pending_layer_->ReleaseResources(); | 1100 pending_layer_->ReleaseResources(); |
| 1103 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1101 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1104 | 1102 |
| 1105 // This should create new tilings. | 1103 // This should create new tilings. |
| 1106 SetupDrawPropertiesAndManageTilings(pending_layer_, | 1104 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 1107 1.3f, // ideal contents scale | 1105 1.3f, // ideal contents scale |
| 1108 2.7f, // device scale | 1106 2.7f, // device scale |
| 1109 3.2f, // page scale | 1107 3.2f, // page scale |
| 1110 1.f, // maximum animation scale | 1108 1.f, // maximum animation scale |
| 1111 false); | 1109 false); |
| 1112 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1110 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1113 } | 1111 } |
| 1114 | 1112 |
| 1115 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { | 1113 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { |
| 1116 // The default max tile size is larger than 400x400. | 1114 // The default max tile size is larger than 400x400. |
| 1117 gfx::Size tile_size(400, 400); | 1115 gfx::Size tile_size(400, 400); |
| 1118 gfx::Size layer_bounds(5000, 5000); | 1116 gfx::Size layer_bounds(5000, 5000); |
| 1119 | 1117 |
| 1120 scoped_refptr<FakePicturePileImpl> pending_pile = | 1118 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1121 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1119 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1122 scoped_refptr<FakePicturePileImpl> active_pile = | 1120 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1123 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1121 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1124 | 1122 |
| 1125 SetupTrees(pending_pile, active_pile); | 1123 SetupTrees(pending_pile, active_pile); |
| 1126 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1124 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1127 | 1125 |
| 1128 SetupDrawPropertiesAndManageTilings( | 1126 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1129 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
| 1130 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1127 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1131 | 1128 |
| 1132 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1129 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1133 | 1130 |
| 1134 // The default value. | 1131 // The default value. |
| 1135 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1132 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| 1136 host_impl_.settings().default_tile_size.ToString()); | 1133 host_impl_.settings().default_tile_size.ToString()); |
| 1137 | 1134 |
| 1138 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1135 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1139 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1136 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| 1140 tile->content_rect().size().ToString()); | 1137 tile->content_rect().size().ToString()); |
| 1141 | 1138 |
| 1142 pending_layer_->ReleaseResources(); | 1139 pending_layer_->ReleaseResources(); |
| 1143 | 1140 |
| 1144 // Change the max texture size on the output surface context. | 1141 // Change the max texture size on the output surface context. |
| 1145 scoped_ptr<TestWebGraphicsContext3D> context = | 1142 scoped_ptr<TestWebGraphicsContext3D> context = |
| 1146 TestWebGraphicsContext3D::Create(); | 1143 TestWebGraphicsContext3D::Create(); |
| 1147 context->set_max_texture_size(140); | 1144 context->set_max_texture_size(140); |
| 1148 host_impl_.DidLoseOutputSurface(); | 1145 host_impl_.DidLoseOutputSurface(); |
| 1149 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( | 1146 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
| 1150 context.Pass()).PassAs<OutputSurface>()); | 1147 context.Pass()).PassAs<OutputSurface>()); |
| 1151 | 1148 |
| 1152 SetupDrawPropertiesAndManageTilings( | 1149 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1153 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
| 1154 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1150 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1155 | 1151 |
| 1156 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1152 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1157 | 1153 |
| 1158 // Verify the tiles are not larger than the context's max texture size. | 1154 // Verify the tiles are not larger than the context's max texture size. |
| 1159 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1155 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1160 EXPECT_GE(140, tile->content_rect().width()); | 1156 EXPECT_GE(140, tile->content_rect().width()); |
| 1161 EXPECT_GE(140, tile->content_rect().height()); | 1157 EXPECT_GE(140, tile->content_rect().height()); |
| 1162 } | 1158 } |
| 1163 | 1159 |
| 1164 TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { | 1160 TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { |
| 1165 // The default max tile size is larger than 400x400. | 1161 // The default max tile size is larger than 400x400. |
| 1166 gfx::Size tile_size(400, 400); | 1162 gfx::Size tile_size(400, 400); |
| 1167 gfx::Size layer_bounds(500, 500); | 1163 gfx::Size layer_bounds(500, 500); |
| 1168 | 1164 |
| 1169 scoped_refptr<FakePicturePileImpl> pending_pile = | 1165 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1170 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1166 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1171 scoped_refptr<FakePicturePileImpl> active_pile = | 1167 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1172 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1168 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1173 | 1169 |
| 1174 SetupTrees(pending_pile, active_pile); | 1170 SetupTrees(pending_pile, active_pile); |
| 1175 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1171 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1176 | 1172 |
| 1177 SetupDrawPropertiesAndManageTilings( | 1173 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1178 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
| 1179 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); | 1174 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); |
| 1180 | 1175 |
| 1181 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1176 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1182 | 1177 |
| 1183 // The default value. The layer is smaller than this. | 1178 // The default value. The layer is smaller than this. |
| 1184 EXPECT_EQ(gfx::Size(512, 512).ToString(), | 1179 EXPECT_EQ(gfx::Size(512, 512).ToString(), |
| 1185 host_impl_.settings().max_untiled_layer_size.ToString()); | 1180 host_impl_.settings().max_untiled_layer_size.ToString()); |
| 1186 | 1181 |
| 1187 // There should be a single tile since the layer is small. | 1182 // There should be a single tile since the layer is small. |
| 1188 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1183 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); |
| 1189 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); | 1184 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1190 | 1185 |
| 1191 pending_layer_->ReleaseResources(); | 1186 pending_layer_->ReleaseResources(); |
| 1192 | 1187 |
| 1193 // Change the max texture size on the output surface context. | 1188 // Change the max texture size on the output surface context. |
| 1194 scoped_ptr<TestWebGraphicsContext3D> context = | 1189 scoped_ptr<TestWebGraphicsContext3D> context = |
| 1195 TestWebGraphicsContext3D::Create(); | 1190 TestWebGraphicsContext3D::Create(); |
| 1196 context->set_max_texture_size(140); | 1191 context->set_max_texture_size(140); |
| 1197 host_impl_.DidLoseOutputSurface(); | 1192 host_impl_.DidLoseOutputSurface(); |
| 1198 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( | 1193 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
| 1199 context.Pass()).PassAs<OutputSurface>()); | 1194 context.Pass()).PassAs<OutputSurface>()); |
| 1200 | 1195 |
| 1201 SetupDrawPropertiesAndManageTilings( | 1196 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1202 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
| 1203 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); | 1197 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); |
| 1204 | 1198 |
| 1205 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1199 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1206 | 1200 |
| 1207 // There should be more than one tile since the max texture size won't cover | 1201 // There should be more than one tile since the max texture size won't cover |
| 1208 // the layer. | 1202 // the layer. |
| 1209 high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1203 high_res_tiling = pending_layer_->tilings()->tiling_at(0); |
| 1210 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); | 1204 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1211 | 1205 |
| 1212 // Verify the tiles are not larger than the context's max texture size. | 1206 // Verify the tiles are not larger than the context's max texture size. |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 host_impl_.SetUseGpuRasterization(false); | 1581 host_impl_.SetUseGpuRasterization(false); |
| 1588 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1582 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1589 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 1583 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 1590 } | 1584 } |
| 1591 | 1585 |
| 1592 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { | 1586 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { |
| 1593 SetupDefaultTrees(gfx::Size(10, 10)); | 1587 SetupDefaultTrees(gfx::Size(10, 10)); |
| 1594 host_impl_.active_tree()->UpdateDrawProperties(); | 1588 host_impl_.active_tree()->UpdateDrawProperties(); |
| 1595 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); | 1589 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); |
| 1596 | 1590 |
| 1597 SetupDrawPropertiesAndManageTilings( | 1591 SetupDrawPropertiesAndUpdateTiles( |
| 1598 active_layer_, 0.5f, 0.5f, 0.5f, 0.5f, false); | 1592 active_layer_, 0.5f, 0.5f, 0.5f, 0.5f, false); |
| 1599 active_layer_->tilings()->RemoveAllTilings(); | 1593 active_layer_->tilings()->RemoveAllTilings(); |
| 1600 PictureLayerTiling* tiling = active_layer_->tilings()->AddTiling(0.5f); | 1594 PictureLayerTiling* tiling = active_layer_->tilings()->AddTiling(0.5f); |
| 1601 active_layer_->tilings()->AddTiling(1.5f); | 1595 active_layer_->tilings()->AddTiling(1.5f); |
| 1602 active_layer_->tilings()->AddTiling(0.25f); | 1596 active_layer_->tilings()->AddTiling(0.25f); |
| 1603 tiling->set_resolution(HIGH_RESOLUTION); | 1597 tiling->set_resolution(HIGH_RESOLUTION); |
| 1604 | 1598 |
| 1605 // Sanity checks. | 1599 // Sanity checks. |
| 1606 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1600 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 1607 ASSERT_EQ(tiling, active_layer_->tilings()->TilingAtScale(0.5f)); | 1601 ASSERT_EQ(tiling, active_layer_->tilings()->TilingAtScale(0.5f)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1635 } | 1629 } |
| 1636 | 1630 |
| 1637 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { | 1631 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { |
| 1638 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); | 1632 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); |
| 1639 gfx::Size layer_bounds(default_tile_size.width() * 4, | 1633 gfx::Size layer_bounds(default_tile_size.width() * 4, |
| 1640 default_tile_size.height() * 4); | 1634 default_tile_size.height() * 4); |
| 1641 | 1635 |
| 1642 SetupDefaultTrees(layer_bounds); | 1636 SetupDefaultTrees(layer_bounds); |
| 1643 EXPECT_FALSE(host_impl_.use_gpu_rasterization()); | 1637 EXPECT_FALSE(host_impl_.use_gpu_rasterization()); |
| 1644 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1638 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1645 SetupDrawPropertiesAndManageTilings( | 1639 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1646 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
| 1647 // Should have a low-res and a high-res tiling. | 1640 // Should have a low-res and a high-res tiling. |
| 1648 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1641 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1649 | 1642 |
| 1650 ResetTilingsAndRasterScales(); | 1643 ResetTilingsAndRasterScales(); |
| 1651 | 1644 |
| 1652 host_impl_.SetUseGpuRasterization(true); | 1645 host_impl_.SetUseGpuRasterization(true); |
| 1653 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); | 1646 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); |
| 1654 SetupDrawPropertiesAndManageTilings( | 1647 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1655 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
| 1656 | 1648 |
| 1657 // Should only have the high-res tiling. | 1649 // Should only have the high-res tiling. |
| 1658 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 1650 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 1659 } | 1651 } |
| 1660 | 1652 |
| 1661 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { | 1653 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { |
| 1662 // Set up layers with tilings. | 1654 // Set up layers with tilings. |
| 1663 SetupDefaultTrees(gfx::Size(10, 10)); | 1655 SetupDefaultTrees(gfx::Size(10, 10)); |
| 1664 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); | 1656 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); |
| 1665 pending_layer_->PushPropertiesTo(active_layer_); | 1657 pending_layer_->PushPropertiesTo(active_layer_); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1747 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1739 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1748 | 1740 |
| 1749 SetupTrees(pending_pile, active_pile); | 1741 SetupTrees(pending_pile, active_pile); |
| 1750 } | 1742 } |
| 1751 }; | 1743 }; |
| 1752 | 1744 |
| 1753 // This test is really a LayerTreeHostImpl test, in that it makes sure | 1745 // This test is really a LayerTreeHostImpl test, in that it makes sure |
| 1754 // that trees need update draw properties after deferred initialization. | 1746 // that trees need update draw properties after deferred initialization. |
| 1755 // However, this is also a regression test for PictureLayerImpl in that | 1747 // However, this is also a regression test for PictureLayerImpl in that |
| 1756 // not having this update will cause a crash. | 1748 // not having this update will cause a crash. |
| 1757 TEST_F(DeferredInitPictureLayerImplTest, | 1749 TEST_F(DeferredInitPictureLayerImplTest, PreventUpdateTilesDuringLostContext) { |
| 1758 PreventUpdateTilePrioritiesDuringLostContext) { | |
| 1759 host_impl_.pending_tree()->UpdateDrawProperties(); | 1750 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 1760 host_impl_.active_tree()->UpdateDrawProperties(); | 1751 host_impl_.active_tree()->UpdateDrawProperties(); |
| 1761 EXPECT_FALSE(host_impl_.pending_tree()->needs_update_draw_properties()); | 1752 EXPECT_FALSE(host_impl_.pending_tree()->needs_update_draw_properties()); |
| 1762 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); | 1753 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); |
| 1763 | 1754 |
| 1764 FakeOutputSurface* fake_output_surface = | 1755 FakeOutputSurface* fake_output_surface = |
| 1765 static_cast<FakeOutputSurface*>(host_impl_.output_surface()); | 1756 static_cast<FakeOutputSurface*>(host_impl_.output_surface()); |
| 1766 ASSERT_TRUE(fake_output_surface->InitializeAndSetContext3d( | 1757 ASSERT_TRUE(fake_output_surface->InitializeAndSetContext3d( |
| 1767 TestContextProvider::Create())); | 1758 TestContextProvider::Create())); |
| 1768 | 1759 |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2269 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2279 scoped_refptr<FakePicturePileImpl> active_pile = | 2270 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2280 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2271 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2281 | 2272 |
| 2282 SetupTrees(pending_pile, active_pile); | 2273 SetupTrees(pending_pile, active_pile); |
| 2283 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 2274 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 2284 | 2275 |
| 2285 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 2276 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 2286 EXPECT_LT(low_res_factor, 1.f); | 2277 EXPECT_LT(low_res_factor, 1.f); |
| 2287 | 2278 |
| 2288 SetupDrawPropertiesAndManageTilings(pending_layer_, | 2279 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 2289 6.f, // ideal contents scale | 2280 6.f, // ideal contents scale |
| 2290 3.f, // device scale | 2281 3.f, // device scale |
| 2291 2.f, // page scale | 2282 2.f, // page scale |
| 2292 1.f, // maximum animation scale | 2283 1.f, // maximum animation scale |
| 2293 false); | 2284 false); |
| 2294 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 2285 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 2295 EXPECT_FLOAT_EQ(6.f, | 2286 EXPECT_FLOAT_EQ(6.f, |
| 2296 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 2287 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 2297 | 2288 |
| 2298 // If we change the page scale factor, then we should get new tilings. | 2289 // If we change the page scale factor, then we should get new tilings. |
| 2299 SetupDrawPropertiesAndManageTilings(pending_layer_, | 2290 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 2300 6.6f, // ideal contents scale | 2291 6.6f, // ideal contents scale |
| 2301 3.f, // device scale | 2292 3.f, // device scale |
| 2302 2.2f, // page scale | 2293 2.2f, // page scale |
| 2303 1.f, // maximum animation scale | 2294 1.f, // maximum animation scale |
| 2304 false); | 2295 false); |
| 2305 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 2296 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 2306 EXPECT_FLOAT_EQ(6.6f, | 2297 EXPECT_FLOAT_EQ(6.6f, |
| 2307 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 2298 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 2308 | 2299 |
| 2309 // If we change the device scale factor, then we should get new tilings. | 2300 // If we change the device scale factor, then we should get new tilings. |
| 2310 SetupDrawPropertiesAndManageTilings(pending_layer_, | 2301 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 2311 7.26f, // ideal contents scale | 2302 7.26f, // ideal contents scale |
| 2312 3.3f, // device scale | 2303 3.3f, // device scale |
| 2313 2.2f, // page scale | 2304 2.2f, // page scale |
| 2314 1.f, // maximum animation scale | 2305 1.f, // maximum animation scale |
| 2315 false); | 2306 false); |
| 2316 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); | 2307 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); |
| 2317 EXPECT_FLOAT_EQ(7.26f, | 2308 EXPECT_FLOAT_EQ(7.26f, |
| 2318 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 2309 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 2319 | 2310 |
| 2320 // If we change the device scale factor, but end up at the same total scale | 2311 // If we change the device scale factor, but end up at the same total scale |
| 2321 // factor somehow, then we don't get new tilings. | 2312 // factor somehow, then we don't get new tilings. |
| 2322 SetupDrawPropertiesAndManageTilings(pending_layer_, | 2313 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 2323 7.26f, // ideal contents scale | 2314 7.26f, // ideal contents scale |
| 2324 2.2f, // device scale | 2315 2.2f, // device scale |
| 2325 3.3f, // page scale | 2316 3.3f, // page scale |
| 2326 1.f, // maximum animation scale | 2317 1.f, // maximum animation scale |
| 2327 false); | 2318 false); |
| 2328 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); | 2319 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); |
| 2329 EXPECT_FLOAT_EQ(7.26f, | 2320 EXPECT_FLOAT_EQ(7.26f, |
| 2330 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 2321 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 2331 } | 2322 } |
| 2332 | 2323 |
| 2333 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredNullTiles) { | 2324 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredNullTiles) { |
| 2334 gfx::Size tile_size(100, 100); | 2325 gfx::Size tile_size(100, 100); |
| 2335 gfx::Size layer_bounds(1000, 1000); | 2326 gfx::Size layer_bounds(1000, 1000); |
| 2336 | 2327 |
| 2337 scoped_refptr<FakePicturePileImpl> pending_pile = | 2328 scoped_refptr<FakePicturePileImpl> pending_pile = |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2412 | 2403 |
| 2413 scoped_refptr<FakePicturePileImpl> pending_pile = | 2404 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2414 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2405 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2415 scoped_refptr<FakePicturePileImpl> active_pile = | 2406 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2416 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2407 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2417 | 2408 |
| 2418 SetupTrees(pending_pile, active_pile); | 2409 SetupTrees(pending_pile, active_pile); |
| 2419 | 2410 |
| 2420 Region invalidation; | 2411 Region invalidation; |
| 2421 AddDefaultTilingsWithInvalidation(invalidation); | 2412 AddDefaultTilingsWithInvalidation(invalidation); |
| 2422 SetupDrawPropertiesAndManageTilings(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 2413 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 2423 | 2414 |
| 2424 // UpdateTilePriorities with valid viewport. Should update tile viewport. | 2415 // UpdateTiles with valid viewport. Should update tile viewport. |
| 2425 bool valid_for_tile_management = true; | 2416 bool valid_for_tile_management = true; |
| 2426 gfx::Rect viewport = gfx::Rect(layer_bounds); | 2417 gfx::Rect viewport = gfx::Rect(layer_bounds); |
| 2427 gfx::Transform transform; | 2418 gfx::Transform transform; |
| 2428 host_impl_.SetExternalDrawConstraints( | 2419 host_impl_.SetExternalDrawConstraints( |
| 2429 transform, viewport, viewport, valid_for_tile_management); | 2420 transform, viewport, viewport, valid_for_tile_management); |
| 2430 active_layer_->draw_properties().visible_content_rect = viewport; | 2421 active_layer_->draw_properties().visible_content_rect = viewport; |
| 2431 active_layer_->draw_properties().screen_space_transform = transform; | 2422 active_layer_->draw_properties().screen_space_transform = transform; |
| 2432 active_layer_->UpdateTilePriorities(); | 2423 active_layer_->UpdateTiles(); |
| 2433 | 2424 |
| 2434 gfx::Rect visible_rect_for_tile_priority = | 2425 gfx::Rect visible_rect_for_tile_priority = |
| 2435 active_layer_->visible_rect_for_tile_priority(); | 2426 active_layer_->visible_rect_for_tile_priority(); |
| 2436 EXPECT_FALSE(visible_rect_for_tile_priority.IsEmpty()); | 2427 EXPECT_FALSE(visible_rect_for_tile_priority.IsEmpty()); |
| 2437 gfx::Size viewport_size_for_tile_priority = | 2428 gfx::Size viewport_size_for_tile_priority = |
| 2438 active_layer_->viewport_size_for_tile_priority(); | 2429 active_layer_->viewport_size_for_tile_priority(); |
| 2439 EXPECT_FALSE(viewport_size_for_tile_priority.IsEmpty()); | 2430 EXPECT_FALSE(viewport_size_for_tile_priority.IsEmpty()); |
| 2440 gfx::Transform screen_space_transform_for_tile_priority = | 2431 gfx::Transform screen_space_transform_for_tile_priority = |
| 2441 active_layer_->screen_space_transform_for_tile_priority(); | 2432 active_layer_->screen_space_transform_for_tile_priority(); |
| 2442 | 2433 |
| 2443 // Expand viewport and set it as invalid for prioritizing tiles. | 2434 // Expand viewport and set it as invalid for prioritizing tiles. |
| 2444 // Should not update tile viewport. | 2435 // Should not update tile viewport. |
| 2445 time_ticks += base::TimeDelta::FromMilliseconds(200); | 2436 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 2446 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 2437 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
| 2447 valid_for_tile_management = false; | 2438 valid_for_tile_management = false; |
| 2448 viewport = gfx::ScaleToEnclosingRect(viewport, 2); | 2439 viewport = gfx::ScaleToEnclosingRect(viewport, 2); |
| 2449 transform.Translate(1.f, 1.f); | 2440 transform.Translate(1.f, 1.f); |
| 2450 active_layer_->draw_properties().visible_content_rect = viewport; | 2441 active_layer_->draw_properties().visible_content_rect = viewport; |
| 2451 active_layer_->draw_properties().screen_space_transform = transform; | 2442 active_layer_->draw_properties().screen_space_transform = transform; |
| 2452 host_impl_.SetExternalDrawConstraints( | 2443 host_impl_.SetExternalDrawConstraints( |
| 2453 transform, viewport, viewport, valid_for_tile_management); | 2444 transform, viewport, viewport, valid_for_tile_management); |
| 2454 active_layer_->UpdateTilePriorities(); | 2445 active_layer_->UpdateTiles(); |
| 2455 | 2446 |
| 2456 EXPECT_RECT_EQ(visible_rect_for_tile_priority, | 2447 EXPECT_RECT_EQ(visible_rect_for_tile_priority, |
| 2457 active_layer_->visible_rect_for_tile_priority()); | 2448 active_layer_->visible_rect_for_tile_priority()); |
| 2458 EXPECT_SIZE_EQ(viewport_size_for_tile_priority, | 2449 EXPECT_SIZE_EQ(viewport_size_for_tile_priority, |
| 2459 active_layer_->viewport_size_for_tile_priority()); | 2450 active_layer_->viewport_size_for_tile_priority()); |
| 2460 EXPECT_TRANSFORMATION_MATRIX_EQ( | 2451 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 2461 screen_space_transform_for_tile_priority, | 2452 screen_space_transform_for_tile_priority, |
| 2462 active_layer_->screen_space_transform_for_tile_priority()); | 2453 active_layer_->screen_space_transform_for_tile_priority()); |
| 2463 | 2454 |
| 2464 // Keep expanded viewport but mark it valid. Should update tile viewport. | 2455 // Keep expanded viewport but mark it valid. Should update tile viewport. |
| 2465 time_ticks += base::TimeDelta::FromMilliseconds(200); | 2456 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 2466 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 2457 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
| 2467 valid_for_tile_management = true; | 2458 valid_for_tile_management = true; |
| 2468 host_impl_.SetExternalDrawConstraints( | 2459 host_impl_.SetExternalDrawConstraints( |
| 2469 transform, viewport, viewport, valid_for_tile_management); | 2460 transform, viewport, viewport, valid_for_tile_management); |
| 2470 active_layer_->UpdateTilePriorities(); | 2461 active_layer_->UpdateTiles(); |
| 2471 | 2462 |
| 2472 EXPECT_FALSE(visible_rect_for_tile_priority == | 2463 EXPECT_FALSE(visible_rect_for_tile_priority == |
| 2473 active_layer_->visible_rect_for_tile_priority()); | 2464 active_layer_->visible_rect_for_tile_priority()); |
| 2474 EXPECT_FALSE(viewport_size_for_tile_priority == | 2465 EXPECT_FALSE(viewport_size_for_tile_priority == |
| 2475 active_layer_->viewport_size_for_tile_priority()); | 2466 active_layer_->viewport_size_for_tile_priority()); |
| 2476 EXPECT_FALSE(screen_space_transform_for_tile_priority == | 2467 EXPECT_FALSE(screen_space_transform_for_tile_priority == |
| 2477 active_layer_->screen_space_transform_for_tile_priority()); | 2468 active_layer_->screen_space_transform_for_tile_priority()); |
| 2478 } | 2469 } |
| 2479 | 2470 |
| 2480 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportAfterReleaseResources) { | 2471 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportAfterReleaseResources) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2497 bool valid_for_tile_management = false; | 2488 bool valid_for_tile_management = false; |
| 2498 gfx::Rect viewport = gfx::Rect(layer_bounds); | 2489 gfx::Rect viewport = gfx::Rect(layer_bounds); |
| 2499 host_impl_.SetExternalDrawConstraints( | 2490 host_impl_.SetExternalDrawConstraints( |
| 2500 gfx::Transform(), viewport, viewport, valid_for_tile_management); | 2491 gfx::Transform(), viewport, viewport, valid_for_tile_management); |
| 2501 ResetTilingsAndRasterScales(); | 2492 ResetTilingsAndRasterScales(); |
| 2502 host_impl_.pending_tree()->UpdateDrawProperties(); | 2493 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 2503 host_impl_.active_tree()->UpdateDrawProperties(); | 2494 host_impl_.active_tree()->UpdateDrawProperties(); |
| 2504 EXPECT_TRUE(active_layer_->HighResTiling()); | 2495 EXPECT_TRUE(active_layer_->HighResTiling()); |
| 2505 | 2496 |
| 2506 size_t num_tilings = active_layer_->num_tilings(); | 2497 size_t num_tilings = active_layer_->num_tilings(); |
| 2507 active_layer_->UpdateTilePriorities(); | 2498 active_layer_->UpdateTiles(); |
| 2508 pending_layer_->AddTiling(0.5f); | 2499 pending_layer_->AddTiling(0.5f); |
| 2509 EXPECT_EQ(num_tilings + 1, active_layer_->num_tilings()); | 2500 EXPECT_EQ(num_tilings + 1, active_layer_->num_tilings()); |
| 2510 } | 2501 } |
| 2511 | 2502 |
| 2512 TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { | 2503 TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { |
| 2513 gfx::Size tile_size(400, 400); | 2504 gfx::Size tile_size(400, 400); |
| 2514 gfx::Size layer_bounds(1300, 1900); | 2505 gfx::Size layer_bounds(1300, 1900); |
| 2515 | 2506 |
| 2516 scoped_refptr<FakePicturePileImpl> pending_pile = | 2507 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2517 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2508 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2579 // Now move the ideal scale to 1.0. Our target stays 1.2. | 2570 // Now move the ideal scale to 1.0. Our target stays 1.2. |
| 2580 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); | 2571 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); |
| 2581 | 2572 |
| 2582 // All the tilings are between are target and the ideal, so they are not | 2573 // All the tilings are between are target and the ideal, so they are not |
| 2583 // removed. | 2574 // removed. |
| 2584 used_tilings.clear(); | 2575 used_tilings.clear(); |
| 2585 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 2576 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 2586 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 2577 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 2587 | 2578 |
| 2588 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. | 2579 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
| 2589 SetupDrawPropertiesAndManageTilings( | 2580 SetupDrawPropertiesAndUpdateTiles( |
| 2590 active_layer_, 1.1f, device_scale, page_scale, 1.f, false); | 2581 active_layer_, 1.1f, device_scale, page_scale, 1.f, false); |
| 2591 | 2582 |
| 2592 // Because the pending layer's ideal scale is still 1.0, our tilings fall | 2583 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
| 2593 // in the range [1.0,1.2] and are kept. | 2584 // in the range [1.0,1.2] and are kept. |
| 2594 used_tilings.clear(); | 2585 used_tilings.clear(); |
| 2595 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 2586 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 2596 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 2587 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 2597 | 2588 |
| 2598 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays | 2589 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
| 2599 // 1.2 still. | 2590 // 1.2 still. |
| 2600 SetupDrawPropertiesAndManageTilings( | 2591 SetupDrawPropertiesAndUpdateTiles( |
| 2601 pending_layer_, 1.1f, device_scale, page_scale, 1.f, false); | 2592 pending_layer_, 1.1f, device_scale, page_scale, 1.f, false); |
| 2602 | 2593 |
| 2603 // Our 1.0 tiling now falls outside the range between our ideal scale and our | 2594 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
| 2604 // target raster scale. But it is in our used tilings set, so nothing is | 2595 // target raster scale. But it is in our used tilings set, so nothing is |
| 2605 // deleted. | 2596 // deleted. |
| 2606 used_tilings.clear(); | 2597 used_tilings.clear(); |
| 2607 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 2598 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
| 2608 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 2599 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 2609 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 2600 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 2610 | 2601 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2632 float active_contents_scale = 2.f; | 2623 float active_contents_scale = 2.f; |
| 2633 float device_scale_factor = 1.f; | 2624 float device_scale_factor = 1.f; |
| 2634 float page_scale_factor = 1.f; | 2625 float page_scale_factor = 1.f; |
| 2635 float maximum_animation_contents_scale = 1.f; | 2626 float maximum_animation_contents_scale = 1.f; |
| 2636 bool animating_transform = false; | 2627 bool animating_transform = false; |
| 2637 | 2628 |
| 2638 EXPECT_TRUE(host_impl_.settings().create_low_res_tiling); | 2629 EXPECT_TRUE(host_impl_.settings().create_low_res_tiling); |
| 2639 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 2630 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 2640 EXPECT_LT(low_res_factor, 1.f); | 2631 EXPECT_LT(low_res_factor, 1.f); |
| 2641 | 2632 |
| 2642 SetupDrawPropertiesAndManageTilings(pending_layer_, | 2633 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 2643 pending_contents_scale, | 2634 pending_contents_scale, |
| 2644 device_scale_factor, | 2635 device_scale_factor, |
| 2645 page_scale_factor, | 2636 page_scale_factor, |
| 2646 maximum_animation_contents_scale, | 2637 maximum_animation_contents_scale, |
| 2647 animating_transform); | 2638 animating_transform); |
| 2648 SetupDrawPropertiesAndManageTilings(active_layer_, | 2639 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 2649 active_contents_scale, | 2640 active_contents_scale, |
| 2650 device_scale_factor, | 2641 device_scale_factor, |
| 2651 page_scale_factor, | 2642 page_scale_factor, |
| 2652 maximum_animation_contents_scale, | 2643 maximum_animation_contents_scale, |
| 2653 animating_transform); | 2644 animating_transform); |
| 2654 | 2645 |
| 2655 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); | 2646 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); |
| 2656 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | 2647 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
| 2657 | 2648 |
| 2658 EXPECT_EQ(active_contents_scale, | 2649 EXPECT_EQ(active_contents_scale, |
| 2659 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 2650 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 2660 EXPECT_EQ(pending_contents_scale, | 2651 EXPECT_EQ(pending_contents_scale, |
| 2661 pending_layer_->tilings()->tiling_at(1)->contents_scale()); | 2652 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
| 2662 EXPECT_EQ(active_contents_scale * low_res_factor, | 2653 EXPECT_EQ(active_contents_scale * low_res_factor, |
| 2663 pending_layer_->tilings()->tiling_at(2)->contents_scale()); | 2654 pending_layer_->tilings()->tiling_at(2)->contents_scale()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2694 gfx::Size layer_bounds(1300, 1900); | 2685 gfx::Size layer_bounds(1300, 1900); |
| 2695 | 2686 |
| 2696 scoped_refptr<FakePicturePileImpl> pending_pile = | 2687 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2697 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2688 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2698 scoped_refptr<FakePicturePileImpl> active_pile = | 2689 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2699 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2690 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2700 | 2691 |
| 2701 SetupTrees(pending_pile, active_pile); | 2692 SetupTrees(pending_pile, active_pile); |
| 2702 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 2693 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 2703 | 2694 |
| 2704 SetupDrawPropertiesAndManageTilings(pending_layer_, | 2695 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 2705 1.3f, // ideal contents scale | 2696 1.3f, // ideal contents scale |
| 2706 2.7f, // device scale | 2697 2.7f, // device scale |
| 2707 3.2f, // page scale | 2698 3.2f, // page scale |
| 2708 1.f, // maximum animation scale | 2699 1.f, // maximum animation scale |
| 2709 false); | 2700 false); |
| 2710 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 2701 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 2711 | 2702 |
| 2712 // All tilings should be removed when losing output surface. | 2703 // All tilings should be removed when losing output surface. |
| 2713 active_layer_->ReleaseResources(); | 2704 active_layer_->ReleaseResources(); |
| 2714 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 2705 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 2715 pending_layer_->ReleaseResources(); | 2706 pending_layer_->ReleaseResources(); |
| 2716 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 2707 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 2717 | 2708 |
| 2718 // This should create new tilings. | 2709 // This should create new tilings. |
| 2719 SetupDrawPropertiesAndManageTilings(pending_layer_, | 2710 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 2720 1.3f, // ideal contents scale | 2711 1.3f, // ideal contents scale |
| 2721 2.7f, // device scale | 2712 2.7f, // device scale |
| 2722 3.2f, // page scale | 2713 3.2f, // page scale |
| 2723 1.f, // maximum animation scale | 2714 1.f, // maximum animation scale |
| 2724 false); | 2715 false); |
| 2725 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 2716 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 2726 } | 2717 } |
| 2727 | 2718 |
| 2728 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { | 2719 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { |
| 2729 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 2720 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
| 2730 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 2721 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 2731 MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); | 2722 MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker); |
| 2732 | 2723 |
| 2733 gfx::Size tile_size(400, 400); | 2724 gfx::Size tile_size(400, 400); |
| 2734 gfx::Size layer_bounds(1000, 2000); | 2725 gfx::Size layer_bounds(1000, 2000); |
| 2735 | 2726 |
| 2736 scoped_refptr<FakePicturePileImpl> pending_pile = | 2727 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2737 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2728 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2738 scoped_refptr<FakePicturePileImpl> active_pile = | 2729 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2739 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2730 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2740 | 2731 |
| 2741 SetupTrees(pending_pile, active_pile); | 2732 SetupTrees(pending_pile, active_pile); |
| 2742 | 2733 |
| 2743 SetupDrawPropertiesAndManageTilings( | 2734 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 2.5f, 1.f, 1.f, 1.f, false); |
| 2744 pending_layer_, 2.5f, 1.f, 1.f, 1.f, false); | |
| 2745 host_impl_.pending_tree()->UpdateDrawProperties(); | 2735 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 2746 | 2736 |
| 2747 active_layer_->draw_properties().visible_content_rect = | 2737 active_layer_->draw_properties().visible_content_rect = |
| 2748 gfx::Rect(layer_bounds); | 2738 gfx::Rect(layer_bounds); |
| 2749 host_impl_.active_tree()->UpdateDrawProperties(); | 2739 host_impl_.active_tree()->UpdateDrawProperties(); |
| 2750 | 2740 |
| 2751 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); | 2741 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); |
| 2752 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); | 2742 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); |
| 2753 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, | 2743 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, |
| 2754 SK_MScalar1 / max_contents_scale); | 2744 SK_MScalar1 / max_contents_scale); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2814 | 2804 |
| 2815 host_impl_.pending_tree()->SetRootLayer(root.Pass()); | 2805 host_impl_.pending_tree()->SetRootLayer(root.Pass()); |
| 2816 | 2806 |
| 2817 EXPECT_FALSE(pending_mask_content->tilings()); | 2807 EXPECT_FALSE(pending_mask_content->tilings()); |
| 2818 host_impl_.pending_tree()->UpdateDrawProperties(); | 2808 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 2819 EXPECT_NE(0u, pending_mask_content->num_tilings()); | 2809 EXPECT_NE(0u, pending_mask_content->num_tilings()); |
| 2820 } | 2810 } |
| 2821 | 2811 |
| 2822 } // namespace | 2812 } // namespace |
| 2823 } // namespace cc | 2813 } // namespace cc |
| OLD | NEW |