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

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

Issue 2880023002: cc::SurfaceDependencyTracker should not crash when a Display goes away (Closed)
Patch Set: Fix LayerTreeHostImpl unit tests Created 3 years, 7 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/surface_layer_impl.cc ('k') | cc/scheduler/begin_frame_source_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/surface_layer_impl.h" 5 #include "cc/layers/surface_layer_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/layers/append_quads_data.h" 9 #include "cc/layers/append_quads_data.h"
10 #include "cc/test/layer_test_common.h" 10 #include "cc/test/layer_test_common.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 EXPECT_EQ(1u, partially_occluded_count); 140 EXPECT_EQ(1u, partially_occluded_count);
141 } 141 }
142 } 142 }
143 143
144 TEST(SurfaceLayerImplTest, SurfaceStretchedToLayerBounds) { 144 TEST(SurfaceLayerImplTest, SurfaceStretchedToLayerBounds) {
145 LayerTestCommon::LayerImplTest impl; 145 LayerTestCommon::LayerImplTest impl;
146 SurfaceLayerImpl* surface_layer_impl = 146 SurfaceLayerImpl* surface_layer_impl =
147 impl.AddChildToRoot<SurfaceLayerImpl>(); 147 impl.AddChildToRoot<SurfaceLayerImpl>();
148 const LocalSurfaceId kArbitraryLocalSurfaceId( 148 const LocalSurfaceId kArbitraryLocalSurfaceId(
149 9, base::UnguessableToken::Create()); 149 9, base::UnguessableToken::Create());
150 const LocalSurfaceId kArbitraryLocalSurfaceId2(
151 10, base::UnguessableToken::Create());
150 152
151 // Given condition: layer and surface have different size and different 153 // Given condition: layer and surface have different size and different
152 // aspect ratios. 154 // aspect ratios.
153 gfx::Size layer_size(400, 100); 155 gfx::Size layer_size(400, 100);
154 gfx::Size surface_size(300, 300); 156 gfx::Size surface_size(300, 300);
155 gfx::Size viewport_size(1000, 1000); 157 gfx::Size viewport_size(1000, 1000);
156 float surface_scale = 1.f; 158 float surface_scale = 1.f;
157 gfx::Transform target_space_transform( 159 gfx::Transform target_space_transform(
158 surface_layer_impl->draw_properties().target_space_transform); 160 surface_layer_impl->draw_properties().target_space_transform);
159 161
160 // The following code is mimicking the PushPropertiesTo from pending to 162 // The following code is mimicking the PushPropertiesTo from pending to
161 // active tree. 163 // active tree.
162 surface_layer_impl->SetBounds(layer_size); 164 surface_layer_impl->SetBounds(layer_size);
163 surface_layer_impl->SetDrawsContent(true); 165 surface_layer_impl->SetDrawsContent(true);
164 SurfaceId surface_id(kArbitraryFrameSinkId, kArbitraryLocalSurfaceId); 166 SurfaceId surface_id(kArbitraryFrameSinkId, kArbitraryLocalSurfaceId);
167 SurfaceId surface_id2(kArbitraryFrameSinkId, kArbitraryLocalSurfaceId2);
165 surface_layer_impl->SetPrimarySurfaceInfo( 168 surface_layer_impl->SetPrimarySurfaceInfo(
166 SurfaceInfo(surface_id, surface_scale, surface_size)); 169 SurfaceInfo(surface_id, surface_scale, surface_size));
170 surface_layer_impl->SetFallbackSurfaceInfo(
171 SurfaceInfo(surface_id2, surface_scale, surface_size));
167 surface_layer_impl->SetStretchContentToFillBounds(true); 172 surface_layer_impl->SetStretchContentToFillBounds(true);
168 173
169 impl.CalcDrawProps(viewport_size); 174 impl.CalcDrawProps(viewport_size);
170 175
171 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); 176 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
172 AppendQuadsData data; 177 AppendQuadsData data;
173 surface_layer_impl->AppendQuads(render_pass.get(), &data); 178 surface_layer_impl->AppendQuads(render_pass.get(), &data);
174 EXPECT_THAT(data.activation_dependencies, UnorderedElementsAre(surface_id)); 179 EXPECT_THAT(data.activation_dependencies, UnorderedElementsAre(surface_id));
175 180
176 const QuadList& quads = render_pass->quad_list; 181 const QuadList& quads = render_pass->quad_list;
177 ASSERT_EQ(1u, quads.size()); 182 ASSERT_EQ(2u, quads.size());
178 const SharedQuadState* shared_quad_state = quads.front()->shared_quad_state; 183 const SharedQuadState* shared_quad_state = quads.front()->shared_quad_state;
179 184
180 // We expect that the transform for the quad stretches the quad to cover the 185 // We expect that the transform for the quad stretches the quad to cover the
181 // entire bounds of the layer. 186 // entire bounds of the layer.
182 gfx::Transform expected_transform(target_space_transform); 187 gfx::Transform expected_transform(target_space_transform);
183 float scale_x = static_cast<float>(surface_size.width()) / layer_size.width(); 188 float scale_x = static_cast<float>(surface_size.width()) / layer_size.width();
184 float scale_y = 189 float scale_y =
185 static_cast<float>(surface_size.height()) / layer_size.height(); 190 static_cast<float>(surface_size.height()) / layer_size.height();
186 expected_transform.Scale(SK_MScalar1 / scale_x, SK_MScalar1 / scale_y); 191 expected_transform.Scale(SK_MScalar1 / scale_x, SK_MScalar1 / scale_y);
187 EXPECT_EQ(expected_transform, shared_quad_state->quad_to_target_transform); 192 EXPECT_EQ(expected_transform, shared_quad_state->quad_to_target_transform);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 ASSERT_TRUE(surface_draw_quad1); 346 ASSERT_TRUE(surface_draw_quad1);
342 347
343 EXPECT_EQ(SurfaceDrawQuadType::PRIMARY, 348 EXPECT_EQ(SurfaceDrawQuadType::PRIMARY,
344 surface_draw_quad1->surface_draw_quad_type); 349 surface_draw_quad1->surface_draw_quad_type);
345 EXPECT_EQ(surface_id1, surface_draw_quad1->surface_id); 350 EXPECT_EQ(surface_id1, surface_draw_quad1->surface_id);
346 EXPECT_FALSE(surface_draw_quad1->fallback_quad); 351 EXPECT_FALSE(surface_draw_quad1->fallback_quad);
347 } 352 }
348 353
349 } // namespace 354 } // namespace
350 } // namespace cc 355 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/surface_layer_impl.cc ('k') | cc/scheduler/begin_frame_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698