Revert "Move ViewDisplayList to GraphicsLayer"

This reverts commit 97aec2f2a341c96bce31aa8264828135c44e1ccb, aka r185263.

This a speculative revert to fix Android Tests (dbg), which is currently
blocking the Blink roll.

TBR=trchen,pdr
BUG=

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

git-svn-id: svn://svn.chromium.org/blink/trunk@185287 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 9c8b3c86
......@@ -26,11 +26,6 @@ crbug.com/437743 [ Mac ] virtual/slimmingpaint/fast/block/float/float-avoidance.
crbug.com/437743 [ Mac ] virtual/slimmingpaint/fast/block/positioning/inline-block-relposition.html [ ImageOnlyFailure ]
crbug.com/437743 [ Mac ] virtual/slimmingpaint/fast/block/margin-collapse/103.html [ ImageOnlyFailure ]
crbug.com/432713 [ Debug ] virtual/slimmingpaint/fast/block/float/021.html [ ImageOnlyFailure ]
crbug.com/432713 [ Debug ] virtual/slimmingpaint/fast/block/positioning/relative-overflow-block.html [ ImageOnlyFailure ]
crbug.com/432713 [ Debug ] virtual/slimmingpaint/fast/block/positioning/relative-overflow-replaced-float.html [ ImageOnlyFailure ]
crbug.com/432713 [ Debug ] virtual/slimmingpaint/fast/block/positioning/relative-overflow-replaced.html [ ImageOnlyFailure ]
# Text::inDocument() returns false but should not.
crbug.com/264138 dom/xhtml/level3/core/nodecomparedocumentposition38.xhtml [ Failure ]
......
......@@ -1516,6 +1516,8 @@
'paint/TableSectionPainter.h',
'paint/VideoPainter.cpp',
'paint/VideoPainter.h',
'paint/ViewDisplayList.cpp',
'paint/ViewDisplayList.h',
'paint/ViewPainter.cpp',
'paint/ViewPainter.h',
'plugins/DOMMimeType.cpp',
......@@ -1575,8 +1577,6 @@
'rendering/OrderIterator.h',
'rendering/PaintInvalidationState.cpp',
'rendering/PaintInvalidationState.h',
'rendering/PaintPhase.cpp',
'rendering/PaintPhase.h',
'rendering/PointerEventsHitRules.cpp',
'rendering/PointerEventsHitRules.h',
'rendering/RenderApplet.cpp',
......@@ -3554,8 +3554,6 @@
'rendering/RenderPartTest.cpp',
'rendering/RenderTableCellTest.cpp',
'rendering/RenderTableRowTest.cpp',
'rendering/RenderingTestHelper.cpp',
'rendering/RenderingTestHelper.h',
'rendering/TextPainterTest.cpp',
'rendering/shapes/BoxShapeTest.cpp',
'rendering/style/OutlineValueTest.cpp',
......
......@@ -7,14 +7,25 @@
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/RenderView.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/paint/ClipDisplayItem.h"
#include "platform/graphics/paint/DisplayItemList.h"
namespace blink {
void ClipDisplayItem::replay(GraphicsContext* context)
{
context->save();
context->clip(m_clipRect);
for (RoundedRect roundedRect : m_roundedRectClips)
context->clipRoundedRect(roundedRect);
}
void EndClipDisplayItem::replay(GraphicsContext* context)
{
context->restore();
}
ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsContext, DisplayItem::Type clipType, const ClipRect& clipRect)
: m_graphicsContext(graphicsContext)
, m_renderLayer(renderLayer)
......@@ -24,12 +35,8 @@ ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsCo
graphicsContext->save();
graphicsContext->clip(snappedClipRect);
} else {
m_clipDisplayItem = new ClipDisplayItem(nullptr, clipType, snappedClipRect);
#ifndef NDEBUG
m_clipDisplayItem->setClientDebugString("nullptr");
#endif
if (RenderLayer* container = m_renderLayer->enclosingLayerForPaintInvalidationCrossingFrameBoundaries())
container->graphicsLayerBacking()->displayItemList().add(adoptPtr(m_clipDisplayItem));
m_clipDisplayItem = new ClipDisplayItem(0, renderLayer, clipType, snappedClipRect);
m_renderLayer->renderer()->view()->viewDisplayList().add(adoptPtr(m_clipDisplayItem));
}
}
......@@ -45,11 +52,19 @@ ClipRecorder::~ClipRecorder()
{
if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem);
if (RenderLayer* container = m_renderLayer->enclosingLayerForPaintInvalidationCrossingFrameBoundaries())
container->graphicsLayerBacking()->displayItemList().add(endClip.release());
m_renderLayer->renderer()->view()->viewDisplayList().add(endClip.release());
} else {
m_graphicsContext->restore();
}
}
#ifndef NDEBUG
WTF::String ClipDisplayItem::asDebugString() const
{
return String::format("{%s, type: \"%s\", clipRect: [%d,%d,%d,%d]}",
rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()).utf8().data(),
m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height());
}
#endif
} // namespace blink
......@@ -5,15 +5,42 @@
#ifndef ClipRecorder_h
#define ClipRecorder_h
#include "platform/graphics/paint/DisplayItem.h"
#include "core/paint/ViewDisplayList.h"
#include "core/rendering/PaintPhase.h"
#include "platform/geometry/RoundedRect.h"
#include "wtf/Vector.h"
namespace blink {
class ClipDisplayItem;
class ClipRect;
class GraphicsContext;
class RenderObject;
class RenderLayer;
class RoundedRect;
class ClipDisplayItem : public DisplayItem {
public:
ClipDisplayItem(RenderObject* renderer, RenderLayer*, Type type, IntRect clipRect)
: DisplayItem(renderer, type), m_clipRect(clipRect) { }
Vector<RoundedRect>& roundedRectClips() { return m_roundedRectClips; }
private:
virtual void replay(GraphicsContext*) override;
IntRect m_clipRect;
Vector<RoundedRect> m_roundedRectClips;
#ifndef NDEBUG
virtual WTF::String asDebugString() const override;
#endif
};
class EndClipDisplayItem : public DisplayItem {
public:
EndClipDisplayItem() : DisplayItem(0, EndClip) { }
private:
virtual void replay(GraphicsContext*) override;
};
class ClipRecorder {
public:
......@@ -30,4 +57,4 @@ private:
} // namespace blink
#endif // ClipRecorder_h
#endif // ViewDisplayList_h
......@@ -9,8 +9,6 @@
#include "core/rendering/RenderingTestHelper.h"
#include "core/rendering/compositing/RenderLayerCompositor.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/paint/DisplayItemList.h"
#include <gtest/gtest.h>
namespace blink {
......@@ -22,7 +20,6 @@ public:
protected:
RenderView* renderView() { return m_renderView; }
DisplayItemList& rootDisplayItemList() { return renderView()->layer()->graphicsLayerBacking()->displayItemList(); }
private:
virtual void SetUp() override
......@@ -30,7 +27,6 @@ private:
RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
RenderingTest::SetUp();
enableCompositing();
m_renderView = document().view()->renderView();
ASSERT_TRUE(m_renderView);
......@@ -50,10 +46,10 @@ TEST_F(ClipRecorderTest, ClipRecorderTest_Single)
{
GraphicsContext* context = new GraphicsContext(nullptr);
FloatRect bound = renderView()->viewRect();
EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size());
EXPECT_EQ((size_t)0, renderView()->viewDisplayList().paintList().size());
drawClip(context, renderView(), PaintPhaseForeground, bound);
EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size());
EXPECT_EQ((size_t)2, renderView()->viewDisplayList().paintList().size());
}
}
......
......@@ -5,17 +5,18 @@
#include "config.h"
#include "core/paint/DrawingRecorder.h"
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/RenderView.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/graphics/DisplayList.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/paint/DisplayItemList.h"
#include "platform/graphics/paint/DrawingDisplayItem.h"
namespace blink {
void DrawingDisplayItem::replay(GraphicsContext* context)
{
context->drawPicture(m_picture.get(), m_location);
}
#if ENABLE(ASSERT)
static bool s_inDrawingRecorder = false;
#endif
......@@ -51,18 +52,18 @@ DrawingRecorder::~DrawingRecorder()
return;
ASSERT(displayList->bounds() == m_bounds);
OwnPtr<DrawingDisplayItem> drawingItem = adoptPtr(
new DrawingDisplayItem(m_renderer->displayItemClient(), (DisplayItem::Type)m_phase, displayList->picture(), m_bounds.location()));
#ifndef NDEBUG
if (!m_renderer)
drawingItem->setClientDebugString("nullptr");
else if (m_renderer->node())
drawingItem->setClientDebugString(String::format("nodeName: \"%s\", renderer: \"%p\"", m_renderer->node()->nodeName().utf8().data(), m_renderer));
else
drawingItem->setClientDebugString(String::format("renderer: \"%p\"", m_renderer));
#endif
new DrawingDisplayItem(displayList->picture(), m_bounds.location(), m_phase, m_renderer));
ASSERT(m_renderer->view());
m_renderer->view()->viewDisplayList().add(drawingItem.release());
}
if (RenderLayer* container = m_renderer->enclosingLayer()->enclosingLayerForPaintInvalidationCrossingFrameBoundaries())
container->graphicsLayerBacking()->displayItemList().add(drawingItem.release());
#ifndef NDEBUG
WTF::String DrawingDisplayItem::asDebugString() const
{
return String::format("{%s, type: \"%s\", location: [%f,%f]}",
rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()).utf8().data(),
m_location.x(), m_location.y());
}
#endif
} // namespace blink
......@@ -5,13 +5,29 @@
#ifndef DrawingRecorder_h
#define DrawingRecorder_h
#include "core/rendering/PaintPhase.h"
#include "platform/geometry/FloatRect.h"
#include "core/paint/ViewDisplayList.h"
#include "platform/graphics/DisplayList.h"
namespace blink {
class GraphicsContext;
class RenderObject;
class DrawingDisplayItem : public DisplayItem {
public:
DrawingDisplayItem(PassRefPtr<SkPicture> picture, const FloatPoint& location, PaintPhase phase, const RenderObject* renderer)
: DisplayItem(renderer, (Type)phase), m_picture(picture), m_location(location) { }
PassRefPtr<SkPicture> picture() const { return m_picture; }
const FloatPoint& location() const { return m_location; }
private:
virtual void replay(GraphicsContext*);
RefPtr<SkPicture> m_picture;
const FloatPoint m_location;
#ifndef NDEBUG
virtual WTF::String asDebugString() const override;
#endif
};
class DrawingRecorder {
public:
......
......@@ -5,12 +5,9 @@
#include "config.h"
#include "core/paint/DrawingRecorder.h"
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderView.h"
#include "core/rendering/RenderingTestHelper.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/paint/DisplayItemList.h"
#include <gtest/gtest.h>
namespace blink {
......@@ -22,7 +19,6 @@ public:
protected:
RenderView* renderView() { return m_renderView; }
DisplayItemList& rootDisplayItemList() { return renderView()->layer()->graphicsLayerBacking()->displayItemList(); }
private:
virtual void SetUp() override
......@@ -30,7 +26,6 @@ private:
RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
RenderingTest::SetUp();
enableCompositing();
m_renderView = document().view()->renderView();
ASSERT_TRUE(m_renderView);
......@@ -56,10 +51,10 @@ TEST_F(DrawingRecorderTest, DrawingRecorderTest_Nothing)
{
GraphicsContext* context = new GraphicsContext(nullptr);
FloatRect bound = renderView()->viewRect();
EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size());
EXPECT_EQ((size_t)0, renderView()->viewDisplayList().paintList().size());
drawNothing(context, renderView(), PaintPhaseForeground, bound);
EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size());
EXPECT_EQ((size_t)0, renderView()->viewDisplayList().paintList().size());
}
TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect)
......@@ -67,7 +62,7 @@ TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect)
GraphicsContext* context = new GraphicsContext(nullptr);
FloatRect bound = renderView()->viewRect();
drawRect(context, renderView(), PaintPhaseForeground, bound);
EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size());
EXPECT_EQ((size_t)1, renderView()->viewDisplayList().paintList().size());
}
}
......
......@@ -3,18 +3,23 @@
// found in the LICENSE file.
#include "config.h"
#include "platform/graphics/paint/DisplayItemList.h"
#include "core/paint/ViewDisplayList.h"
#include "platform/NotImplemented.h"
#include "platform/RuntimeEnabledFeatures.h"
#ifndef NDEBUG
#include "platform/graphics/paint/DisplayItem.h"
#include "wtf/text/StringBuilder.h"
#include "core/rendering/RenderObject.h"
#include "wtf/text/WTFString.h"
#endif
namespace blink {
const PaintList& DisplayItemList::paintList()
// DisplayItem types must be kept in sync with PaintPhase.
COMPILE_ASSERT((unsigned)DisplayItem::DrawingPaintPhaseBlockBackground == (unsigned)PaintPhaseBlockBackground, DisplayItem_Type_should_stay_in_sync);
COMPILE_ASSERT((unsigned)DisplayItem::DrawingPaintPhaseClippingMask == (unsigned)PaintPhaseClippingMask, DisplayItem_Type_should_stay_in_sync);
const PaintList& ViewDisplayList::paintList()
{
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
......@@ -22,22 +27,22 @@ const PaintList& DisplayItemList::paintList()
return m_paintList;
}
void DisplayItemList::add(WTF::PassOwnPtr<DisplayItem> displayItem)
void ViewDisplayList::add(WTF::PassOwnPtr<DisplayItem> displayItem)
{
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
m_newPaints.append(displayItem);
}
void DisplayItemList::invalidate(DisplayItemClient renderer)
void ViewDisplayList::invalidate(const RenderObject* renderer)
{
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
m_invalidated.add(renderer);
}
PaintList::iterator DisplayItemList::findDisplayItem(PaintList::iterator begin, const DisplayItem& displayItem)
PaintList::iterator ViewDisplayList::findDisplayItem(PaintList::iterator begin, const DisplayItem& displayItem)
{
PaintList::iterator end = m_paintList.end();
if (displayItem.client() && !m_paintListRenderers.contains(displayItem.client()))
if (displayItem.renderer() && !m_paintListRenderers.contains(displayItem.renderer()))
return end;
for (PaintList::iterator it = begin; it != end; ++it) {
......@@ -47,19 +52,19 @@ PaintList::iterator DisplayItemList::findDisplayItem(PaintList::iterator begin,
}
// FIXME: Properly handle clips.
ASSERT(!displayItem.client());
ASSERT(!displayItem.renderer());
return end;
}
bool DisplayItemList::wasInvalidated(const DisplayItem& displayItem) const
bool ViewDisplayList::wasInvalidated(const DisplayItem& displayItem) const
{
// FIXME: Use a bit on DisplayItemClient instead of tracking m_invalidated.
return displayItem.client() && m_invalidated.contains(displayItem.client());
// FIXME: Use a bit on RenderObject instead of tracking m_invalidated.
return displayItem.renderer() && m_invalidated.contains(displayItem.renderer());
}
static void appendDisplayItem(PaintList& list, HashSet<DisplayItemClient>& renderers, WTF::PassOwnPtr<DisplayItem> displayItem)
static void appendDisplayItem(PaintList& list, HashSet<const RenderObject*>& renderers, WTF::PassOwnPtr<DisplayItem> displayItem)
{
if (DisplayItemClient renderer = displayItem->client())
if (const RenderObject* renderer = displayItem->renderer())
renderers.add(renderer);
list.append(displayItem);
}
......@@ -69,10 +74,10 @@ static void appendDisplayItem(PaintList& list, HashSet<DisplayItemClient>& rende
//
// The algorithm is O(|existing paint list| + |newly painted list|): by using
// the ordering implied by the existing paint list, extra treewalks are avoided.
void DisplayItemList::updatePaintList()
void ViewDisplayList::updatePaintList()
{
PaintList updatedList;
HashSet<DisplayItemClient> updatedRenderers;
HashSet<const RenderObject*> updatedRenderers;
if (int maxCapacity = m_newPaints.size() + std::max(0, (int)m_paintList.size() - (int)m_invalidated.size()))
updatedList.reserveCapacity(maxCapacity);
......@@ -111,6 +116,53 @@ void DisplayItemList::updatePaintList()
}
#ifndef NDEBUG
WTF::String DisplayItem::typeAsDebugString(DisplayItem::Type type)
{
switch (type) {
case DisplayItem::DrawingPaintPhaseBlockBackground: return "DrawingPaintPhaseBlockBackground";
case DisplayItem::DrawingPaintPhaseChildBlockBackground: return "DrawingPaintPhaseChildBlockBackground";
case DisplayItem::DrawingPaintPhaseChildBlockBackgrounds: return "DrawingPaintPhaseChildBlockBackgrounds";
case DisplayItem::DrawingPaintPhaseFloat: return "DrawingPaintPhaseFloat";
case DisplayItem::DrawingPaintPhaseForeground: return "DrawingPaintPhaseForeground";
case DisplayItem::DrawingPaintPhaseOutline: return "DrawingPaintPhaseOutline";
case DisplayItem::DrawingPaintPhaseChildOutlines: return "DrawingPaintPhaseChildOutlines";
case DisplayItem::DrawingPaintPhaseSelfOutline: return "DrawingPaintPhaseSelfOutline";
case DisplayItem::DrawingPaintPhaseSelection: return "DrawingPaintPhaseSelection";
case DisplayItem::DrawingPaintPhaseCollapsedTableBorders: return "DrawingPaintPhaseCollapsedTableBorders";
case DisplayItem::DrawingPaintPhaseTextClip: return "DrawingPaintPhaseTextClip";
case DisplayItem::DrawingPaintPhaseMask: return "DrawingPaintPhaseMask";
case DisplayItem::DrawingPaintPhaseClippingMask: return "DrawingPaintPhaseClippingMask";
case DisplayItem::ClipLayerOverflowControls: return "ClipLayerOverflowControls";
case DisplayItem::ClipLayerBackground: return "ClipLayerBackground";
case DisplayItem::ClipLayerParent: return "ClipLayerParent";
case DisplayItem::ClipLayerFilter: return "ClipLayerFilter";
case DisplayItem::ClipLayerForeground: return "ClipLayerForeground";
case DisplayItem::ClipLayerFragmentFloat: return "ClipLayerFragmentFloat";
case DisplayItem::ClipLayerFragmentForeground: return "ClipLayerFragmentForeground";
case DisplayItem::ClipLayerFragmentChildOutline: return "ClipLayerFragmentChildOutline";
case DisplayItem::ClipLayerFragmentOutline: return "ClipLayerFragmentOutline";
case DisplayItem::ClipLayerFragmentMask: return "ClipLayerFragmentMask";
case DisplayItem::ClipLayerFragmentClippingMask: return "ClipLayerFragmentClippingMask";
case DisplayItem::ClipLayerFragmentParent: return "ClipLayerFragmentParent";
case DisplayItem::ClipLayerFragmentSelection: return "ClipLayerFragmentSelection";
case DisplayItem::ClipLayerFragmentChildBlockBackgrounds: return "ClipLayerFragmentChildBlockBackgrounds";
case DisplayItem::EndClip: return "EndClip";
}
ASSERT_NOT_REACHED();
return "Unknown";
}
WTF::String DisplayItem::rendererDebugString(const RenderObject* renderer)
{
if (renderer && renderer->node())
return String::format("nodeName: \"%s\", renderer: \"%p\"", renderer->node()->nodeName().utf8().data(), renderer);
return String::format("renderer: \"%p\"", renderer);
}
WTF::String DisplayItem::asDebugString() const
{
return String::format("{%s, type: \"%s\"}", rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()).utf8().data());
}
static WTF::String paintListAsDebugString(const PaintList& list)
{
......@@ -125,12 +177,11 @@ static WTF::String paintListAsDebugString(const PaintList& list)
return stringBuilder.toString();
}
void DisplayItemList::showDebugData() const
void ViewDisplayList::showDebugData() const
{
fprintf(stderr, "paint list: [%s]\n", paintListAsDebugString(m_paintList).utf8().data());
fprintf(stderr, "new paints: [%s]\n", paintListAsDebugString(m_newPaints).utf8().data());
}
#endif
} // namespace blink
......@@ -2,22 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DisplayItem_h
#define DisplayItem_h
#ifndef ViewDisplayList_h
#define ViewDisplayList_h
#include "platform/PlatformExport.h"
#ifndef NDEBUG
#include "wtf/text/WTFString.h"
#endif
#include "core/rendering/PaintPhase.h"
#include "wtf/HashSet.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/Vector.h"
namespace blink {
class GraphicsContext;
class RenderObject;
typedef void* DisplayItemClient;
class PLATFORM_EXPORT DisplayItem {
class DisplayItem {
public:
enum Type {
// DisplayItem types must be kept in sync with PaintPhase.
......@@ -55,39 +53,58 @@ public:
virtual void replay(GraphicsContext*) = 0;
DisplayItemClient client() const { return m_id.client; }
const RenderObject* renderer() const { return m_id.renderer; }
Type type() const { return m_id.type; }
bool idsEqual(const DisplayItem& other) const { return m_id.client == other.m_id.client && m_id.type == other.m_id.type; }
bool idsEqual(const DisplayItem& other) const { return m_id.renderer == other.m_id.renderer && m_id.type == other.m_id.type; }
#ifndef NDEBUG
static WTF::String typeAsDebugString(DisplayItem::Type);
void setClientDebugString(const WTF::String& clientDebugString) { m_clientDebugString = clientDebugString; }
const WTF::String& clientDebugString() const { return m_clientDebugString; }
static WTF::String rendererDebugString(const RenderObject*);
virtual WTF::String asDebugString() const;
#endif
protected:
DisplayItem(DisplayItemClient client, Type type)
: m_id(client, type)
DisplayItem(const RenderObject* renderer, Type type)
: m_id(renderer, type)
{ }
private:
struct Id {
Id(DisplayItemClient c, Type t)
: client(c)
Id(const RenderObject* r, Type t)
: renderer(r)
, type(t)
{ }
const DisplayItemClient client;
const RenderObject* renderer;
const Type type;
} m_id;
};
typedef Vector<OwnPtr<DisplayItem> > PaintList;
class ViewDisplayList {
public:
ViewDisplayList() { };
const PaintList& paintList();
void add(WTF::PassOwnPtr<DisplayItem>);
void invalidate(const RenderObject*);
#ifndef NDEBUG
WTF::String m_clientDebugString;
void showDebugData() const;
#endif
private:
PaintList::iterator findDisplayItem(PaintList::iterator, const DisplayItem&);
bool wasInvalidated(const DisplayItem&) const;
void updatePaintList();
PaintList m_paintList;
HashSet<const RenderObject*> m_paintListRenderers;
HashSet<const RenderObject*> m_invalidated;
PaintList m_newPaints;
};
}
} // namespace blink
#endif // DisplayItem_h
#endif // ViewDisplayList_h
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "config.h"
#include "core/paint/ViewDisplayList.h"
#include "core/paint/ClipRecorder.h"
#include "core/paint/DrawingRecorder.h"
......@@ -10,8 +11,6 @@
#include "core/rendering/RenderingTestHelper.h"
#include "core/rendering/compositing/RenderLayerCompositor.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/paint/DisplayItemList.h"
#include <gtest/gtest.h>
namespace blink {
......@@ -23,7 +22,6 @@ public:
protected:
RenderView* renderView() { return m_renderView; }
DisplayItemList& rootDisplayItemList() { return renderView()->layer()->graphicsLayerBacking()->displayItemList(); }
private:
virtual void SetUp() override
......@@ -31,7 +29,6 @@ private:
RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
RenderingTest::SetUp();
enableCompositing();
m_renderView = document().view()->renderView();
ASSERT_TRUE(m_renderView);
......@@ -61,7 +58,7 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
FloatRect bound = renderView()->viewRect();
drawClippedRect(context, renderView(), PaintPhaseForeground, bound);
EXPECT_EQ((size_t)3, rootDisplayItemList().paintList().size());
EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size());
// TODO(schenney): Check that the IDs are what we expect.
}
......@@ -77,12 +74,12 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
drawRect(context, second, PaintPhaseChildBlockBackground, FloatRect(100, 100, 200, 200));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
EXPECT_EQ((size_t)3, rootDisplayItemList().paintList().size());
EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size());
rootDisplayItemList().invalidate(second);
renderView()->viewDisplayList().invalidate(second);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size());
EXPECT_EQ((size_t)2, renderView()->viewDisplayList().paintList().size());
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
......@@ -97,21 +94,21 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
drawRect(context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300, 10, 10));
const PaintList& firstList = rootDisplayItemList().paintList();
const PaintList& firstList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)3, firstList.size());
EXPECT_EQ(first, firstList[0]->client());
EXPECT_EQ(second, firstList[1]->client());
EXPECT_EQ(unaffected, firstList[2]->client());
EXPECT_EQ(first, firstList[0]->renderer());
EXPECT_EQ(second, firstList[1]->renderer());
EXPECT_EQ(unaffected, firstList[2]->renderer());
rootDisplayItemList().invalidate(second);
renderView()->viewDisplayList().invalidate(second);
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
const PaintList& secondList = rootDisplayItemList().paintList();
const PaintList& secondList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)3, secondList.size());
EXPECT_EQ(second, secondList[0]->client());
EXPECT_EQ(first, secondList[1]->client());
EXPECT_EQ(unaffected, secondList[2]->client());
EXPECT_EQ(second, secondList[0]->renderer());
EXPECT_EQ(first, secondList[1]->renderer());
EXPECT_EQ(unaffected, secondList[2]->renderer());
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
......@@ -125,21 +122,21 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
const PaintList& firstList = rootDisplayItemList().paintList();
const PaintList& firstList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)2, firstList.size());
EXPECT_EQ(first, firstList[0]->client());
EXPECT_EQ(second, firstList[1]->client());
EXPECT_EQ(first, firstList[0]->renderer());
EXPECT_EQ(second, firstList[1]->renderer());
rootDisplayItemList().invalidate(third);
renderView()->viewDisplayList().invalidate(third);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
drawRect(context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200, 50));
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
const PaintList& secondList = rootDisplayItemList().paintList();
const PaintList& secondList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)3, secondList.size());
EXPECT_EQ(first, secondList[0]->client());
EXPECT_EQ(third, secondList[1]->client());
EXPECT_EQ(second, secondList[2]->client());
EXPECT_EQ(first, secondList[0]->renderer());
EXPECT_EQ(third, secondList[1]->renderer());
EXPECT_EQ(second, secondList[2]->renderer());
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
......@@ -160,15 +157,15 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200));
drawRect(context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50));
const PaintList& firstList = rootDisplayItemList().paintList();
const PaintList& firstList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)9, firstList.size());
for (int item = 0; item < 9; item += 3) {
EXPECT_EQ(first, firstList[item % 3 + 0]->client());
EXPECT_EQ(second, firstList[item % 3 + 1]->client());
EXPECT_EQ(third, firstList[item % 3 + 2]->client());
EXPECT_EQ(first, firstList[item % 3 + 0]->renderer());
EXPECT_EQ(second, firstList[item % 3 + 1]->renderer());
EXPECT_EQ(third, firstList[item % 3 + 2]->renderer());
}
rootDisplayItemList().invalidate(second);
renderView()->viewDisplayList().invalidate(second);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
drawRect(context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100));
......@@ -176,20 +173,20 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100));
drawRect(context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200));
const PaintList& secondList = rootDisplayItemList().paintList();
const PaintList& secondList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)9, secondList.size());
for (int item = 0; item < 9; item += 3) {
EXPECT_EQ(first, secondList[item % 3 + 0]->client());
EXPECT_EQ(second, secondList[item % 3 + 1]->client());
EXPECT_EQ(third, secondList[item % 3 + 2]->client());
EXPECT_EQ(first, secondList[item % 3 + 0]->renderer());
EXPECT_EQ(second, secondList[item % 3 + 1]->renderer());
EXPECT_EQ(third, secondList[item % 3 + 2]->renderer());
}
rootDisplayItemList().invalidate(second);
const PaintList& thirdList = rootDisplayItemList().paintList();
renderView()->viewDisplayList().invalidate(second);
const PaintList& thirdList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)6, thirdList.size());
for (int item = 0; item < 6; item += 2) {
EXPECT_EQ(first, thirdList[item % 2 + 0]->client());
EXPECT_EQ(third, thirdList[item % 2 + 1]->client());
EXPECT_EQ(first, thirdList[item % 2 + 0]->renderer());
EXPECT_EQ(third, thirdList[item % 2 + 1]->renderer());
}
}
......@@ -203,27 +200,27 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
const PaintList& firstList = rootDisplayItemList().paintList();
const PaintList& firstList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)2, firstList.size());
EXPECT_EQ(second, firstList[0]->client());
EXPECT_EQ(second, firstList[1]->client());
EXPECT_EQ(second, firstList[0]->renderer());
EXPECT_EQ(second, firstList[1]->renderer());
rootDisplayItemList().invalidate(first);
renderView()->viewDisplayList().invalidate(first);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
const PaintList& secondList = rootDisplayItemList().paintList();
const PaintList& secondList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)4, secondList.size());
EXPECT_EQ(first, secondList[0]->client());
EXPECT_EQ(first, secondList[1]->client());
EXPECT_EQ(second, secondList[2]->client());
EXPECT_EQ(second, secondList[3]->client());
EXPECT_EQ(first, secondList[0]->renderer());
EXPECT_EQ(first, secondList[1]->renderer());
EXPECT_EQ(second, secondList[2]->renderer());
EXPECT_EQ(second, secondList[3]->renderer());
rootDisplayItemList().invalidate(first);
const PaintList& thirdList = rootDisplayItemList().paintList();
renderView()->viewDisplayList().invalidate(first);
const PaintList& thirdList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)2, thirdList.size());
EXPECT_EQ(second, thirdList[0]->client());
EXPECT_EQ(second, thirdList[1]->client());
EXPECT_EQ(second, thirdList[0]->renderer());
EXPECT_EQ(second, thirdList[1]->renderer());
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap)
......@@ -236,33 +233,33 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap)
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
const PaintList& firstList = rootDisplayItemList().paintList();
const PaintList& firstList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)2, firstList.size());
EXPECT_EQ(second, firstList[0]->client());
EXPECT_EQ(second, firstList[1]->client());
EXPECT_EQ(second, firstList[0]->renderer());
EXPECT_EQ(second, firstList[1]->renderer());
rootDisplayItemList().invalidate(first);
rootDisplayItemList().invalidate(second);
renderView()->viewDisplayList().invalidate(first);
renderView()->viewDisplayList().invalidate(second);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
const PaintList& secondList = rootDisplayItemList().paintList();
const PaintList& secondList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)4, secondList.size());
EXPECT_EQ(first, secondList[0]->client());
EXPECT_EQ(first, secondList[1]->client());
EXPECT_EQ(second, secondList[2]->client());
EXPECT_EQ(second, secondList[3]->client());
EXPECT_EQ(first, secondList[0]->renderer());
EXPECT_EQ(first, secondList[1]->renderer());
EXPECT_EQ(second, secondList[2]->renderer());
EXPECT_EQ(second, secondList[3]->renderer());
rootDisplayItemList().invalidate(first);
renderView()->viewDisplayList().invalidate(first);
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
const PaintList& thirdList = rootDisplayItemList().paintList();
const PaintList& thirdList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)2, thirdList.size());
EXPECT_EQ(second, thirdList[0]->client());
EXPECT_EQ(second, thirdList[1]->client());
EXPECT_EQ(second, thirdList[0]->renderer());
EXPECT_EQ(second, thirdList[1]->renderer());
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap)
......@@ -275,27 +272,27 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap)
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 50));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 50, 50));
const PaintList& firstList = rootDisplayItemList().paintList();
const PaintList& firstList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)2, firstList.size());
EXPECT_EQ(first, firstList[0]->client());
EXPECT_EQ(first, firstList[1]->client());
EXPECT_EQ(first, firstList[0]->renderer());
EXPECT_EQ(first, firstList[1]->renderer());
rootDisplayItemList().invalidate(second);
renderView()->viewDisplayList().invalidate(second);
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
const PaintList& secondList = rootDisplayItemList().paintList();
const PaintList& secondList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)4, secondList.size());
EXPECT_EQ(second, secondList[0]->client());
EXPECT_EQ(second, secondList[1]->client());
EXPECT_EQ(first, secondList[2]->client());
EXPECT_EQ(first, secondList[3]->client());
EXPECT_EQ(second, secondList[0]->renderer());
EXPECT_EQ(second, secondList[1]->renderer());
EXPECT_EQ(first, secondList[2]->renderer());
EXPECT_EQ(first, secondList[3]->renderer());
rootDisplayItemList().invalidate(second);
const PaintList& thirdList = rootDisplayItemList().paintList();
renderView()->viewDisplayList().invalidate(second);
const PaintList& thirdList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)2, thirdList.size());
EXPECT_EQ(first, thirdList[0]->client());
EXPECT_EQ(first, thirdList[1]->client());
EXPECT_EQ(first, thirdList[0]->renderer());
EXPECT_EQ(first, thirdList[1]->renderer());
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap)
......@@ -308,34 +305,34 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap)
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
const PaintList& firstList = rootDisplayItemList().paintList();
const PaintList& firstList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)2, firstList.size());
EXPECT_EQ(first, firstList[0]->client());
EXPECT_EQ(first, firstList[1]->client());
EXPECT_EQ(first, firstList[0]->renderer());
EXPECT_EQ(first, firstList[1]->renderer());
rootDisplayItemList().invalidate(first);
rootDisplayItemList().invalidate(second);
renderView()->viewDisplayList().invalidate(first);
renderView()->viewDisplayList().invalidate(second);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
drawRect(context, second, PaintPhaseBlockBackground, FloatRect(200, 200, 50, 50));
drawRect(context, second, PaintPhaseOutline, FloatRect(200, 200, 50, 50));
const PaintList& secondList = rootDisplayItemList().paintList();
const PaintList& secondList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)4, secondList.size());
EXPECT_EQ(first, secondList[0]->client());
EXPECT_EQ(first, secondList[1]->client());
EXPECT_EQ(second, secondList[2]->client());
EXPECT_EQ(second, secondList[3]->client());
EXPECT_EQ(first, secondList[0]->renderer());
EXPECT_EQ(first, secondList[1]->renderer());
EXPECT_EQ(second, secondList[2]->renderer());
EXPECT_EQ(second, secondList[3]->renderer());
rootDisplayItemList().invalidate(first);
rootDisplayItemList().invalidate(second);
renderView()->viewDisplayList().invalidate(first);
renderView()->viewDisplayList().invalidate(second);
drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
const PaintList& thirdList = rootDisplayItemList().paintList();
const PaintList& thirdList = renderView()->viewDisplayList().paintList();
EXPECT_EQ((size_t)2, thirdList.size());
EXPECT_EQ(first, thirdList[0]->client());
EXPECT_EQ(first, thirdList[1]->client());
EXPECT_EQ(first, thirdList[0]->renderer());
EXPECT_EQ(first, thirdList[1]->renderer());
}
}
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "core/rendering/PaintPhase.h"
#include "platform/graphics/paint/DisplayItem.h"
#include "wtf/Assertions.h"
namespace blink {
// DisplayItem types must be kept in sync with PaintPhase.
COMPILE_ASSERT((unsigned)DisplayItem::DrawingPaintPhaseBlockBackground == (unsigned)PaintPhaseBlockBackground, DisplayItem_Type_should_stay_in_sync);
COMPILE_ASSERT((unsigned)DisplayItem::DrawingPaintPhaseClippingMask == (unsigned)PaintPhaseClippingMask, DisplayItem_Type_should_stay_in_sync);
} // namespace blink
......@@ -85,7 +85,6 @@
#include "platform/TracedValue.h"
#include "platform/geometry/TransformState.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/paint/DisplayItemList.h"
#include "wtf/RefCountedLeakCounter.h"
#include "wtf/text/StringBuilder.h"
#include "wtf/text/WTFString.h"
......@@ -1122,10 +1121,8 @@ LayoutRect RenderObject::computePaintInvalidationRect(const RenderLayerModelObje
void RenderObject::invalidatePaintUsingContainer(const RenderLayerModelObject* paintInvalidationContainer, const LayoutRect& r, PaintInvalidationReason invalidationReason) const
{
if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
if (RenderLayer* container = enclosingLayer()->enclosingLayerForPaintInvalidationCrossingFrameBoundaries())
container->graphicsLayerBacking()->displayItemList().invalidate(displayItemClient());
}
if (RuntimeEnabledFeatures::slimmingPaintEnabled())
view()->viewDisplayList().invalidate(this);
if (r.isEmpty())
return;
......
......@@ -47,7 +47,6 @@
#include "platform/geometry/LayoutRect.h"
#include "platform/graphics/CompositingReasons.h"
#include "platform/graphics/PaintInvalidationReason.h"
#include "platform/graphics/paint/DisplayItem.h"
#include "platform/transforms/TransformationMatrix.h"
namespace blink {
......@@ -1056,8 +1055,6 @@ public:
virtual LayoutRect viewRect() const;
DisplayItemClient displayItemClient() const { return (void*)this; }
protected:
enum RenderObjectType {
RenderObjectBr,
......
......@@ -23,6 +23,7 @@
#define RenderView_h
#include "core/frame/FrameView.h"
#include "core/paint/ViewDisplayList.h"
#include "core/rendering/LayoutState.h"
#include "core/rendering/PaintInvalidationState.h"
#include "core/rendering/RenderBlockFlow.h"
......@@ -164,6 +165,14 @@ public:
void popLayoutState();
virtual void invalidateTreeIfNeeded(const PaintInvalidationState&) override final;
ViewDisplayList& viewDisplayList()
{
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
if (!m_viewDisplayList)
m_viewDisplayList = adoptPtr(new ViewDisplayList());
return *m_viewDisplayList;
}
private:
virtual void mapLocalToContainer(const RenderLayerModelObject* paintInvalidationContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0, const PaintInvalidationState* = 0) const override;
virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const override;
......@@ -200,6 +209,7 @@ private:
unsigned m_renderCounterCount;
unsigned m_hitTestCount;
OwnPtr<ViewDisplayList> m_viewDisplayList;
};
DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderView, isRenderView());
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "core/rendering/RenderingTestHelper.h"
#include "core/loader/EmptyClients.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/GraphicsLayerFactory.h"
namespace blink {
class FakeGraphicsLayerFactory : public GraphicsLayerFactory {
public:
virtual PassOwnPtr<GraphicsLayer> createGraphicsLayer(GraphicsLayerClient* client) override
{
return adoptPtr(new GraphicsLayer(client));
}
};
class FakeChromeClient : public EmptyChromeClient {
public:
virtual GraphicsLayerFactory* graphicsLayerFactory() const
{
static FakeGraphicsLayerFactory* factory = adoptPtr(new FakeGraphicsLayerFactory).leakPtr();
return factory;
}
};
void RenderingTest::SetUp()
{
fillWithEmptyClients(m_pageClients);
static FakeChromeClient* chromeClient = adoptPtr(new FakeChromeClient).leakPtr();
m_pageClients.chromeClient = chromeClient;
m_pageHolder = DummyPageHolder::create(IntSize(800, 600), &m_pageClients);
document().settings()->setRegionBasedColumnsEnabled(true);
// This ensures that the minimal DOM tree gets attached
// correctly for tests that don't call setBodyInnerHTML.
document().view()->updateLayoutAndStyleIfNeededRecursive();
}
} // namespace blink
......@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef RenderingTestHelper_h
#define RenderingTestHelper_h
#include "core/dom/Document.h"
#include "core/frame/FrameView.h"
#include "core/frame/Settings.h"
......@@ -17,27 +14,27 @@ namespace blink {
class RenderingTest : public testing::Test {
protected:
virtual void SetUp() override;
virtual void SetUp()
{
m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
document().settings()->setRegionBasedColumnsEnabled(true);
// This ensures that the minimal DOM tree gets attached
// correctly for tests that don't call setBodyInnerHTML.
document().view()->updateLayoutAndStyleIfNeededRecursive();
}
Document& document() const { return m_pageHolder->document(); }
void setBodyInnerHTML(const String& htmlContent)
{
document().body()->setInnerHTML(htmlContent, ASSERT_NO_EXCEPTION);
document().view()->updateLayoutAndStyleForPainting();
}
void enableCompositing()
{
m_pageHolder->page().settings().setAcceleratedCompositingEnabled(true);
document().view()->updateLayoutAndStyleForPainting();
document().view()->updateLayoutAndStyleIfNeededRecursive();
}
private:
Page::PageClients m_pageClients;
OwnPtr<DummyPageHolder> m_pageHolder;
};
} // namespace blink
#endif // RenderingTestHelper_h
......@@ -2085,6 +2085,19 @@ void CompositedLayerMapping::doPaintTask(const GraphicsLayerPaintInfo& paintInfo
LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBehaviorNormal, paintInfo.renderLayer->subpixelAccumulation());
LayerPainter(*paintInfo.renderLayer).paintLayerContents(context, paintingInfo, paintLayerFlags);
if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
#ifndef NDEBUG
context->fillRect(dirtyRect, Color(0xFF, 0, 0));
#endif
if (RenderView* view = paintInfo.renderLayer->renderer()->view()) {
const PaintList& paintList = view->viewDisplayList().paintList();
for (PaintList::const_iterator it = paintList.begin(); it != paintList.end(); ++it)
(*it)->replay(context);
}
}
if (paintInfo.renderLayer->containsDirtyOverlayScrollbars())
LayerPainter(*paintInfo.renderLayer).paintLayerContents(context, paintingInfo, paintLayerFlags | PaintLayerPaintingOverlayScrollbars);
} else {
......
......@@ -524,14 +524,6 @@
'graphics/gpu/WebGLImageConversion.h',
'graphics/media/MediaPlayer.cpp',
'graphics/media/MediaPlayer.h',
'graphics/paint/ClipDisplayItem.cpp',
'graphics/paint/ClipDisplayItem.h',
'graphics/paint/DisplayItem.cpp',
'graphics/paint/DisplayItem.h',
'graphics/paint/DisplayItemList.cpp',
'graphics/paint/DisplayItemList.h',
'graphics/paint/DrawingDisplayItem.cpp',
'graphics/paint/DrawingDisplayItem.h',
'graphics/skia/GaneshUtils.cpp',
'graphics/skia/GaneshUtils.h',
'graphics/skia/NativeImageSkia.cpp',
......
......@@ -28,16 +28,13 @@
#include "SkImageFilter.h"
#include "SkMatrix44.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/TraceEvent.h"
#include "platform/geometry/FloatRect.h"
#include "platform/geometry/LayoutRect.h"
#include "platform/graphics/FirstPaintInvalidationTracking.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayerFactory.h"
#include "platform/graphics/Image.h"
#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
#include "platform/graphics/paint/DisplayItemList.h"
#include "platform/graphics/skia/NativeImageSkia.h"
#include "platform/scroll/ScrollableArea.h"
#include "platform/text/TextStream.h"
......@@ -274,20 +271,6 @@ void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const I
m_debugInfo.clearAnnotatedInvalidateRects();
incrementPaintCount();
m_client->paintContents(this, context, m_paintingPhase, clip);
if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
#ifndef NDEBUG
context.fillRect(clip, Color(0xFF, 0, 0));
#endif
// FIXME: This is incorrect for squashed layers.
// We should do proper translation in CompositedLayerMapping once transform paint item is implemented.
context.translate(-m_offsetFromRenderer.width(), -m_offsetFromRenderer.height());
const PaintList& paintList = displayItemList().paintList();
for (PaintList::const_iterator it = paintList.begin(); it != paintList.end(); ++it)
(*it)->replay(&context);
context.translate(m_offsetFromRenderer.width(), m_offsetFromRenderer.height());
}
}
void GraphicsLayer::updateChildList()
......@@ -1072,14 +1055,6 @@ void GraphicsLayer::didScroll()
}
}
DisplayItemList& GraphicsLayer::displayItemList()
{
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
if (!m_displayItemList)
m_displayItemList = adoptPtr(new DisplayItemList());
return *m_displayItemList;
}
} // namespace blink
#ifndef NDEBUG
......
......@@ -51,7 +51,6 @@
namespace blink {
class DisplayItemList;
class FloatRect;
class GraphicsContext;
class GraphicsLayer;
......@@ -243,16 +242,12 @@ public:
// WebLayerScrollClient implementation.
virtual void didScroll() override;
DisplayItemList& displayItemList();
protected:
String debugName(WebLayer*) const;
explicit GraphicsLayer(GraphicsLayerClient*);
// GraphicsLayerFactoryChromium that wants to create a GraphicsLayer need to be friends.
friend class GraphicsLayerFactoryChromium;
// for testing
friend class FakeGraphicsLayerFactory;
// Exposed for tests.
virtual WebLayer* contentsLayer() const { return m_contentsLayer; }
......@@ -346,8 +341,6 @@ private:
ScrollableArea* m_scrollableArea;
GraphicsLayerDebugInfo m_debugInfo;
int m_3dRenderingContext;
OwnPtr<DisplayItemList> m_displayItemList;
};
} // namespace blink
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "platform/graphics/paint/ClipDisplayItem.h"
#include "platform/geometry/RoundedRect.h"
#include "platform/graphics/GraphicsContext.h"
namespace blink {
void ClipDisplayItem::replay(GraphicsContext* context)
{
context->save();
context->clip(m_clipRect);
for (RoundedRect roundedRect : m_roundedRectClips)
context->clipRoundedRect(roundedRect);
}
void EndClipDisplayItem::replay(GraphicsContext* context)
{
context->restore();
}
#ifndef NDEBUG
WTF::String ClipDisplayItem::asDebugString() const
{
return String::format("{%s, type: \"%s\", clipRect: [%d,%d,%d,%d]}",
clientDebugString().utf8().data(), typeAsDebugString(type()).utf8().data(),
m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height());
}
#endif
} // namespace blink
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ClipDisplayItem_h
#define ClipDisplayItem_h
#include "platform/PlatformExport.h"
#include "platform/geometry/IntRect.h"
#include "platform/graphics/paint/DisplayItem.h"
#include "wtf/Vector.h"
namespace blink {
class RoundedRect;
class PLATFORM_EXPORT ClipDisplayItem : public DisplayItem {
public:
ClipDisplayItem(DisplayItemClient client, Type type, IntRect clipRect)
: DisplayItem(client, type), m_clipRect(clipRect) { }
Vector<RoundedRect>& roundedRectClips() { return m_roundedRectClips; }
private:
virtual void replay(GraphicsContext*) override;
IntRect m_clipRect;
Vector<RoundedRect> m_roundedRectClips;
#ifndef NDEBUG
virtual WTF::String asDebugString() const override;
#endif
};
class PLATFORM_EXPORT EndClipDisplayItem : public DisplayItem {
public:
EndClipDisplayItem() : DisplayItem(0, EndClip) { }
private:
virtual void replay(GraphicsContext*) override;
};
} // namespace blink
#endif // ClipDisplayItem_h
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "platform/graphics/paint/DisplayItem.h"
namespace blink {
#ifndef NDEBUG
WTF::String DisplayItem::typeAsDebugString(DisplayItem::Type type)
{
switch (type) {
case DisplayItem::DrawingPaintPhaseBlockBackground: return "DrawingPaintPhaseBlockBackground";
case DisplayItem::DrawingPaintPhaseChildBlockBackground: return "DrawingPaintPhaseChildBlockBackground";
case DisplayItem::DrawingPaintPhaseChildBlockBackgrounds: return "DrawingPaintPhaseChildBlockBackgrounds";
case DisplayItem::DrawingPaintPhaseFloat: return "DrawingPaintPhaseFloat";
case DisplayItem::DrawingPaintPhaseForeground: return "DrawingPaintPhaseForeground";
case DisplayItem::DrawingPaintPhaseOutline: return "DrawingPaintPhaseOutline";
case DisplayItem::DrawingPaintPhaseChildOutlines: return "DrawingPaintPhaseChildOutlines";
case DisplayItem::DrawingPaintPhaseSelfOutline: return "DrawingPaintPhaseSelfOutline";
case DisplayItem::DrawingPaintPhaseSelection: return "DrawingPaintPhaseSelection";
case DisplayItem::DrawingPaintPhaseCollapsedTableBorders: return "DrawingPaintPhaseCollapsedTableBorders";
case DisplayItem::DrawingPaintPhaseTextClip: return "DrawingPaintPhaseTextClip";
case DisplayItem::DrawingPaintPhaseMask: return "DrawingPaintPhaseMask";
case DisplayItem::DrawingPaintPhaseClippingMask: return "DrawingPaintPhaseClippingMask";
case DisplayItem::ClipLayerOverflowControls: return "ClipLayerOverflowControls";
case DisplayItem::ClipLayerBackground: return "ClipLayerBackground";
case DisplayItem::ClipLayerParent: return "ClipLayerParent";
case DisplayItem::ClipLayerFilter: return "ClipLayerFilter";
case DisplayItem::ClipLayerForeground: return "ClipLayerForeground";
case DisplayItem::ClipLayerFragmentFloat: return "ClipLayerFragmentFloat";
case DisplayItem::ClipLayerFragmentForeground: return "ClipLayerFragmentForeground";
case DisplayItem::ClipLayerFragmentChildOutline: return "ClipLayerFragmentChildOutline";
case DisplayItem::ClipLayerFragmentOutline: return "ClipLayerFragmentOutline";
case DisplayItem::ClipLayerFragmentMask: return "ClipLayerFragmentMask";
case DisplayItem::ClipLayerFragmentClippingMask: return "ClipLayerFragmentClippingMask";
case DisplayItem::ClipLayerFragmentParent: return "ClipLayerFragmentParent";
case DisplayItem::ClipLayerFragmentSelection: return "ClipLayerFragmentSelection";
case DisplayItem::ClipLayerFragmentChildBlockBackgrounds: return "ClipLayerFragmentChildBlockBackgrounds";
case DisplayItem::EndClip: return "EndClip";
}
ASSERT_NOT_REACHED();
return "Unknown";
}
WTF::String DisplayItem::asDebugString() const
{
return String::format("{%s, type: \"%s\"}", clientDebugString().utf8().data(), typeAsDebugString(type()).utf8().data());
}
#endif
} // namespace blink
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DisplayItemList_h
#define DisplayItemList_h
#include "platform/PlatformExport.h"
#include "platform/graphics/paint/DisplayItem.h"
#include "wtf/HashSet.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/Vector.h"
namespace blink {
typedef Vector<OwnPtr<DisplayItem> > PaintList;
class PLATFORM_EXPORT DisplayItemList {
WTF_MAKE_NONCOPYABLE(DisplayItemList);
public:
DisplayItemList() { };
const PaintList& paintList();
void add(WTF::PassOwnPtr<DisplayItem>);
void invalidate(DisplayItemClient);
#ifndef NDEBUG
void showDebugData() const;
#endif
private:
PaintList::iterator findDisplayItem(PaintList::iterator, const DisplayItem&);
bool wasInvalidated(const DisplayItem&) const;
void updatePaintList();
PaintList m_paintList;
HashSet<DisplayItemClient> m_paintListRenderers;
HashSet<DisplayItemClient> m_invalidated;
PaintList m_newPaints;
};
} // namespace blink
#endif // DisplayItemList_h
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "platform/graphics/paint/DrawingDisplayItem.h"
#include "platform/graphics/GraphicsContext.h"
namespace blink {
void DrawingDisplayItem::replay(GraphicsContext* context)
{
context->drawPicture(m_picture.get(), m_location);
}
#ifndef NDEBUG
WTF::String DrawingDisplayItem::asDebugString() const
{
return String::format("{%s, type: \"%s\", location: [%f,%f]}",
clientDebugString().utf8().data(), typeAsDebugString(type()).utf8().data(),
m_location.x(), m_location.y());
}
#endif
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DrawingDisplayItem_h
#define DrawingDisplayItem_h
#include "platform/PlatformExport.h"
#include "platform/geometry/FloatPoint.h"
#include "platform/graphics/paint/DisplayItem.h"
#include "third_party/skia/include/core/SkPicture.h"
namespace blink {
class PLATFORM_EXPORT DrawingDisplayItem : public DisplayItem {
public:
DrawingDisplayItem(DisplayItemClient client, Type type, PassRefPtr<SkPicture> picture, const FloatPoint& location)
: DisplayItem(client, type), m_picture(picture), m_location(location) { }
PassRefPtr<SkPicture> picture() const { return m_picture; }
const FloatPoint& location() const { return m_location; }
private:
virtual void replay(GraphicsContext*);
RefPtr<SkPicture> m_picture;
const FloatPoint m_location;
#ifndef NDEBUG
virtual WTF::String asDebugString() const override;
#endif
};
} // namespace blink
#endif // DrawingDisplayItem_h
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