Index: Source/core/paint/LayerPainter.cpp |
diff --git a/Source/core/paint/LayerPainter.cpp b/Source/core/paint/LayerPainter.cpp |
index 0d815861c0155c14512cbcb7dbb6f4b272e01af9..75b7acc4e7f73fd552822ee1503ecb3020268799 100644 |
--- a/Source/core/paint/LayerPainter.cpp |
+++ b/Source/core/paint/LayerPainter.cpp |
@@ -8,7 +8,6 @@ |
#include "core/frame/Settings.h" |
#include "core/page/Page.h" |
#include "core/paint/FilterPainter.h" |
-#include "core/paint/LayerClipRecorder.h" |
#include "core/paint/TransformDisplayItem.h" |
#include "core/paint/TransparencyDisplayItem.h" |
#include "core/rendering/ClipPathOperation.h" |
@@ -79,6 +78,47 @@ |
paintLayerContentsAndReflection(context, paintingInfo, paintFlags); |
} |
+ |
+class TransparencyLayerHelper { |
+public: |
+ TransparencyLayerHelper(GraphicsContext* context, RenderLayer& renderLayer, const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelAccumulation, PaintBehavior paintBehavior) |
+ : m_transparencyLayerInProgress(false) |
+ , m_context(context) |
+ , m_renderLayer(renderLayer) |
+ { |
+ // Blending operations must be performed only with the nearest ancestor stacking context. |
+ // Note that there is no need to create a transparency layer if we're painting the root. |
+ // FIXME: this should be unified further into RenderLayer::paintsWithTransparency(). |
+ bool shouldUseTransparencyLayerForBlendMode = !renderLayer.renderer()->isDocumentElement() && renderLayer.stackingNode()->isStackingContext() && renderLayer.hasNonIsolatedDescendantWithBlendMode(); |
+ if (!shouldUseTransparencyLayerForBlendMode && !renderLayer.paintsWithTransparency(paintBehavior)) |
+ return; |
+ |
+ OwnPtr<BeginTransparencyDisplayItem> beginTransparencyDisplayItem = adoptPtr(new BeginTransparencyDisplayItem( |
+ renderLayer.renderer(), DisplayItem::BeginTransparency, renderLayer.paintingExtent(rootLayer, paintDirtyRect, subPixelAccumulation, paintBehavior), |
+ renderLayer.renderer()->style()->blendMode(), renderLayer.renderer()->opacity())); |
+ if (RuntimeEnabledFeatures::slimmingPaintEnabled()) |
+ renderLayer.renderer()->view()->viewDisplayList().add(beginTransparencyDisplayItem.release()); |
+ else |
+ beginTransparencyDisplayItem->replay(context); |
+ |
+ m_transparencyLayerInProgress = true; |
+ } |
+ |
+ ~TransparencyLayerHelper() |
+ { |
+ if (!m_transparencyLayerInProgress) |
+ return; |
+ OwnPtr<EndTransparencyDisplayItem> endTransparencyDisplayItem = adoptPtr(new EndTransparencyDisplayItem(m_renderLayer.renderer(), DisplayItem::EndTransparency)); |
+ if (RuntimeEnabledFeatures::slimmingPaintEnabled()) |
+ m_renderLayer.renderer()->view()->viewDisplayList().add(endTransparencyDisplayItem.release()); |
+ else |
+ endTransparencyDisplayItem->replay(m_context); |
+ } |
+private: |
+ bool m_transparencyLayerInProgress; |
+ GraphicsContext* m_context; |
+ const RenderLayer& m_renderLayer; |
+}; |
void LayerPainter::paintLayerContentsAndReflection(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) |
{ |
@@ -203,21 +243,7 @@ |
// These helpers output clip and transparency layers using a RAII pattern. Stack-allocated-varibles are destructed in the reverse order of construction, |
// so they are nested properly. |
ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRelativeBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); |
- |
- OwnPtr<TransparencyRecorder> transparencyRecorder; |
- OwnPtr<LayerClipRecorder> clipRecorder; |
- // Blending operations must be performed only with the nearest ancestor stacking context. |
- // Note that there is no need to create a transparency layer if we're painting the root. |
- // FIXME: this should be unified further into RenderLayer::paintsWithTransparency(). |
- bool shouldUseTransparencyLayerForBlendMode = !m_renderLayer.renderer()->isDocumentElement() && m_renderLayer.stackingNode()->isStackingContext() && m_renderLayer.hasNonIsolatedDescendantWithBlendMode(); |
- if (shouldUseTransparencyLayerForBlendMode || m_renderLayer.paintsWithTransparency(paintingInfo.paintBehavior)) { |
- clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer(), context, DisplayItem::TransparencyClip, |
- m_renderLayer.paintingExtent(paintingInfo.rootLayer, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior), |
- &paintingInfo, LayoutPoint(), paintFlags)); |
- |
- transparencyRecorder = adoptPtr(new TransparencyRecorder(context, m_renderLayer.renderer(), DisplayItem::BeginTransparency, |
- m_renderLayer.renderer()->style()->blendMode(), m_renderLayer.renderer()->opacity())); |
- } |
+ TransparencyLayerHelper transparencyLayerHelper(context, m_renderLayer, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior); |
LayerPaintingInfo localPaintingInfo(paintingInfo); |
@@ -362,7 +388,7 @@ |
} |
for (const auto& fragment: fragments) { |
- OwnPtr<LayerClipRecorder> clipRecorder; |
+ OwnPtr<ClipRecorder> clipRecorder; |
if (parentLayer) { |
ClipRect clipRectForFragment(clipRect); |
clipRectForFragment.moveBy(fragment.paginationOffset); |
@@ -370,7 +396,7 @@ |
if (clipRectForFragment.isEmpty()) |
continue; |
if (needsToClip(paintingInfo, clipRectForFragment)) |
- clipRecorder = adoptPtr(new LayerClipRecorder(parentLayer->renderer(), context, DisplayItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginationOffset, paintFlags)); |
+ clipRecorder = adoptPtr(new ClipRecorder(parentLayer->renderer(), context, DisplayItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginationOffset, paintFlags)); |
} |
paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, fragment.paginationOffset); |
@@ -466,10 +492,10 @@ |
for (size_t i = 0; i < layerFragments.size(); ++i) { |
const LayerFragment& fragment = layerFragments.at(i); |
- OwnPtr<LayerClipRecorder> clipRecorder; |
+ OwnPtr<ClipRecorder> clipRecorder; |
if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { |
- clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fragment.paginationOffset, paintFlags)); |
+ clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fragment.paginationOffset, paintFlags)); |
} |
if (RenderLayerScrollableArea* scrollableArea = m_renderLayer.scrollableArea()) |
scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoint(fragment.layerBounds.location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))), pixelSnappedIntRect(fragment.backgroundRect.rect()), true); |
@@ -618,9 +644,9 @@ |
void LayerPainter::paintFragmentWithPhase(PaintPhase phase, const LayerFragment& fragment, GraphicsContext* context, const ClipRect& clipRect, const LayerPaintingInfo& paintingInfo, PaintBehavior paintBehavior, RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags, ClipState clipState) |
{ |
- OwnPtr<LayerClipRecorder> clipRecorder; |
+ OwnPtr<ClipRecorder> clipRecorder; |
if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(paintingInfo, clipRect)) { |
- LayerClipRecorder::BorderRadiusClippingRule clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; |
+ ClipRecorder::BorderRadiusClippingRule clippingRule = ClipRecorder::IncludeSelfForBorderRadius; |
DisplayItem::Type clipType = DisplayItem::ClipLayerFragmentFloat; |
switch (phase) { |
case PaintPhaseFloat: |
@@ -639,15 +665,15 @@ |
break; |
case PaintPhaseBlockBackground: |
clipType = DisplayItem::ClipLayerBackground; |
- clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; // Background painting will handle clipping to self. |
+ clippingRule = ClipRecorder::DoNotIncludeSelfForBorderRadius; // Background painting will handle clipping to self. |
break; |
case PaintPhaseSelfOutline: |
clipType = DisplayItem::ClipLayerFragmentOutline; |
- clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; |
+ clippingRule = ClipRecorder::DoNotIncludeSelfForBorderRadius; |
break; |
case PaintPhaseMask: |
clipType = DisplayItem::ClipLayerFragmentMask; |
- clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; // Mask painting will handle clipping to self. |
+ clippingRule = ClipRecorder::DoNotIncludeSelfForBorderRadius; // Mask painting will handle clipping to self. |
break; |
case PaintPhaseClippingMask: |
clipType = DisplayItem::ClipLayerFragmentClippingMask; |
@@ -656,7 +682,7 @@ |
ASSERT_NOT_REACHED(); |
} |
- clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer(), context, clipType, clipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule)); |
+ clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, clipType, clipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule)); |
} |
PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, paintBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->renderer()); |
@@ -679,9 +705,9 @@ |
// Optimize clipping for the single fragment case. |
bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty(); |
ClipState clipState = HasNotClipped; |
- OwnPtr<LayerClipRecorder> clipRecorder; |
+ OwnPtr<ClipRecorder> clipRecorder; |
if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroundRect)) { |
- clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, layerFragments[0].paginationOffset, paintFlags)); |
+ clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, layerFragments[0].paginationOffset, paintFlags)); |
clipState = HasClipped; |
} |