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

Side by Side Diff: cc/solid_color_layer_impl_unittest.cc

Issue 11519018: [cc] Make LayerImpls point at LayerTreeImpl instead of LTHI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
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"
(...skipping 10 matching lines...) Expand all
21 namespace { 21 namespace {
22 22
23 TEST(SolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap) 23 TEST(SolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap)
24 { 24 {
25 MockQuadCuller quadCuller; 25 MockQuadCuller quadCuller;
26 gfx::Size layerSize = gfx::Size(800, 600); 26 gfx::Size layerSize = gfx::Size(800, 600);
27 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); 27 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize);
28 28
29 FakeImplProxy proxy; 29 FakeImplProxy proxy;
30 FakeLayerTreeHostImpl hostImpl(&proxy); 30 FakeLayerTreeHostImpl hostImpl(&proxy);
31 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(&hostImp l, 1); 31 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(hostImpl .activeTree(), 1);
32 layer->drawProperties().visible_content_rect = visibleContentRect; 32 layer->drawProperties().visible_content_rect = visibleContentRect;
33 layer->setBounds(layerSize); 33 layer->setBounds(layerSize);
34 layer->setContentBounds(layerSize); 34 layer->setContentBounds(layerSize);
35 layer->createRenderSurface(); 35 layer->createRenderSurface();
36 layer->drawProperties().render_target = layer.get(); 36 layer->drawProperties().render_target = layer.get();
37 37
38 AppendQuadsData data; 38 AppendQuadsData data;
39 layer->appendQuads(quadCuller, data); 39 layer->appendQuads(quadCuller, data);
40 40
41 verifyQuadsExactlyCoverRect(quadCuller.quadList(), visibleContentRect); 41 verifyQuadsExactlyCoverRect(quadCuller.quadList(), visibleContentRect);
42 } 42 }
43 43
44 TEST(SolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad) 44 TEST(SolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad)
45 { 45 {
46 SkColor testColor = 0xFFA55AFF; 46 SkColor testColor = 0xFFA55AFF;
47 47
48 MockQuadCuller quadCuller; 48 MockQuadCuller quadCuller;
49 gfx::Size layerSize = gfx::Size(100, 100); 49 gfx::Size layerSize = gfx::Size(100, 100);
50 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); 50 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize);
51 51
52 FakeImplProxy proxy; 52 FakeImplProxy proxy;
53 FakeLayerTreeHostImpl hostImpl(&proxy); 53 FakeLayerTreeHostImpl hostImpl(&proxy);
54 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(&hostImp l, 1); 54 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(hostImpl .activeTree(), 1);
55 layer->drawProperties().visible_content_rect = visibleContentRect; 55 layer->drawProperties().visible_content_rect = visibleContentRect;
56 layer->setBounds(layerSize); 56 layer->setBounds(layerSize);
57 layer->setContentBounds(layerSize); 57 layer->setContentBounds(layerSize);
58 layer->setBackgroundColor(testColor); 58 layer->setBackgroundColor(testColor);
59 layer->createRenderSurface(); 59 layer->createRenderSurface();
60 layer->drawProperties().render_target = layer.get(); 60 layer->drawProperties().render_target = layer.get();
61 61
62 AppendQuadsData data; 62 AppendQuadsData data;
63 layer->appendQuads(quadCuller, data); 63 layer->appendQuads(quadCuller, data);
64 64
65 ASSERT_EQ(quadCuller.quadList().size(), 1U); 65 ASSERT_EQ(quadCuller.quadList().size(), 1U);
66 EXPECT_EQ(SolidColorDrawQuad::MaterialCast(quadCuller.quadList()[0])->color, testColor); 66 EXPECT_EQ(SolidColorDrawQuad::MaterialCast(quadCuller.quadList()[0])->color, testColor);
67 } 67 }
68 68
69 TEST(SolidColorLayerImplTest, verifyCorrectOpacityInQuad) 69 TEST(SolidColorLayerImplTest, verifyCorrectOpacityInQuad)
70 { 70 {
71 const float opacity = 0.5f; 71 const float opacity = 0.5f;
72 72
73 MockQuadCuller quadCuller; 73 MockQuadCuller quadCuller;
74 gfx::Size layerSize = gfx::Size(100, 100); 74 gfx::Size layerSize = gfx::Size(100, 100);
75 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); 75 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize);
76 76
77 FakeImplProxy proxy; 77 FakeImplProxy proxy;
78 FakeLayerTreeHostImpl hostImpl(&proxy); 78 FakeLayerTreeHostImpl hostImpl(&proxy);
79 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(&hostImp l, 1); 79 scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::create(hostImpl .activeTree(), 1);
80 layer->drawProperties().visible_content_rect = visibleContentRect; 80 layer->drawProperties().visible_content_rect = visibleContentRect;
81 layer->setBounds(layerSize); 81 layer->setBounds(layerSize);
82 layer->setContentBounds(layerSize); 82 layer->setContentBounds(layerSize);
83 layer->drawProperties().opacity = opacity; 83 layer->drawProperties().opacity = opacity;
84 layer->createRenderSurface(); 84 layer->createRenderSurface();
85 layer->drawProperties().render_target = layer.get(); 85 layer->drawProperties().render_target = layer.get();
86 86
87 AppendQuadsData data; 87 AppendQuadsData data;
88 layer->appendQuads(quadCuller, data); 88 layer->appendQuads(quadCuller, data);
89 89
(...skipping 13 matching lines...) Expand all
103 layer->drawProperties().visible_content_rect = visibleContentRect; 103 layer->drawProperties().visible_content_rect = visibleContentRect;
104 layer->setBounds(layerSize); 104 layer->setBounds(layerSize);
105 layer->createRenderSurface(); 105 layer->createRenderSurface();
106 layer->drawProperties().render_target = layer.get(); 106 layer->drawProperties().render_target = layer.get();
107 107
108 EXPECT_FALSE(layer->contentsOpaque()); 108 EXPECT_FALSE(layer->contentsOpaque());
109 layer->setBackgroundColor(SkColorSetARGBInline(255, 10, 20, 30)); 109 layer->setBackgroundColor(SkColorSetARGBInline(255, 10, 20, 30));
110 EXPECT_TRUE(layer->contentsOpaque()); 110 EXPECT_TRUE(layer->contentsOpaque());
111 111
112 { 112 {
113 scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::create( &hostImpl, layer->id()); 113 scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::create( hostImpl.activeTree(), layer->id());
114 layer->pushPropertiesTo(layerImpl.get()); 114 layer->pushPropertiesTo(layerImpl.get());
115 115
116 // The impl layer should call itself opaque as well. 116 // The impl layer should call itself opaque as well.
117 EXPECT_TRUE(layerImpl->contentsOpaque()); 117 EXPECT_TRUE(layerImpl->contentsOpaque());
118 118
119 // Impl layer has 1 opacity, and the color is opaque, so the opaqueRect should be the full tile. 119 // Impl layer has 1 opacity, and the color is opaque, so the opaqueRect should be the full tile.
120 layerImpl->drawProperties().opacity = 1; 120 layerImpl->drawProperties().opacity = 1;
121 121
122 MockQuadCuller quadCuller; 122 MockQuadCuller quadCuller;
123 AppendQuadsData data; 123 AppendQuadsData data;
124 layerImpl->appendQuads(quadCuller, data); 124 layerImpl->appendQuads(quadCuller, data);
125 125
126 ASSERT_EQ(quadCuller.quadList().size(), 1U); 126 ASSERT_EQ(quadCuller.quadList().size(), 1U);
127 EXPECT_EQ(visibleContentRect.ToString(), quadCuller.quadList()[0]->opaqu e_rect.ToString()); 127 EXPECT_EQ(visibleContentRect.ToString(), quadCuller.quadList()[0]->opaqu e_rect.ToString());
128 } 128 }
129 129
130 EXPECT_TRUE(layer->contentsOpaque()); 130 EXPECT_TRUE(layer->contentsOpaque());
131 layer->setBackgroundColor(SkColorSetARGBInline(254, 10, 20, 30)); 131 layer->setBackgroundColor(SkColorSetARGBInline(254, 10, 20, 30));
132 EXPECT_FALSE(layer->contentsOpaque()); 132 EXPECT_FALSE(layer->contentsOpaque());
133 133
134 { 134 {
135 scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::create( &hostImpl, layer->id()); 135 scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::create( hostImpl.activeTree(), layer->id());
136 layer->pushPropertiesTo(layerImpl.get()); 136 layer->pushPropertiesTo(layerImpl.get());
137 137
138 // The impl layer should callnot itself opaque anymore. 138 // The impl layer should callnot itself opaque anymore.
139 EXPECT_FALSE(layerImpl->contentsOpaque()); 139 EXPECT_FALSE(layerImpl->contentsOpaque());
140 140
141 // Impl layer has 1 opacity, but the color is not opaque, so the opaque_ rect should be empty. 141 // Impl layer has 1 opacity, but the color is not opaque, so the opaque_ rect should be empty.
142 layerImpl->drawProperties().opacity = 1; 142 layerImpl->drawProperties().opacity = 1;
143 143
144 MockQuadCuller quadCuller; 144 MockQuadCuller quadCuller;
145 AppendQuadsData data; 145 AppendQuadsData data;
146 layerImpl->appendQuads(quadCuller, data); 146 layerImpl->appendQuads(quadCuller, data);
147 147
148 ASSERT_EQ(quadCuller.quadList().size(), 1U); 148 ASSERT_EQ(quadCuller.quadList().size(), 1U);
149 EXPECT_EQ(gfx::Rect().ToString(), quadCuller.quadList()[0]->opaque_rect. ToString()); 149 EXPECT_EQ(gfx::Rect().ToString(), quadCuller.quadList()[0]->opaque_rect. ToString());
150 } 150 }
151 } 151 }
152 152
153 } // namespace 153 } // namespace
154 } // namespace cc 154 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698