Commit 0280efc0 authored by trchen@chromium.org's avatar trchen@chromium.org

Move ViewDisplayList to GraphicsLayer

This CL moves ViewDisplayList to GraphicsLayer and renames it to
DisplayItemList.

DisplayItemList and the DisplayItems are also moved to platform/graphics
to resolve layering violation. The recorders stay in core/paint.

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

git-svn-id: svn://svn.chromium.org/blink/trunk@185263 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 1e7db55c
......@@ -26,6 +26,11 @@ 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,8 +1516,6 @@
'paint/TableSectionPainter.h',
'paint/VideoPainter.cpp',
'paint/VideoPainter.h',
'paint/ViewDisplayList.cpp',
'paint/ViewDisplayList.h',
'paint/ViewPainter.cpp',
'paint/ViewPainter.h',
'plugins/DOMMimeType.cpp',
......@@ -1577,6 +1575,8 @@
'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,6 +3554,8 @@
'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,25 +7,14 @@
#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)
......@@ -35,8 +24,12 @@ ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsCo
graphicsContext->save();
graphicsContext->clip(snappedClipRect);
} else {
m_clipDisplayItem = new ClipDisplayItem(0, renderLayer, clipType, snappedClipRect);
m_renderLayer->renderer()->view()->viewDisplayList().add(adoptPtr(m_clipDisplayItem));
m_clipDisplayItem = new ClipDisplayItem(nullptr, clipType, snappedClipRect);
#ifndef NDEBUG
m_clipDisplayItem->setClientDebugString("nullptr");
#endif
if (RenderLayer* container = m_renderLayer->enclosingLayerForPaintInvalidationCrossingFrameBoundaries())
container->graphicsLayerBacking()->displayItemList().add(adoptPtr(m_clipDisplayItem));
}
}
......@@ -52,19 +45,11 @@ ClipRecorder::~ClipRecorder()
{
if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem);
m_renderLayer->renderer()->view()->viewDisplayList().add(endClip.release());
if (RenderLayer* container = m_renderLayer->enclosingLayerForPaintInvalidationCrossingFrameBoundaries())
container->graphicsLayerBacking()->displayItemList().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,42 +5,15 @@
#ifndef ClipRecorder_h
#define ClipRecorder_h
#include "core/paint/ViewDisplayList.h"
#include "core/rendering/PaintPhase.h"
#include "platform/geometry/RoundedRect.h"
#include "wtf/Vector.h"
#include "platform/graphics/paint/DisplayItem.h"
namespace blink {
class ClipDisplayItem;
class ClipRect;
class GraphicsContext;
class RenderObject;
class RenderLayer;
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 RoundedRect;
class ClipRecorder {
public:
......@@ -57,4 +30,4 @@ private:
} // namespace blink
#endif // ViewDisplayList_h
#endif // ClipRecorder_h
......@@ -9,6 +9,8 @@
#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 {
......@@ -20,6 +22,7 @@ public:
protected:
RenderView* renderView() { return m_renderView; }
DisplayItemList& rootDisplayItemList() { return renderView()->layer()->graphicsLayerBacking()->displayItemList(); }
private:
virtual void SetUp() override
......@@ -27,6 +30,7 @@ private:
RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
RenderingTest::SetUp();
enableCompositing();
m_renderView = document().view()->renderView();
ASSERT_TRUE(m_renderView);
......@@ -46,10 +50,10 @@ TEST_F(ClipRecorderTest, ClipRecorderTest_Single)
{
GraphicsContext* context = new GraphicsContext(nullptr);
FloatRect bound = renderView()->viewRect();
EXPECT_EQ((size_t)0, renderView()->viewDisplayList().paintList().size());
EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size());
drawClip(context, renderView(), PaintPhaseForeground, bound);
EXPECT_EQ((size_t)2, renderView()->viewDisplayList().paintList().size());
EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size());
}
}
......
......@@ -5,18 +5,17 @@
#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
......@@ -52,18 +51,18 @@ DrawingRecorder::~DrawingRecorder()
return;
ASSERT(displayList->bounds() == m_bounds);
OwnPtr<DrawingDisplayItem> drawingItem = adoptPtr(
new DrawingDisplayItem(displayList->picture(), m_bounds.location(), m_phase, m_renderer));
ASSERT(m_renderer->view());
m_renderer->view()->viewDisplayList().add(drawingItem.release());
}
new DrawingDisplayItem(m_renderer->displayItemClient(), (DisplayItem::Type)m_phase, displayList->picture(), m_bounds.location()));
#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());
}
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
if (RenderLayer* container = m_renderer->enclosingLayer()->enclosingLayerForPaintInvalidationCrossingFrameBoundaries())
container->graphicsLayerBacking()->displayItemList().add(drawingItem.release());
}
} // namespace blink
......@@ -5,29 +5,13 @@
#ifndef DrawingRecorder_h
#define DrawingRecorder_h
#include "core/paint/ViewDisplayList.h"
#include "platform/graphics/DisplayList.h"
#include "core/rendering/PaintPhase.h"
#include "platform/geometry/FloatRect.h"
namespace blink {
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 GraphicsContext;
class RenderObject;
class DrawingRecorder {
public:
......
......@@ -5,9 +5,12 @@
#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 {
......@@ -19,6 +22,7 @@ public:
protected:
RenderView* renderView() { return m_renderView; }
DisplayItemList& rootDisplayItemList() { return renderView()->layer()->graphicsLayerBacking()->displayItemList(); }
private:
virtual void SetUp() override
......@@ -26,6 +30,7 @@ private:
RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
RenderingTest::SetUp();
enableCompositing();
m_renderView = document().view()->renderView();
ASSERT_TRUE(m_renderView);
......@@ -51,10 +56,10 @@ TEST_F(DrawingRecorderTest, DrawingRecorderTest_Nothing)
{
GraphicsContext* context = new GraphicsContext(nullptr);
FloatRect bound = renderView()->viewRect();
EXPECT_EQ((size_t)0, renderView()->viewDisplayList().paintList().size());
EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size());
drawNothing(context, renderView(), PaintPhaseForeground, bound);
EXPECT_EQ((size_t)0, renderView()->viewDisplayList().paintList().size());
EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size());
}
TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect)
......@@ -62,7 +67,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, renderView()->viewDisplayList().paintList().size());
EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size());
}
}
......
// 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,6 +85,7 @@
#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"
......@@ -1121,8 +1122,10 @@ LayoutRect RenderObject::computePaintInvalidationRect(const RenderLayerModelObje
void RenderObject::invalidatePaintUsingContainer(const RenderLayerModelObject* paintInvalidationContainer, const LayoutRect& r, PaintInvalidationReason invalidationReason) const
{
if (RuntimeEnabledFeatures::slimmingPaintEnabled())
view()->viewDisplayList().invalidate(this);
if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
if (RenderLayer* container = enclosingLayer()->enclosingLayerForPaintInvalidationCrossingFrameBoundaries())
container->graphicsLayerBacking()->displayItemList().invalidate(displayItemClient());
}
if (r.isEmpty())
return;
......
......@@ -47,6 +47,7 @@
#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 {
......@@ -1055,6 +1056,8 @@ public:
virtual LayoutRect viewRect() const;
DisplayItemClient displayItemClient() const { return (void*)this; }
protected:
enum RenderObjectType {
RenderObjectBr,
......
......@@ -23,7 +23,6 @@
#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"
......@@ -165,14 +164,6 @@ 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;
......@@ -209,7 +200,6 @@ 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,6 +2,9 @@
// 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"
......@@ -14,27 +17,27 @@ namespace blink {
class RenderingTest : public testing::Test {
protected:
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();
}
virtual void SetUp() override;
Document& document() const { return m_pageHolder->document(); }
void setBodyInnerHTML(const String& htmlContent)
{
document().body()->setInnerHTML(htmlContent, ASSERT_NO_EXCEPTION);
document().view()->updateLayoutAndStyleIfNeededRecursive();
document().view()->updateLayoutAndStyleForPainting();
}
void enableCompositing()
{
m_pageHolder->page().settings().setAcceleratedCompositingEnabled(true);
document().view()->updateLayoutAndStyleForPainting();
}
private:
Page::PageClients m_pageClients;
OwnPtr<DummyPageHolder> m_pageHolder;
};
} // namespace blink
#endif // RenderingTestHelper_h
......@@ -2085,19 +2085,6 @@ 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,6 +524,14 @@
'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,13 +28,16 @@
#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"
......@@ -271,6 +274,20 @@ 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()
......@@ -1055,6 +1072,14 @@ 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,6 +51,7 @@
namespace blink {
class DisplayItemList;
class FloatRect;
class GraphicsContext;
class GraphicsLayer;
......@@ -242,12 +243,16 @@ 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; }
......@@ -341,6 +346,8 @@ 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
......@@ -2,20 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ViewDisplayList_h
#define ViewDisplayList_h
#ifndef DisplayItem_h
#define DisplayItem_h
#include "core/rendering/PaintPhase.h"
#include "wtf/HashSet.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/Vector.h"
#include "platform/PlatformExport.h"
#ifndef NDEBUG
#include "wtf/text/WTFString.h"
#endif
namespace blink {
class GraphicsContext;
class RenderObject;
class DisplayItem {
typedef void* DisplayItemClient;
class PLATFORM_EXPORT DisplayItem {
public:
enum Type {
// DisplayItem types must be kept in sync with PaintPhase.
......@@ -53,58 +55,39 @@ public:
virtual void replay(GraphicsContext*) = 0;
const RenderObject* renderer() const { return m_id.renderer; }
DisplayItemClient client() const { return m_id.client; }
Type type() const { return m_id.type; }
bool idsEqual(const DisplayItem& other) const { return m_id.renderer == other.m_id.renderer && m_id.type == other.m_id.type; }
bool idsEqual(const DisplayItem& other) const { return m_id.client == other.m_id.client && m_id.type == other.m_id.type; }
#ifndef NDEBUG
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;
#endif
protected:
DisplayItem(const RenderObject* renderer, Type type)
: m_id(renderer, type)
DisplayItem(DisplayItemClient client, Type type)
: m_id(client, type)
{ }
private:
struct Id {
Id(const RenderObject* r, Type t)
: renderer(r)
Id(DisplayItemClient c, Type t)
: client(c)
, type(t)
{ }
const RenderObject* renderer;
const DisplayItemClient client;
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
void showDebugData() const;
WTF::String m_clientDebugString;
#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 // ViewDisplayList_h
#endif // DisplayItem_h
......@@ -3,23 +3,18 @@
// found in the LICENSE file.
#include "config.h"
#include "core/paint/ViewDisplayList.h"
#include "platform/graphics/paint/DisplayItemList.h"
#include "platform/NotImplemented.h"
#include "platform/RuntimeEnabledFeatures.h"
#ifndef NDEBUG
#include "core/rendering/RenderObject.h"
#include "wtf/text/WTFString.h"
#include "platform/graphics/paint/DisplayItem.h"
#include "wtf/text/StringBuilder.h"
#endif
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);
const PaintList& ViewDisplayList::paintList()
const PaintList& DisplayItemList::paintList()
{
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
......@@ -27,22 +22,22 @@ const PaintList& ViewDisplayList::paintList()
return m_paintList;
}
void ViewDisplayList::add(WTF::PassOwnPtr<DisplayItem> displayItem)
void DisplayItemList::add(WTF::PassOwnPtr<DisplayItem> displayItem)
{
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
m_newPaints.append(displayItem);
}
void ViewDisplayList::invalidate(const RenderObject* renderer)
void DisplayItemList::invalidate(DisplayItemClient renderer)
{
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
m_invalidated.add(renderer);
}
PaintList::iterator ViewDisplayList::findDisplayItem(PaintList::iterator begin, const DisplayItem& displayItem)
PaintList::iterator DisplayItemList::findDisplayItem(PaintList::iterator begin, const DisplayItem& displayItem)
{
PaintList::iterator end = m_paintList.end();
if (displayItem.renderer() && !m_paintListRenderers.contains(displayItem.renderer()))
if (displayItem.client() && !m_paintListRenderers.contains(displayItem.client()))
return end;
for (PaintList::iterator it = begin; it != end; ++it) {
......@@ -52,19 +47,19 @@ PaintList::iterator ViewDisplayList::findDisplayItem(PaintList::iterator begin,
}
// FIXME: Properly handle clips.
ASSERT(!displayItem.renderer());
ASSERT(!displayItem.client());
return end;
}
bool ViewDisplayList::wasInvalidated(const DisplayItem& displayItem) const
bool DisplayItemList::wasInvalidated(const DisplayItem& displayItem) const
{
// FIXME: Use a bit on RenderObject instead of tracking m_invalidated.
return displayItem.renderer() && m_invalidated.contains(displayItem.renderer());
// FIXME: Use a bit on DisplayItemClient instead of tracking m_invalidated.
return displayItem.client() && m_invalidated.contains(displayItem.client());
}
static void appendDisplayItem(PaintList& list, HashSet<const RenderObject*>& renderers, WTF::PassOwnPtr<DisplayItem> displayItem)
static void appendDisplayItem(PaintList& list, HashSet<DisplayItemClient>& renderers, WTF::PassOwnPtr<DisplayItem> displayItem)
{
if (const RenderObject* renderer = displayItem->renderer())
if (DisplayItemClient renderer = displayItem->client())
renderers.add(renderer);
list.append(displayItem);
}
......@@ -74,10 +69,10 @@ static void appendDisplayItem(PaintList& list, HashSet<const RenderObject*>& ren
//
// 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 ViewDisplayList::updatePaintList()
void DisplayItemList::updatePaintList()
{
PaintList updatedList;
HashSet<const RenderObject*> updatedRenderers;
HashSet<DisplayItemClient> updatedRenderers;
if (int maxCapacity = m_newPaints.size() + std::max(0, (int)m_paintList.size() - (int)m_invalidated.size()))
updatedList.reserveCapacity(maxCapacity);
......@@ -116,53 +111,6 @@ void ViewDisplayList::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)
{
......@@ -177,11 +125,12 @@ static WTF::String paintListAsDebugString(const PaintList& list)
return stringBuilder.toString();
}
void ViewDisplayList::showDebugData() const
void DisplayItemList::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
// 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