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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include "cc/animation/keyframed_animation_curve.h" | 7 #include "cc/animation/keyframed_animation_curve.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/base/thread.h" | 9 #include "cc/base/thread.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(settings); | 969 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(settings); |
970 layer_tree_host->SetRootLayer(layer); | 970 layer_tree_host->SetRootLayer(layer); |
971 layer->SetLayerTreeHost(layer_tree_host.get()); | 971 layer->SetLayerTreeHost(layer_tree_host.get()); |
972 AssertLayerTreeHostMatchesForSubtree(layer.get(), layer_tree_host.get()); | 972 AssertLayerTreeHostMatchesForSubtree(layer.get(), layer_tree_host.get()); |
973 | 973 |
974 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the | 974 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the |
975 // animation should be rejected. | 975 // animation should be rejected. |
976 EXPECT_FALSE(AddTestAnimation(layer.get())); | 976 EXPECT_FALSE(AddTestAnimation(layer.get())); |
977 } | 977 } |
978 | 978 |
| 979 TEST_F(LayerTest, SafeOpaqueBackgroundColor) { |
| 980 LayerTreeHostFactory factory; |
| 981 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
| 982 |
| 983 scoped_refptr<Layer> layer = Layer::Create(); |
| 984 layer_tree_host->SetRootLayer(layer); |
| 985 |
| 986 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { |
| 987 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { |
| 988 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { |
| 989 layer->SetContentsOpaque(!!contents_opaque); |
| 990 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED |
| 991 : SK_ColorTRANSPARENT); |
| 992 layer_tree_host->set_background_color( |
| 993 host_opaque ? SK_ColorRED : SK_ColorTRANSPARENT); |
| 994 |
| 995 SkColor safe_color = layer->SafeOpaqueBackgroundColor(); |
| 996 if (contents_opaque) { |
| 997 EXPECT_EQ(SkColorGetA(safe_color), 255u) |
| 998 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " |
| 999 << host_opaque << "\n"; |
| 1000 } else { |
| 1001 EXPECT_NE(SkColorGetA(safe_color), 255u) |
| 1002 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " |
| 1003 << host_opaque << "\n"; |
| 1004 } |
| 1005 } |
| 1006 } |
| 1007 } |
| 1008 } |
| 1009 |
979 } // namespace | 1010 } // namespace |
980 } // namespace cc | 1011 } // namespace cc |
OLD | NEW |