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

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

Issue 2100483003: cc: Change directly composited image raster source scale occasionally. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests Created 4 years, 5 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 4926 matching lines...) Expand 10 before | Expand all | Expand 10 after
4937 active_layer->AppendQuads(render_pass.get(), &data); 4937 active_layer->AppendQuads(render_pass.get(), &data);
4938 active_layer->DidDraw(nullptr); 4938 active_layer->DidDraw(nullptr);
4939 4939
4940 ASSERT_FALSE(render_pass->quad_list.empty()); 4940 ASSERT_FALSE(render_pass->quad_list.empty());
4941 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material); 4941 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material);
4942 4942
4943 // Tiles are ready at correct scale, so should not set had_incomplete_tile. 4943 // Tiles are ready at correct scale, so should not set had_incomplete_tile.
4944 EXPECT_EQ(0, data.num_incomplete_tiles); 4944 EXPECT_EQ(0, data.num_incomplete_tiles);
4945 } 4945 }
4946 4946
4947 TEST_F(PictureLayerImplTest, CompositedImageRasterScaleChanges) {
4948 gfx::Size layer_bounds(400, 400);
4949 scoped_refptr<FakeRasterSource> pending_raster_source =
4950 FakeRasterSource::CreateFilled(layer_bounds);
4951
4952 host_impl()->CreatePendingTree();
4953 LayerTreeImpl* pending_tree = host_impl()->pending_tree();
4954
4955 std::unique_ptr<FakePictureLayerImpl> pending_layer =
4956 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, layer_id(),
4957 pending_raster_source);
4958 pending_layer->set_is_directly_composited_image(true);
4959 pending_layer->SetDrawsContent(true);
4960 FakePictureLayerImpl* pending_layer_ptr = pending_layer.get();
4961 pending_tree->SetRootLayer(std::move(pending_layer));
4962 pending_tree->BuildLayerListAndPropertyTreesForTesting();
4963
4964 float expected_contents_scale = 0.25f;
4965 for (int i = 1; i < 30; ++i) {
4966 float ideal_contents_scale = 0.1f * i - 1e-6;
4967 switch (i) {
4968 // Scale 0.3.
4969 case 3:
4970 expected_contents_scale = 0.5f;
4971 break;
4972 // Scale 0.6.
4973 case 6:
4974 expected_contents_scale = 1.f;
4975 break;
4976 }
4977 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale,
4978 1.f, 1.f, 1.f, 1.f, false);
4979 EXPECT_FLOAT_EQ(expected_contents_scale,
4980 pending_layer_ptr->picture_layer_tiling_set()
4981 ->FindTilingWithResolution(HIGH_RESOLUTION)
4982 ->contents_scale())
4983 << "ideal_contents_scale: " << ideal_contents_scale;
4984 }
4985
4986 expected_contents_scale = 1.f;
4987 for (int i = 30; i >= 1; --i) {
4988 float ideal_contents_scale = 0.1f * i - 1e-6;
4989 switch (i) {
4990 // Scale 0.2.
4991 case 2:
4992 expected_contents_scale = 0.5f;
4993 break;
4994 // Scale 0.1.
4995 case 1:
4996 expected_contents_scale = 0.25f;
4997 break;
4998 }
4999 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale,
5000 1.f, 1.f, 1.f, 1.f, false);
5001 EXPECT_FLOAT_EQ(expected_contents_scale,
5002 pending_layer_ptr->picture_layer_tiling_set()
5003 ->FindTilingWithResolution(HIGH_RESOLUTION)
5004 ->contents_scale())
5005 << "ideal_contents_scale: " << ideal_contents_scale;
5006 }
5007 }
5008
4947 } // namespace 5009 } // namespace
4948 } // namespace cc 5010 } // 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