summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/delegated_renderer_layer_impl_unittest.cc20
-rw-r--r--cc/layer_tree_host_common.cc14
2 files changed, 30 insertions, 4 deletions
diff --git a/cc/delegated_renderer_layer_impl_unittest.cc b/cc/delegated_renderer_layer_impl_unittest.cc
index 56d8136..5f51956 100644
--- a/cc/delegated_renderer_layer_impl_unittest.cc
+++ b/cc/delegated_renderer_layer_impl_unittest.cc
@@ -238,7 +238,7 @@ TEST_F(DelegatedRendererLayerImplTestSimple, DoesNotOwnARenderSurface)
m_hostImpl->didDrawAllLayers(frame);
}
-TEST_F(DelegatedRendererLayerImplTestSimple, DoesOwnARenderSurface)
+TEST_F(DelegatedRendererLayerImplTestSimple, DoesOwnARenderSurfaceForOpacity)
{
m_delegatedRendererLayerPtr->setOpacity(0.5f);
@@ -254,6 +254,24 @@ TEST_F(DelegatedRendererLayerImplTestSimple, DoesOwnARenderSurface)
m_hostImpl->didDrawAllLayers(frame);
}
+TEST_F(DelegatedRendererLayerImplTestSimple, DoesOwnARenderSurfaceForTransform)
+{
+ gfx::Transform rotation;
+ rotation.RotateAboutZAxis(30.0);
+ m_delegatedRendererLayerPtr->setTransform(rotation);
+
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
+
+ // This test case has quads from multiple layers in the delegated renderer,
+ // so if the DelegatedRendererLayer has opacity < 1, it should end up with
+ // a render surface.
+ EXPECT_TRUE(m_delegatedRendererLayerPtr->renderSurface());
+
+ m_hostImpl->drawLayers(frame);
+ m_hostImpl->didDrawAllLayers(frame);
+}
+
class DelegatedRendererLayerImplTestOwnSurface : public DelegatedRendererLayerImplTestSimple {
public:
DelegatedRendererLayerImplTestOwnSurface()
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc
index 5746dde..f4bf634 100644
--- a/cc/layer_tree_host_common.cc
+++ b/cc/layer_tree_host_common.cc
@@ -132,7 +132,7 @@ static bool isSurfaceBackFaceVisible(LayerType* layer, const gfx::Transform& dra
template<typename LayerType>
static inline bool layerClipsSubtree(LayerType* layer)
{
- return layer->masksToBounds() || layer->maskLayer();
+ return layer->masksToBounds() || layer->maskLayer() || layer->hasDelegatedContent();
}
template<typename LayerType>
@@ -302,8 +302,7 @@ static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig
// subtree overlap. But checking layer overlaps is unnecessarily costly so
// instead we conservatively create a surface whenever at least two layers
// draw content for this subtree.
- bool atLeastTwoLayersInSubtreeDrawContent = layer->hasDelegatedContent() ||
- (numDescendantsThatDrawContent > 0 && (layer->drawsContent() || numDescendantsThatDrawContent > 1));
+ bool atLeastTwoLayersInSubtreeDrawContent = numDescendantsThatDrawContent > 0 && (layer->drawsContent() || numDescendantsThatDrawContent > 1);
if (layer->opacity() != 1 && !layer->preserves3D() && atLeastTwoLayersInSubtreeDrawContent) {
TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface opacity");
@@ -495,6 +494,15 @@ static inline void removeSurfaceForEarlyExit(LayerType* layerToRemove, LayerList
template<typename LayerType>
static void preCalculateMetaInformation(LayerType* layer)
{
+ if (layer->hasDelegatedContent()) {
+ // Layers with delegated content need to be treated as if they have as many children as the number
+ // of layers they own delegated quads for. Since we don't know this number right now, we choose
+ // one that acts like infinity for our purposes.
+ layer->drawProperties().num_descendants_that_draw_content = 1000;
+ layer->drawProperties().descendants_can_clip_selves = false;
+ return;
+ }
+
int numDescendantsThatDrawContent = 0;
bool descendantsCanClipSelves = true;
bool sublayerTransformPreventsClip = !layer->sublayerTransform().IsPositiveScaleOrTranslation();