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_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 Loading... |
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 | |
115 gfx::Rect viewport(100, 200); | 111 gfx::Rect viewport(100, 200); |
116 SetupDrawPropertiesAndUpdateTiles(layer_ptr, 2.f, 3.f, 4.f, 1.f, false, | 112 SetupDrawPropertiesAndUpdateTiles( |
117 viewport); | 113 layer.get(), 2.f, 3.f, 4.f, 1.f, false, viewport); |
118 EXPECT_FLOAT_EQ(1.f, layer_ptr->MaximumTilingContentsScale()); | 114 EXPECT_FLOAT_EQ(1.f, layer->MaximumTilingContentsScale()); |
119 } | 115 } |
120 | 116 |
121 TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { | 117 TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { |
122 scoped_ptr<TestablePictureImageLayerImpl> pending_layer( | 118 scoped_ptr<TestablePictureImageLayerImpl> pending_layer( |
123 CreateLayer(1, PENDING_TREE)); | 119 CreateLayer(1, PENDING_TREE)); |
124 pending_layer->SetDrawsContent(true); | 120 pending_layer->SetDrawsContent(true); |
125 | 121 |
126 gfx::Rect viewport(100, 200); | 122 gfx::Rect viewport(100, 200); |
127 | 123 |
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 | |
132 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f which is not equal | 124 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f which is not equal |
133 // to the content scale used by PictureImageLayerImpl. | 125 // to the content scale used by PictureImageLayerImpl. |
134 const float suggested_ideal_contents_scale = 2.f; | 126 const float suggested_ideal_contents_scale = 2.f; |
135 const float device_scale_factor = 3.f; | 127 const float device_scale_factor = 3.f; |
136 const float page_scale_factor = 4.f; | 128 const float page_scale_factor = 4.f; |
137 const float maximum_animation_contents_scale = 1.f; | 129 const float maximum_animation_contents_scale = 1.f; |
138 const bool animating_transform_to_screen = false; | 130 const bool animating_transform_to_screen = false; |
139 SetupDrawPropertiesAndUpdateTiles( | 131 SetupDrawPropertiesAndUpdateTiles(pending_layer.get(), |
140 pending_layer_ptr, suggested_ideal_contents_scale, device_scale_factor, | 132 suggested_ideal_contents_scale, |
141 page_scale_factor, maximum_animation_contents_scale, | 133 device_scale_factor, |
142 animating_transform_to_screen, viewport); | 134 page_scale_factor, |
143 EXPECT_EQ(1.f, pending_layer_ptr->tilings()->tiling_at(0)->contents_scale()); | 135 maximum_animation_contents_scale, |
| 136 animating_transform_to_screen, |
| 137 viewport); |
| 138 EXPECT_EQ(1.f, pending_layer->tilings()->tiling_at(0)->contents_scale()); |
144 | 139 |
145 // Push to active layer. | 140 // Push to active layer. |
| 141 host_impl_.pending_tree()->SetRootLayer(std::move(pending_layer)); |
146 host_impl_.ActivateSyncTree(); | 142 host_impl_.ActivateSyncTree(); |
147 | 143 |
148 TestablePictureImageLayerImpl* active_layer = | 144 TestablePictureImageLayerImpl* active_layer = |
149 static_cast<TestablePictureImageLayerImpl*>( | 145 static_cast<TestablePictureImageLayerImpl*>( |
150 host_impl_.active_tree()->root_layer()); | 146 host_impl_.active_tree()->root_layer()); |
151 SetupDrawPropertiesAndUpdateTiles(active_layer, | 147 SetupDrawPropertiesAndUpdateTiles(active_layer, |
152 suggested_ideal_contents_scale, | 148 suggested_ideal_contents_scale, |
153 device_scale_factor, | 149 device_scale_factor, |
154 page_scale_factor, | 150 page_scale_factor, |
155 maximum_animation_contents_scale, | 151 maximum_animation_contents_scale, |
(...skipping 13 matching lines...) Expand all Loading... |
169 active_layer->DidDraw(nullptr); | 165 active_layer->DidDraw(nullptr); |
170 | 166 |
171 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material); | 167 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material); |
172 | 168 |
173 // Tiles are ready at correct scale, so should not set had_incomplete_tile. | 169 // Tiles are ready at correct scale, so should not set had_incomplete_tile. |
174 EXPECT_EQ(0, data.num_incomplete_tiles); | 170 EXPECT_EQ(0, data.num_incomplete_tiles); |
175 } | 171 } |
176 | 172 |
177 } // namespace | 173 } // namespace |
178 } // namespace cc | 174 } // namespace cc |
OLD | NEW |