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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/solid_color_layer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/solid_color_layer_impl_unittest.cc
diff --git a/cc/solid_color_layer_impl_unittest.cc b/cc/solid_color_layer_impl_unittest.cc
index e5346010d4881a64d3410d5f0243e7ea27d9d7f8..f5149a967323f800d03f51bdd138df2c5d5a69af 100644
--- a/cc/solid_color_layer_impl_unittest.cc
+++ b/cc/solid_color_layer_impl_unittest.cc
@@ -9,6 +9,7 @@
#include "cc/append_quads_data.h"
#include "cc/single_thread_proxy.h"
#include "cc/solid_color_draw_quad.h"
+#include "cc/solid_color_layer.h"
#include "cc/test/layer_test_common.h"
#include "cc/test/mock_quad_culler.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -90,4 +91,64 @@ TEST(SolidColorLayerImplTest, verifyCorrectOpacityInQuad)
EXPECT_EQ(opacity, SolidColorDrawQuad::materialCast(quadCuller.quadList()[0])->opacity());
}
+TEST(SolidColorLayerImplTest, verifyOpaqueRect)
+{
+ scoped_refptr<SolidColorLayer> layer = SolidColorLayer::create();
+ gfx::Size layerSize = gfx::Size(100, 100);
+ gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize);
+
+ layer->setVisibleContentRect(visibleContentRect);
+ layer->setBounds(layerSize);
+ layer->createRenderSurface();
+ layer->setRenderTarget(layer.get());
+
+ EXPECT_FALSE(layer->contentsOpaque());
+ layer->setBackgroundColor(SkColorSetARGBInline(255, 10, 20, 30));
+ EXPECT_TRUE(layer->contentsOpaque());
+
+ {
+ DebugScopedSetImplThread scopedImplThread;
+ MockQuadCuller quadCuller;
+
+ scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::create(layer->id());
+ layer->pushPropertiesTo(layerImpl.get());
+
+ // The impl layer should call itself opaque as well.
+ EXPECT_TRUE(layerImpl->contentsOpaque());
+
+ // Impl layer has 1 opacity, and the color is opaque, so the opaqueRect should be the full tile.
+ layerImpl->setDrawOpacity(1);
+
+ AppendQuadsData data;
+ layerImpl->appendQuads(quadCuller, data);
+
+ ASSERT_EQ(quadCuller.quadList().size(), 1U);
+ EXPECT_EQ(visibleContentRect.ToString(), quadCuller.quadList()[0]->opaqueRect().ToString());
+ }
+
+ EXPECT_TRUE(layer->contentsOpaque());
+ layer->setBackgroundColor(SkColorSetARGBInline(254, 10, 20, 30));
+ EXPECT_FALSE(layer->contentsOpaque());
+
+ {
+ DebugScopedSetImplThread scopedImplThread;
+ MockQuadCuller quadCuller;
+
+ scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::create(layer->id());
+ layer->pushPropertiesTo(layerImpl.get());
+
+ // The impl layer should callnot itself opaque anymore.
+ EXPECT_FALSE(layerImpl->contentsOpaque());
+
+ // Impl layer has 1 opacity, but the color is not opaque, so the opaqueRect should be empty.
+ layerImpl->setDrawOpacity(1);
+
+ AppendQuadsData data;
+ layerImpl->appendQuads(quadCuller, data);
+
+ ASSERT_EQ(quadCuller.quadList().size(), 1U);
+ EXPECT_EQ(gfx::Rect().ToString(), quadCuller.quadList()[0]->opaqueRect().ToString());
+ }
+}
+
} // anonymous namespace
« 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