Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "cc/layers/append_quads_data.h" | 12 #include "cc/layers/append_quads_data.h" |
| 13 #include "cc/layers/picture_layer.h" | 13 #include "cc/layers/picture_layer.h" |
| 14 #include "cc/test/fake_content_layer_client.h" | 14 #include "cc/test/fake_content_layer_client.h" |
| 15 #include "cc/test/fake_impl_proxy.h" | 15 #include "cc/test/fake_impl_proxy.h" |
| 16 #include "cc/test/fake_layer_tree_host_impl.h" | 16 #include "cc/test/fake_layer_tree_host_impl.h" |
| 17 #include "cc/test/fake_output_surface.h" | 17 #include "cc/test/fake_output_surface.h" |
| 18 #include "cc/test/fake_picture_layer_impl.h" | 18 #include "cc/test/fake_picture_layer_impl.h" |
| 19 #include "cc/test/fake_picture_pile_impl.h" | 19 #include "cc/test/fake_picture_pile_impl.h" |
| 20 #include "cc/test/geometry_test_utils.h" | 20 #include "cc/test/geometry_test_utils.h" |
| 21 #include "cc/test/impl_side_painting_settings.h" | 21 #include "cc/test/impl_side_painting_settings.h" |
| 22 #include "cc/test/layer_test_common.h" | 22 #include "cc/test/layer_test_common.h" |
| 23 #include "cc/test/mock_quad_culler.h" | 23 #include "cc/test/mock_quad_culler.h" |
| 24 #include "cc/test/test_shared_bitmap_manager.h" | 24 #include "cc/test/test_shared_bitmap_manager.h" |
| 25 #include "cc/test/test_web_graphics_context_3d.h" | 25 #include "cc/test/test_web_graphics_context_3d.h" |
| 26 #include "cc/trees/layer_tree_impl.h" | 26 #include "cc/trees/layer_tree_impl.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 28 #include "ui/gfx/rect_conversions.h" | 28 #include "ui/gfx/rect_conversions.h" |
| 29 #include "ui/gfx/size_conversions.h" | |
| 29 | 30 |
| 30 namespace cc { | 31 namespace cc { |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 class MockCanvas : public SkCanvas { | 34 class MockCanvas : public SkCanvas { |
| 34 public: | 35 public: |
| 35 explicit MockCanvas(int w, int h) : SkCanvas(w, h) {} | 36 explicit MockCanvas(int w, int h) : SkCanvas(w, h) {} |
| 36 | 37 |
| 37 virtual void drawRect(const SkRect& rect, const SkPaint& paint) OVERRIDE { | 38 virtual void drawRect(const SkRect& rect, const SkPaint& paint) OVERRIDE { |
| 38 // Capture calls before SkCanvas quickReject() kicks in. | 39 // Capture calls before SkCanvas quickReject() kicks in. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); | 134 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); |
| 134 pending_layer->SetDrawsContent(true); | 135 pending_layer->SetDrawsContent(true); |
| 135 pending_layer->SetAnchorPoint(gfx::PointF()); | 136 pending_layer->SetAnchorPoint(gfx::PointF()); |
| 136 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); | 137 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); |
| 137 | 138 |
| 138 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 139 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
| 139 host_impl_.pending_tree()->LayerById(id_)); | 140 host_impl_.pending_tree()->LayerById(id_)); |
| 140 pending_layer_->DoPostCommitInitializationIfNeeded(); | 141 pending_layer_->DoPostCommitInitializationIfNeeded(); |
| 141 } | 142 } |
| 142 | 143 |
| 144 void SetupDrawPropertiesAndUpdateTilePriorities( | |
| 145 FakePictureLayerImpl* layer, | |
| 146 float ideal_contents_scale, | |
| 147 float device_scale_factor, | |
| 148 float page_scale_factor, | |
| 149 float maximum_animation_contents_scale, | |
| 150 bool animating_transform_to_screen) { | |
| 151 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; | |
| 152 layer->draw_properties().device_scale_factor = device_scale_factor; | |
| 153 layer->draw_properties().page_scale_factor = page_scale_factor; | |
| 154 layer->draw_properties().maximum_animation_contents_scale = | |
| 155 maximum_animation_contents_scale; | |
| 156 layer->draw_properties().screen_space_transform_is_animating = | |
| 157 animating_transform_to_screen; | |
| 158 layer->UpdateTilePriorities(); | |
| 159 } | |
| 143 static void VerifyAllTilesExistAndHavePile( | 160 static void VerifyAllTilesExistAndHavePile( |
| 144 const PictureLayerTiling* tiling, | 161 const PictureLayerTiling* tiling, |
| 145 PicturePileImpl* pile) { | 162 PicturePileImpl* pile) { |
| 146 for (PictureLayerTiling::CoverageIterator iter( | 163 for (PictureLayerTiling::CoverageIterator iter( |
| 147 tiling, tiling->contents_scale(), tiling->TilingRect()); | 164 tiling, tiling->contents_scale(), tiling->TilingRect()); |
| 148 iter; | 165 iter; |
| 149 ++iter) { | 166 ++iter) { |
| 150 EXPECT_TRUE(*iter); | 167 EXPECT_TRUE(*iter); |
| 151 EXPECT_EQ(pile, iter->picture_pile()); | 168 EXPECT_EQ(pile, iter->picture_pile()); |
| 152 } | 169 } |
| 153 } | 170 } |
| 154 | 171 |
| 155 void SetContentsScaleOnBothLayers(float contents_scale, | 172 void SetContentsScaleOnBothLayers(float contents_scale, |
| 156 float device_scale_factor, | 173 float device_scale_factor, |
| 157 float page_scale_factor, | 174 float page_scale_factor, |
| 158 float maximum_animation_contents_scale, | 175 float maximum_animation_contents_scale, |
| 159 bool animating_transform) { | 176 bool animating_transform) { |
| 160 float result_scale_x, result_scale_y; | 177 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 161 gfx::Size result_bounds; | 178 contents_scale, |
| 162 pending_layer_->CalculateContentsScale(contents_scale, | 179 device_scale_factor, |
| 163 device_scale_factor, | 180 page_scale_factor, |
| 164 page_scale_factor, | 181 maximum_animation_contents_scale, |
| 165 maximum_animation_contents_scale, | 182 animating_transform); |
| 166 animating_transform, | 183 |
| 167 &result_scale_x, | 184 SetupDrawPropertiesAndUpdateTilePriorities(active_layer_, |
| 168 &result_scale_y, | 185 contents_scale, |
| 169 &result_bounds); | 186 device_scale_factor, |
| 170 active_layer_->CalculateContentsScale(contents_scale, | 187 page_scale_factor, |
| 171 device_scale_factor, | 188 maximum_animation_contents_scale, |
| 172 page_scale_factor, | 189 animating_transform); |
| 173 maximum_animation_contents_scale, | |
| 174 animating_transform, | |
| 175 &result_scale_x, | |
| 176 &result_scale_y, | |
| 177 &result_bounds); | |
| 178 } | 190 } |
| 179 | 191 |
| 180 void ResetTilingsAndRasterScales() { | 192 void ResetTilingsAndRasterScales() { |
| 181 pending_layer_->ReleaseResources(); | 193 pending_layer_->ReleaseResources(); |
| 182 active_layer_->ReleaseResources(); | 194 active_layer_->ReleaseResources(); |
| 183 } | 195 } |
| 184 | 196 |
| 185 void AssertAllTilesRequired(PictureLayerTiling* tiling) { | 197 void AssertAllTilesRequired(PictureLayerTiling* tiling) { |
| 186 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 198 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 187 for (size_t i = 0; i < tiles.size(); ++i) | 199 for (size_t i = 0; i < tiles.size(); ++i) |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 204 settings.default_tile_size.width() * 7 / 2, | 216 settings.default_tile_size.width() * 7 / 2, |
| 205 settings.default_tile_size.height() * 7 / 2); | 217 settings.default_tile_size.height() * 7 / 2); |
| 206 | 218 |
| 207 scoped_refptr<FakePicturePileImpl> pending_pile = | 219 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 208 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); | 220 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
| 209 scoped_refptr<FakePicturePileImpl> active_pile = | 221 scoped_refptr<FakePicturePileImpl> active_pile = |
| 210 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); | 222 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
| 211 | 223 |
| 212 SetupTrees(pending_pile, active_pile); | 224 SetupTrees(pending_pile, active_pile); |
| 213 | 225 |
| 214 float result_scale_x, result_scale_y; | 226 SetupDrawPropertiesAndUpdateTilePriorities( |
| 215 gfx::Size result_bounds; | 227 active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 216 active_layer_->CalculateContentsScale(1.f, | |
| 217 1.f, | |
| 218 1.f, | |
| 219 1.f, | |
| 220 false, | |
| 221 &result_scale_x, | |
| 222 &result_scale_y, | |
| 223 &result_bounds); | |
| 224 | 228 |
| 225 // Add 1x1 rects at the centers of each tile, then re-record pile contents | 229 // Add 1x1 rects at the centers of each tile, then re-record pile contents |
| 226 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 230 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 227 std::vector<Tile*> tiles = | 231 std::vector<Tile*> tiles = |
| 228 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 232 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
| 229 EXPECT_EQ(16u, tiles.size()); | 233 EXPECT_EQ(16u, tiles.size()); |
| 230 std::vector<SkRect> rects; | 234 std::vector<SkRect> rects; |
| 231 std::vector<Tile*>::const_iterator tile_iter; | 235 std::vector<Tile*>::const_iterator tile_iter; |
| 232 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { | 236 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { |
| 233 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); | 237 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 scoped_refptr<FakePicturePileImpl> active_pile = | 312 scoped_refptr<FakePicturePileImpl> active_pile = |
| 309 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 313 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 310 | 314 |
| 311 SetupTrees(pending_pile, active_pile); | 315 SetupTrees(pending_pile, active_pile); |
| 312 | 316 |
| 313 std::vector<TileManager::PairedPictureLayer> paired_layers; | 317 std::vector<TileManager::PairedPictureLayer> paired_layers; |
| 314 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | 318 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); |
| 315 EXPECT_EQ(0u, paired_layers.size()); | 319 EXPECT_EQ(0u, paired_layers.size()); |
| 316 | 320 |
| 317 // Update tile priorities will force the layer to register itself. | 321 // Update tile priorities will force the layer to register itself. |
| 318 float dummy_contents_scale_x; | 322 SetupDrawPropertiesAndUpdateTilePriorities( |
| 319 float dummy_contents_scale_y; | 323 active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 320 gfx::Size dummy_content_bounds; | 324 SetupDrawPropertiesAndUpdateTilePriorities( |
| 321 active_layer_->CalculateContentsScale(1.f, | 325 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 322 1.f, | |
| 323 1.f, | |
| 324 1.f, | |
| 325 false, | |
| 326 &dummy_contents_scale_x, | |
| 327 &dummy_contents_scale_y, | |
| 328 &dummy_content_bounds); | |
| 329 active_layer_->UpdateTilePriorities(); | |
| 330 host_impl_.pending_tree()->UpdateDrawProperties(); | |
| 331 pending_layer_->CalculateContentsScale(1.f, | |
| 332 1.f, | |
| 333 1.f, | |
| 334 1.f, | |
| 335 false, | |
| 336 &dummy_contents_scale_x, | |
| 337 &dummy_contents_scale_y, | |
| 338 &dummy_content_bounds); | |
| 339 pending_layer_->UpdateTilePriorities(); | |
| 340 | 326 |
| 341 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | 327 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); |
| 342 EXPECT_EQ(1u, paired_layers.size()); | 328 EXPECT_EQ(1u, paired_layers.size()); |
| 343 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); | 329 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); |
| 344 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); | 330 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); |
| 345 | 331 |
| 346 // Destroy and recreate tile manager. | 332 // Destroy and recreate tile manager. |
| 347 host_impl_.DidLoseOutputSurface(); | 333 host_impl_.DidLoseOutputSurface(); |
| 348 scoped_ptr<TestWebGraphicsContext3D> context = | 334 scoped_ptr<TestWebGraphicsContext3D> context = |
| 349 TestWebGraphicsContext3D::Create(); | 335 TestWebGraphicsContext3D::Create(); |
| 350 host_impl_.InitializeRenderer( | 336 host_impl_.InitializeRenderer( |
| 351 FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>()); | 337 FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>()); |
| 352 | 338 |
| 353 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | 339 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); |
| 354 EXPECT_EQ(0u, paired_layers.size()); | 340 EXPECT_EQ(0u, paired_layers.size()); |
| 355 | 341 |
| 356 active_layer_->CalculateContentsScale(1.f, | 342 SetupDrawPropertiesAndUpdateTilePriorities( |
| 357 1.f, | 343 active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 358 1.f, | 344 |
| 359 1.f, | 345 SetupDrawPropertiesAndUpdateTilePriorities( |
| 360 false, | 346 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 361 &dummy_contents_scale_x, | |
| 362 &dummy_contents_scale_y, | |
| 363 &dummy_content_bounds); | |
| 364 active_layer_->UpdateTilePriorities(); | |
| 365 host_impl_.pending_tree()->UpdateDrawProperties(); | |
| 366 pending_layer_->CalculateContentsScale(1.f, | |
| 367 1.f, | |
| 368 1.f, | |
| 369 1.f, | |
| 370 false, | |
| 371 &dummy_contents_scale_x, | |
| 372 &dummy_contents_scale_y, | |
| 373 &dummy_content_bounds); | |
| 374 pending_layer_->UpdateTilePriorities(); | |
| 375 | 347 |
| 376 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | 348 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); |
| 377 EXPECT_EQ(1u, paired_layers.size()); | 349 EXPECT_EQ(1u, paired_layers.size()); |
| 378 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); | 350 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); |
| 379 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); | 351 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); |
| 380 } | 352 } |
| 381 | 353 |
| 382 TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { | 354 TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
| 383 base::TimeTicks time_ticks; | 355 base::TimeTicks time_ticks; |
| 384 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 356 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
| 385 | 357 |
| 386 gfx::Size tile_size(100, 100); | 358 gfx::Size tile_size(100, 100); |
| 387 gfx::Size layer_bounds(400, 400); | 359 gfx::Size layer_bounds(400, 400); |
| 388 | 360 |
| 389 scoped_refptr<FakePicturePileImpl> pending_pile = | 361 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 390 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 362 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 391 scoped_refptr<FakePicturePileImpl> active_pile = | 363 scoped_refptr<FakePicturePileImpl> active_pile = |
| 392 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 364 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 393 | 365 |
| 394 SetupTrees(pending_pile, active_pile); | 366 SetupTrees(pending_pile, active_pile); |
| 395 | 367 |
| 396 Region invalidation; | 368 Region invalidation; |
| 397 AddDefaultTilingsWithInvalidation(invalidation); | 369 AddDefaultTilingsWithInvalidation(invalidation); |
| 398 float dummy_contents_scale_x; | 370 SetupDrawPropertiesAndUpdateTilePriorities( |
| 399 float dummy_contents_scale_y; | 371 active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 400 gfx::Size dummy_content_bounds; | |
| 401 active_layer_->CalculateContentsScale(1.f, | |
| 402 1.f, | |
| 403 1.f, | |
| 404 1.f, | |
| 405 false, | |
| 406 &dummy_contents_scale_x, | |
| 407 &dummy_contents_scale_y, | |
| 408 &dummy_content_bounds); | |
| 409 | 372 |
| 410 // UpdateTilePriorities with valid viewport. Should update tile viewport. | 373 // UpdateTilePriorities with valid viewport. Should update tile viewport. |
| 411 bool valid_for_tile_management = true; | 374 bool valid_for_tile_management = true; |
| 412 gfx::Rect viewport = gfx::Rect(layer_bounds); | 375 gfx::Rect viewport = gfx::Rect(layer_bounds); |
| 413 gfx::Transform transform; | 376 gfx::Transform transform; |
| 414 host_impl_.SetExternalDrawConstraints( | 377 host_impl_.SetExternalDrawConstraints( |
| 415 transform, viewport, viewport, valid_for_tile_management); | 378 transform, viewport, viewport, valid_for_tile_management); |
| 416 active_layer_->draw_properties().visible_content_rect = viewport; | 379 active_layer_->draw_properties().visible_content_rect = viewport; |
| 417 active_layer_->draw_properties().screen_space_transform = transform; | 380 active_layer_->draw_properties().screen_space_transform = transform; |
| 418 active_layer_->UpdateTilePriorities(); | 381 active_layer_->UpdateTilePriorities(); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 | 618 |
| 656 TEST_F(PictureLayerImplTest, ManageTilingsWithNoRecording) { | 619 TEST_F(PictureLayerImplTest, ManageTilingsWithNoRecording) { |
| 657 gfx::Size tile_size(400, 400); | 620 gfx::Size tile_size(400, 400); |
| 658 gfx::Size layer_bounds(1300, 1900); | 621 gfx::Size layer_bounds(1300, 1900); |
| 659 | 622 |
| 660 scoped_refptr<FakePicturePileImpl> pending_pile = | 623 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 661 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 624 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| 662 scoped_refptr<FakePicturePileImpl> active_pile = | 625 scoped_refptr<FakePicturePileImpl> active_pile = |
| 663 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 626 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| 664 | 627 |
| 665 float result_scale_x, result_scale_y; | |
| 666 gfx::Size result_bounds; | |
| 667 | |
| 668 SetupTrees(pending_pile, active_pile); | 628 SetupTrees(pending_pile, active_pile); |
| 669 | 629 |
| 670 pending_layer_->CalculateContentsScale(1.f, | 630 SetupDrawPropertiesAndUpdateTilePriorities( |
| 671 1.f, | 631 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 672 1.f, | |
| 673 1.f, | |
| 674 false, | |
| 675 &result_scale_x, | |
| 676 &result_scale_y, | |
| 677 &result_bounds); | |
| 678 | 632 |
| 679 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 633 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 680 } | 634 } |
| 681 | 635 |
| 682 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { | 636 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
| 683 gfx::Size tile_size(400, 400); | 637 gfx::Size tile_size(400, 400); |
| 684 gfx::Size layer_bounds(1300, 1900); | 638 gfx::Size layer_bounds(1300, 1900); |
| 685 | 639 |
| 686 scoped_refptr<FakePicturePileImpl> pending_pile = | 640 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 687 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 641 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 688 scoped_refptr<FakePicturePileImpl> active_pile = | 642 scoped_refptr<FakePicturePileImpl> active_pile = |
| 689 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 643 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 690 | 644 |
| 691 float result_scale_x, result_scale_y; | |
| 692 gfx::Size result_bounds; | |
| 693 | |
| 694 SetupTrees(pending_pile, active_pile); | 645 SetupTrees(pending_pile, active_pile); |
| 695 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 646 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 696 | 647 |
| 697 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 648 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 698 EXPECT_LT(low_res_factor, 1.f); | 649 EXPECT_LT(low_res_factor, 1.f); |
| 699 | 650 |
| 700 pending_layer_->CalculateContentsScale(6.f, // ideal contents scale | 651 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 701 3.f, // device scale | 652 6.f, // ideal contents scale |
| 702 2.f, // page scale | 653 3.f, // device scale |
| 703 1.f, // maximum animation scale | 654 2.f, // page scale |
| 704 false, | 655 1.f, // maximum animation scale |
| 705 &result_scale_x, | 656 false); |
| 706 &result_scale_y, | |
| 707 &result_bounds); | |
| 708 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 657 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 709 EXPECT_FLOAT_EQ(6.f, | 658 EXPECT_FLOAT_EQ(6.f, |
| 710 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 659 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 711 EXPECT_FLOAT_EQ(6.f * low_res_factor, | 660 EXPECT_FLOAT_EQ(6.f * low_res_factor, |
| 712 pending_layer_->tilings()->tiling_at(1)->contents_scale()); | 661 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
| 713 | 662 |
| 714 // If we change the page scale factor, then we should get new tilings. | 663 // If we change the page scale factor, then we should get new tilings. |
| 715 pending_layer_->CalculateContentsScale(6.6f, // ideal contents scale | 664 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 716 3.f, // device scale | 665 6.6f, // ideal contents scale |
| 717 2.2f, // page scale | 666 3.f, // device scale |
| 718 1.f, // maximum animation scale | 667 2.2f, // page scale |
| 719 false, | 668 1.f, // maximum animation scale |
| 720 &result_scale_x, | 669 false); |
| 721 &result_scale_y, | |
| 722 &result_bounds); | |
| 723 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); | 670 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); |
| 724 EXPECT_FLOAT_EQ(6.6f, | 671 EXPECT_FLOAT_EQ(6.6f, |
| 725 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 672 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 726 EXPECT_FLOAT_EQ(6.6f * low_res_factor, | 673 EXPECT_FLOAT_EQ(6.6f * low_res_factor, |
| 727 pending_layer_->tilings()->tiling_at(2)->contents_scale()); | 674 pending_layer_->tilings()->tiling_at(2)->contents_scale()); |
| 728 | 675 |
| 729 // If we change the device scale factor, then we should get new tilings. | 676 // If we change the device scale factor, then we should get new tilings. |
| 730 pending_layer_->CalculateContentsScale(7.26f, // ideal contents scale | 677 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 731 3.3f, // device scale | 678 7.26f, // ideal contents scale |
| 732 2.2f, // page scale | 679 3.3f, // device scale |
| 733 1.f, // maximum animation scale | 680 2.2f, // page scale |
| 734 false, | 681 1.f, // maximum animation scale |
| 735 &result_scale_x, | 682 false); |
| 736 &result_scale_y, | |
| 737 &result_bounds); | |
| 738 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); | 683 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); |
| 739 EXPECT_FLOAT_EQ(7.26f, | 684 EXPECT_FLOAT_EQ(7.26f, |
| 740 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 685 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 741 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 686 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
| 742 pending_layer_->tilings()->tiling_at(3)->contents_scale()); | 687 pending_layer_->tilings()->tiling_at(3)->contents_scale()); |
| 743 | 688 |
| 744 // If we change the device scale factor, but end up at the same total scale | 689 // If we change the device scale factor, but end up at the same total scale |
| 745 // factor somehow, then we don't get new tilings. | 690 // factor somehow, then we don't get new tilings. |
| 746 pending_layer_->CalculateContentsScale(7.26f, // ideal contents scale | 691 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 747 2.2f, // device scale | 692 7.26f, // ideal contents scale |
| 748 3.3f, // page scale | 693 2.2f, // device scale |
| 749 1.f, // maximum animation scale | 694 3.3f, // page scale |
| 750 false, | 695 1.f, // maximum animation scale |
| 751 &result_scale_x, | 696 false); |
| 752 &result_scale_y, | |
| 753 &result_bounds); | |
| 754 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); | 697 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); |
| 755 EXPECT_FLOAT_EQ(7.26f, | 698 EXPECT_FLOAT_EQ(7.26f, |
| 756 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 699 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 757 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 700 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
| 758 pending_layer_->tilings()->tiling_at(3)->contents_scale()); | 701 pending_layer_->tilings()->tiling_at(3)->contents_scale()); |
| 759 } | 702 } |
| 760 | 703 |
| 761 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { | 704 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
| 762 // This test makes sure that if a layer can have tilings, then a commit makes | 705 // This test makes sure that if a layer can have tilings, then a commit makes |
| 763 // it not able to have tilings (empty size), and then a future commit that | 706 // it not able to have tilings (empty size), and then a future commit that |
| 764 // makes it valid again should be able to create tilings. | 707 // makes it valid again should be able to create tilings. |
| 765 gfx::Size tile_size(400, 400); | 708 gfx::Size tile_size(400, 400); |
| 766 gfx::Size layer_bounds(1300, 1900); | 709 gfx::Size layer_bounds(1300, 1900); |
| 767 | 710 |
| 768 scoped_refptr<FakePicturePileImpl> empty_pile = | 711 scoped_refptr<FakePicturePileImpl> empty_pile = |
| 769 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 712 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| 770 scoped_refptr<FakePicturePileImpl> valid_pile = | 713 scoped_refptr<FakePicturePileImpl> valid_pile = |
| 771 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 714 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 772 | 715 |
| 773 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 716 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 774 EXPECT_LT(low_res_factor, 1.f); | 717 EXPECT_LT(low_res_factor, 1.f); |
| 775 | 718 |
| 776 float high_res_scale = 1.3f; | 719 float high_res_scale = 1.3f; |
| 777 float low_res_scale = high_res_scale * low_res_factor; | 720 float low_res_scale = high_res_scale * low_res_factor; |
| 778 float device_scale = 1.7f; | 721 float device_scale = 1.7f; |
| 779 float page_scale = 3.2f; | 722 float page_scale = 3.2f; |
| 780 float maximum_animation_scale = 1.f; | 723 float maximum_animation_scale = 1.f; |
| 781 float result_scale_x, result_scale_y; | |
| 782 gfx::Size result_bounds; | |
| 783 | 724 |
| 784 SetupPendingTree(valid_pile); | 725 SetupPendingTree(valid_pile); |
| 785 pending_layer_->CalculateContentsScale(high_res_scale, | 726 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 786 device_scale, | 727 high_res_scale, |
| 787 page_scale, | 728 device_scale, |
| 788 maximum_animation_scale, | 729 page_scale, |
| 789 false, | 730 maximum_animation_scale, |
| 790 &result_scale_x, | 731 false); |
| 791 &result_scale_y, | |
| 792 &result_bounds); | |
| 793 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 732 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 794 EXPECT_FLOAT_EQ(high_res_scale, | 733 EXPECT_FLOAT_EQ(high_res_scale, |
| 795 pending_layer_->HighResTiling()->contents_scale()); | 734 pending_layer_->HighResTiling()->contents_scale()); |
| 796 EXPECT_FLOAT_EQ(low_res_scale, | 735 EXPECT_FLOAT_EQ(low_res_scale, |
| 797 pending_layer_->LowResTiling()->contents_scale()); | 736 pending_layer_->LowResTiling()->contents_scale()); |
| 798 | 737 |
| 799 ActivateTree(); | 738 ActivateTree(); |
| 800 SetupPendingTree(empty_pile); | 739 SetupPendingTree(empty_pile); |
| 801 pending_layer_->CalculateContentsScale(high_res_scale, | 740 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 802 device_scale, | 741 high_res_scale, |
| 803 page_scale, | 742 device_scale, |
| 804 maximum_animation_scale, | 743 page_scale, |
| 805 false, | 744 maximum_animation_scale, |
| 806 &result_scale_x, | 745 false); |
| 807 &result_scale_y, | |
| 808 &result_bounds); | |
| 809 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 746 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 810 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 747 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 811 | 748 |
| 812 ActivateTree(); | 749 ActivateTree(); |
| 813 active_layer_->CalculateContentsScale(high_res_scale, | 750 SetupDrawPropertiesAndUpdateTilePriorities(active_layer_, |
| 814 device_scale, | 751 high_res_scale, |
| 815 page_scale, | 752 device_scale, |
| 816 maximum_animation_scale, | 753 page_scale, |
| 817 false, | 754 maximum_animation_scale, |
| 818 &result_scale_x, | 755 false); |
| 819 &result_scale_y, | |
| 820 &result_bounds); | |
| 821 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); | 756 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 822 | 757 |
| 823 SetupPendingTree(valid_pile); | 758 SetupPendingTree(valid_pile); |
| 824 pending_layer_->CalculateContentsScale(high_res_scale, | 759 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 825 device_scale, | 760 high_res_scale, |
| 826 page_scale, | 761 device_scale, |
| 827 maximum_animation_scale, | 762 page_scale, |
| 828 false, | 763 maximum_animation_scale, |
| 829 &result_scale_x, | 764 false); |
| 830 &result_scale_y, | |
| 831 &result_bounds); | |
| 832 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 765 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 833 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); | 766 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 834 EXPECT_FLOAT_EQ(high_res_scale, | 767 EXPECT_FLOAT_EQ(high_res_scale, |
| 835 pending_layer_->HighResTiling()->contents_scale()); | 768 pending_layer_->HighResTiling()->contents_scale()); |
| 836 EXPECT_FLOAT_EQ(low_res_scale, | 769 EXPECT_FLOAT_EQ(low_res_scale, |
| 837 pending_layer_->LowResTiling()->contents_scale()); | 770 pending_layer_->LowResTiling()->contents_scale()); |
| 838 } | 771 } |
| 839 | 772 |
| 840 TEST_F(PictureLayerImplTest, ZoomOutCrash) { | 773 TEST_F(PictureLayerImplTest, ZoomOutCrash) { |
| 841 gfx::Size tile_size(400, 400); | 774 gfx::Size tile_size(400, 400); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 955 | 888 |
| 956 TEST_F(PictureLayerImplTest, CleanUpTilings) { | 889 TEST_F(PictureLayerImplTest, CleanUpTilings) { |
| 957 gfx::Size tile_size(400, 400); | 890 gfx::Size tile_size(400, 400); |
| 958 gfx::Size layer_bounds(1300, 1900); | 891 gfx::Size layer_bounds(1300, 1900); |
| 959 | 892 |
| 960 scoped_refptr<FakePicturePileImpl> pending_pile = | 893 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 961 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 894 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 962 scoped_refptr<FakePicturePileImpl> active_pile = | 895 scoped_refptr<FakePicturePileImpl> active_pile = |
| 963 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 896 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 964 | 897 |
| 965 float result_scale_x, result_scale_y; | |
| 966 gfx::Size result_bounds; | |
| 967 std::vector<PictureLayerTiling*> used_tilings; | 898 std::vector<PictureLayerTiling*> used_tilings; |
| 968 | 899 |
| 969 SetupTrees(pending_pile, active_pile); | 900 SetupTrees(pending_pile, active_pile); |
| 970 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 901 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 971 | 902 |
| 972 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 903 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 973 EXPECT_LT(low_res_factor, 1.f); | 904 EXPECT_LT(low_res_factor, 1.f); |
| 974 | 905 |
| 975 float device_scale = 1.7f; | 906 float device_scale = 1.7f; |
| 976 float page_scale = 3.2f; | 907 float page_scale = 3.2f; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1030 // Now move the ideal scale to 1.0. Our target stays 1.2. | 961 // Now move the ideal scale to 1.0. Our target stays 1.2. |
| 1031 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); | 962 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); |
| 1032 | 963 |
| 1033 // All the tilings are between are target and the ideal, so they are not | 964 // All the tilings are between are target and the ideal, so they are not |
| 1034 // removed. | 965 // removed. |
| 1035 used_tilings.clear(); | 966 used_tilings.clear(); |
| 1036 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 967 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1037 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 968 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 1038 | 969 |
| 1039 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. | 970 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
| 1040 active_layer_->CalculateContentsScale(1.1f, | 971 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1041 device_scale, | 972 active_layer_, 1.1f, device_scale, page_scale, 1.f, false); |
| 1042 page_scale, | |
| 1043 1.f, | |
| 1044 false, | |
| 1045 &result_scale_x, | |
| 1046 &result_scale_y, | |
| 1047 &result_bounds); | |
| 1048 | 973 |
| 1049 // Because the pending layer's ideal scale is still 1.0, our tilings fall | 974 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
| 1050 // in the range [1.0,1.2] and are kept. | 975 // in the range [1.0,1.2] and are kept. |
| 1051 used_tilings.clear(); | 976 used_tilings.clear(); |
| 1052 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 977 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1053 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 978 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 1054 | 979 |
| 1055 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays | 980 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
| 1056 // 1.2 still. | 981 // 1.2 still. |
| 1057 pending_layer_->CalculateContentsScale(1.1f, | 982 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1058 device_scale, | 983 pending_layer_, 1.1f, device_scale, page_scale, 1.f, false); |
| 1059 page_scale, | |
| 1060 1.f, | |
| 1061 false, | |
| 1062 &result_scale_x, | |
| 1063 &result_scale_y, | |
| 1064 &result_bounds); | |
| 1065 | 984 |
| 1066 // Our 1.0 tiling now falls outside the range between our ideal scale and our | 985 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
| 1067 // target raster scale. But it is in our used tilings set, so nothing is | 986 // target raster scale. But it is in our used tilings set, so nothing is |
| 1068 // deleted. | 987 // deleted. |
| 1069 used_tilings.clear(); | 988 used_tilings.clear(); |
| 1070 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 989 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
| 1071 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 990 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1072 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 991 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 1073 | 992 |
| 1074 // If we remove it from our used tilings set, it is outside the range to keep | 993 // If we remove it from our used tilings set, it is outside the range to keep |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1208 | 1127 |
| 1209 TEST_F(PictureLayerImplTest, ReleaseResources) { | 1128 TEST_F(PictureLayerImplTest, ReleaseResources) { |
| 1210 gfx::Size tile_size(400, 400); | 1129 gfx::Size tile_size(400, 400); |
| 1211 gfx::Size layer_bounds(1300, 1900); | 1130 gfx::Size layer_bounds(1300, 1900); |
| 1212 | 1131 |
| 1213 scoped_refptr<FakePicturePileImpl> pending_pile = | 1132 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1214 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1133 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1215 scoped_refptr<FakePicturePileImpl> active_pile = | 1134 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1216 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1135 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1217 | 1136 |
| 1218 float result_scale_x, result_scale_y; | |
| 1219 gfx::Size result_bounds; | |
| 1220 | |
| 1221 SetupTrees(pending_pile, active_pile); | 1137 SetupTrees(pending_pile, active_pile); |
| 1222 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1138 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1223 | 1139 |
| 1224 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale | 1140 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 1225 2.7f, // device scale | 1141 1.3f, // ideal contents scale |
| 1226 3.2f, // page scale | 1142 2.7f, // device scale |
| 1227 1.f, // maximum animation scale | 1143 3.2f, // page scale |
| 1228 false, | 1144 1.f, // maximum animation scale |
| 1229 &result_scale_x, | 1145 false); |
| 1230 &result_scale_y, | |
| 1231 &result_bounds); | |
| 1232 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1146 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1233 | 1147 |
| 1234 // All tilings should be removed when losing output surface. | 1148 // All tilings should be removed when losing output surface. |
| 1235 active_layer_->ReleaseResources(); | 1149 active_layer_->ReleaseResources(); |
| 1236 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 1150 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 1237 pending_layer_->ReleaseResources(); | 1151 pending_layer_->ReleaseResources(); |
| 1238 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1152 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1239 | 1153 |
| 1240 // This should create new tilings. | 1154 // This should create new tilings. |
| 1241 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale | 1155 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 1242 2.7f, // device scale | 1156 1.3f, // ideal contents scale |
| 1243 3.2f, // page scale | 1157 2.7f, // device scale |
| 1244 1.f, // maximum animation scale | 1158 3.2f, // page scale |
| 1245 false, | 1159 1.f, // maximum animation scale |
| 1246 &result_scale_x, | 1160 false); |
| 1247 &result_scale_y, | |
| 1248 &result_bounds); | |
| 1249 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1161 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1250 } | 1162 } |
| 1251 | 1163 |
| 1252 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { | 1164 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { |
| 1253 // The default max tile size is larger than 400x400. | 1165 // The default max tile size is larger than 400x400. |
| 1254 gfx::Size tile_size(400, 400); | 1166 gfx::Size tile_size(400, 400); |
| 1255 gfx::Size layer_bounds(5000, 5000); | 1167 gfx::Size layer_bounds(5000, 5000); |
| 1256 | 1168 |
| 1257 scoped_refptr<FakePicturePileImpl> pending_pile = | 1169 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1258 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1170 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1259 scoped_refptr<FakePicturePileImpl> active_pile = | 1171 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1260 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1172 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1261 | 1173 |
| 1262 float result_scale_x, result_scale_y; | |
| 1263 gfx::Size result_bounds; | |
| 1264 | |
| 1265 SetupTrees(pending_pile, active_pile); | 1174 SetupTrees(pending_pile, active_pile); |
| 1266 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1175 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1267 | 1176 |
| 1268 pending_layer_->CalculateContentsScale(1.f, | 1177 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1269 1.f, | 1178 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1270 1.f, | |
| 1271 1.f, | |
| 1272 false, | |
| 1273 &result_scale_x, | |
| 1274 &result_scale_y, | |
| 1275 &result_bounds); | |
| 1276 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1179 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1277 | 1180 |
| 1278 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1181 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1279 | 1182 |
| 1280 // The default value. | 1183 // The default value. |
| 1281 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1184 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| 1282 host_impl_.settings().default_tile_size.ToString()); | 1185 host_impl_.settings().default_tile_size.ToString()); |
| 1283 | 1186 |
| 1284 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1187 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1285 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1188 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| 1286 tile->content_rect().size().ToString()); | 1189 tile->content_rect().size().ToString()); |
| 1287 | 1190 |
| 1288 pending_layer_->ReleaseResources(); | 1191 pending_layer_->ReleaseResources(); |
| 1289 | 1192 |
| 1290 // Change the max texture size on the output surface context. | 1193 // Change the max texture size on the output surface context. |
| 1291 scoped_ptr<TestWebGraphicsContext3D> context = | 1194 scoped_ptr<TestWebGraphicsContext3D> context = |
| 1292 TestWebGraphicsContext3D::Create(); | 1195 TestWebGraphicsContext3D::Create(); |
| 1293 context->set_max_texture_size(140); | 1196 context->set_max_texture_size(140); |
| 1294 host_impl_.DidLoseOutputSurface(); | 1197 host_impl_.DidLoseOutputSurface(); |
| 1295 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( | 1198 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
| 1296 context.Pass()).PassAs<OutputSurface>()); | 1199 context.Pass()).PassAs<OutputSurface>()); |
| 1297 | 1200 |
| 1298 pending_layer_->CalculateContentsScale(1.f, | 1201 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1299 1.f, | 1202 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1300 1.f, | |
| 1301 1.f, | |
| 1302 false, | |
| 1303 &result_scale_x, | |
| 1304 &result_scale_y, | |
| 1305 &result_bounds); | |
| 1306 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1203 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1307 | 1204 |
| 1308 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1205 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1309 | 1206 |
| 1310 // Verify the tiles are not larger than the context's max texture size. | 1207 // Verify the tiles are not larger than the context's max texture size. |
| 1311 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1208 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1312 EXPECT_GE(140, tile->content_rect().width()); | 1209 EXPECT_GE(140, tile->content_rect().width()); |
| 1313 EXPECT_GE(140, tile->content_rect().height()); | 1210 EXPECT_GE(140, tile->content_rect().height()); |
| 1314 } | 1211 } |
| 1315 | 1212 |
| 1316 TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { | 1213 TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { |
| 1317 // The default max tile size is larger than 400x400. | 1214 // The default max tile size is larger than 400x400. |
| 1318 gfx::Size tile_size(400, 400); | 1215 gfx::Size tile_size(400, 400); |
| 1319 gfx::Size layer_bounds(500, 500); | 1216 gfx::Size layer_bounds(500, 500); |
| 1320 | 1217 |
| 1321 scoped_refptr<FakePicturePileImpl> pending_pile = | 1218 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1322 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1219 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1323 scoped_refptr<FakePicturePileImpl> active_pile = | 1220 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1324 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1221 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1325 | 1222 |
| 1326 float result_scale_x, result_scale_y; | |
| 1327 gfx::Size result_bounds; | |
| 1328 | |
| 1329 SetupTrees(pending_pile, active_pile); | 1223 SetupTrees(pending_pile, active_pile); |
| 1330 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1224 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1331 | 1225 |
| 1332 pending_layer_->CalculateContentsScale(1.f, | 1226 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1333 1.f, | 1227 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1334 1.f, | |
| 1335 1.f, | |
| 1336 false, | |
| 1337 &result_scale_x, | |
| 1338 &result_scale_y, | |
| 1339 &result_bounds); | |
| 1340 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); | 1228 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); |
| 1341 | 1229 |
| 1342 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1230 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1343 | 1231 |
| 1344 // The default value. The layer is smaller than this. | 1232 // The default value. The layer is smaller than this. |
| 1345 EXPECT_EQ(gfx::Size(512, 512).ToString(), | 1233 EXPECT_EQ(gfx::Size(512, 512).ToString(), |
| 1346 host_impl_.settings().max_untiled_layer_size.ToString()); | 1234 host_impl_.settings().max_untiled_layer_size.ToString()); |
| 1347 | 1235 |
| 1348 // There should be a single tile since the layer is small. | 1236 // There should be a single tile since the layer is small. |
| 1349 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1237 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); |
| 1350 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); | 1238 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1351 | 1239 |
| 1352 pending_layer_->ReleaseResources(); | 1240 pending_layer_->ReleaseResources(); |
| 1353 | 1241 |
| 1354 // Change the max texture size on the output surface context. | 1242 // Change the max texture size on the output surface context. |
| 1355 scoped_ptr<TestWebGraphicsContext3D> context = | 1243 scoped_ptr<TestWebGraphicsContext3D> context = |
| 1356 TestWebGraphicsContext3D::Create(); | 1244 TestWebGraphicsContext3D::Create(); |
| 1357 context->set_max_texture_size(140); | 1245 context->set_max_texture_size(140); |
| 1358 host_impl_.DidLoseOutputSurface(); | 1246 host_impl_.DidLoseOutputSurface(); |
| 1359 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( | 1247 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
| 1360 context.Pass()).PassAs<OutputSurface>()); | 1248 context.Pass()).PassAs<OutputSurface>()); |
| 1361 | 1249 |
| 1362 pending_layer_->CalculateContentsScale(1.f, | 1250 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1363 1.f, | 1251 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1364 1.f, | |
| 1365 1.f, | |
| 1366 false, | |
| 1367 &result_scale_x, | |
| 1368 &result_scale_y, | |
| 1369 &result_bounds); | |
| 1370 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); | 1252 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); |
| 1371 | 1253 |
| 1372 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1254 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1373 | 1255 |
| 1374 // There should be more than one tile since the max texture size won't cover | 1256 // There should be more than one tile since the max texture size won't cover |
| 1375 // the layer. | 1257 // the layer. |
| 1376 high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1258 high_res_tiling = pending_layer_->tilings()->tiling_at(0); |
| 1377 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); | 1259 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1378 | 1260 |
| 1379 // Verify the tiles are not larger than the context's max texture size. | 1261 // Verify the tiles are not larger than the context's max texture size. |
| 1380 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1262 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1381 EXPECT_GE(140, tile->content_rect().width()); | 1263 EXPECT_GE(140, tile->content_rect().width()); |
| 1382 EXPECT_GE(140, tile->content_rect().height()); | 1264 EXPECT_GE(140, tile->content_rect().height()); |
| 1383 } | 1265 } |
| 1384 | 1266 |
| 1385 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { | 1267 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { |
| 1386 MockQuadCuller quad_culler; | 1268 MockQuadCuller quad_culler; |
| 1387 | 1269 |
| 1388 gfx::Size tile_size(400, 400); | 1270 gfx::Size tile_size(400, 400); |
| 1389 gfx::Size layer_bounds(1300, 1900); | 1271 gfx::Size layer_bounds(1300, 1900); |
| 1390 | 1272 |
| 1391 scoped_refptr<FakePicturePileImpl> pending_pile = | 1273 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1392 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1274 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1393 scoped_refptr<FakePicturePileImpl> active_pile = | 1275 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1394 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1276 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1395 | 1277 |
| 1396 SetupTrees(pending_pile, active_pile); | 1278 SetupTrees(pending_pile, active_pile); |
| 1397 | 1279 |
| 1398 active_layer_->SetContentBounds(layer_bounds); | |
| 1399 active_layer_->draw_properties().visible_content_rect = | 1280 active_layer_->draw_properties().visible_content_rect = |
| 1400 gfx::Rect(layer_bounds); | 1281 gfx::Rect(layer_bounds); |
| 1401 | 1282 |
| 1402 gfx::Rect layer_invalidation(150, 200, 30, 180); | 1283 gfx::Rect layer_invalidation(150, 200, 30, 180); |
| 1403 Region invalidation(layer_invalidation); | 1284 Region invalidation(layer_invalidation); |
| 1404 AddDefaultTilingsWithInvalidation(invalidation); | 1285 AddDefaultTilingsWithInvalidation(invalidation); |
| 1405 | 1286 |
| 1406 AppendQuadsData data; | 1287 AppendQuadsData data; |
| 1407 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); | 1288 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); |
| 1408 active_layer_->AppendQuads(&quad_culler, &data); | 1289 active_layer_->AppendQuads(&quad_culler, &data); |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1806 pending_layer_->tilings()->TilingAtScale(1.0f)->resolution()); | 1687 pending_layer_->tilings()->TilingAtScale(1.0f)->resolution()); |
| 1807 ASSERT_TRUE(pending_layer_->tilings()->TilingAtScale(1.5f)); | 1688 ASSERT_TRUE(pending_layer_->tilings()->TilingAtScale(1.5f)); |
| 1808 EXPECT_EQ(NON_IDEAL_RESOLUTION, | 1689 EXPECT_EQ(NON_IDEAL_RESOLUTION, |
| 1809 pending_layer_->tilings()->TilingAtScale(1.5f)->resolution()); | 1690 pending_layer_->tilings()->TilingAtScale(1.5f)->resolution()); |
| 1810 } | 1691 } |
| 1811 | 1692 |
| 1812 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { | 1693 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { |
| 1813 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); | 1694 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); |
| 1814 gfx::Size layer_bounds(default_tile_size.width() * 4, | 1695 gfx::Size layer_bounds(default_tile_size.width() * 4, |
| 1815 default_tile_size.height() * 4); | 1696 default_tile_size.height() * 4); |
| 1816 float result_scale_x, result_scale_y; | |
| 1817 gfx::Size result_bounds; | |
| 1818 | 1697 |
| 1819 SetupDefaultTrees(layer_bounds); | 1698 SetupDefaultTrees(layer_bounds); |
| 1820 EXPECT_FALSE(host_impl_.use_gpu_rasterization()); | 1699 EXPECT_FALSE(host_impl_.use_gpu_rasterization()); |
| 1821 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1700 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1822 pending_layer_->CalculateContentsScale(1.f, | 1701 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1823 1.f, | 1702 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1824 1.f, | |
| 1825 1.f, | |
| 1826 false, | |
| 1827 &result_scale_x, | |
| 1828 &result_scale_y, | |
| 1829 &result_bounds); | |
| 1830 // Should have a low-res and a high-res tiling. | 1703 // Should have a low-res and a high-res tiling. |
| 1831 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1704 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1832 | 1705 |
| 1833 ResetTilingsAndRasterScales(); | 1706 ResetTilingsAndRasterScales(); |
| 1834 | 1707 |
| 1835 host_impl_.SetUseGpuRasterization(true); | 1708 host_impl_.SetUseGpuRasterization(true); |
| 1836 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); | 1709 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); |
| 1837 pending_layer_->CalculateContentsScale(1.f, | 1710 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1838 1.f, | 1711 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1839 1.f, | 1712 |
| 1840 1.f, | |
| 1841 false, | |
| 1842 &result_scale_x, | |
| 1843 &result_scale_y, | |
| 1844 &result_bounds); | |
| 1845 // Should only have the high-res tiling. | 1713 // Should only have the high-res tiling. |
| 1846 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 1714 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 1847 } | 1715 } |
| 1848 | 1716 |
| 1849 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { | 1717 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { |
| 1850 // Set up layers with tilings. | 1718 // Set up layers with tilings. |
| 1851 SetupDefaultTrees(gfx::Size(10, 10)); | 1719 SetupDefaultTrees(gfx::Size(10, 10)); |
| 1852 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); | 1720 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); |
| 1853 pending_layer_->PushPropertiesTo(active_layer_); | 1721 pending_layer_->PushPropertiesTo(active_layer_); |
| 1854 EXPECT_TRUE(pending_layer_->DrawsContent()); | 1722 EXPECT_TRUE(pending_layer_->DrawsContent()); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2178 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); | 2046 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); |
| 2179 } | 2047 } |
| 2180 | 2048 |
| 2181 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); | 2049 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); |
| 2182 | 2050 |
| 2183 bool mark_required = false; | 2051 bool mark_required = false; |
| 2184 for (std::vector<Tile*>::iterator it = all_tiles.begin(); | 2052 for (std::vector<Tile*>::iterator it = all_tiles.begin(); |
| 2185 it != all_tiles.end(); | 2053 it != all_tiles.end(); |
| 2186 ++it) { | 2054 ++it) { |
| 2187 Tile* tile = *it; | 2055 Tile* tile = *it; |
| 2056 | |
|
danakj
2014/05/23 17:07:34
nit: don't add whitespace here
| |
| 2188 if (mark_required) | 2057 if (mark_required) |
| 2189 tile->MarkRequiredForActivation(); | 2058 tile->MarkRequiredForActivation(); |
| 2190 mark_required = !mark_required; | 2059 mark_required = !mark_required; |
| 2191 } | 2060 } |
| 2192 | 2061 |
| 2193 // Sanity checks. | 2062 // Sanity checks. |
| 2194 EXPECT_EQ(91u, all_tiles.size()); | 2063 EXPECT_EQ(91u, all_tiles.size()); |
| 2195 EXPECT_EQ(91u, all_tiles_set.size()); | 2064 EXPECT_EQ(91u, all_tiles_set.size()); |
| 2196 | 2065 |
| 2197 // Empty iterator. | 2066 // Empty iterator. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2384 contents_scale = 0.5f; | 2253 contents_scale = 0.5f; |
| 2385 | 2254 |
| 2386 SetContentsScaleOnBothLayers(contents_scale, | 2255 SetContentsScaleOnBothLayers(contents_scale, |
| 2387 device_scale, | 2256 device_scale, |
| 2388 page_scale, | 2257 page_scale, |
| 2389 maximum_animation_scale, | 2258 maximum_animation_scale, |
| 2390 animating_transform); | 2259 animating_transform); |
| 2391 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 2260 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
| 2392 } | 2261 } |
| 2393 | 2262 |
| 2263 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { | |
| 2264 MockQuadCuller quad_culler; | |
| 2265 | |
| 2266 gfx::Size tile_size(400, 400); | |
| 2267 gfx::Size layer_bounds(1000, 2000); | |
| 2268 | |
| 2269 scoped_refptr<FakePicturePileImpl> pending_pile = | |
| 2270 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
| 2271 scoped_refptr<FakePicturePileImpl> active_pile = | |
| 2272 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
| 2273 | |
| 2274 SetupTrees(pending_pile, active_pile); | |
| 2275 | |
| 2276 SetupDrawPropertiesAndUpdateTilePriorities( | |
| 2277 pending_layer_, 2.5f, 1.f, 1.f, 1.f, false); | |
| 2278 | |
| 2279 active_layer_->draw_properties().visible_content_rect = | |
| 2280 gfx::Rect(layer_bounds); | |
| 2281 | |
| 2282 float max_contents_scale = active_layer_->MaximumTilingContentScale(); | |
| 2283 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); | |
| 2284 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, | |
| 2285 SK_MScalar1 / max_contents_scale); | |
| 2286 | |
| 2287 AppendQuadsData data; | |
| 2288 active_layer_->AppendQuads(&quad_culler, &data); | |
| 2289 | |
| 2290 // SharedQuadState should have be of size 1, as we are doing AppenQuad once. | |
| 2291 EXPECT_EQ(1u, quad_culler.shared_quad_state_list().size()); | |
| 2292 // The content_to_target_transform should be scaled by the | |
| 2293 // MaximumTilingContentScale on the layer. | |
| 2294 EXPECT_EQ(scaled_draw_transform.ToString(), | |
| 2295 quad_culler.shared_quad_state_list()[0] | |
| 2296 ->content_to_target_transform.ToString()); | |
| 2297 // The content_bounds should be scaled by the | |
| 2298 // MaximumTilingContentScale on the layer. | |
| 2299 EXPECT_EQ(gfx::Size(2500u, 5000u).ToString(), | |
| 2300 quad_culler.shared_quad_state_list()[0]->content_bounds.ToString()); | |
| 2301 // The visible_content_rect should be scaled by the | |
| 2302 // MaximumTilingContentScale on the layer. | |
| 2303 EXPECT_EQ( | |
| 2304 gfx::Rect(0u, 0u, 2500u, 5000u).ToString(), | |
| 2305 quad_culler.shared_quad_state_list()[0]->visible_content_rect.ToString()); | |
| 2306 } | |
| 2307 | |
| 2394 } // namespace | 2308 } // namespace |
| 2395 } // namespace cc | 2309 } // namespace cc |
| OLD | NEW |