diff options
Diffstat (limited to 'WebCore/rendering/RenderLayerCompositor.cpp')
-rw-r--r-- | WebCore/rendering/RenderLayerCompositor.cpp | 69 |
1 files changed, 45 insertions, 24 deletions
diff --git a/WebCore/rendering/RenderLayerCompositor.cpp b/WebCore/rendering/RenderLayerCompositor.cpp index fb15800..5201287 100644 --- a/WebCore/rendering/RenderLayerCompositor.cpp +++ b/WebCore/rendering/RenderLayerCompositor.cpp @@ -34,8 +34,8 @@ #include "Frame.h" #include "FrameView.h" #include "GraphicsLayer.h" -#include "HitTestRequest.h" #include "HitTestResult.h" +#include "HTMLCanvasElement.h" #include "Page.h" #include "RenderLayerBacking.h" #include "RenderVideo.h" @@ -92,7 +92,6 @@ RenderLayerCompositor::RenderLayerCompositor(RenderView* renderView) RenderLayerCompositor::~RenderLayerCompositor() { ASSERT(!m_rootLayerAttached); - delete m_rootPlatformLayer; } void RenderLayerCompositor::enableCompositingMode(bool enable /* = true */) @@ -287,6 +286,13 @@ IntRect RenderLayerCompositor::calculateCompositedBounds(const RenderLayer* laye return boundingBoxRect; } + if (RenderLayer* reflection = layer->reflectionLayer()) { + if (!reflection->isComposited()) { + IntRect childUnionBounds = calculateCompositedBounds(reflection, layer); + unionBounds.unite(childUnionBounds); + } + } + ASSERT(layer->isStackingContext() || (!layer->m_posZOrderList || layer->m_posZOrderList->size() == 0)); if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) { @@ -425,11 +431,11 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* layer, O bool haveComputedBounds = false; IntRect absBounds; - if (overlapMap && mustOverlapCompositedLayers) { + if (overlapMap && !overlapMap->isEmpty()) { // If we're testing for overlap, we only need to composite if we overlap something that is already composited. absBounds = layer->renderer()->localToAbsoluteQuad(FloatRect(layer->localBoundingBox())).enclosingBoundingBox(); haveComputedBounds = true; - mustOverlapCompositedLayers &= overlapsCompositedLayers(*overlapMap, absBounds); + mustOverlapCompositedLayers = overlapsCompositedLayers(*overlapMap, absBounds); } layer->setMustOverlapCompositedLayers(mustOverlapCompositedLayers); @@ -503,8 +509,7 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* layer, O // If we have a software transform, and we have layers under us, we need to also // be composited. Also, if we have opacity < 1, then we need to be a layer so that // the child layers are opaque, then rendered with opacity on this layer. - if (childState.m_subtreeIsCompositing && - (layer->renderer()->hasTransform() || layer->renderer()->style()->opacity() < 1)) { + if (childState.m_subtreeIsCompositing && requiresCompositingWhenDescendantsAreCompositing(layer->renderer())) { layer->setMustOverlapCompositedLayers(true); if (overlapMap) addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds); @@ -530,6 +535,7 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* layer, O void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, RenderLayer* parentLayer) { + ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer); ASSERT(childLayer->isComposited()); // It's possible to be called with a parent that isn't yet composited when we're doing @@ -573,7 +579,7 @@ bool RenderLayerCompositor::canAccelerateVideoRendering(RenderVideo* o) const { // FIXME: ideally we need to look at all ancestors for mask or video. But for now, // just bail on the obvious cases. - if (o->hasMask() || o->hasReflection() || !m_hasAcceleratedCompositing) + if (o->hasReflection() || !m_hasAcceleratedCompositing) return false; return o->supportsAcceleratedRendering(); @@ -589,8 +595,7 @@ void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, stru if (layerBacking) { // The compositing state of all our children has been updated already, so now // we can compute and cache the composited bounds for this layer. - layerBacking->setCompositedBounds(calculateCompositedBounds(layer, layer)); - + layerBacking->updateCompositedBounds(); layerBacking->updateGraphicsLayerConfiguration(); layerBacking->updateGraphicsLayerGeometry(); @@ -632,10 +637,10 @@ void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, stru } if (updateHierarchy && layerBacking && layerBacking->foregroundLayer()) { - // we only have a contents layer if we have an m_layer layerBacking->foregroundLayer()->removeFromParent(); - - GraphicsLayer* hostingLayer = layerBacking->clippingLayer() ? layerBacking->clippingLayer() : layerBacking->graphicsLayer(); + + // The foreground layer has to be correctly sorted with child layers, so needs to become a child of the clipping layer. + GraphicsLayer* hostingLayer = layerBacking->parentForSublayers(); hostingLayer->addChild(layerBacking->foregroundLayer()); } } @@ -670,7 +675,7 @@ void RenderLayerCompositor::updateCompositingDescendantGeometry(RenderLayer* com { if (layer != compositingAncestor) { if (RenderLayerBacking* layerBacking = layer->backing()) { - layerBacking->setCompositedBounds(calculateCompositedBounds(layer, layer)); + layerBacking->updateCompositedBounds(); layerBacking->updateGraphicsLayerGeometry(); if (updateDepth == RenderLayerBacking::CompositingChildren) return; @@ -759,7 +764,7 @@ RenderLayer* RenderLayerCompositor::rootRenderLayer() const GraphicsLayer* RenderLayerCompositor::rootPlatformLayer() const { - return m_rootPlatformLayer; + return m_rootPlatformLayer.get(); } void RenderLayerCompositor::didMoveOnscreen() @@ -772,7 +777,7 @@ void RenderLayerCompositor::didMoveOnscreen() if (!page) return; - page->chrome()->client()->attachRootGraphicsLayer(frame, m_rootPlatformLayer); + page->chrome()->client()->attachRootGraphicsLayer(frame, m_rootPlatformLayer.get()); m_rootLayerAttached = true; } @@ -793,7 +798,7 @@ void RenderLayerCompositor::willMoveOffscreen() void RenderLayerCompositor::updateRootLayerPosition() { if (m_rootPlatformLayer) - m_rootPlatformLayer->setSize(FloatSize(m_renderView->overflowWidth(), m_renderView->overflowHeight())); + m_rootPlatformLayer->setSize(FloatSize(m_renderView->rightLayoutOverflow(), m_renderView->bottomLayoutOverflow())); } void RenderLayerCompositor::didStartAcceleratedAnimation() @@ -821,11 +826,12 @@ bool RenderLayerCompositor::needsToBeComposited(const RenderLayer* layer) const // Use needsToBeComposited() to determine if a RL actually needs a compositing layer. // static bool RenderLayerCompositor::requiresCompositingLayer(const RenderLayer* layer) const -{ +{ // The root layer always has a compositing layer, but it may not have backing. return (inCompositingMode() && layer->isRootLayer()) || requiresCompositingForTransform(layer->renderer()) || requiresCompositingForVideo(layer->renderer()) || + requiresCompositingForCanvas(layer->renderer()) || layer->renderer()->style()->backfaceVisibility() == BackfaceVisibilityHidden || clipsCompositingDescendants(layer) || requiresCompositingForAnimation(layer->renderer()); @@ -862,10 +868,8 @@ bool RenderLayerCompositor::clippedByAncestor(RenderLayer* layer) const if (!computeClipRoot || computeClipRoot == layer) return false; - ClipRects parentRects; - layer->parentClipRects(computeClipRoot, parentRects, true); - - return parentRects.overflowClipRect() != ClipRects::infiniteRect(); + IntRect backgroundRect = layer->backgroundClipRect(computeClipRoot, true); + return backgroundRect != ClipRects::infiniteRect(); } // Return true if the given layer is a stacking context and has compositing child @@ -897,6 +901,19 @@ bool RenderLayerCompositor::requiresCompositingForVideo(RenderObject* renderer) return false; } +bool RenderLayerCompositor::requiresCompositingForCanvas(RenderObject* renderer) const +{ +#if ENABLE(3D_CANVAS) + if (renderer->isCanvas()) { + HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(renderer->node()); + return canvas->is3D(); + } +#else + UNUSED_PARAM(renderer); +#endif + return false; +} + bool RenderLayerCompositor::requiresCompositingForAnimation(RenderObject* renderer) const { if (AnimationController* animController = renderer->animation()) { @@ -906,6 +923,11 @@ bool RenderLayerCompositor::requiresCompositingForAnimation(RenderObject* render return false; } +bool RenderLayerCompositor::requiresCompositingWhenDescendantsAreCompositing(RenderObject* renderer) const +{ + return renderer->hasTransform() || renderer->isTransparent() || renderer->hasMask(); +} + // If an element has negative z-index children, those children render in front of the // layer background, so we need an extra 'contents' layer for the foreground of the layer // object. @@ -919,8 +941,8 @@ void RenderLayerCompositor::ensureRootPlatformLayer() if (m_rootPlatformLayer) return; - m_rootPlatformLayer = GraphicsLayer::createGraphicsLayer(0); - m_rootPlatformLayer->setSize(FloatSize(m_renderView->overflowWidth(), m_renderView->overflowHeight())); + m_rootPlatformLayer = GraphicsLayer::create(0); + m_rootPlatformLayer->setSize(FloatSize(m_renderView->rightLayoutOverflow(), m_renderView->bottomLayoutOverflow())); m_rootPlatformLayer->setPosition(FloatPoint(0, 0)); // The root layer does flipping if we need it on this platform. m_rootPlatformLayer->setGeometryOrientation(GraphicsLayer::compositingCoordinatesOrientation()); @@ -937,7 +959,6 @@ void RenderLayerCompositor::destroyRootPlatformLayer() return; willMoveOffscreen(); - delete m_rootPlatformLayer; m_rootPlatformLayer = 0; } |