| 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 <memory> | 10 #include <memory> |
| (...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 | 1573 |
| 1574 root->SetBounds(gfx::Size(10, 10)); | 1574 root->SetBounds(gfx::Size(10, 10)); |
| 1575 child->SetBounds(gfx::Size(10, 10)); | 1575 child->SetBounds(gfx::Size(10, 10)); |
| 1576 child->SetDrawsContent(true); | 1576 child->SetDrawsContent(true); |
| 1577 child->test_properties()->blend_mode = SkBlendMode::kMultiply; | 1577 child->test_properties()->blend_mode = SkBlendMode::kMultiply; |
| 1578 child->test_properties()->opacity = 0.5f; | 1578 child->test_properties()->opacity = 0.5f; |
| 1579 child->test_properties()->force_render_surface = true; | 1579 child->test_properties()->force_render_surface = true; |
| 1580 ExecuteCalculateDrawProperties(root); | 1580 ExecuteCalculateDrawProperties(root); |
| 1581 | 1581 |
| 1582 // Since the child layer has a blend mode other than normal, it should get | 1582 // Since the child layer has a blend mode other than normal, it should get |
| 1583 // its own render surface. Also, layer's draw_properties should contain the | 1583 // its own render surface. |
| 1584 // default blend mode, since the render surface becomes responsible for | |
| 1585 // applying the blend mode. | |
| 1586 ASSERT_TRUE(child->GetRenderSurface()); | 1584 ASSERT_TRUE(child->GetRenderSurface()); |
| 1587 EXPECT_EQ(1.0f, child->draw_opacity()); | 1585 EXPECT_EQ(1.0f, child->draw_opacity()); |
| 1588 EXPECT_EQ(0.5f, child->GetRenderSurface()->draw_opacity()); | 1586 EXPECT_EQ(0.5f, child->GetRenderSurface()->draw_opacity()); |
| 1589 EXPECT_EQ(SkBlendMode::kSrcOver, child->draw_blend_mode()); | 1587 EXPECT_EQ(SkBlendMode::kMultiply, child->GetRenderSurface()->BlendMode()); |
| 1590 } | 1588 } |
| 1591 | 1589 |
| 1592 TEST_F(LayerTreeHostCommonTest, RenderSurfaceDrawOpacity) { | 1590 TEST_F(LayerTreeHostCommonTest, RenderSurfaceDrawOpacity) { |
| 1593 LayerImpl* root = root_layer_for_testing(); | 1591 LayerImpl* root = root_layer_for_testing(); |
| 1594 LayerImpl* surface1 = AddChildToRoot<LayerImpl>(); | 1592 LayerImpl* surface1 = AddChildToRoot<LayerImpl>(); |
| 1595 LayerImpl* not_surface = AddChild<LayerImpl>(surface1); | 1593 LayerImpl* not_surface = AddChild<LayerImpl>(surface1); |
| 1596 LayerImpl* surface2 = AddChild<LayerImpl>(not_surface); | 1594 LayerImpl* surface2 = AddChild<LayerImpl>(not_surface); |
| 1597 | 1595 |
| 1598 root->SetBounds(gfx::Size(10, 10)); | 1596 root->SetBounds(gfx::Size(10, 10)); |
| 1599 surface1->SetBounds(gfx::Size(10, 10)); | 1597 surface1->SetBounds(gfx::Size(10, 10)); |
| (...skipping 9269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10869 | 10867 |
| 10870 // Check child layer draw properties. | 10868 // Check child layer draw properties. |
| 10871 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 10869 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 10872 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); | 10870 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); |
| 10873 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); | 10871 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); |
| 10874 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); | 10872 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); |
| 10875 } | 10873 } |
| 10876 | 10874 |
| 10877 } // namespace | 10875 } // namespace |
| 10878 } // namespace cc | 10876 } // namespace cc |
| OLD | NEW |