| Index: cc/layer_tree_host_unittest.cc
|
| diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc
|
| index cb0c6e9fc3ed95f562bce113cd3df337e32fbb8d..20eb0c95209848840a5506ce03326028485ca934 100644
|
| --- a/cc/layer_tree_host_unittest.cc
|
| +++ b/cc/layer_tree_host_unittest.cc
|
| @@ -1348,333 +1348,6 @@ TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread)
|
| runTest(true);
|
| }
|
|
|
| -class TestLayer : public Layer {
|
| -public:
|
| - static scoped_refptr<TestLayer> create() { return make_scoped_refptr(new TestLayer()); }
|
| -
|
| - virtual void update(ResourceUpdateQueue&, const OcclusionTracker* occlusion, RenderingStats&) OVERRIDE
|
| - {
|
| - // Gain access to internals of the OcclusionTracker.
|
| - const TestOcclusionTracker* testOcclusion = static_cast<const TestOcclusionTracker*>(occlusion);
|
| - if (!testOcclusion) {
|
| - m_occlusion.Clear();
|
| - return;
|
| - }
|
| - m_occlusion = UnionRegions(testOcclusion->occlusionFromInsideTarget(), testOcclusion->occlusionFromOutsideTarget());
|
| - }
|
| -
|
| - virtual bool drawsContent() const OVERRIDE { return true; }
|
| -
|
| - const Region& occlusion() const { return m_occlusion; }
|
| - void clearOcclusion() { m_occlusion.Clear(); }
|
| -
|
| -private:
|
| - TestLayer() : Layer() { }
|
| - virtual ~TestLayer() { }
|
| -
|
| - Region m_occlusion;
|
| -};
|
| -
|
| -static void setTestLayerPropertiesForTesting(TestLayer* layer, Layer* parent, const gfx::Transform& transform, const gfx::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool opaque)
|
| -{
|
| - setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bounds, opaque);
|
| - layer->clearOcclusion();
|
| -}
|
| -
|
| -class LayerTreeHostTestLayerOcclusion : public LayerTreeHostTest {
|
| -public:
|
| - LayerTreeHostTestLayerOcclusion() { }
|
| -
|
| - virtual void beginTest() OVERRIDE
|
| - {
|
| - scoped_refptr<TestLayer> rootLayer = TestLayer::create();
|
| - scoped_refptr<TestLayer> child = TestLayer::create();
|
| - scoped_refptr<TestLayer> child2 = TestLayer::create();
|
| - scoped_refptr<TestLayer> grandChild = TestLayer::create();
|
| - scoped_refptr<TestLayer> mask = TestLayer::create();
|
| -
|
| - gfx::Transform identityMatrix;
|
| -
|
| - child->setMasksToBounds(true);
|
| - child->setForceRenderSurface(true);
|
| -
|
| - // See LayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedSurface for a nice visual of these layers and how they end up
|
| - // positioned on the screen.
|
| -
|
| - // The child layer is a surface and the grandChild is opaque, but clipped to the child and rootLayer
|
| - setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
|
| - setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), false);
|
| - setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true);
|
| -
|
| - m_layerTreeHost->setRootLayer(rootLayer);
|
| - m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
|
| - ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
|
| - ResourceUpdateQueue queue;
|
| - m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
|
| - m_layerTreeHost->commitComplete();
|
| -
|
| - EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(0, 0, 10, 190).ToString(), child->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(10, 10, 10, 190).ToString(), rootLayer->occlusion().ToString());
|
| -
|
| - // If the child layer is opaque, then it adds to the occlusion seen by the rootLayer.
|
| - setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
|
| - setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
|
| - setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true);
|
| -
|
| - m_layerTreeHost->setRootLayer(rootLayer);
|
| - m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
|
| - m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
|
| - m_layerTreeHost->commitComplete();
|
| -
|
| - EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(0, 0, 10, 190).ToString(), child->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(10, 10, 190, 190).ToString(), rootLayer->occlusion().ToString());
|
| -
|
| - // Add a second child to the root layer and the regions should merge
|
| - setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
|
| - setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), false);
|
| - setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true);
|
| - setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true);
|
| -
|
| - m_layerTreeHost->setRootLayer(rootLayer);
|
| - m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
|
| - m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
|
| - m_layerTreeHost->commitComplete();
|
| -
|
| - EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(10, 0, 10, 190).ToString(), grandChild->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(0, 0, 20, 190).ToString(), child->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(10, 10, 20, 190).ToString(), rootLayer->occlusion().ToString());
|
| -
|
| - // If the child layer has a mask on it, then it shouldn't contribute to occlusion on stuff below it
|
| - setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
|
| - setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
|
| - setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(20, 20), gfx::Size(500, 500), true);
|
| - setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(500, 500), true);
|
| -
|
| - child->setMaskLayer(mask.get());
|
| -
|
| - m_layerTreeHost->setRootLayer(rootLayer);
|
| - m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
|
| - m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
|
| - m_layerTreeHost->commitComplete();
|
| -
|
| - EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(0, 0, 180, 180).ToString(), child->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(10, 10, 190, 190).ToString(), rootLayer->occlusion().ToString());
|
| -
|
| - // If the child layer with a mask is below child2, then child2 should contribute to occlusion on everything, and child shouldn't contribute to the rootLayer
|
| - setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
|
| - setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
|
| - setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true);
|
| - setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true);
|
| -
|
| - child->setMaskLayer(mask.get());
|
| -
|
| - m_layerTreeHost->setRootLayer(rootLayer);
|
| - m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
|
| - m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
|
| - m_layerTreeHost->commitComplete();
|
| -
|
| - EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(10, 0, 10, 190).ToString(), grandChild->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(0, 0, 20, 190).ToString(), child->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(20, 10, 10, 190), rootLayer->occlusion());
|
| -
|
| - // If the child layer has a non-opaque drawOpacity, then it shouldn't contribute to occlusion on stuff below it
|
| - setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
|
| - setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true);
|
| - setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
|
| - setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true);
|
| -
|
| - child->setMaskLayer(0);
|
| - child->setOpacity(0.5);
|
| -
|
| - m_layerTreeHost->setRootLayer(rootLayer);
|
| - m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
|
| - m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
|
| - m_layerTreeHost->commitComplete();
|
| -
|
| - EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(0, 0, 10, 190).ToString(), child->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(20, 10, 10, 190).ToString(), rootLayer->occlusion().ToString());
|
| -
|
| - // If the child layer with non-opaque drawOpacity is below child2, then child2 should contribute to occlusion on everything, and child shouldn't contribute to the rootLayer
|
| - setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
|
| - setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
|
| - setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true);
|
| - setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true);
|
| -
|
| - child->setMaskLayer(0);
|
| - child->setOpacity(0.5);
|
| -
|
| - m_layerTreeHost->setRootLayer(rootLayer);
|
| - m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
|
| - m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
|
| - m_layerTreeHost->commitComplete();
|
| -
|
| - EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(10, 0, 10, 190).ToString(), grandChild->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(0, 0, 20, 190).ToString(), child->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(20, 10, 10, 190).ToString(), rootLayer->occlusion().ToString());
|
| -
|
| - // Kill the layerTreeHost immediately.
|
| - m_layerTreeHost->setRootLayer(0);
|
| - m_layerTreeHost.reset();
|
| -
|
| - endTest();
|
| - }
|
| -
|
| - virtual void afterTest() OVERRIDE
|
| - {
|
| - }
|
| -};
|
| -
|
| -SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLayerOcclusion)
|
| -
|
| -class LayerTreeHostTestLayerOcclusionWithFilters : public LayerTreeHostTest {
|
| -public:
|
| - LayerTreeHostTestLayerOcclusionWithFilters() { }
|
| -
|
| - virtual void beginTest() OVERRIDE
|
| - {
|
| - scoped_refptr<TestLayer> rootLayer = TestLayer::create();
|
| - scoped_refptr<TestLayer> child = TestLayer::create();
|
| - scoped_refptr<TestLayer> child2 = TestLayer::create();
|
| - scoped_refptr<TestLayer> grandChild = TestLayer::create();
|
| - scoped_refptr<TestLayer> mask = TestLayer::create();
|
| -
|
| - gfx::Transform identityMatrix;
|
| - gfx::Transform childTransform;
|
| - childTransform.Translate(250, 250);
|
| - childTransform.Rotate(90);
|
| - childTransform.Translate(-250, -250);
|
| -
|
| - child->setMasksToBounds(true);
|
| -
|
| - // If the child layer has a filter that changes alpha values, and is below child2, then child2 should contribute to occlusion on everything,
|
| - // and child shouldn't contribute to the rootLayer
|
| - setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
|
| - setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true);
|
| - setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
|
| - setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true);
|
| -
|
| - {
|
| - WebKit::WebFilterOperations filters;
|
| - filters.append(WebKit::WebFilterOperation::createOpacityFilter(0.5));
|
| - child->setFilters(filters);
|
| - }
|
| -
|
| - m_layerTreeHost->setRootLayer(rootLayer);
|
| - m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
|
| - ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
|
| - ResourceUpdateQueue queue;
|
| - m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
|
| - m_layerTreeHost->commitComplete();
|
| -
|
| - EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(40, 330, 130, 190).ToString(), grandChild->occlusion().ToString());
|
| - EXPECT_EQ(UnionRegions(gfx::Rect(10, 330, 160, 170), gfx::Rect(40, 500, 130, 20)).ToString(), child->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occlusion().ToString());
|
| -
|
| - // If the child layer has a filter that moves pixels/changes alpha, and is below child2, then child should not inherit occlusion from outside its subtree,
|
| - // and should not contribute to the rootLayer
|
| - setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
|
| - setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true);
|
| - setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
|
| - setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true);
|
| -
|
| - {
|
| - WebKit::WebFilterOperations filters;
|
| - filters.append(WebKit::WebFilterOperation::createBlurFilter(10));
|
| - child->setFilters(filters);
|
| - }
|
| -
|
| - m_layerTreeHost->setRootLayer(rootLayer);
|
| - m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds());
|
| - m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
|
| - m_layerTreeHost->commitComplete();
|
| -
|
| - EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(10, 330, 160, 170).ToString(), child->occlusion().ToString());
|
| - EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occlusion().ToString());
|
| -
|
| - // Kill the layerTreeHost immediately.
|
| - m_layerTreeHost->setRootLayer(0);
|
| - m_layerTreeHost.reset();
|
| -
|
| - LayerTreeHost::setNeedsFilterContext(false);
|
| - endTest();
|
| - }
|
| -
|
| - virtual void afterTest() OVERRIDE
|
| - {
|
| - }
|
| -};
|
| -
|
| -SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLayerOcclusionWithFilters)
|
| -
|
| -class LayerTreeHostTestManySurfaces : public LayerTreeHostTest {
|
| -public:
|
| - LayerTreeHostTestManySurfaces() { }
|
| -
|
| - virtual void beginTest() OVERRIDE
|
| - {
|
| - // We create enough RenderSurfaces that it will trigger Vector reallocation while computing occlusion.
|
| - Region occluded;
|
| - const gfx::Transform identityMatrix;
|
| - std::vector<scoped_refptr<TestLayer> > layers;
|
| - std::vector<scoped_refptr<TestLayer> > children;
|
| - int numSurfaces = 20;
|
| - scoped_refptr<TestLayer> replica = TestLayer::create();
|
| -
|
| - for (int i = 0; i < numSurfaces; ++i) {
|
| - layers.push_back(TestLayer::create());
|
| - if (!i) {
|
| - setTestLayerPropertiesForTesting(layers.back().get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
|
| - layers.back()->createRenderSurface();
|
| - } else {
|
| - setTestLayerPropertiesForTesting(layers.back().get(), layers[layers.size()-2].get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(1, 1), gfx::Size(200-i, 200-i), true);
|
| - layers.back()->setMasksToBounds(true);
|
| - layers.back()->setReplicaLayer(replica.get()); // Make it have a RenderSurfaceImpl
|
| - }
|
| - }
|
| -
|
| - for (int i = 1; i < numSurfaces; ++i) {
|
| - children.push_back(TestLayer::create());
|
| - setTestLayerPropertiesForTesting(children.back().get(), layers[i].get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false);
|
| - }
|
| -
|
| - m_layerTreeHost->setRootLayer(layers[0].get());
|
| - m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds());
|
| - ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
|
| - ResourceUpdateQueue queue;
|
| - m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
|
| - m_layerTreeHost->commitComplete();
|
| -
|
| - for (int i = 0; i < numSurfaces-1; ++i) {
|
| - gfx::Rect expectedOcclusion(1, 1, 200-i-1, 200-i-1);
|
| - EXPECT_EQ(expectedOcclusion.ToString(), layers[i]->occlusion().ToString());
|
| - }
|
| -
|
| - // Kill the layerTreeHost immediately.
|
| - m_layerTreeHost->setRootLayer(0);
|
| - m_layerTreeHost.reset();
|
| -
|
| - endTest();
|
| - }
|
| -
|
| - virtual void afterTest() OVERRIDE
|
| - {
|
| - }
|
| -};
|
| -
|
| -SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestManySurfaces)
|
| -
|
| // A loseOutputSurface(1) should lead to a didRecreateOutputSurface(true)
|
| class LayerTreeHostTestSetSingleLostContext : public LayerTreeHostTest {
|
| public:
|
|
|