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. ...@@ -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/positioning/inline-block-relposition.html [ ImageOnlyFailure ]
crbug.com/437743 [ Mac ] virtual/slimmingpaint/fast/block/margin-collapse/103.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. # Text::inDocument() returns false but should not.
crbug.com/264138 dom/xhtml/level3/core/nodecomparedocumentposition38.xhtml [ Failure ] crbug.com/264138 dom/xhtml/level3/core/nodecomparedocumentposition38.xhtml [ Failure ]
......
...@@ -1516,6 +1516,8 @@ ...@@ -1516,6 +1516,8 @@
'paint/TableSectionPainter.h', 'paint/TableSectionPainter.h',
'paint/VideoPainter.cpp', 'paint/VideoPainter.cpp',
'paint/VideoPainter.h', 'paint/VideoPainter.h',
'paint/ViewDisplayList.cpp',
'paint/ViewDisplayList.h',
'paint/ViewPainter.cpp', 'paint/ViewPainter.cpp',
'paint/ViewPainter.h', 'paint/ViewPainter.h',
'plugins/DOMMimeType.cpp', 'plugins/DOMMimeType.cpp',
...@@ -1575,8 +1577,6 @@ ...@@ -1575,8 +1577,6 @@
'rendering/OrderIterator.h', 'rendering/OrderIterator.h',
'rendering/PaintInvalidationState.cpp', 'rendering/PaintInvalidationState.cpp',
'rendering/PaintInvalidationState.h', 'rendering/PaintInvalidationState.h',
'rendering/PaintPhase.cpp',
'rendering/PaintPhase.h',
'rendering/PointerEventsHitRules.cpp', 'rendering/PointerEventsHitRules.cpp',
'rendering/PointerEventsHitRules.h', 'rendering/PointerEventsHitRules.h',
'rendering/RenderApplet.cpp', 'rendering/RenderApplet.cpp',
...@@ -3554,8 +3554,6 @@ ...@@ -3554,8 +3554,6 @@
'rendering/RenderPartTest.cpp', 'rendering/RenderPartTest.cpp',
'rendering/RenderTableCellTest.cpp', 'rendering/RenderTableCellTest.cpp',
'rendering/RenderTableRowTest.cpp', 'rendering/RenderTableRowTest.cpp',
'rendering/RenderingTestHelper.cpp',
'rendering/RenderingTestHelper.h',
'rendering/TextPainterTest.cpp', 'rendering/TextPainterTest.cpp',
'rendering/shapes/BoxShapeTest.cpp', 'rendering/shapes/BoxShapeTest.cpp',
'rendering/style/OutlineValueTest.cpp', 'rendering/style/OutlineValueTest.cpp',
......
...@@ -7,14 +7,25 @@ ...@@ -7,14 +7,25 @@
#include "core/rendering/RenderLayer.h" #include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderObject.h" #include "core/rendering/RenderObject.h"
#include "core/rendering/RenderView.h"
#include "platform/RuntimeEnabledFeatures.h" #include "platform/RuntimeEnabledFeatures.h"
#include "platform/graphics/GraphicsContext.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 { 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) ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsContext, DisplayItem::Type clipType, const ClipRect& clipRect)
: m_graphicsContext(graphicsContext) : m_graphicsContext(graphicsContext)
, m_renderLayer(renderLayer) , m_renderLayer(renderLayer)
...@@ -24,12 +35,8 @@ ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsCo ...@@ -24,12 +35,8 @@ ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsCo
graphicsContext->save(); graphicsContext->save();
graphicsContext->clip(snappedClipRect); graphicsContext->clip(snappedClipRect);
} else { } else {
m_clipDisplayItem = new ClipDisplayItem(nullptr, clipType, snappedClipRect); m_clipDisplayItem = new ClipDisplayItem(0, renderLayer, clipType, snappedClipRect);
#ifndef NDEBUG m_renderLayer->renderer()->view()->viewDisplayList().add(adoptPtr(m_clipDisplayItem));
m_clipDisplayItem->setClientDebugString("nullptr");
#endif
if (RenderLayer* container = m_renderLayer->enclosingLayerForPaintInvalidationCrossingFrameBoundaries())
container->graphicsLayerBacking()->displayItemList().add(adoptPtr(m_clipDisplayItem));
} }
} }
...@@ -45,11 +52,19 @@ ClipRecorder::~ClipRecorder() ...@@ -45,11 +52,19 @@ ClipRecorder::~ClipRecorder()
{ {
if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem); OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem);
if (RenderLayer* container = m_renderLayer->enclosingLayerForPaintInvalidationCrossingFrameBoundaries()) m_renderLayer->renderer()->view()->viewDisplayList().add(endClip.release());
container->graphicsLayerBacking()->displayItemList().add(endClip.release());
} else { } else {
m_graphicsContext->restore(); 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 } // namespace blink
...@@ -5,15 +5,42 @@ ...@@ -5,15 +5,42 @@
#ifndef ClipRecorder_h #ifndef ClipRecorder_h
#define 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 { namespace blink {
class ClipDisplayItem;
class ClipRect; class ClipRect;
class GraphicsContext; class GraphicsContext;
class RenderObject;
class RenderLayer; 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 { class ClipRecorder {
public: public:
...@@ -30,4 +57,4 @@ private: ...@@ -30,4 +57,4 @@ private:
} // namespace blink } // namespace blink
#endif // ClipRecorder_h #endif // ViewDisplayList_h
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
#include "core/rendering/RenderingTestHelper.h" #include "core/rendering/RenderingTestHelper.h"
#include "core/rendering/compositing/RenderLayerCompositor.h" #include "core/rendering/compositing/RenderLayerCompositor.h"
#include "platform/graphics/GraphicsContext.h" #include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/paint/DisplayItemList.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
namespace blink { namespace blink {
...@@ -22,7 +20,6 @@ public: ...@@ -22,7 +20,6 @@ public:
protected: protected:
RenderView* renderView() { return m_renderView; } RenderView* renderView() { return m_renderView; }
DisplayItemList& rootDisplayItemList() { return renderView()->layer()->graphicsLayerBacking()->displayItemList(); }
private: private:
virtual void SetUp() override virtual void SetUp() override
...@@ -30,7 +27,6 @@ private: ...@@ -30,7 +27,6 @@ private:
RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
RenderingTest::SetUp(); RenderingTest::SetUp();
enableCompositing();
m_renderView = document().view()->renderView(); m_renderView = document().view()->renderView();
ASSERT_TRUE(m_renderView); ASSERT_TRUE(m_renderView);
...@@ -50,10 +46,10 @@ TEST_F(ClipRecorderTest, ClipRecorderTest_Single) ...@@ -50,10 +46,10 @@ TEST_F(ClipRecorderTest, ClipRecorderTest_Single)
{ {
GraphicsContext* context = new GraphicsContext(nullptr); GraphicsContext* context = new GraphicsContext(nullptr);
FloatRect bound = renderView()->viewRect(); 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); 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 @@ ...@@ -5,17 +5,18 @@
#include "config.h" #include "config.h"
#include "core/paint/DrawingRecorder.h" #include "core/paint/DrawingRecorder.h"
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderObject.h" #include "core/rendering/RenderObject.h"
#include "core/rendering/RenderView.h"
#include "platform/RuntimeEnabledFeatures.h" #include "platform/RuntimeEnabledFeatures.h"
#include "platform/graphics/DisplayList.h"
#include "platform/graphics/GraphicsContext.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 { namespace blink {
void DrawingDisplayItem::replay(GraphicsContext* context)
{
context->drawPicture(m_picture.get(), m_location);
}
#if ENABLE(ASSERT) #if ENABLE(ASSERT)
static bool s_inDrawingRecorder = false; static bool s_inDrawingRecorder = false;
#endif #endif
...@@ -51,18 +52,18 @@ DrawingRecorder::~DrawingRecorder() ...@@ -51,18 +52,18 @@ DrawingRecorder::~DrawingRecorder()
return; return;
ASSERT(displayList->bounds() == m_bounds); ASSERT(displayList->bounds() == m_bounds);
OwnPtr<DrawingDisplayItem> drawingItem = adoptPtr( OwnPtr<DrawingDisplayItem> drawingItem = adoptPtr(
new DrawingDisplayItem(m_renderer->displayItemClient(), (DisplayItem::Type)m_phase, displayList->picture(), m_bounds.location())); new DrawingDisplayItem(displayList->picture(), m_bounds.location(), m_phase, m_renderer));
#ifndef NDEBUG ASSERT(m_renderer->view());
if (!m_renderer) m_renderer->view()->viewDisplayList().add(drawingItem.release());
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
if (RenderLayer* container = m_renderer->enclosingLayer()->enclosingLayerForPaintInvalidationCrossingFrameBoundaries()) #ifndef NDEBUG
container->graphicsLayerBacking()->displayItemList().add(drawingItem.release()); 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 } // namespace blink
...@@ -5,13 +5,29 @@ ...@@ -5,13 +5,29 @@
#ifndef DrawingRecorder_h #ifndef DrawingRecorder_h
#define DrawingRecorder_h #define DrawingRecorder_h
#include "core/rendering/PaintPhase.h" #include "core/paint/ViewDisplayList.h"
#include "platform/geometry/FloatRect.h" #include "platform/graphics/DisplayList.h"
namespace blink { namespace blink {
class GraphicsContext; class DrawingDisplayItem : public DisplayItem {
class RenderObject; 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 { class DrawingRecorder {
public: public:
......
...@@ -5,12 +5,9 @@ ...@@ -5,12 +5,9 @@
#include "config.h" #include "config.h"
#include "core/paint/DrawingRecorder.h" #include "core/paint/DrawingRecorder.h"
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderView.h" #include "core/rendering/RenderView.h"
#include "core/rendering/RenderingTestHelper.h" #include "core/rendering/RenderingTestHelper.h"
#include "platform/graphics/GraphicsContext.h" #include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/paint/DisplayItemList.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
namespace blink { namespace blink {
...@@ -22,7 +19,6 @@ public: ...@@ -22,7 +19,6 @@ public:
protected: protected:
RenderView* renderView() { return m_renderView; } RenderView* renderView() { return m_renderView; }
DisplayItemList& rootDisplayItemList() { return renderView()->layer()->graphicsLayerBacking()->displayItemList(); }
private: private:
virtual void SetUp() override virtual void SetUp() override
...@@ -30,7 +26,6 @@ private: ...@@ -30,7 +26,6 @@ private:
RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
RenderingTest::SetUp(); RenderingTest::SetUp();
enableCompositing();
m_renderView = document().view()->renderView(); m_renderView = document().view()->renderView();
ASSERT_TRUE(m_renderView); ASSERT_TRUE(m_renderView);
...@@ -56,10 +51,10 @@ TEST_F(DrawingRecorderTest, DrawingRecorderTest_Nothing) ...@@ -56,10 +51,10 @@ TEST_F(DrawingRecorderTest, DrawingRecorderTest_Nothing)
{ {
GraphicsContext* context = new GraphicsContext(nullptr); GraphicsContext* context = new GraphicsContext(nullptr);
FloatRect bound = renderView()->viewRect(); 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); 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) TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect)
...@@ -67,7 +62,7 @@ TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect) ...@@ -67,7 +62,7 @@ TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect)
GraphicsContext* context = new GraphicsContext(nullptr); GraphicsContext* context = new GraphicsContext(nullptr);
FloatRect bound = renderView()->viewRect(); FloatRect bound = renderView()->viewRect();
drawRect(context, renderView(), PaintPhaseForeground, bound); 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 @@ ...@@ -3,18 +3,23 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "config.h" #include "config.h"
#include "platform/graphics/paint/DisplayItemList.h" #include "core/paint/ViewDisplayList.h"
#include "platform/NotImplemented.h" #include "platform/NotImplemented.h"
#include "platform/RuntimeEnabledFeatures.h" #include "platform/RuntimeEnabledFeatures.h"
#ifndef NDEBUG #ifndef NDEBUG
#include "platform/graphics/paint/DisplayItem.h" #include "core/rendering/RenderObject.h"
#include "wtf/text/StringBuilder.h" #include "wtf/text/WTFString.h"
#endif #endif
namespace blink { 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()); ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
...@@ -22,22 +27,22 @@ const PaintList& DisplayItemList::paintList() ...@@ -22,22 +27,22 @@ const PaintList& DisplayItemList::paintList()
return m_paintList; return m_paintList;
} }
void DisplayItemList::add(WTF::PassOwnPtr<DisplayItem> displayItem) void ViewDisplayList::add(WTF::PassOwnPtr<DisplayItem> displayItem)
{ {
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
m_newPaints.append(displayItem); m_newPaints.append(displayItem);
} }
void DisplayItemList::invalidate(DisplayItemClient renderer) void ViewDisplayList::invalidate(const RenderObject* renderer)
{ {
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
m_invalidated.add(renderer); 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(); PaintList::iterator end = m_paintList.end();
if (displayItem.client() && !m_paintListRenderers.contains(displayItem.client())) if (displayItem.renderer() && !m_paintListRenderers.contains(displayItem.renderer()))
return end; return end;
for (PaintList::iterator it = begin; it != end; ++it) { for (PaintList::iterator it = begin; it != end; ++it) {
...@@ -47,19 +52,19 @@ PaintList::iterator DisplayItemList::findDisplayItem(PaintList::iterator begin, ...@@ -47,19 +52,19 @@ PaintList::iterator DisplayItemList::findDisplayItem(PaintList::iterator begin,
} }
// FIXME: Properly handle clips. // FIXME: Properly handle clips.
ASSERT(!displayItem.client()); ASSERT(!displayItem.renderer());
return end; 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. // FIXME: Use a bit on RenderObject instead of tracking m_invalidated.
return displayItem.client() && m_invalidated.contains(displayItem.client()); 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); renderers.add(renderer);
list.append(displayItem); list.append(displayItem);
} }
...@@ -69,10 +74,10 @@ static void appendDisplayItem(PaintList& list, HashSet<DisplayItemClient>& rende ...@@ -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 algorithm is O(|existing paint list| + |newly painted list|): by using
// the ordering implied by the existing paint list, extra treewalks are avoided. // the ordering implied by the existing paint list, extra treewalks are avoided.
void DisplayItemList::updatePaintList() void ViewDisplayList::updatePaintList()
{ {
PaintList updatedList; 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())) if (int maxCapacity = m_newPaints.size() + std::max(0, (int)m_paintList.size() - (int)m_invalidated.size()))
updatedList.reserveCapacity(maxCapacity); updatedList.reserveCapacity(maxCapacity);
...@@ -111,6 +116,53 @@ void DisplayItemList::updatePaintList() ...@@ -111,6 +116,53 @@ void DisplayItemList::updatePaintList()
} }
#ifndef NDEBUG #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) static WTF::String paintListAsDebugString(const PaintList& list)
{ {
...@@ -125,12 +177,11 @@ static WTF::String paintListAsDebugString(const PaintList& list) ...@@ -125,12 +177,11 @@ static WTF::String paintListAsDebugString(const PaintList& list)
return stringBuilder.toString(); return stringBuilder.toString();
} }
void DisplayItemList::showDebugData() const void ViewDisplayList::showDebugData() const
{ {
fprintf(stderr, "paint list: [%s]\n", paintListAsDebugString(m_paintList).utf8().data()); fprintf(stderr, "paint list: [%s]\n", paintListAsDebugString(m_paintList).utf8().data());
fprintf(stderr, "new paints: [%s]\n", paintListAsDebugString(m_newPaints).utf8().data()); fprintf(stderr, "new paints: [%s]\n", paintListAsDebugString(m_newPaints).utf8().data());
} }
#endif #endif
} // namespace blink } // namespace blink
...@@ -2,22 +2,20 @@ ...@@ -2,22 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef DisplayItem_h #ifndef ViewDisplayList_h
#define DisplayItem_h #define ViewDisplayList_h
#include "platform/PlatformExport.h" #include "core/rendering/PaintPhase.h"
#include "wtf/HashSet.h"
#ifndef NDEBUG #include "wtf/PassOwnPtr.h"
#include "wtf/text/WTFString.h" #include "wtf/Vector.h"
#endif
namespace blink { namespace blink {
class GraphicsContext; class GraphicsContext;
class RenderObject;
typedef void* DisplayItemClient; class DisplayItem {
class PLATFORM_EXPORT DisplayItem {
public: public:
enum Type { enum Type {
// DisplayItem types must be kept in sync with PaintPhase. // DisplayItem types must be kept in sync with PaintPhase.
...@@ -55,39 +53,58 @@ public: ...@@ -55,39 +53,58 @@ public:
virtual void replay(GraphicsContext*) = 0; 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; } 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 #ifndef NDEBUG
static WTF::String typeAsDebugString(DisplayItem::Type); static WTF::String typeAsDebugString(DisplayItem::Type);
static WTF::String rendererDebugString(const RenderObject*);
void setClientDebugString(const WTF::String& clientDebugString) { m_clientDebugString = clientDebugString; }
const WTF::String& clientDebugString() const { return m_clientDebugString; }
virtual WTF::String asDebugString() const; virtual WTF::String asDebugString() const;
#endif #endif
protected: protected:
DisplayItem(DisplayItemClient client, Type type) DisplayItem(const RenderObject* renderer, Type type)
: m_id(client, type) : m_id(renderer, type)
{ } { }
private: private:
struct Id { struct Id {
Id(DisplayItemClient c, Type t) Id(const RenderObject* r, Type t)
: client(c) : renderer(r)
, type(t) , type(t)
{ } { }
const DisplayItemClient client; const RenderObject* renderer;
const Type type; const Type type;
} m_id; } 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 #ifndef NDEBUG
WTF::String m_clientDebugString; void showDebugData() const;
#endif #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
// 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 @@ ...@@ -85,7 +85,6 @@
#include "platform/TracedValue.h" #include "platform/TracedValue.h"
#include "platform/geometry/TransformState.h" #include "platform/geometry/TransformState.h"
#include "platform/graphics/GraphicsContext.h" #include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/paint/DisplayItemList.h"
#include "wtf/RefCountedLeakCounter.h" #include "wtf/RefCountedLeakCounter.h"
#include "wtf/text/StringBuilder.h" #include "wtf/text/StringBuilder.h"
#include "wtf/text/WTFString.h" #include "wtf/text/WTFString.h"
...@@ -1122,10 +1121,8 @@ LayoutRect RenderObject::computePaintInvalidationRect(const RenderLayerModelObje ...@@ -1122,10 +1121,8 @@ LayoutRect RenderObject::computePaintInvalidationRect(const RenderLayerModelObje
void RenderObject::invalidatePaintUsingContainer(const RenderLayerModelObject* paintInvalidationContainer, const LayoutRect& r, PaintInvalidationReason invalidationReason) const void RenderObject::invalidatePaintUsingContainer(const RenderLayerModelObject* paintInvalidationContainer, const LayoutRect& r, PaintInvalidationReason invalidationReason) const
{ {
if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { if (RuntimeEnabledFeatures::slimmingPaintEnabled())
if (RenderLayer* container = enclosingLayer()->enclosingLayerForPaintInvalidationCrossingFrameBoundaries()) view()->viewDisplayList().invalidate(this);
container->graphicsLayerBacking()->displayItemList().invalidate(displayItemClient());
}
if (r.isEmpty()) if (r.isEmpty())
return; return;
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include "platform/geometry/LayoutRect.h" #include "platform/geometry/LayoutRect.h"
#include "platform/graphics/CompositingReasons.h" #include "platform/graphics/CompositingReasons.h"
#include "platform/graphics/PaintInvalidationReason.h" #include "platform/graphics/PaintInvalidationReason.h"
#include "platform/graphics/paint/DisplayItem.h"
#include "platform/transforms/TransformationMatrix.h" #include "platform/transforms/TransformationMatrix.h"
namespace blink { namespace blink {
...@@ -1056,8 +1055,6 @@ public: ...@@ -1056,8 +1055,6 @@ public:
virtual LayoutRect viewRect() const; virtual LayoutRect viewRect() const;
DisplayItemClient displayItemClient() const { return (void*)this; }
protected: protected:
enum RenderObjectType { enum RenderObjectType {
RenderObjectBr, RenderObjectBr,
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#define RenderView_h #define RenderView_h
#include "core/frame/FrameView.h" #include "core/frame/FrameView.h"
#include "core/paint/ViewDisplayList.h"
#include "core/rendering/LayoutState.h" #include "core/rendering/LayoutState.h"
#include "core/rendering/PaintInvalidationState.h" #include "core/rendering/PaintInvalidationState.h"
#include "core/rendering/RenderBlockFlow.h" #include "core/rendering/RenderBlockFlow.h"
...@@ -164,6 +165,14 @@ public: ...@@ -164,6 +165,14 @@ public:
void popLayoutState(); void popLayoutState();
virtual void invalidateTreeIfNeeded(const PaintInvalidationState&) override final; virtual void invalidateTreeIfNeeded(const PaintInvalidationState&) override final;
ViewDisplayList& viewDisplayList()
{
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
if (!m_viewDisplayList)
m_viewDisplayList = adoptPtr(new ViewDisplayList());
return *m_viewDisplayList;
}
private: private:
virtual void mapLocalToContainer(const RenderLayerModelObject* paintInvalidationContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0, const PaintInvalidationState* = 0) const override; 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; virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const override;
...@@ -200,6 +209,7 @@ private: ...@@ -200,6 +209,7 @@ private:
unsigned m_renderCounterCount; unsigned m_renderCounterCount;
unsigned m_hitTestCount; unsigned m_hitTestCount;
OwnPtr<ViewDisplayList> m_viewDisplayList;
}; };
DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderView, isRenderView()); 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 @@ ...@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef RenderingTestHelper_h
#define RenderingTestHelper_h
#include "core/dom/Document.h" #include "core/dom/Document.h"
#include "core/frame/FrameView.h" #include "core/frame/FrameView.h"
#include "core/frame/Settings.h" #include "core/frame/Settings.h"
...@@ -17,27 +14,27 @@ namespace blink { ...@@ -17,27 +14,27 @@ namespace blink {
class RenderingTest : public testing::Test { class RenderingTest : public testing::Test {
protected: 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(); } Document& document() const { return m_pageHolder->document(); }
void setBodyInnerHTML(const String& htmlContent) void setBodyInnerHTML(const String& htmlContent)
{ {
document().body()->setInnerHTML(htmlContent, ASSERT_NO_EXCEPTION); document().body()->setInnerHTML(htmlContent, ASSERT_NO_EXCEPTION);
document().view()->updateLayoutAndStyleForPainting(); document().view()->updateLayoutAndStyleIfNeededRecursive();
}
void enableCompositing()
{
m_pageHolder->page().settings().setAcceleratedCompositingEnabled(true);
document().view()->updateLayoutAndStyleForPainting();
} }
private: private:
Page::PageClients m_pageClients;
OwnPtr<DummyPageHolder> m_pageHolder; OwnPtr<DummyPageHolder> m_pageHolder;
}; };
} // namespace blink } // namespace blink
#endif // RenderingTestHelper_h
...@@ -2085,6 +2085,19 @@ void CompositedLayerMapping::doPaintTask(const GraphicsLayerPaintInfo& paintInfo ...@@ -2085,6 +2085,19 @@ void CompositedLayerMapping::doPaintTask(const GraphicsLayerPaintInfo& paintInfo
LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBehaviorNormal, paintInfo.renderLayer->subpixelAccumulation()); LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBehaviorNormal, paintInfo.renderLayer->subpixelAccumulation());
LayerPainter(*paintInfo.renderLayer).paintLayerContents(context, paintingInfo, paintLayerFlags); 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()) if (paintInfo.renderLayer->containsDirtyOverlayScrollbars())
LayerPainter(*paintInfo.renderLayer).paintLayerContents(context, paintingInfo, paintLayerFlags | PaintLayerPaintingOverlayScrollbars); LayerPainter(*paintInfo.renderLayer).paintLayerContents(context, paintingInfo, paintLayerFlags | PaintLayerPaintingOverlayScrollbars);
} else { } else {
......
...@@ -524,14 +524,6 @@ ...@@ -524,14 +524,6 @@
'graphics/gpu/WebGLImageConversion.h', 'graphics/gpu/WebGLImageConversion.h',
'graphics/media/MediaPlayer.cpp', 'graphics/media/MediaPlayer.cpp',
'graphics/media/MediaPlayer.h', '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.cpp',
'graphics/skia/GaneshUtils.h', 'graphics/skia/GaneshUtils.h',
'graphics/skia/NativeImageSkia.cpp', 'graphics/skia/NativeImageSkia.cpp',
......
...@@ -28,16 +28,13 @@ ...@@ -28,16 +28,13 @@
#include "SkImageFilter.h" #include "SkImageFilter.h"
#include "SkMatrix44.h" #include "SkMatrix44.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/TraceEvent.h" #include "platform/TraceEvent.h"
#include "platform/geometry/FloatRect.h" #include "platform/geometry/FloatRect.h"
#include "platform/geometry/LayoutRect.h" #include "platform/geometry/LayoutRect.h"
#include "platform/graphics/FirstPaintInvalidationTracking.h" #include "platform/graphics/FirstPaintInvalidationTracking.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayerFactory.h" #include "platform/graphics/GraphicsLayerFactory.h"
#include "platform/graphics/Image.h" #include "platform/graphics/Image.h"
#include "platform/graphics/filters/SkiaImageFilterBuilder.h" #include "platform/graphics/filters/SkiaImageFilterBuilder.h"
#include "platform/graphics/paint/DisplayItemList.h"
#include "platform/graphics/skia/NativeImageSkia.h" #include "platform/graphics/skia/NativeImageSkia.h"
#include "platform/scroll/ScrollableArea.h" #include "platform/scroll/ScrollableArea.h"
#include "platform/text/TextStream.h" #include "platform/text/TextStream.h"
...@@ -274,20 +271,6 @@ void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const I ...@@ -274,20 +271,6 @@ void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const I
m_debugInfo.clearAnnotatedInvalidateRects(); m_debugInfo.clearAnnotatedInvalidateRects();
incrementPaintCount(); incrementPaintCount();
m_client->paintContents(this, context, m_paintingPhase, clip); 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() void GraphicsLayer::updateChildList()
...@@ -1072,14 +1055,6 @@ void GraphicsLayer::didScroll() ...@@ -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 } // namespace blink
#ifndef NDEBUG #ifndef NDEBUG
......
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
namespace blink { namespace blink {
class DisplayItemList;
class FloatRect; class FloatRect;
class GraphicsContext; class GraphicsContext;
class GraphicsLayer; class GraphicsLayer;
...@@ -243,16 +242,12 @@ public: ...@@ -243,16 +242,12 @@ public:
// WebLayerScrollClient implementation. // WebLayerScrollClient implementation.
virtual void didScroll() override; virtual void didScroll() override;
DisplayItemList& displayItemList();
protected: protected:
String debugName(WebLayer*) const; String debugName(WebLayer*) const;
explicit GraphicsLayer(GraphicsLayerClient*); explicit GraphicsLayer(GraphicsLayerClient*);
// GraphicsLayerFactoryChromium that wants to create a GraphicsLayer need to be friends. // GraphicsLayerFactoryChromium that wants to create a GraphicsLayer need to be friends.
friend class GraphicsLayerFactoryChromium; friend class GraphicsLayerFactoryChromium;
// for testing
friend class FakeGraphicsLayerFactory;
// Exposed for tests. // Exposed for tests.
virtual WebLayer* contentsLayer() const { return m_contentsLayer; } virtual WebLayer* contentsLayer() const { return m_contentsLayer; }
...@@ -346,8 +341,6 @@ private: ...@@ -346,8 +341,6 @@ private:
ScrollableArea* m_scrollableArea; ScrollableArea* m_scrollableArea;
GraphicsLayerDebugInfo m_debugInfo; GraphicsLayerDebugInfo m_debugInfo;
int m_3dRenderingContext; int m_3dRenderingContext;
OwnPtr<DisplayItemList> m_displayItemList;
}; };
} // namespace blink } // 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