| 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
|
|
|