OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1384 // Since the child layer has a blend mode other than normal, it should get | 1384 // Since the child layer has a blend mode other than normal, it should get |
1385 // its own render surface. Also, layer's draw_properties should contain the | 1385 // its own render surface. Also, layer's draw_properties should contain the |
1386 // default blend mode, since the render surface becomes responsible for | 1386 // default blend mode, since the render surface becomes responsible for |
1387 // applying the blend mode. | 1387 // applying the blend mode. |
1388 ASSERT_TRUE(child->render_surface()); | 1388 ASSERT_TRUE(child->render_surface()); |
1389 EXPECT_EQ(1.0f, child->draw_opacity()); | 1389 EXPECT_EQ(1.0f, child->draw_opacity()); |
1390 EXPECT_EQ(0.5f, child->render_surface()->draw_opacity()); | 1390 EXPECT_EQ(0.5f, child->render_surface()->draw_opacity()); |
1391 EXPECT_EQ(SkXfermode::kSrcOver_Mode, child->draw_blend_mode()); | 1391 EXPECT_EQ(SkXfermode::kSrcOver_Mode, child->draw_blend_mode()); |
1392 } | 1392 } |
1393 | 1393 |
1394 TEST_F(LayerTreeHostCommonTest, RenderSurfaceDrawOpacity) { | |
1395 LayerImpl* root = root_layer(); | |
1396 LayerImpl* surface1 = AddChildToRoot<LayerImpl>(); | |
1397 LayerImpl* not_surface = AddChild<LayerImpl>(surface1); | |
1398 LayerImpl* surface2 = AddChild<LayerImpl>(not_surface); | |
1399 | |
1400 const gfx::Transform identity_matrix; | |
1401 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
1402 gfx::PointF(), gfx::Size(10, 10), true, false, | |
1403 true); | |
1404 SetLayerPropertiesForTesting(surface1, identity_matrix, gfx::Point3F(), | |
1405 gfx::PointF(), gfx::Size(10, 10), true, false, | |
1406 true); | |
1407 SetLayerPropertiesForTesting(not_surface, identity_matrix, gfx::Point3F(), | |
1408 gfx::PointF(), gfx::Size(10, 10), true, false, | |
1409 false); | |
1410 SetLayerPropertiesForTesting(surface2, identity_matrix, gfx::Point3F(), | |
1411 gfx::PointF(), gfx::Size(10, 10), true, false, | |
1412 true); | |
1413 surface1->SetDrawsContent(true); | |
1414 surface2->SetDrawsContent(true); | |
1415 | |
1416 surface1->SetOpacity(0.5f); | |
1417 not_surface->SetOpacity(0.5f); | |
1418 surface2->SetOpacity(0.5f); | |
1419 | |
1420 ExecuteCalculateDrawProperties(root); | |
1421 | |
1422 ASSERT_TRUE(surface1->render_surface()); | |
1423 ASSERT_FALSE(not_surface->render_surface()); | |
1424 ASSERT_TRUE(surface2->render_surface()); | |
1425 EXPECT_EQ(0.5f, surface1->render_surface()->draw_opacity()); | |
1426 // surface2's draw opacity should include the opacity of not-surface and | |
1427 // itself, but not the opacity od surface1. | |
ajuma
2016/01/21 14:20:36
typo: s/od/of
| |
1428 EXPECT_EQ(0.25f, surface2->render_surface()->draw_opacity()); | |
1429 } | |
1430 | |
1394 TEST_F(LayerTreeHostCommonTest, DrawOpacityWhenCannotRenderToSeparateSurface) { | 1431 TEST_F(LayerTreeHostCommonTest, DrawOpacityWhenCannotRenderToSeparateSurface) { |
1395 // Tests that when separate surfaces are disabled, a layer's draw opacity is | 1432 // Tests that when separate surfaces are disabled, a layer's draw opacity is |
1396 // the product of all ancestor layer opacties and the layer's own opacity. | 1433 // the product of all ancestor layer opacties and the layer's own opacity. |
1397 // (Rendering will still be incorrect in situations where we really do need | 1434 // (Rendering will still be incorrect in situations where we really do need |
1398 // surfaces to apply opacity, such as when we have overlapping layers with an | 1435 // surfaces to apply opacity, such as when we have overlapping layers with an |
1399 // ancestor whose opacity is <1.) | 1436 // ancestor whose opacity is <1.) |
1400 LayerImpl* root = root_layer(); | 1437 LayerImpl* root = root_layer(); |
1401 LayerImpl* parent = AddChild<LayerImpl>(root); | 1438 LayerImpl* parent = AddChild<LayerImpl>(root); |
1402 LayerImpl* child1 = AddChild<LayerImpl>(parent); | 1439 LayerImpl* child1 = AddChild<LayerImpl>(parent); |
1403 LayerImpl* child2 = AddChild<LayerImpl>(parent); | 1440 LayerImpl* child2 = AddChild<LayerImpl>(parent); |
(...skipping 8268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9672 proto::ScrollAndScaleSet proto; | 9709 proto::ScrollAndScaleSet proto; |
9673 scroll_and_scale_set.ToProtobuf(&proto); | 9710 scroll_and_scale_set.ToProtobuf(&proto); |
9674 ScrollAndScaleSet new_scroll_and_scale_set; | 9711 ScrollAndScaleSet new_scroll_and_scale_set; |
9675 new_scroll_and_scale_set.FromProtobuf(proto); | 9712 new_scroll_and_scale_set.FromProtobuf(proto); |
9676 | 9713 |
9677 EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set)); | 9714 EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set)); |
9678 } | 9715 } |
9679 | 9716 |
9680 } // namespace | 9717 } // namespace |
9681 } // namespace cc | 9718 } // namespace cc |
OLD | NEW |