Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (104902 => 104903)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2012-01-13 08:47:04 UTC (rev 104902)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2012-01-13 09:05:22 UTC (rev 104903)
@@ -2698,6 +2698,19 @@
RenderObject* paintingRoot, RenderRegion* region, OverlapTestRequestMap* overlapTestRequests,
PaintLayerFlags paintFlags)
{
+#if USE(ACCELERATED_COMPOSITING)
+ if (isComposited()) {
+ // The updatingControlTints() painting pass goes through compositing layers,
+ // but we need to ensure that we don't cache clip rects computed with the wrong root in this case.
+ if (p->updatingControlTints() || (paintBehavior & PaintBehaviorFlattenCompositingLayers))
+ paintFlags |= PaintLayerTemporaryClipRects;
+ else if (!backing()->paintingGoesToWindow() && !shouldDoSoftwarePaint(this, paintFlags & PaintLayerPaintingReflection)) {
+ // If this RenderLayer should paint into its backing, that will be done via RenderLayerBacking::paintIntoLayer().
+ return;
+ }
+ }
+#endif
+
if (shouldSuppressPaintingLayer(this))
return;
@@ -2708,6 +2721,7 @@
if (paintsWithTransparency(paintBehavior))
paintFlags |= PaintLayerHaveTransparency;
+ // PaintLayerAppliedTransform is used in RenderReplica, to avoid applying the transform twice.
if (paintsWithTransform(paintBehavior) && !(paintFlags & PaintLayerAppliedTransform)) {
TransformationMatrix layerTransform = renderableTransform(paintBehavior);
// If the transform can't be inverted, then don't paint anything.
@@ -2746,7 +2760,7 @@
p->concatCTM(transform.toAffineTransform());
// Now do a paint with the root layer shifted to be us.
- paintLayer(this, p, transform.inverse().mapRect(paintDirtyRect), paintBehavior, paintingRoot, region, overlapTestRequests, paintFlags | PaintLayerAppliedTransform);
+ paintLayerContentsAndReflection(this, p, transform.inverse().mapRect(paintDirtyRect), paintBehavior, paintingRoot, region, overlapTestRequests, paintFlags);
}
// Restore the clip.
@@ -2756,36 +2770,15 @@
return;
}
- paintLayerContents(rootLayer, p, paintDirtyRect, paintBehavior, paintingRoot, region, overlapTestRequests, paintFlags);
+ paintLayerContentsAndReflection(rootLayer, p, paintDirtyRect, paintBehavior, paintingRoot, region, overlapTestRequests, paintFlags);
}
-void RenderLayer::paintLayerContents(RenderLayer* rootLayer, GraphicsContext* p,
+void RenderLayer::paintLayerContentsAndReflection(RenderLayer* rootLayer, GraphicsContext* p,
const LayoutRect& paintDirtyRect, PaintBehavior paintBehavior,
RenderObject* paintingRoot, RenderRegion* region, OverlapTestRequestMap* overlapTestRequests,
PaintLayerFlags paintFlags)
{
-#if USE(ACCELERATED_COMPOSITING)
- if (isComposited()) {
- // The updatingControlTints() painting pass goes through compositing layers,
- // but we need to ensure that we don't cache clip rects computed with the wrong root in this case.
- if (p->updatingControlTints() || (paintBehavior & PaintBehaviorFlattenCompositingLayers))
- paintFlags |= PaintLayerTemporaryClipRects;
- else if (!backing()->paintingGoesToWindow() && !shouldDoSoftwarePaint(this, paintFlags & PaintLayerPaintingReflection)) {
- // If this RenderLayer should paint into its backing, that will be done via RenderLayerBacking::paintIntoLayer().
- return;
- }
- }
-#endif
-
- if (shouldSuppressPaintingLayer(this))
- return;
-
- // If this layer is totally invisible then there is nothing to paint.
- if (!renderer()->opacity())
- return;
-
PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform);
- bool haveTransparency = localPaintFlags & PaintLayerHaveTransparency;
// Paint the reflection first if we have one.
if (m_reflection && !m_paintingInsideReflection) {
@@ -2795,6 +2788,17 @@
m_paintingInsideReflection = false;
}
+ localPaintFlags |= PaintLayerPaintingCompositingAllPhases;
+ paintLayerContents(rootLayer, p, paintDirtyRect, paintBehavior, paintingRoot, region, overlapTestRequests, localPaintFlags);
+}
+
+void RenderLayer::paintLayerContents(RenderLayer* rootLayer, GraphicsContext* p,
+ const LayoutRect& paintDirtyRect, PaintBehavior paintBehavior,
+ RenderObject* paintingRoot, RenderRegion* region, OverlapTestRequestMap* overlapTestRequests,
+ PaintLayerFlags paintFlags)
+{
+ PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform);
+ bool haveTransparency = localPaintFlags & PaintLayerHaveTransparency;
bool isSelfPaintingLayer = this->isSelfPaintingLayer();
bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScrollbars;
// Outline always needs to be painted even if we have no visible content.
@@ -2833,72 +2837,82 @@
// We want to paint our layer, but only if we intersect the damage rect.
shouldPaintContent &= intersectsDamageRect(layerBounds, damageRect.rect(), rootLayer);
- if (shouldPaintContent && !selectionOnly) {
- // Begin transparency layers lazily now that we know we have to paint something.
- if (haveTransparency)
- beginTransparencyLayers(p, rootLayer, paintBehavior);
+
+ if (localPaintFlags & PaintLayerPaintingCompositingBackgroundPhase) {
+ if (shouldPaintContent && !selectionOnly) {
+ // Begin transparency layers lazily now that we know we have to paint something.
+ if (haveTransparency)
+ beginTransparencyLayers(p, rootLayer, paintBehavior);
#if ENABLE(CSS_FILTERS)
- if (filterPainter.haveFilterEffect())
- p = filterPainter.beginFilterEffect(this, p, transparencyClipBox(this, rootLayer, paintBehavior));
+ if (filterPainter.haveFilterEffect())
+ p = filterPainter.beginFilterEffect(this, p, transparencyClipBox(this, rootLayer, paintBehavior));
#endif
- // Paint our background first, before painting any child layers.
- // Establish the clip used to paint our background.
- clipToRect(rootLayer, p, paintDirtyRect, damageRect, DoNotIncludeSelfForBorderRadius); // Background painting will handle clipping to self.
+ // Paint our background first, before painting any child layers.
+ // Establish the clip used to paint our background.
+ clipToRect(rootLayer, p, paintDirtyRect, damageRect, DoNotIncludeSelfForBorderRadius); // Background painting will handle clipping to self.
- // Paint the background.
- PaintInfo paintInfo(p, damageRect.rect(), PaintPhaseBlockBackground, false, paintingRootForRenderer, region, 0);
- renderer()->paint(paintInfo, paintOffset);
+ // Paint the background.
+ PaintInfo paintInfo(p, damageRect.rect(), PaintPhaseBlockBackground, false, paintingRootForRenderer, region, 0);
+ renderer()->paint(paintInfo, paintOffset);
- // Restore the clip.
- restoreClip(p, paintDirtyRect, damageRect);
+ // Restore the clip.
+ restoreClip(p, paintDirtyRect, damageRect);
+ }
+
+ // Now walk the sorted list of children with negative z-indices.
+ paintList(m_negZOrderList, rootLayer, p, paintDirtyRect, paintBehavior, paintingRoot, region, overlapTestRequests, localPaintFlags);
}
+
+ if (localPaintFlags & PaintLayerPaintingCompositingForegroundPhase) {
+ // Now establish the appropriate clip and paint our child RenderObjects.
+ if (shouldPaintContent && !clipRectToApply.isEmpty()) {
+ // Begin transparency layers lazily now that we know we have to paint something.
+ if (haveTransparency)
+ beginTransparencyLayers(p, rootLayer, paintBehavior);
- // Now walk the sorted list of children with negative z-indices.
- paintList(m_negZOrderList, rootLayer, p, paintDirtyRect, paintBehavior, paintingRoot, region, overlapTestRequests, localPaintFlags);
+#if ENABLE(CSS_FILTERS)
+ // If the filter was not started yet, start it now, after the transparency layer was lazily created.
+ if (filterPainter.haveFilterEffect() && !filterPainter.hasStartedFilterEffect())
+ p = filterPainter.beginFilterEffect(this, p, transparencyClipBox(this, rootLayer, paintBehavior));
+#endif
+ // Set up the clip used when painting our children.
+ clipToRect(rootLayer, p, paintDirtyRect, clipRectToApply);
+ PaintInfo paintInfo(p, clipRectToApply.rect(),
+ selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds,
+ forceBlackText, paintingRootForRenderer, region, 0);
+ renderer()->paint(paintInfo, paintOffset);
+ if (!selectionOnly) {
+ paintInfo.phase = PaintPhaseFloat;
+ renderer()->paint(paintInfo, paintOffset);
+ paintInfo.phase = PaintPhaseForeground;
+ paintInfo.overlapTestRequests = overlapTestRequests;
+ renderer()->paint(paintInfo, paintOffset);
+ paintInfo.phase = PaintPhaseChildOutlines;
+ renderer()->paint(paintInfo, paintOffset);
+ }
- // Now establish the appropriate clip and paint our child RenderObjects.
- if (shouldPaintContent && !clipRectToApply.isEmpty()) {
- // Begin transparency layers lazily now that we know we have to paint something.
- if (haveTransparency)
- beginTransparencyLayers(p, rootLayer, paintBehavior);
+ // Now restore our clip.
+ restoreClip(p, paintDirtyRect, clipRectToApply);
+ }
- // Set up the clip used when painting our children.
- clipToRect(rootLayer, p, paintDirtyRect, clipRectToApply);
- PaintInfo paintInfo(p, clipRectToApply.rect(),
- selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds,
- forceBlackText, paintingRootForRenderer, region, 0);
- renderer()->paint(paintInfo, paintOffset);
- if (!selectionOnly) {
- paintInfo.phase = PaintPhaseFloat;
+ if (shouldPaintOutline && !outlineRect.isEmpty()) {
+ // Paint our own outline
+ PaintInfo paintInfo(p, outlineRect.rect(), PaintPhaseSelfOutline, false, paintingRootForRenderer, region, 0);
+ clipToRect(rootLayer, p, paintDirtyRect, outlineRect, DoNotIncludeSelfForBorderRadius);
renderer()->paint(paintInfo, paintOffset);
- paintInfo.phase = PaintPhaseForeground;
- paintInfo.overlapTestRequests = overlapTestRequests;
- renderer()->paint(paintInfo, paintOffset);
- paintInfo.phase = PaintPhaseChildOutlines;
- renderer()->paint(paintInfo, paintOffset);
+ restoreClip(p, paintDirtyRect, outlineRect);
}
-
- // Now restore our clip.
- restoreClip(p, paintDirtyRect, clipRectToApply);
+
+ // Paint any child layers that have overflow.
+ paintList(m_normalFlowList, rootLayer, p, paintDirtyRect, paintBehavior, paintingRoot, region, overlapTestRequests, localPaintFlags);
+
+ // Now walk the sorted list of children with positive z-indices.
+ paintList(m_posZOrderList, rootLayer, p, paintDirtyRect, paintBehavior, paintingRoot, region, overlapTestRequests, localPaintFlags);
}
-
- if (shouldPaintOutline && !outlineRect.isEmpty()) {
- // Paint our own outline
- PaintInfo paintInfo(p, outlineRect.rect(), PaintPhaseSelfOutline, false, paintingRootForRenderer, region, 0);
- clipToRect(rootLayer, p, paintDirtyRect, outlineRect, DoNotIncludeSelfForBorderRadius);
- renderer()->paint(paintInfo, paintOffset);
- restoreClip(p, paintDirtyRect, outlineRect);
- }
- // Paint any child layers that have overflow.
- paintList(m_normalFlowList, rootLayer, p, paintDirtyRect, paintBehavior, paintingRoot, region, overlapTestRequests, localPaintFlags);
-
- // Now walk the sorted list of children with positive z-indices.
- paintList(m_posZOrderList, rootLayer, p, paintDirtyRect, paintBehavior, paintingRoot, region, overlapTestRequests, localPaintFlags);
-
- if (shouldPaintContent && renderer()->hasMask() && !selectionOnly) {
+ if ((localPaintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && renderer()->hasMask() && !selectionOnly) {
clipToRect(rootLayer, p, paintDirtyRect, damageRect, DoNotIncludeSelfForBorderRadius); // Mask painting will handle clipping to self.
// Paint the mask.
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (104902 => 104903)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2012-01-13 08:47:04 UTC (rev 104902)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2012-01-13 09:05:22 UTC (rev 104903)
@@ -1093,7 +1093,6 @@
}
}
-// Share this with RenderLayer::paintLayer, which would have to be educated about GraphicsLayerPaintingPhase?
void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext* context,
const LayoutRect& paintDirtyRect, // In the coords of rootLayer.
PaintBehavior paintBehavior, GraphicsLayerPaintingPhase paintingPhase,
@@ -1106,105 +1105,17 @@
FontCachePurgePreventer fontCachePurgePreventer;
- m_owningLayer->updateLayerListsIfNeeded();
-
- bool shouldPaintContent = (m_owningLayer->hasVisibleContent() || m_owningLayer->hasVisibleDescendant()) && m_owningLayer->isSelfPaintingLayer();
- if (!shouldPaintContent)
- return;
-
- // Calculate the clip rects we should use.
- LayoutRect layerBounds;
- ClipRect damageRect, clipRectToApply, outlineRect;
- m_owningLayer->calculateRects(rootLayer, 0, paintDirtyRect, layerBounds, damageRect, clipRectToApply, outlineRect); // FIXME: Incorrect for CSS regions.
- LayoutPoint paintOffset = toPoint(layerBounds.location() - m_owningLayer->renderBoxLocation());
-
- // If this layer's renderer is a child of the paintingRoot, we render unconditionally, which
- // is done by passing a nil paintingRoot down to our renderer (as if no paintingRoot was ever set).
- // Else, our renderer tree may or may not contain the painting root, so we pass that root along
- // so it will be tested against as we decend through the renderers.
- RenderObject *paintingRootForRenderer = 0;
- if (paintingRoot && !renderer()->isDescendantOf(paintingRoot))
- paintingRootForRenderer = paintingRoot;
-
-#if ENABLE(CSS_FILTERS)
- FilterEffectRendererHelper filterPainter(m_owningLayer->paintsWithFilters());
- if (filterPainter.haveFilterEffect())
- context = filterPainter.beginFilterEffect(m_owningLayer, context, layerBounds);
-#endif
-
- if (paintingPhase & GraphicsLayerPaintBackground) {
- // Paint our background first, before painting any child layers.
- // Establish the clip used to paint our background.
- m_owningLayer->clipToRect(rootLayer, context, paintDirtyRect, damageRect, DoNotIncludeSelfForBorderRadius);
+ RenderLayer::PaintLayerFlags paintFlags = 0;
+ if (paintingPhase & GraphicsLayerPaintBackground)
+ paintFlags |= RenderLayer::PaintLayerPaintingCompositingBackgroundPhase;
+ if (paintingPhase & GraphicsLayerPaintForeground)
+ paintFlags |= RenderLayer::PaintLayerPaintingCompositingForegroundPhase;
+ if (paintingPhase & GraphicsLayerPaintMask)
+ paintFlags |= RenderLayer::PaintLayerPaintingCompositingMaskPhase;
- PaintInfo info(context, damageRect.rect(), PaintPhaseBlockBackground, false, paintingRootForRenderer, 0, 0);
- renderer()->paint(info, paintOffset);
+ // FIXME: GraphicsLayers need a way to split for RenderRegions.
+ m_owningLayer->paintLayerContents(rootLayer, context, paintDirtyRect, paintBehavior, paintingRoot, 0, 0, paintFlags);
- // Restore the clip.
- m_owningLayer->restoreClip(context, paintDirtyRect, damageRect);
-
- // Now walk the sorted list of children with negative z-indices. Only RenderLayers without compositing layers will paint.
- m_owningLayer->paintList(m_owningLayer->negZOrderList(), rootLayer, context, paintDirtyRect, paintBehavior, paintingRoot, 0, 0, 0);
- }
-
- bool forceBlackText = paintBehavior & PaintBehaviorForceBlackText;
- bool selectionOnly = paintBehavior & PaintBehaviorSelectionOnly;
-
- if (paintingPhase & GraphicsLayerPaintForeground) {
- // Set up the clip used when painting our children.
- m_owningLayer->clipToRect(rootLayer, context, paintDirtyRect, clipRectToApply);
- PaintInfo paintInfo(context, clipRectToApply.rect(),
- selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds,
- forceBlackText, paintingRootForRenderer, 0, 0);
- renderer()->paint(paintInfo, paintOffset);
-
- if (!selectionOnly) {
- paintInfo.phase = PaintPhaseFloat;
- renderer()->paint(paintInfo, paintOffset);
-
- paintInfo.phase = PaintPhaseForeground;
- renderer()->paint(paintInfo, paintOffset);
-
- paintInfo.phase = PaintPhaseChildOutlines;
- renderer()->paint(paintInfo, paintOffset);
- }
-
- // Now restore our clip.
- m_owningLayer->restoreClip(context, paintDirtyRect, clipRectToApply);
-
- if (!outlineRect.isEmpty()) {
- // Paint our own outline
- PaintInfo paintInfo(context, outlineRect.rect(), PaintPhaseSelfOutline, false, paintingRootForRenderer, 0, 0);
- m_owningLayer->clipToRect(rootLayer, context, paintDirtyRect, outlineRect, DoNotIncludeSelfForBorderRadius);
- renderer()->paint(paintInfo, paintOffset);
- m_owningLayer->restoreClip(context, paintDirtyRect, outlineRect);
- }
-
- // Paint any child layers that have overflow.
- m_owningLayer->paintList(m_owningLayer->normalFlowList(), rootLayer, context, paintDirtyRect, paintBehavior, paintingRoot, 0, 0, 0);
-
- // Now walk the sorted list of children with positive z-indices.
- m_owningLayer->paintList(m_owningLayer->posZOrderList(), rootLayer, context, paintDirtyRect, paintBehavior, paintingRoot, 0, 0, 0);
- }
-
- if (paintingPhase & GraphicsLayerPaintMask) {
- if (renderer()->hasMask() && !selectionOnly && !damageRect.isEmpty()) {
- m_owningLayer->clipToRect(rootLayer, context, paintDirtyRect, damageRect, DoNotIncludeSelfForBorderRadius);
-
- // Paint the mask.
- PaintInfo paintInfo(context, damageRect.rect(), PaintPhaseMask, false, paintingRootForRenderer, 0, 0);
- renderer()->paint(paintInfo, paintOffset);
-
- // Restore the clip.
- m_owningLayer->restoreClip(context, paintDirtyRect, damageRect);
- }
- }
-
-#if ENABLE(CSS_FILTERS)
- if (filterPainter.hasStartedFilterEffect())
- context = filterPainter.applyFilterEffect();
-#endif
-
ASSERT(!m_owningLayer->m_usedTransparency);
}