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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 // Since the layer is transparent, render_surface1->render_surface() should | 1385 // Since the layer is transparent, render_surface1->render_surface() should |
1386 // not have gotten added anywhere. Also, the drawable content rect should not | 1386 // not have gotten added anywhere. Also, the drawable content rect should not |
1387 // have been extended by the children. | 1387 // have been extended by the children. |
1388 ASSERT_TRUE(parent->render_surface()); | 1388 ASSERT_TRUE(parent->render_surface()); |
1389 EXPECT_EQ(0U, parent->render_surface()->layer_list().size()); | 1389 EXPECT_EQ(0U, parent->render_surface()->layer_list().size()); |
1390 EXPECT_EQ(1U, render_surface_layer_list.size()); | 1390 EXPECT_EQ(1U, render_surface_layer_list.size()); |
1391 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); | 1391 EXPECT_EQ(parent->id(), render_surface_layer_list.at(0)->id()); |
1392 EXPECT_EQ(gfx::Rect(), parent->drawable_content_rect()); | 1392 EXPECT_EQ(gfx::Rect(), parent->drawable_content_rect()); |
1393 } | 1393 } |
1394 | 1394 |
| 1395 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) { |
| 1396 scoped_refptr<Layer> parent = Layer::Create(); |
| 1397 scoped_refptr<LayerWithForcedDrawsContent> child = |
| 1398 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 1399 |
| 1400 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
| 1401 host->SetRootLayer(parent); |
| 1402 |
| 1403 const gfx::Transform identity_matrix; |
| 1404 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; |
| 1405 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
| 1406 gfx::PointF(), gfx::Size(10, 10), true, false); |
| 1407 |
| 1408 parent->AddChild(child); |
| 1409 child->SetBlendMode(blend_mode); |
| 1410 |
| 1411 RenderSurfaceLayerList render_surface_layer_list; |
| 1412 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
| 1413 parent.get(), parent->bounds(), &render_surface_layer_list); |
| 1414 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 1415 |
| 1416 // Since the child layer has a blend mode other than normal, it should get |
| 1417 // its own render surface. Also, layer's draw_properties should contain the |
| 1418 // default blend mode, since the render surface becomes responsible for |
| 1419 // applying the blend mode. |
| 1420 ASSERT_TRUE(child->render_surface()); |
| 1421 EXPECT_EQ(1U, child->render_surface()->layer_list().size()); |
| 1422 EXPECT_EQ(SkXfermode::kSrcOver_Mode, child->draw_properties().blend_mode); |
| 1423 } |
| 1424 |
1395 TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) { | 1425 TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) { |
1396 scoped_refptr<Layer> parent = Layer::Create(); | 1426 scoped_refptr<Layer> parent = Layer::Create(); |
1397 scoped_refptr<Layer> render_surface1 = Layer::Create(); | 1427 scoped_refptr<Layer> render_surface1 = Layer::Create(); |
1398 scoped_refptr<LayerWithForcedDrawsContent> child = | 1428 scoped_refptr<LayerWithForcedDrawsContent> child = |
1399 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 1429 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
1400 render_surface1->SetForceRenderSurface(true); | 1430 render_surface1->SetForceRenderSurface(true); |
1401 | 1431 |
1402 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 1432 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
1403 host->SetRootLayer(parent); | 1433 host->SetRootLayer(parent); |
1404 | 1434 |
(...skipping 7152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8557 // by the viewport. | 8587 // by the viewport. |
8558 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); | 8588 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); |
8559 | 8589 |
8560 // Layers drawing to a child render surface should still have their visible | 8590 // Layers drawing to a child render surface should still have their visible |
8561 // content rect clipped by the viewport. | 8591 // content rect clipped by the viewport. |
8562 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); | 8592 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); |
8563 } | 8593 } |
8564 | 8594 |
8565 } // namespace | 8595 } // namespace |
8566 } // namespace cc | 8596 } // namespace cc |
OLD | NEW |