OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/solid_color_layer_impl.h" | 7 #include "cc/solid_color_layer_impl.h" |
8 | 8 |
9 #include "cc/append_quads_data.h" | 9 #include "cc/append_quads_data.h" |
10 #include "cc/single_thread_proxy.h" | 10 #include "cc/single_thread_proxy.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 { | 23 { |
24 DebugScopedSetImplThread scopedImplThread; | 24 DebugScopedSetImplThread scopedImplThread; |
25 | 25 |
26 MockQuadCuller quadCuller; | 26 MockQuadCuller quadCuller; |
27 IntSize layerSize = IntSize(800, 600); | 27 IntSize layerSize = IntSize(800, 600); |
28 IntRect visibleContentRect = IntRect(IntPoint(), layerSize); | 28 IntRect visibleContentRect = IntRect(IntPoint(), layerSize); |
29 | 29 |
30 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(1); | 30 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(1); |
31 layer->setVisibleContentRect(visibleContentRect); | 31 layer->setVisibleContentRect(visibleContentRect); |
32 layer->setBounds(layerSize); | 32 layer->setBounds(layerSize); |
33 layer->setContentBounds(layerSize); | |
34 layer->createRenderSurface(); | 33 layer->createRenderSurface(); |
35 layer->setRenderTarget(layer.get()); | 34 layer->setRenderTarget(layer.get()); |
36 | 35 |
37 AppendQuadsData data; | 36 AppendQuadsData data; |
38 layer->appendQuads(quadCuller, data); | 37 layer->appendQuads(quadCuller, data); |
39 | 38 |
40 verifyQuadsExactlyCoverRect(quadCuller.quadList(), visibleContentRect); | 39 verifyQuadsExactlyCoverRect(quadCuller.quadList(), visibleContentRect); |
41 } | 40 } |
42 | 41 |
43 TEST(SolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad) | 42 TEST(SolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad) |
44 { | 43 { |
45 DebugScopedSetImplThread scopedImplThread; | 44 DebugScopedSetImplThread scopedImplThread; |
46 | 45 |
47 SkColor testColor = 0xFFA55AFF; | 46 SkColor testColor = 0xFFA55AFF; |
48 | 47 |
49 MockQuadCuller quadCuller; | 48 MockQuadCuller quadCuller; |
50 IntSize layerSize = IntSize(100, 100); | 49 IntSize layerSize = IntSize(100, 100); |
51 IntRect visibleContentRect = IntRect(IntPoint(), layerSize); | 50 IntRect visibleContentRect = IntRect(IntPoint(), layerSize); |
52 | 51 |
53 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(1); | 52 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(1); |
54 layer->setVisibleContentRect(visibleContentRect); | 53 layer->setVisibleContentRect(visibleContentRect); |
55 layer->setBounds(layerSize); | 54 layer->setBounds(layerSize); |
56 layer->setContentBounds(layerSize); | |
57 layer->setBackgroundColor(testColor); | 55 layer->setBackgroundColor(testColor); |
58 layer->createRenderSurface(); | 56 layer->createRenderSurface(); |
59 layer->setRenderTarget(layer.get()); | 57 layer->setRenderTarget(layer.get()); |
60 | 58 |
61 AppendQuadsData data; | 59 AppendQuadsData data; |
62 layer->appendQuads(quadCuller, data); | 60 layer->appendQuads(quadCuller, data); |
63 | 61 |
64 ASSERT_EQ(quadCuller.quadList().size(), 1U); | 62 ASSERT_EQ(quadCuller.quadList().size(), 1U); |
65 EXPECT_EQ(SolidColorDrawQuad::materialCast(quadCuller.quadList()[0])->color(
), testColor); | 63 EXPECT_EQ(SolidColorDrawQuad::materialCast(quadCuller.quadList()[0])->color(
), testColor); |
66 } | 64 } |
67 | 65 |
68 TEST(SolidColorLayerImplTest, verifyCorrectOpacityInQuad) | 66 TEST(SolidColorLayerImplTest, verifyCorrectOpacityInQuad) |
69 { | 67 { |
70 DebugScopedSetImplThread scopedImplThread; | 68 DebugScopedSetImplThread scopedImplThread; |
71 | 69 |
72 const float opacity = 0.5f; | 70 const float opacity = 0.5f; |
73 | 71 |
74 MockQuadCuller quadCuller; | 72 MockQuadCuller quadCuller; |
75 IntSize layerSize = IntSize(100, 100); | 73 IntSize layerSize = IntSize(100, 100); |
76 IntRect visibleContentRect = IntRect(IntPoint(), layerSize); | 74 IntRect visibleContentRect = IntRect(IntPoint(), layerSize); |
77 | 75 |
78 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(1); | 76 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(1); |
79 layer->setVisibleContentRect(visibleContentRect); | 77 layer->setVisibleContentRect(visibleContentRect); |
80 layer->setBounds(layerSize); | 78 layer->setBounds(layerSize); |
81 layer->setContentBounds(layerSize); | |
82 layer->setDrawOpacity(opacity); | 79 layer->setDrawOpacity(opacity); |
83 layer->createRenderSurface(); | 80 layer->createRenderSurface(); |
84 layer->setRenderTarget(layer.get()); | 81 layer->setRenderTarget(layer.get()); |
85 | 82 |
86 AppendQuadsData data; | 83 AppendQuadsData data; |
87 layer->appendQuads(quadCuller, data); | 84 layer->appendQuads(quadCuller, data); |
88 | 85 |
89 ASSERT_EQ(quadCuller.quadList().size(), 1U); | 86 ASSERT_EQ(quadCuller.quadList().size(), 1U); |
90 EXPECT_EQ(opacity, SolidColorDrawQuad::materialCast(quadCuller.quadList()[0]
)->opacity()); | 87 EXPECT_EQ(opacity, SolidColorDrawQuad::materialCast(quadCuller.quadList()[0]
)->opacity()); |
91 } | 88 } |
92 | 89 |
93 } // namespace | 90 } // namespace |
OLD | NEW |