Commit 97b836e3 authored by pdr@chromium.org's avatar pdr@chromium.org

[Slimming Paint] Track clip renderers

This patch updates the clip recorder and clip items to track a
RenderLayerModelObject (a subclass of RenderObject) so invalidations
are properly handled in the update algorithm just like regular
DisplayItems. Clipper callsites have been updated accordingly.

With this patch, the ASSERT in ViewDisplayList::findDisplayItem can
now be removed.

TEST=ViewDisplayListTest_UpdateClip

Review URL: https://codereview.chromium.org/719353004

git-svn-id: svn://svn.chromium.org/blink/trunk@185341 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 68ae0bc1
......@@ -5,8 +5,7 @@
#include "config.h"
#include "core/paint/ClipRecorder.h"
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/ClipRect.h"
#include "core/rendering/RenderView.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/graphics/GraphicsContext.h"
......@@ -26,17 +25,17 @@ void EndClipDisplayItem::replay(GraphicsContext* context)
context->restore();
}
ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsContext, DisplayItem::Type clipType, const ClipRect& clipRect)
ClipRecorder::ClipRecorder(const RenderLayerModelObject* renderer, GraphicsContext* graphicsContext, DisplayItem::Type clipType, const ClipRect& clipRect)
: m_graphicsContext(graphicsContext)
, m_renderLayer(renderLayer)
, m_renderer(renderer)
{
IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect());
if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) {
graphicsContext->save();
graphicsContext->clip(snappedClipRect);
} else {
m_clipDisplayItem = new ClipDisplayItem(0, renderLayer, clipType, snappedClipRect);
m_renderLayer->renderer()->view()->viewDisplayList().add(adoptPtr(m_clipDisplayItem));
m_clipDisplayItem = new ClipDisplayItem(renderer, clipType, snappedClipRect);
m_renderer->view()->viewDisplayList().add(adoptPtr(m_clipDisplayItem));
}
}
......@@ -51,8 +50,8 @@ void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect)
ClipRecorder::~ClipRecorder()
{
if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem);
m_renderLayer->renderer()->view()->viewDisplayList().add(endClip.release());
OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem(m_renderer));
m_renderer->view()->viewDisplayList().add(endClip.release());
} else {
m_graphicsContext->restore();
}
......
......@@ -7,6 +7,7 @@
#include "core/paint/ViewDisplayList.h"
#include "core/rendering/PaintPhase.h"
#include "core/rendering/RenderLayerModelObject.h"
#include "platform/geometry/RoundedRect.h"
#include "wtf/Vector.h"
......@@ -14,12 +15,10 @@ namespace blink {
class ClipRect;
class GraphicsContext;
class RenderObject;
class RenderLayer;
class ClipDisplayItem : public DisplayItem {
public:
ClipDisplayItem(RenderObject* renderer, RenderLayer*, Type type, IntRect clipRect)
ClipDisplayItem(const RenderLayerModelObject* renderer, Type type, IntRect clipRect)
: DisplayItem(renderer, type), m_clipRect(clipRect) { }
Vector<RoundedRect>& roundedRectClips() { return m_roundedRectClips; }
......@@ -36,7 +35,7 @@ private:
class EndClipDisplayItem : public DisplayItem {
public:
EndClipDisplayItem() : DisplayItem(0, EndClip) { }
EndClipDisplayItem(const RenderLayerModelObject* renderer) : DisplayItem(renderer, EndClip) { }
private:
virtual void replay(GraphicsContext*) override;
......@@ -44,7 +43,7 @@ private:
class ClipRecorder {
public:
explicit ClipRecorder(RenderLayer*, GraphicsContext*, DisplayItem::Type, const ClipRect&);
explicit ClipRecorder(const RenderLayerModelObject*, GraphicsContext*, DisplayItem::Type, const ClipRect&);
void addRoundedRectClip(const RoundedRect&);
~ClipRecorder();
......@@ -52,7 +51,7 @@ public:
private:
ClipDisplayItem* m_clipDisplayItem;
GraphicsContext* m_graphicsContext;
RenderLayer* m_renderLayer;
const RenderLayerModelObject* m_renderer;
};
} // namespace blink
......
......@@ -39,7 +39,7 @@ void drawClip(GraphicsContext* context, RenderView* renderer, PaintPhase phase,
{
IntRect rect(1, 1, 9, 9);
ClipRect clipRect(rect);
ClipRecorder clipRecorder(renderer->compositor()->rootRenderLayer(), context, DisplayItem::ClipLayerForeground, clipRect);
ClipRecorder clipRecorder(renderer->compositor()->rootRenderLayer()->renderer(), context, DisplayItem::ClipLayerForeground, clipRect);
}
TEST_F(ClipRecorderTest, ClipRecorderTest_Single)
......
......@@ -45,7 +45,7 @@ FilterPainter::FilterPainter(RenderLayer& renderLayer, GraphicsContext* context,
paintingInfo.clipToDirtyRect = false;
if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius()) {
m_clipRecorder = adoptPtr(new ClipRecorder(&renderLayer, context, DisplayItem::ClipLayerFilter, clipRect));
m_clipRecorder = adoptPtr(new ClipRecorder(renderLayer.renderer(), context, DisplayItem::ClipLayerFilter, clipRect));
if (clipRect.hasRadius())
LayerPainter::applyRoundedRectClips(renderLayer, paintingInfo, context, paintFlags, *m_clipRecorder);
}
......
......@@ -102,7 +102,7 @@ void LayerPainter::paintLayer(GraphicsContext* context, const LayerPaintingInfo&
clipRect.intersect(paintingInfo.paintDirtyRect);
if (needsToClip(paintingInfo, clipRect)) {
clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent(), context, DisplayItem::ClipLayerParent, clipRect));
clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent()->renderer(), context, DisplayItem::ClipLayerParent, clipRect));
if (clipRect.hasRadius())
applyRoundedRectClips(*m_renderLayer.parent(), paintingInfo, context, paintFlags, *clipRecorder);
}
......@@ -503,7 +503,7 @@ void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer
OwnPtr<ClipRecorder> clipRecorder;
if (needsToClip(localPaintingInfo, fragment.backgroundRect)) {
clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect));
clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect));
if (fragment.backgroundRect.hasRadius())
applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, paintFlags, *clipRecorder);
}
......@@ -692,7 +692,7 @@ void LayerPainter::paintFragmentWithPhase(PaintPhase phase, const LayerFragment&
ASSERT_NOT_REACHED();
}
clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, clipType, clipRect));
clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, clipType, clipRect));
if (clipRect.hasRadius())
applyRoundedRectClips(m_renderLayer, paintingInfo, context, paintFlags, *clipRecorder, clippingRule);
}
......@@ -719,7 +719,7 @@ void LayerPainter::paintForegroundForFragments(const LayerFragments& layerFragme
ClipState clipState = HasNotClipped;
OwnPtr<ClipRecorder> clipRecorder;
if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroundRect)) {
clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, DisplayItem::ClipLayerForeground, layerFragments[0].foregroundRect));
clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerForeground, layerFragments[0].foregroundRect));
if (layerFragments[0].foregroundRect.hasRadius())
applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, paintFlags, *clipRecorder);
clipState = HasClipped;
......@@ -810,7 +810,7 @@ void LayerPainter::paintTransformedLayerIntoFragments(GraphicsContext* context,
OwnPtr<ClipRecorder> clipRecorder;
if (needsToClip(paintingInfo, clipRect))
clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent(), context, DisplayItem::ClipLayerFragmentParent, clipRect));
clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerFragmentParent, clipRect));
paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragment.paginationOffset);
}
......
......@@ -51,8 +51,7 @@ PaintList::iterator ViewDisplayList::findDisplayItem(PaintList::iterator begin,
return it;
}
// FIXME: Properly handle clips.
ASSERT(!displayItem.renderer());
ASSERT_NOT_REACHED();
return end;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment