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 @@ ...@@ -5,8 +5,7 @@
#include "config.h" #include "config.h"
#include "core/paint/ClipRecorder.h" #include "core/paint/ClipRecorder.h"
#include "core/rendering/RenderLayer.h" #include "core/rendering/ClipRect.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/RenderView.h" #include "core/rendering/RenderView.h"
#include "platform/RuntimeEnabledFeatures.h" #include "platform/RuntimeEnabledFeatures.h"
#include "platform/graphics/GraphicsContext.h" #include "platform/graphics/GraphicsContext.h"
...@@ -26,17 +25,17 @@ void EndClipDisplayItem::replay(GraphicsContext* context) ...@@ -26,17 +25,17 @@ void EndClipDisplayItem::replay(GraphicsContext* context)
context->restore(); 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_graphicsContext(graphicsContext)
, m_renderLayer(renderLayer) , m_renderer(renderer)
{ {
IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect());
if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) { if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) {
graphicsContext->save(); graphicsContext->save();
graphicsContext->clip(snappedClipRect); graphicsContext->clip(snappedClipRect);
} else { } else {
m_clipDisplayItem = new ClipDisplayItem(0, renderLayer, clipType, snappedClipRect); m_clipDisplayItem = new ClipDisplayItem(renderer, clipType, snappedClipRect);
m_renderLayer->renderer()->view()->viewDisplayList().add(adoptPtr(m_clipDisplayItem)); m_renderer->view()->viewDisplayList().add(adoptPtr(m_clipDisplayItem));
} }
} }
...@@ -51,8 +50,8 @@ void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect) ...@@ -51,8 +50,8 @@ void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect)
ClipRecorder::~ClipRecorder() ClipRecorder::~ClipRecorder()
{ {
if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem); OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem(m_renderer));
m_renderLayer->renderer()->view()->viewDisplayList().add(endClip.release()); m_renderer->view()->viewDisplayList().add(endClip.release());
} else { } else {
m_graphicsContext->restore(); m_graphicsContext->restore();
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "core/paint/ViewDisplayList.h" #include "core/paint/ViewDisplayList.h"
#include "core/rendering/PaintPhase.h" #include "core/rendering/PaintPhase.h"
#include "core/rendering/RenderLayerModelObject.h"
#include "platform/geometry/RoundedRect.h" #include "platform/geometry/RoundedRect.h"
#include "wtf/Vector.h" #include "wtf/Vector.h"
...@@ -14,12 +15,10 @@ namespace blink { ...@@ -14,12 +15,10 @@ namespace blink {
class ClipRect; class ClipRect;
class GraphicsContext; class GraphicsContext;
class RenderObject;
class RenderLayer;
class ClipDisplayItem : public DisplayItem { class ClipDisplayItem : public DisplayItem {
public: public:
ClipDisplayItem(RenderObject* renderer, RenderLayer*, Type type, IntRect clipRect) ClipDisplayItem(const RenderLayerModelObject* renderer, Type type, IntRect clipRect)
: DisplayItem(renderer, type), m_clipRect(clipRect) { } : DisplayItem(renderer, type), m_clipRect(clipRect) { }
Vector<RoundedRect>& roundedRectClips() { return m_roundedRectClips; } Vector<RoundedRect>& roundedRectClips() { return m_roundedRectClips; }
...@@ -36,7 +35,7 @@ private: ...@@ -36,7 +35,7 @@ private:
class EndClipDisplayItem : public DisplayItem { class EndClipDisplayItem : public DisplayItem {
public: public:
EndClipDisplayItem() : DisplayItem(0, EndClip) { } EndClipDisplayItem(const RenderLayerModelObject* renderer) : DisplayItem(renderer, EndClip) { }
private: private:
virtual void replay(GraphicsContext*) override; virtual void replay(GraphicsContext*) override;
...@@ -44,7 +43,7 @@ private: ...@@ -44,7 +43,7 @@ private:
class ClipRecorder { class ClipRecorder {
public: public:
explicit ClipRecorder(RenderLayer*, GraphicsContext*, DisplayItem::Type, const ClipRect&); explicit ClipRecorder(const RenderLayerModelObject*, GraphicsContext*, DisplayItem::Type, const ClipRect&);
void addRoundedRectClip(const RoundedRect&); void addRoundedRectClip(const RoundedRect&);
~ClipRecorder(); ~ClipRecorder();
...@@ -52,7 +51,7 @@ public: ...@@ -52,7 +51,7 @@ public:
private: private:
ClipDisplayItem* m_clipDisplayItem; ClipDisplayItem* m_clipDisplayItem;
GraphicsContext* m_graphicsContext; GraphicsContext* m_graphicsContext;
RenderLayer* m_renderLayer; const RenderLayerModelObject* m_renderer;
}; };
} // namespace blink } // namespace blink
......
...@@ -39,7 +39,7 @@ void drawClip(GraphicsContext* context, RenderView* renderer, PaintPhase phase, ...@@ -39,7 +39,7 @@ void drawClip(GraphicsContext* context, RenderView* renderer, PaintPhase phase,
{ {
IntRect rect(1, 1, 9, 9); IntRect rect(1, 1, 9, 9);
ClipRect clipRect(rect); 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) TEST_F(ClipRecorderTest, ClipRecorderTest_Single)
......
...@@ -45,7 +45,7 @@ FilterPainter::FilterPainter(RenderLayer& renderLayer, GraphicsContext* context, ...@@ -45,7 +45,7 @@ FilterPainter::FilterPainter(RenderLayer& renderLayer, GraphicsContext* context,
paintingInfo.clipToDirtyRect = false; paintingInfo.clipToDirtyRect = false;
if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius()) { 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()) if (clipRect.hasRadius())
LayerPainter::applyRoundedRectClips(renderLayer, paintingInfo, context, paintFlags, *m_clipRecorder); LayerPainter::applyRoundedRectClips(renderLayer, paintingInfo, context, paintFlags, *m_clipRecorder);
} }
......
...@@ -102,7 +102,7 @@ void LayerPainter::paintLayer(GraphicsContext* context, const LayerPaintingInfo& ...@@ -102,7 +102,7 @@ void LayerPainter::paintLayer(GraphicsContext* context, const LayerPaintingInfo&
clipRect.intersect(paintingInfo.paintDirtyRect); clipRect.intersect(paintingInfo.paintDirtyRect);
if (needsToClip(paintingInfo, clipRect)) { 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()) if (clipRect.hasRadius())
applyRoundedRectClips(*m_renderLayer.parent(), paintingInfo, context, paintFlags, *clipRecorder); applyRoundedRectClips(*m_renderLayer.parent(), paintingInfo, context, paintFlags, *clipRecorder);
} }
...@@ -503,7 +503,7 @@ void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer ...@@ -503,7 +503,7 @@ void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer
OwnPtr<ClipRecorder> clipRecorder; OwnPtr<ClipRecorder> clipRecorder;
if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { 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()) if (fragment.backgroundRect.hasRadius())
applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, paintFlags, *clipRecorder); applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, paintFlags, *clipRecorder);
} }
...@@ -692,7 +692,7 @@ void LayerPainter::paintFragmentWithPhase(PaintPhase phase, const LayerFragment& ...@@ -692,7 +692,7 @@ void LayerPainter::paintFragmentWithPhase(PaintPhase phase, const LayerFragment&
ASSERT_NOT_REACHED(); 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()) if (clipRect.hasRadius())
applyRoundedRectClips(m_renderLayer, paintingInfo, context, paintFlags, *clipRecorder, clippingRule); applyRoundedRectClips(m_renderLayer, paintingInfo, context, paintFlags, *clipRecorder, clippingRule);
} }
...@@ -719,7 +719,7 @@ void LayerPainter::paintForegroundForFragments(const LayerFragments& layerFragme ...@@ -719,7 +719,7 @@ void LayerPainter::paintForegroundForFragments(const LayerFragments& layerFragme
ClipState clipState = HasNotClipped; ClipState clipState = HasNotClipped;
OwnPtr<ClipRecorder> clipRecorder; OwnPtr<ClipRecorder> clipRecorder;
if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroundRect)) { 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()) if (layerFragments[0].foregroundRect.hasRadius())
applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, paintFlags, *clipRecorder); applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, paintFlags, *clipRecorder);
clipState = HasClipped; clipState = HasClipped;
...@@ -810,7 +810,7 @@ void LayerPainter::paintTransformedLayerIntoFragments(GraphicsContext* context, ...@@ -810,7 +810,7 @@ void LayerPainter::paintTransformedLayerIntoFragments(GraphicsContext* context,
OwnPtr<ClipRecorder> clipRecorder; OwnPtr<ClipRecorder> clipRecorder;
if (needsToClip(paintingInfo, clipRect)) 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); paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragment.paginationOffset);
} }
......
...@@ -51,8 +51,7 @@ PaintList::iterator ViewDisplayList::findDisplayItem(PaintList::iterator begin, ...@@ -51,8 +51,7 @@ PaintList::iterator ViewDisplayList::findDisplayItem(PaintList::iterator begin,
return it; return it;
} }
// FIXME: Properly handle clips. ASSERT_NOT_REACHED();
ASSERT(!displayItem.renderer());
return end; return end;
} }
......
...@@ -37,6 +37,22 @@ private: ...@@ -37,6 +37,22 @@ private:
RenderView* m_renderView; RenderView* m_renderView;
}; };
class TestDisplayItem : public DisplayItem {
public:
TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(renderer, type) { }
virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); }
};
#define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \
EXPECT_EQ((size_t)expectedSize, actual.size()); \
const TestDisplayItem expected[] = { __VA_ARGS__ }; \
for (size_t index = 0; index < expectedSize; index++) { \
EXPECT_EQ(expected[index].renderer(), actual[index]->renderer()); \
EXPECT_EQ(expected[index].type(), actual[index]->type()); \
} \
}
void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase, const FloatRect& bound) void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase, const FloatRect& bound)
{ {
DrawingRecorder drawingRecorder(context, renderer, phase, bound); DrawingRecorder drawingRecorder(context, renderer, phase, bound);
...@@ -44,12 +60,12 @@ void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase ...@@ -44,12 +60,12 @@ void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase
context->drawRect(rect); context->drawRect(rect);
} }
void drawClippedRect(GraphicsContext* context, RenderView* renderView, PaintPhase phase, const FloatRect& bound) void drawClippedRect(GraphicsContext* context, RenderLayerModelObject* renderer, PaintPhase phase, const FloatRect& bound)
{ {
IntRect rect(1, 1, 9, 9); IntRect rect(1, 1, 9, 9);
ClipRect clipRect(rect); ClipRect clipRect(rect);
ClipRecorder clipRecorder(renderView->compositor()->rootRenderLayer(), context, DisplayItem::ClipLayerForeground, clipRect); ClipRecorder clipRecorder(renderer, context, DisplayItem::ClipLayerForeground, clipRect);
drawRect(context, renderView, phase, bound); drawRect(context, renderer, phase, bound);
} }
TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders) TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
...@@ -58,9 +74,11 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders) ...@@ -58,9 +74,11 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
FloatRect bound = renderView()->viewRect(); FloatRect bound = renderView()->viewRect();
drawClippedRect(context, renderView(), PaintPhaseForeground, bound); drawClippedRect(context, renderView(), PaintPhaseForeground, bound);
EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size());
// TODO(schenney): Check that the IDs are what we expect. EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3,
TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground),
TestDisplayItem(renderView(), DisplayItem::DrawingPaintPhaseForeground),
TestDisplayItem(renderView(), DisplayItem::EndClip));
} }
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic) TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
...@@ -74,12 +92,18 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic) ...@@ -74,12 +92,18 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
drawRect(context, second, PaintPhaseChildBlockBackground, FloatRect(100, 100, 200, 200)); drawRect(context, second, PaintPhaseChildBlockBackground, FloatRect(100, 100, 200, 200));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size()); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
TestDisplayItem(second, DisplayItem::DrawingPaintPhaseChildBlockBackground),
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(second); renderView()->viewDisplayList().invalidate(second);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300)); drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300)); drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
EXPECT_EQ((size_t)2, renderView()->viewDisplayList().paintList().size());
EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
} }
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder) TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
...@@ -94,21 +118,19 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder) ...@@ -94,21 +118,19 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
drawRect(context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300, 10, 10)); drawRect(context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300, 10, 10));
const PaintList& firstList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3,
EXPECT_EQ((size_t)3, firstList.size()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, firstList[0]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(second, firstList[1]->renderer()); TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackground));
EXPECT_EQ(unaffected, firstList[2]->renderer());
renderView()->viewDisplayList().invalidate(second); renderView()->viewDisplayList().invalidate(second);
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
const PaintList& secondList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3,
EXPECT_EQ((size_t)3, secondList.size()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(second, secondList[0]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, secondList[1]->renderer()); TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackground));
EXPECT_EQ(unaffected, secondList[2]->renderer());
} }
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle) TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
...@@ -122,21 +144,19 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle) ...@@ -122,21 +144,19 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
const PaintList& firstList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
EXPECT_EQ((size_t)2, firstList.size()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, firstList[0]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground));
EXPECT_EQ(second, firstList[1]->renderer());
renderView()->viewDisplayList().invalidate(third); renderView()->viewDisplayList().invalidate(third);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
drawRect(context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200, 50)); drawRect(context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200, 50));
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200)); drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
const PaintList& secondList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 3,
EXPECT_EQ((size_t)3, secondList.size()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, secondList[0]->renderer()); TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(third, secondList[1]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground));
EXPECT_EQ(second, secondList[2]->renderer());
} }
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases) TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
...@@ -157,13 +177,16 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases) ...@@ -157,13 +177,16 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200)); drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200));
drawRect(context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50)); drawRect(context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50));
const PaintList& firstList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 9,
EXPECT_EQ((size_t)9, firstList.size()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
for (int item = 0; item < 9; item += 3) { TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, firstList[item % 3 + 0]->renderer()); TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(second, firstList[item % 3 + 1]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground),
EXPECT_EQ(third, firstList[item % 3 + 2]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseForeground),
} TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground),
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline),
TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(second); renderView()->viewDisplayList().invalidate(second);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100)); drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
...@@ -173,21 +196,26 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases) ...@@ -173,21 +196,26 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100)); drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100));
drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200)); drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200));
const PaintList& secondList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 9,
EXPECT_EQ((size_t)9, secondList.size()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
for (int item = 0; item < 9; item += 3) { TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, secondList[item % 3 + 0]->renderer()); TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(second, secondList[item % 3 + 1]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground),
EXPECT_EQ(third, secondList[item % 3 + 2]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseForeground),
} TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground),
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline),
TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
renderView()->viewDisplayList().invalidate(second); renderView()->viewDisplayList().invalidate(second);
const PaintList& thirdList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)6, thirdList.size()); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 6,
for (int item = 0; item < 6; item += 2) { TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, thirdList[item % 2 + 0]->renderer()); TestDisplayItem(third, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(third, thirdList[item % 2 + 1]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseForeground),
} TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground),
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
} }
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap) TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap)
...@@ -200,27 +228,25 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap) ...@@ -200,27 +228,25 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
const PaintList& firstList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
EXPECT_EQ((size_t)2, firstList.size()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(second, firstList[0]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
EXPECT_EQ(second, firstList[1]->renderer());
renderView()->viewDisplayList().invalidate(first); renderView()->viewDisplayList().invalidate(first);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50)); drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50)); drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
const PaintList& secondList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4,
EXPECT_EQ((size_t)4, secondList.size()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, secondList[0]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
EXPECT_EQ(first, secondList[1]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(second, secondList[2]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
EXPECT_EQ(second, secondList[3]->renderer());
renderView()->viewDisplayList().invalidate(first); renderView()->viewDisplayList().invalidate(first);
const PaintList& thirdList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)2, thirdList.size()); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
EXPECT_EQ(second, thirdList[0]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(second, thirdList[1]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
} }
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap) TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap)
...@@ -233,10 +259,9 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap) ...@@ -233,10 +259,9 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
const PaintList& firstList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
EXPECT_EQ((size_t)2, firstList.size()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(second, firstList[0]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
EXPECT_EQ(second, firstList[1]->renderer());
renderView()->viewDisplayList().invalidate(first); renderView()->viewDisplayList().invalidate(first);
renderView()->viewDisplayList().invalidate(second); renderView()->viewDisplayList().invalidate(second);
...@@ -245,21 +270,19 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap) ...@@ -245,21 +270,19 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
const PaintList& secondList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4,
EXPECT_EQ((size_t)4, secondList.size()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, secondList[0]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
EXPECT_EQ(first, secondList[1]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(second, secondList[2]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
EXPECT_EQ(second, secondList[3]->renderer());
renderView()->viewDisplayList().invalidate(first); renderView()->viewDisplayList().invalidate(first);
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
const PaintList& thirdList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
EXPECT_EQ((size_t)2, thirdList.size()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(second, thirdList[0]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
EXPECT_EQ(second, thirdList[1]->renderer());
} }
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap) TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap)
...@@ -272,27 +295,25 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap) ...@@ -272,27 +295,25 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap)
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50)); drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50)); drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
const PaintList& firstList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
EXPECT_EQ((size_t)2, firstList.size()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, firstList[0]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
EXPECT_EQ(first, firstList[1]->renderer());
renderView()->viewDisplayList().invalidate(second); renderView()->viewDisplayList().invalidate(second);
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
const PaintList& secondList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4,
EXPECT_EQ((size_t)4, secondList.size()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(second, secondList[0]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline),
EXPECT_EQ(second, secondList[1]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, secondList[2]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
EXPECT_EQ(first, secondList[3]->renderer());
renderView()->viewDisplayList().invalidate(second); renderView()->viewDisplayList().invalidate(second);
const PaintList& thirdList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)2, thirdList.size()); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
EXPECT_EQ(first, thirdList[0]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, thirdList[1]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
} }
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap) TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap)
...@@ -305,10 +326,9 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap) ...@@ -305,10 +326,9 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap)
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
const PaintList& firstList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
EXPECT_EQ((size_t)2, firstList.size()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, firstList[0]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
EXPECT_EQ(first, firstList[1]->renderer());
renderView()->viewDisplayList().invalidate(first); renderView()->viewDisplayList().invalidate(first);
renderView()->viewDisplayList().invalidate(second); renderView()->viewDisplayList().invalidate(second);
...@@ -317,22 +337,63 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap) ...@@ -317,22 +337,63 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50)); drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50)); drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
const PaintList& secondList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4,
EXPECT_EQ((size_t)4, secondList.size()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, secondList[0]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
EXPECT_EQ(first, secondList[1]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(second, secondList[2]->renderer()); TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
EXPECT_EQ(second, secondList[3]->renderer());
renderView()->viewDisplayList().invalidate(first); renderView()->viewDisplayList().invalidate(first);
renderView()->viewDisplayList().invalidate(second); renderView()->viewDisplayList().invalidate(second);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
const PaintList& thirdList = renderView()->viewDisplayList().paintList(); EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
EXPECT_EQ((size_t)2, thirdList.size()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
EXPECT_EQ(first, thirdList[0]->renderer()); TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
EXPECT_EQ(first, thirdList[1]->renderer()); }
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip)
{
setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document().body()->firstChild()->renderer());
RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document().body()->firstChild()->firstChild()->renderer());
GraphicsContext* context = new GraphicsContext(nullptr);
ClipRect firstClipRect(IntRect(1, 1, 2, 2));
{
ClipRecorder clipRecorder(firstRenderer, context, DisplayItem::ClipLayerForeground, firstClipRect);
drawRect(context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
}
EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4,
TestDisplayItem(firstRenderer, DisplayItem::ClipLayerForeground),
TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
TestDisplayItem(firstRenderer, DisplayItem::EndClip));
renderView()->viewDisplayList().invalidate(firstRenderer);
drawRect(context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 2,
TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackground));
renderView()->viewDisplayList().invalidate(secondRenderer);
drawRect(context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
ClipRect secondClipRect(IntRect(1, 1, 2, 2));
{
ClipRecorder clipRecorder(secondRenderer, context, DisplayItem::ClipLayerForeground, secondClipRect);
drawRect(context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
}
EXPECT_DISPLAY_LIST(renderView()->viewDisplayList().paintList(), 4,
TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground),
TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
TestDisplayItem(secondRenderer, DisplayItem::EndClip));
} }
} }
......
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