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 11360145: cc: The SolidColorLayer should report contentsOpaque() true when its color is opaque (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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.cc ('k') | no next file » | 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 "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"
11 #include "cc/solid_color_draw_quad.h" 11 #include "cc/solid_color_draw_quad.h"
12 #include "cc/solid_color_layer.h"
12 #include "cc/test/layer_test_common.h" 13 #include "cc/test/layer_test_common.h"
13 #include "cc/test/mock_quad_culler.h" 14 #include "cc/test/mock_quad_culler.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 using namespace cc; 18 using namespace cc;
18 using namespace LayerTestCommon; 19 using namespace LayerTestCommon;
19 20
20 namespace { 21 namespace {
21 22
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 layer->createRenderSurface(); 84 layer->createRenderSurface();
84 layer->setRenderTarget(layer.get()); 85 layer->setRenderTarget(layer.get());
85 86
86 AppendQuadsData data; 87 AppendQuadsData data;
87 layer->appendQuads(quadCuller, data); 88 layer->appendQuads(quadCuller, data);
88 89
89 ASSERT_EQ(quadCuller.quadList().size(), 1U); 90 ASSERT_EQ(quadCuller.quadList().size(), 1U);
90 EXPECT_EQ(opacity, SolidColorDrawQuad::materialCast(quadCuller.quadList()[0] )->opacity()); 91 EXPECT_EQ(opacity, SolidColorDrawQuad::materialCast(quadCuller.quadList()[0] )->opacity());
91 } 92 }
92 93
94 TEST(SolidColorLayerImplTest, verifyOpaqueRect)
95 {
96 scoped_refptr<SolidColorLayer> layer = SolidColorLayer::create();
97 gfx::Size layerSize = gfx::Size(100, 100);
98 gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize);
99
100 layer->setVisibleContentRect(visibleContentRect);
101 layer->setBounds(layerSize);
102 layer->createRenderSurface();
103 layer->setRenderTarget(layer.get());
104
105 EXPECT_FALSE(layer->contentsOpaque());
106 layer->setBackgroundColor(SkColorSetARGBInline(255, 10, 20, 30));
107 EXPECT_TRUE(layer->contentsOpaque());
108
109 {
110 DebugScopedSetImplThread scopedImplThread;
111 MockQuadCuller quadCuller;
112
113 scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::create( layer->id());
114 layer->pushPropertiesTo(layerImpl.get());
115
116 // The impl layer should call itself opaque as well.
117 EXPECT_TRUE(layerImpl->contentsOpaque());
118
119 // Impl layer has 1 opacity, and the color is opaque, so the opaqueRect should be the full tile.
120 layerImpl->setDrawOpacity(1);
121
122 AppendQuadsData data;
123 layerImpl->appendQuads(quadCuller, data);
124
125 ASSERT_EQ(quadCuller.quadList().size(), 1U);
126 EXPECT_EQ(visibleContentRect.ToString(), quadCuller.quadList()[0]->opaqu eRect().ToString());
127 }
128
129 EXPECT_TRUE(layer->contentsOpaque());
130 layer->setBackgroundColor(SkColorSetARGBInline(254, 10, 20, 30));
131 EXPECT_FALSE(layer->contentsOpaque());
132
133 {
134 DebugScopedSetImplThread scopedImplThread;
135 MockQuadCuller quadCuller;
136
137 scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::create( layer->id());
138 layer->pushPropertiesTo(layerImpl.get());
139
140 // The impl layer should callnot itself opaque anymore.
141 EXPECT_FALSE(layerImpl->contentsOpaque());
142
143 // Impl layer has 1 opacity, but the color is not opaque, so the opaqueR ect should be empty.
144 layerImpl->setDrawOpacity(1);
145
146 AppendQuadsData data;
147 layerImpl->appendQuads(quadCuller, data);
148
149 ASSERT_EQ(quadCuller.quadList().size(), 1U);
150 EXPECT_EQ(gfx::Rect().ToString(), quadCuller.quadList()[0]->opaqueRect() .ToString());
151 }
152 }
153
93 } // anonymous namespace 154 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/solid_color_layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698