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

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

Issue 1544103002: Determine a layer's IsAffectedByPageScale property without using Layer Tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
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_image_layer_impl.h" 5 #include "cc/layers/picture_image_layer_impl.h"
6 6
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "cc/layers/append_quads_data.h" 8 #include "cc/layers/append_quads_data.h"
9 #include "cc/quads/draw_quad.h" 9 #include "cc/quads/draw_quad.h"
10 #include "cc/test/fake_display_list_raster_source.h" 10 #include "cc/test/fake_display_list_raster_source.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 TestSharedBitmapManager shared_bitmap_manager_; 101 TestSharedBitmapManager shared_bitmap_manager_;
102 TestTaskGraphRunner task_graph_runner_; 102 TestTaskGraphRunner task_graph_runner_;
103 scoped_ptr<OutputSurface> output_surface_; 103 scoped_ptr<OutputSurface> output_surface_;
104 FakeLayerTreeHostImpl host_impl_; 104 FakeLayerTreeHostImpl host_impl_;
105 }; 105 };
106 106
107 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { 107 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) {
108 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); 108 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE));
109 layer->SetDrawsContent(true); 109 layer->SetDrawsContent(true);
110 110
111 TestablePictureImageLayerImpl* layer_ptr = layer.get();
112 host_impl_.pending_tree()->SetRootLayer(std::move(layer));
113 host_impl_.pending_tree()->BuildPropertyTreesForTesting();
114
111 gfx::Rect viewport(100, 200); 115 gfx::Rect viewport(100, 200);
112 SetupDrawPropertiesAndUpdateTiles( 116 SetupDrawPropertiesAndUpdateTiles(layer_ptr, 2.f, 3.f, 4.f, 1.f, false,
113 layer.get(), 2.f, 3.f, 4.f, 1.f, false, viewport); 117 viewport);
114 EXPECT_FLOAT_EQ(1.f, layer->MaximumTilingContentsScale()); 118 EXPECT_FLOAT_EQ(1.f, layer_ptr->MaximumTilingContentsScale());
115 } 119 }
116 120
117 TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { 121 TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) {
118 scoped_ptr<TestablePictureImageLayerImpl> pending_layer( 122 scoped_ptr<TestablePictureImageLayerImpl> pending_layer(
119 CreateLayer(1, PENDING_TREE)); 123 CreateLayer(1, PENDING_TREE));
120 pending_layer->SetDrawsContent(true); 124 pending_layer->SetDrawsContent(true);
121 125
122 gfx::Rect viewport(100, 200); 126 gfx::Rect viewport(100, 200);
123 127
128 TestablePictureImageLayerImpl* pending_layer_ptr = pending_layer.get();
129 host_impl_.pending_tree()->SetRootLayer(std::move(pending_layer));
130 host_impl_.pending_tree()->BuildPropertyTreesForTesting();
131
124 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f which is not equal 132 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f which is not equal
125 // to the content scale used by PictureImageLayerImpl. 133 // to the content scale used by PictureImageLayerImpl.
126 const float suggested_ideal_contents_scale = 2.f; 134 const float suggested_ideal_contents_scale = 2.f;
127 const float device_scale_factor = 3.f; 135 const float device_scale_factor = 3.f;
128 const float page_scale_factor = 4.f; 136 const float page_scale_factor = 4.f;
129 const float maximum_animation_contents_scale = 1.f; 137 const float maximum_animation_contents_scale = 1.f;
130 const bool animating_transform_to_screen = false; 138 const bool animating_transform_to_screen = false;
131 SetupDrawPropertiesAndUpdateTiles(pending_layer.get(), 139 SetupDrawPropertiesAndUpdateTiles(
132 suggested_ideal_contents_scale, 140 pending_layer_ptr, suggested_ideal_contents_scale, device_scale_factor,
133 device_scale_factor, 141 page_scale_factor, maximum_animation_contents_scale,
134 page_scale_factor, 142 animating_transform_to_screen, viewport);
135 maximum_animation_contents_scale, 143 EXPECT_EQ(1.f, pending_layer_ptr->tilings()->tiling_at(0)->contents_scale());
136 animating_transform_to_screen,
137 viewport);
138 EXPECT_EQ(1.f, pending_layer->tilings()->tiling_at(0)->contents_scale());
139 144
140 // Push to active layer. 145 // Push to active layer.
141 host_impl_.pending_tree()->SetRootLayer(std::move(pending_layer));
142 host_impl_.ActivateSyncTree(); 146 host_impl_.ActivateSyncTree();
143 147
144 TestablePictureImageLayerImpl* active_layer = 148 TestablePictureImageLayerImpl* active_layer =
145 static_cast<TestablePictureImageLayerImpl*>( 149 static_cast<TestablePictureImageLayerImpl*>(
146 host_impl_.active_tree()->root_layer()); 150 host_impl_.active_tree()->root_layer());
147 SetupDrawPropertiesAndUpdateTiles(active_layer, 151 SetupDrawPropertiesAndUpdateTiles(active_layer,
148 suggested_ideal_contents_scale, 152 suggested_ideal_contents_scale,
149 device_scale_factor, 153 device_scale_factor,
150 page_scale_factor, 154 page_scale_factor,
151 maximum_animation_contents_scale, 155 maximum_animation_contents_scale,
(...skipping 13 matching lines...) Expand all
165 active_layer->DidDraw(nullptr); 169 active_layer->DidDraw(nullptr);
166 170
167 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material); 171 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material);
168 172
169 // Tiles are ready at correct scale, so should not set had_incomplete_tile. 173 // Tiles are ready at correct scale, so should not set had_incomplete_tile.
170 EXPECT_EQ(0, data.num_incomplete_tiles); 174 EXPECT_EQ(0, data.num_incomplete_tiles);
171 } 175 }
172 176
173 } // namespace 177 } // namespace
174 } // namespace cc 178 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698