Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1333)

Side by Side Diff: cc/solid_color_layer_impl_unittest.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/solid_color_layer_impl.cc ('k') | cc/test/animation_test_common.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/solid_color_layer_impl.h" 5 #include "cc/solid_color_layer_impl.h"
6 6
7 #include "cc/append_quads_data.h" 7 #include "cc/append_quads_data.h"
8 #include "cc/single_thread_proxy.h" 8 #include "cc/single_thread_proxy.h"
9 #include "cc/solid_color_draw_quad.h" 9 #include "cc/solid_color_draw_quad.h"
10 #include "cc/solid_color_layer.h" 10 #include "cc/solid_color_layer.h"
11 #include "cc/test/fake_impl_proxy.h" 11 #include "cc/test/fake_impl_proxy.h"
12 #include "cc/test/fake_layer_tree_host_impl.h" 12 #include "cc/test/fake_layer_tree_host_impl.h"
13 #include "cc/test/layer_test_common.h" 13 #include "cc/test/layer_test_common.h"
14 #include "cc/test/mock_quad_culler.h" 14 #include "cc/test/mock_quad_culler.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace cc { 18 namespace cc {
19 namespace { 19 namespace {
20 20
21 TEST(SolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap) 21 TEST(SolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap)
22 { 22 {
23 MockQuadCuller quadCuller; 23 MockQuadCuller quadCuller;
24 gfx::Size layerSize = gfx::Size(800, 600); 24 gfx::Size layerSize = gfx::Size(800, 600);
25 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); 25 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize);
26 26
27 FakeImplProxy proxy; 27 FakeImplProxy proxy;
28 FakeLayerTreeHostImpl hostImpl(&proxy); 28 FakeLayerTreeHostImpl hostImpl(&proxy);
29 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::Create(hostImpl .activeTree(), 1); 29 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::Create(hostImpl .activeTree(), 1);
30 layer->drawProperties().visible_content_rect = visibleContentRect; 30 layer->draw_properties().visible_content_rect = visibleContentRect;
31 layer->setBounds(layerSize); 31 layer->SetBounds(layerSize);
32 layer->setContentBounds(layerSize); 32 layer->SetContentBounds(layerSize);
33 layer->createRenderSurface(); 33 layer->CreateRenderSurface();
34 layer->drawProperties().render_target = layer.get(); 34 layer->draw_properties().render_target = layer.get();
35 35
36 AppendQuadsData data; 36 AppendQuadsData data;
37 layer->appendQuads(quadCuller, data); 37 layer->AppendQuads(&quadCuller, &data);
38 38
39 LayerTestCommon::verifyQuadsExactlyCoverRect(quadCuller.quadList(), visibleC ontentRect); 39 LayerTestCommon::verifyQuadsExactlyCoverRect(quadCuller.quadList(), visibleC ontentRect);
40 } 40 }
41 41
42 TEST(SolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad) 42 TEST(SolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad)
43 { 43 {
44 SkColor testColor = 0xFFA55AFF; 44 SkColor testColor = 0xFFA55AFF;
45 45
46 MockQuadCuller quadCuller; 46 MockQuadCuller quadCuller;
47 gfx::Size layerSize = gfx::Size(100, 100); 47 gfx::Size layerSize = gfx::Size(100, 100);
48 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); 48 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize);
49 49
50 FakeImplProxy proxy; 50 FakeImplProxy proxy;
51 FakeLayerTreeHostImpl hostImpl(&proxy); 51 FakeLayerTreeHostImpl hostImpl(&proxy);
52 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::Create(hostImpl .activeTree(), 1); 52 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::Create(hostImpl .activeTree(), 1);
53 layer->drawProperties().visible_content_rect = visibleContentRect; 53 layer->draw_properties().visible_content_rect = visibleContentRect;
54 layer->setBounds(layerSize); 54 layer->SetBounds(layerSize);
55 layer->setContentBounds(layerSize); 55 layer->SetContentBounds(layerSize);
56 layer->setBackgroundColor(testColor); 56 layer->SetBackgroundColor(testColor);
57 layer->createRenderSurface(); 57 layer->CreateRenderSurface();
58 layer->drawProperties().render_target = layer.get(); 58 layer->draw_properties().render_target = layer.get();
59 59
60 AppendQuadsData data; 60 AppendQuadsData data;
61 layer->appendQuads(quadCuller, data); 61 layer->AppendQuads(&quadCuller, &data);
62 62
63 ASSERT_EQ(quadCuller.quadList().size(), 1U); 63 ASSERT_EQ(quadCuller.quadList().size(), 1U);
64 EXPECT_EQ(SolidColorDrawQuad::MaterialCast(quadCuller.quadList()[0])->color, testColor); 64 EXPECT_EQ(SolidColorDrawQuad::MaterialCast(quadCuller.quadList()[0])->color, testColor);
65 } 65 }
66 66
67 TEST(SolidColorLayerImplTest, verifyCorrectOpacityInQuad) 67 TEST(SolidColorLayerImplTest, verifyCorrectOpacityInQuad)
68 { 68 {
69 const float opacity = 0.5f; 69 const float opacity = 0.5f;
70 70
71 MockQuadCuller quadCuller; 71 MockQuadCuller quadCuller;
72 gfx::Size layerSize = gfx::Size(100, 100); 72 gfx::Size layerSize = gfx::Size(100, 100);
73 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); 73 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize);
74 74
75 FakeImplProxy proxy; 75 FakeImplProxy proxy;
76 FakeLayerTreeHostImpl hostImpl(&proxy); 76 FakeLayerTreeHostImpl hostImpl(&proxy);
77 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::Create(hostImpl .activeTree(), 1); 77 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::Create(hostImpl .activeTree(), 1);
78 layer->drawProperties().visible_content_rect = visibleContentRect; 78 layer->draw_properties().visible_content_rect = visibleContentRect;
79 layer->setBounds(layerSize); 79 layer->SetBounds(layerSize);
80 layer->setContentBounds(layerSize); 80 layer->SetContentBounds(layerSize);
81 layer->drawProperties().opacity = opacity; 81 layer->draw_properties().opacity = opacity;
82 layer->createRenderSurface(); 82 layer->CreateRenderSurface();
83 layer->drawProperties().render_target = layer.get(); 83 layer->draw_properties().render_target = layer.get();
84 84
85 AppendQuadsData data; 85 AppendQuadsData data;
86 layer->appendQuads(quadCuller, data); 86 layer->AppendQuads(&quadCuller, &data);
87 87
88 ASSERT_EQ(quadCuller.quadList().size(), 1U); 88 ASSERT_EQ(quadCuller.quadList().size(), 1U);
89 EXPECT_EQ(opacity, SolidColorDrawQuad::MaterialCast(quadCuller.quadList()[0] )->opacity()); 89 EXPECT_EQ(opacity, SolidColorDrawQuad::MaterialCast(quadCuller.quadList()[0] )->opacity());
90 } 90 }
91 91
92 TEST(SolidColorLayerImplTest, verifyOpaqueRect) 92 TEST(SolidColorLayerImplTest, verifyOpaqueRect)
93 { 93 {
94 FakeImplProxy proxy; 94 FakeImplProxy proxy;
95 FakeLayerTreeHostImpl hostImpl(&proxy); 95 FakeLayerTreeHostImpl hostImpl(&proxy);
96 96
97 gfx::Size layerSize = gfx::Size(100, 100); 97 gfx::Size layerSize = gfx::Size(100, 100);
98 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); 98 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize);
99 99
100 scoped_refptr<SolidColorLayer> layer = SolidColorLayer::Create(); 100 scoped_refptr<SolidColorLayer> layer = SolidColorLayer::Create();
101 layer->setBounds(layerSize); 101 layer->SetBounds(layerSize);
102 layer->setForceRenderSurface(true); 102 layer->SetForceRenderSurface(true);
103 103
104 scoped_refptr<Layer> root = Layer::create(); 104 scoped_refptr<Layer> root = Layer::Create();
105 root->addChild(layer); 105 root->AddChild(layer);
106 106
107 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 107 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
108 LayerTreeHostCommon::calculateDrawProperties( 108 LayerTreeHostCommon::calculateDrawProperties(
109 root, 109 root,
110 gfx::Size(500, 500), 110 gfx::Size(500, 500),
111 1, 111 1,
112 1, 112 1,
113 1024, 113 1024,
114 false, 114 false,
115 renderSurfaceLayerList); 115 renderSurfaceLayerList);
116 116
117 EXPECT_FALSE(layer->contentsOpaque()); 117 EXPECT_FALSE(layer->contents_opaque());
118 layer->setBackgroundColor(SkColorSetARGBInline(255, 10, 20, 30)); 118 layer->SetBackgroundColor(SkColorSetARGBInline(255, 10, 20, 30));
119 EXPECT_TRUE(layer->contentsOpaque()); 119 EXPECT_TRUE(layer->contents_opaque());
120 120
121 { 121 {
122 scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::Create( hostImpl.activeTree(), layer->id()); 122 scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::Create( hostImpl.activeTree(), layer->id());
123 layer->pushPropertiesTo(layerImpl.get()); 123 layer->PushPropertiesTo(layerImpl.get());
124 124
125 // The impl layer should call itself opaque as well. 125 // The impl layer should call itself opaque as well.
126 EXPECT_TRUE(layerImpl->contentsOpaque()); 126 EXPECT_TRUE(layerImpl->contents_opaque());
127 127
128 // Impl layer has 1 opacity, and the color is opaque, so the opaqueRect should be the full tile. 128 // Impl layer has 1 opacity, and the color is opaque, so the opaqueRect should be the full tile.
129 layerImpl->drawProperties().opacity = 1; 129 layerImpl->draw_properties().opacity = 1;
130 130
131 MockQuadCuller quadCuller; 131 MockQuadCuller quadCuller;
132 AppendQuadsData data; 132 AppendQuadsData data;
133 layerImpl->appendQuads(quadCuller, data); 133 layerImpl->AppendQuads(&quadCuller, &data);
134 134
135 ASSERT_EQ(quadCuller.quadList().size(), 1U); 135 ASSERT_EQ(quadCuller.quadList().size(), 1U);
136 EXPECT_EQ(visibleContentRect.ToString(), quadCuller.quadList()[0]->opaqu e_rect.ToString()); 136 EXPECT_EQ(visibleContentRect.ToString(), quadCuller.quadList()[0]->opaqu e_rect.ToString());
137 } 137 }
138 138
139 EXPECT_TRUE(layer->contentsOpaque()); 139 EXPECT_TRUE(layer->contents_opaque());
140 layer->setBackgroundColor(SkColorSetARGBInline(254, 10, 20, 30)); 140 layer->SetBackgroundColor(SkColorSetARGBInline(254, 10, 20, 30));
141 EXPECT_FALSE(layer->contentsOpaque()); 141 EXPECT_FALSE(layer->contents_opaque());
142 142
143 { 143 {
144 scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::Create( hostImpl.activeTree(), layer->id()); 144 scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::Create( hostImpl.activeTree(), layer->id());
145 layer->pushPropertiesTo(layerImpl.get()); 145 layer->PushPropertiesTo(layerImpl.get());
146 146
147 // The impl layer should callnot itself opaque anymore. 147 // The impl layer should callnot itself opaque anymore.
148 EXPECT_FALSE(layerImpl->contentsOpaque()); 148 EXPECT_FALSE(layerImpl->contents_opaque());
149 149
150 // Impl layer has 1 opacity, but the color is not opaque, so the opaque_ rect should be empty. 150 // Impl layer has 1 opacity, but the color is not opaque, so the opaque_ rect should be empty.
151 layerImpl->drawProperties().opacity = 1; 151 layerImpl->draw_properties().opacity = 1;
152 152
153 MockQuadCuller quadCuller; 153 MockQuadCuller quadCuller;
154 AppendQuadsData data; 154 AppendQuadsData data;
155 layerImpl->appendQuads(quadCuller, data); 155 layerImpl->AppendQuads(&quadCuller, &data);
156 156
157 ASSERT_EQ(quadCuller.quadList().size(), 1U); 157 ASSERT_EQ(quadCuller.quadList().size(), 1U);
158 EXPECT_EQ(gfx::Rect().ToString(), quadCuller.quadList()[0]->opaque_rect. ToString()); 158 EXPECT_EQ(gfx::Rect().ToString(), quadCuller.quadList()[0]->opaque_rect. ToString());
159 } 159 }
160 } 160 }
161 161
162 } // namespace 162 } // namespace
163 } // namespace cc 163 } // namespace cc
OLDNEW
« no previous file with comments | « cc/solid_color_layer_impl.cc ('k') | cc/test/animation_test_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698