Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 2094813003: cc: Merge PictureImageLayerImpl and PictureLayerImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: borders Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 4844 matching lines...) Expand 10 before | Expand all | Expand 10 after
4855 // New high res tiling. 4855 // New high res tiling.
4856 EXPECT_FALSE(tilings->tiling_at(0)->may_contain_low_resolution_tiles()); 4856 EXPECT_FALSE(tilings->tiling_at(0)->may_contain_low_resolution_tiles());
4857 // New low res tiling. 4857 // New low res tiling.
4858 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); 4858 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles());
4859 4859
4860 // This tiling will be high res now, it won't contain low res content since it 4860 // This tiling will be high res now, it won't contain low res content since it
4861 // was all destroyed. 4861 // was all destroyed.
4862 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); 4862 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles());
4863 } 4863 }
4864 4864
4865 TEST_F(PictureLayerImplTest, CompositedImageCalculateContentsScale) {
4866 gfx::Size layer_bounds(400, 400);
4867 scoped_refptr<FakeRasterSource> pending_raster_source =
4868 FakeRasterSource::CreateFilled(layer_bounds);
4869
4870 host_impl()->CreatePendingTree();
4871 LayerTreeImpl* pending_tree = host_impl()->pending_tree();
4872
4873 std::unique_ptr<FakePictureLayerImpl> pending_layer =
4874 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, layer_id(),
4875 pending_raster_source);
4876 pending_layer->set_is_directly_composited_image(true);
4877 pending_layer->SetDrawsContent(true);
4878 FakePictureLayerImpl* pending_layer_ptr = pending_layer.get();
4879 pending_tree->SetRootLayer(std::move(pending_layer));
4880 pending_tree->BuildLayerListAndPropertyTreesForTesting();
4881
4882 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, 2.f, 3.f, 4.f, 1.f, 1.f,
4883 false);
4884 EXPECT_FLOAT_EQ(1.f, pending_layer_ptr->MaximumTilingContentsScale());
4885 }
4886
4887 TEST_F(PictureLayerImplTest, CompositedImageIgnoreIdealContentsScale) {
4888 gfx::Size layer_bounds(400, 400);
4889 scoped_refptr<FakeRasterSource> pending_raster_source =
4890 FakeRasterSource::CreateFilled(layer_bounds);
4891
4892 host_impl()->SetViewportSize(layer_bounds);
4893 host_impl()->CreatePendingTree();
4894 LayerTreeImpl* pending_tree = host_impl()->pending_tree();
4895
4896 std::unique_ptr<FakePictureLayerImpl> pending_layer =
4897 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, layer_id(),
4898 pending_raster_source);
4899 pending_layer->set_is_directly_composited_image(true);
4900 pending_layer->SetDrawsContent(true);
4901 FakePictureLayerImpl* pending_layer_ptr = pending_layer.get();
4902 pending_tree->SetRootLayer(std::move(pending_layer));
4903 pending_tree->BuildLayerListAndPropertyTreesForTesting();
4904
4905 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f.
4906 const float suggested_ideal_contents_scale = 2.f;
4907 const float device_scale_factor = 3.f;
4908 const float page_scale_factor = 4.f;
4909 const float animation_contents_scale = 1.f;
4910 const bool animating_transform_to_screen = false;
4911 SetupDrawPropertiesAndUpdateTiles(
4912 pending_layer_ptr, suggested_ideal_contents_scale, device_scale_factor,
4913 page_scale_factor, animation_contents_scale, animation_contents_scale,
4914 animating_transform_to_screen);
4915 EXPECT_EQ(1.f, pending_layer_ptr->tilings()->tiling_at(0)->contents_scale());
4916
4917 // Push to active layer.
4918 host_impl()->ActivateSyncTree();
4919
4920 FakePictureLayerImpl* active_layer = static_cast<FakePictureLayerImpl*>(
4921 host_impl()->active_tree()->root_layer());
4922 SetupDrawPropertiesAndUpdateTiles(
4923 active_layer, suggested_ideal_contents_scale, device_scale_factor,
4924 page_scale_factor, animation_contents_scale, animation_contents_scale,
4925 animating_transform_to_screen);
4926 EXPECT_EQ(1.f, active_layer->tilings()->tiling_at(0)->contents_scale());
4927 active_layer->set_visible_layer_rect(gfx::Rect(layer_bounds));
4928
4929 // Create resources for the tiles.
4930 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting(
4931 active_layer->tilings()->tiling_at(0)->AllTilesForTesting());
4932
4933 // Draw.
4934 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
4935 AppendQuadsData data;
4936 active_layer->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
4937 active_layer->AppendQuads(render_pass.get(), &data);
4938 active_layer->DidDraw(nullptr);
4939
4940 ASSERT_FALSE(render_pass->quad_list.empty());
4941 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material);
4942
4943 // Tiles are ready at correct scale, so should not set had_incomplete_tile.
4944 EXPECT_EQ(0, data.num_incomplete_tiles);
4945 }
4946
4865 } // namespace 4947 } // namespace
4866 } // namespace cc 4948 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698