Changeset 195156 in webkit


Ignore:
Timestamp:
Jan 15, 2016 3:57:41 PM (8 years ago)
Author:
Simon Fraser
Message:

Make a way to test display-list drawing
https://bugs.webkit.org/show_bug.cgi?id=152956

Reviewed by Ryosuke Niwa.
Source/WebCore:

Make it possible to toggle display-list drawing for a given compositing
layer via internals, as well as getting a textual representation of the display
list, optionally including items with platform-specific behavior.

Add one test that uses this.

Test: displaylists/layer-dispay-list.html

  • platform/graphics/GraphicsLayer.h:

(WebCore::GraphicsLayer::displayListAsText):

  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::GraphicsLayerCA::displayListAsText):

  • platform/graphics/ca/GraphicsLayerCA.h:
  • platform/graphics/displaylists/DisplayList.cpp:

(WebCore::DisplayList::DisplayList::shouldDumpForFlags):
(WebCore::DisplayList::DisplayList::asText):

  • platform/graphics/displaylists/DisplayList.h:
  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::setUsesDisplayListDrawing):
(WebCore::RenderLayerBacking::displayListAsText):

  • rendering/RenderLayerBacking.h:
  • testing/Internals.cpp:

(WebCore::Internals::setElementUsesDisplayListDrawing):
(WebCore::Internals::displayListForElement):

  • testing/Internals.h:
  • testing/Internals.idl:

LayoutTests:

Enable displaylists tests on Mac and iOS.

  • TestExpectations:
  • displaylists/layer-dispay-list-expected.txt: Added.
  • displaylists/layer-dispay-list.html: Added.
  • platform/ios-simulator/TestExpectations:
  • platform/mac/TestExpectations:
Location:
trunk
Files:
3 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r195152 r195156  
     12016-01-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make a way to test display-list drawing
     4        https://bugs.webkit.org/show_bug.cgi?id=152956
     5
     6        Reviewed by Ryosuke Niwa.
     7       
     8        Enable displaylists tests on Mac and iOS.
     9
     10        * TestExpectations:
     11        * displaylists/layer-dispay-list-expected.txt: Added.
     12        * displaylists/layer-dispay-list.html: Added.
     13        * platform/ios-simulator/TestExpectations:
     14        * platform/mac/TestExpectations:
     15
    1162016-01-15  Ryosuke Niwa  <rniwa@webkit.org>
    217
  • trunk/LayoutTests/TestExpectations

    r195087 r195156  
    1212accessibility/mac [ Skip ]
    1313accessibility/win [ Skip ]
     14displaylists [ Skip ]
    1415editing/mac [ Skip ]
    1516editing/pasteboard/gtk [ Skip ]
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r195092 r195156  
    88
    99accessibility/ios-simulator [ Pass ]
     10displaylists [ Pass ]
    1011quicklook [ Pass ]
    1112http/tests/quicklook [ Pass ]
  • trunk/LayoutTests/platform/mac/TestExpectations

    r195147 r195156  
    88
    99accessibility/mac [ Pass ]
     10displaylists [ Pass ]
    1011editing/mac [ Pass ]
    1112fast/scrolling/latching [ Pass ]
  • trunk/Source/WebCore/ChangeLog

    r195154 r195156  
     12016-01-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make a way to test display-list drawing
     4        https://bugs.webkit.org/show_bug.cgi?id=152956
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Make it possible to toggle display-list drawing for a given compositing
     9        layer via internals, as well as getting a textual representation of the display
     10        list, optionally including items with platform-specific behavior.
     11       
     12        Add one test that uses this.
     13
     14        Test: displaylists/layer-dispay-list.html
     15
     16        * platform/graphics/GraphicsLayer.h:
     17        (WebCore::GraphicsLayer::displayListAsText):
     18        * platform/graphics/ca/GraphicsLayerCA.cpp:
     19        (WebCore::GraphicsLayerCA::displayListAsText):
     20        * platform/graphics/ca/GraphicsLayerCA.h:
     21        * platform/graphics/displaylists/DisplayList.cpp:
     22        (WebCore::DisplayList::DisplayList::shouldDumpForFlags):
     23        (WebCore::DisplayList::DisplayList::asText):
     24        * platform/graphics/displaylists/DisplayList.h:
     25        * rendering/RenderLayerBacking.cpp:
     26        (WebCore::RenderLayerBacking::setUsesDisplayListDrawing):
     27        (WebCore::RenderLayerBacking::displayListAsText):
     28        * rendering/RenderLayerBacking.h:
     29        * testing/Internals.cpp:
     30        (WebCore::Internals::setElementUsesDisplayListDrawing):
     31        (WebCore::Internals::displayListForElement):
     32        * testing/Internals.h:
     33        * testing/Internals.idl:
     34
    1352016-01-15  Olivier Blin  <olivier.blin@softathome.com>
    236
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r194825 r195156  
    5555class TransformationMatrix;
    5656
     57namespace DisplayList {
     58typedef unsigned AsTextFlags;
     59}
     60
    5761// Base class for animation values (also used for transitions). Here to
    5862// represent values for properties being animated via the GraphicsLayer,
     
    517521    // pointers for the layers and timing data will be included in the returned string.
    518522    WEBCORE_EXPORT String layerTreeAsText(LayerTreeAsTextBehavior = LayerTreeAsTextBehaviorNormal) const;
     523
     524    // For testing.
     525    WEBCORE_EXPORT virtual String displayListAsText(DisplayList::AsTextFlags) const { return String(); }
    519526
    520527    // Return an estimate of the backing store memory cost (in bytes). May be incorrect for tiled layers.
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r195142 r195156  
    32713271}
    32723272
     3273String GraphicsLayerCA::displayListAsText(DisplayList::AsTextFlags flags) const
     3274{
     3275    if (!m_displayList)
     3276        return String();
     3277
     3278    return m_displayList->asText(flags);
     3279}
     3280
    32733281void GraphicsLayerCA::setDebugBackgroundColor(const Color& color)
    32743282{   
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r194825 r195156  
    208208    WEBCORE_EXPORT virtual void setIsViewportConstrained(bool) override;
    209209    virtual bool isViewportConstrained() const override { return m_isViewportConstrained; }
     210
     211    WEBCORE_EXPORT virtual String displayListAsText(DisplayList::AsTextFlags) const override;
    210212
    211213    WEBCORE_EXPORT virtual double backingStoreMemoryEstimate() const override;
  • trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp

    r194814 r195156  
    5959}
    6060
     61bool DisplayList::shouldDumpForFlags(AsTextFlags flags, const Item& item)
     62{
     63    switch (item.type()) {
     64    case ItemType::SetState:
     65        if (!(flags & AsTextFlag::IncludesPlatformOperations)) {
     66            const auto& stateItem = downcast<SetState>(item);
     67            // FIXME: for now, only drop the item if the only state-change flags are platform-specific.
     68            if (stateItem.state().m_changeFlags == GraphicsContextState::ShouldSubpixelQuantizeFontsChange)
     69                return false;
     70
     71            if (stateItem.state().m_changeFlags == GraphicsContextState::AntialiasedFontDilationEnabledChange)
     72                return false;
     73
     74            if (stateItem.state().m_changeFlags == GraphicsContextState::ShouldSubpixelQuantizeFontsChange)
     75                return false;
     76        }
     77        break;
     78#if USE(CG)
     79    case ItemType::ApplyFillPattern:
     80    case ItemType::ApplyStrokePattern:
     81        if (!(flags & AsTextFlag::IncludesPlatformOperations))
     82            return false;
     83        break;
     84#endif
     85    default:
     86        break;
     87    }
     88    return true;
     89}
     90
     91String DisplayList::asText(AsTextFlags flags) const
     92{
     93    TextStream stream;
     94    size_t numItems = m_list.size();
     95    for (size_t i = 0; i < numItems; ++i) {
     96        const auto& item = m_list[i].get();
     97        if (!shouldDumpForFlags(flags, item))
     98            continue;
     99
     100        TextStream::GroupScope scope(stream);
     101        stream << item;
     102    }
     103    return stream.release();
     104}
     105
    61106void DisplayList::dump(TextStream& ts) const
    62107{
  • trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h

    r194825 r195156  
    4242class Item;
    4343
     44enum AsTextFlag {
     45    None                            = 0,
     46    IncludesPlatformOperations      = 1 << 0,
     47};
     48
     49typedef unsigned AsTextFlags;
     50
    4451class DisplayList {
    4552    WTF_MAKE_NONCOPYABLE(DisplayList);
     
    6572    size_t itemCount() const { return m_list.size(); }
    6673    size_t sizeInBytes() const;
     74   
     75    String asText(AsTextFlags) const;
    6776
    6877#if !defined(NDEBUG) || !LOG_DISABLED
     
    7786        return m_list.last().get();
    7887    }
     88
     89    static bool shouldDumpForFlags(AsTextFlags, const Item&);
    7990
    8091    Vector<Ref<Item>>& list() { return m_list; }
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r194825 r195156  
    183183}
    184184
     185void RenderLayerBacking::setUsesDisplayListDrawing(bool usesDisplayListDrawing)
     186{
     187    // Note that this only affects the primary layer.
     188    if (usesDisplayListDrawing == m_graphicsLayer->usesDisplayListDrawing())
     189        return;
     190
     191    m_graphicsLayer->setUsesDisplayListDrawing(usesDisplayListDrawing);
     192    if (m_graphicsLayer->drawsContent())
     193        m_graphicsLayer->setNeedsDisplay();
     194}
     195
     196String RenderLayerBacking::displayListAsText(DisplayList::AsTextFlags flags) const
     197{
     198    return m_graphicsLayer->displayListAsText(flags);
     199}
     200
    185201void RenderLayerBacking::tiledBackingUsageChanged(const GraphicsLayer* layer, bool usingTiledBacking)
    186202{
  • trunk/Source/WebCore/rendering/RenderLayerBacking.h

    r191680 r195156  
    241241    // Return an estimate of the backing store area (in pixels) allocated by this object's GraphicsLayers.
    242242    WEBCORE_EXPORT double backingStoreMemoryEstimate() const;
     243   
     244    // For testing only.
     245    WEBCORE_EXPORT void setUsesDisplayListDrawing(bool);
     246    WEBCORE_EXPORT String displayListAsText(DisplayList::AsTextFlags) const;
    243247
    244248    LayoutSize devicePixelFractionFromRenderer() const { return m_devicePixelFractionFromRenderer; }
  • trunk/Source/WebCore/testing/Internals.cpp

    r195154 r195156  
    4444#include "DOMStringList.h"
    4545#include "DOMWindow.h"
     46#include "DisplayList.h"
    4647#include "Document.h"
    4748#include "DocumentMarker.h"
     
    9596#include "Range.h"
    9697#include "RenderEmbeddedObject.h"
     98#include "RenderLayerBacking.h"
    9799#include "RenderLayerCompositor.h"
    98100#include "RenderMenuList.h"
     
    19721974
    19731975    return page->nonFastScrollableRects();
     1976}
     1977
     1978void Internals::setElementUsesDisplayListDrawing(Element* element, bool usesDisplayListDrawing, ExceptionCode& ec)
     1979{
     1980    Document* document = contextDocument();
     1981    if (!document || !document->renderView()) {
     1982        ec = INVALID_ACCESS_ERR;
     1983        return;
     1984    }
     1985
     1986    if (!element || !element->renderer() || !element->renderer()->hasLayer()) {
     1987        ec = INVALID_ACCESS_ERR;
     1988        return;
     1989    }
     1990
     1991    RenderLayer* layer = downcast<RenderLayerModelObject>(element->renderer())->layer();
     1992    if (!layer->isComposited()) {
     1993        ec = INVALID_ACCESS_ERR;
     1994        return;
     1995    }
     1996   
     1997    layer->backing()->setUsesDisplayListDrawing(usesDisplayListDrawing);
     1998}
     1999
     2000String Internals::displayListForElement(Element* element, ExceptionCode& ec)
     2001{
     2002    return displayListForElement(element, 0, ec);
     2003}
     2004
     2005String Internals::displayListForElement(Element* element, unsigned flags, ExceptionCode& ec)
     2006{
     2007    Document* document = contextDocument();
     2008    if (!document || !document->renderView()) {
     2009        ec = INVALID_ACCESS_ERR;
     2010        return String();
     2011    }
     2012
     2013    if (!element || !element->renderer() || !element->renderer()->hasLayer()) {
     2014        ec = INVALID_ACCESS_ERR;
     2015        return String();
     2016    }
     2017   
     2018    RenderLayer* layer = downcast<RenderLayerModelObject>(element->renderer())->layer();
     2019    if (!layer->isComposited()) {
     2020        ec = INVALID_ACCESS_ERR;
     2021        return String();
     2022    }
     2023
     2024    DisplayList::AsTextFlags displayListFlags = 0;
     2025    if (flags & DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS)
     2026        displayListFlags |= DisplayList::AsTextFlag::IncludesPlatformOperations;
     2027   
     2028    return layer->backing()->displayListAsText(displayListFlags);
    19742029}
    19752030
  • trunk/Source/WebCore/testing/Internals.h

    r194706 r195156  
    254254    RefPtr<ClientRectList> nonFastScrollableRects(ExceptionCode&) const;
    255255
     256    void setElementUsesDisplayListDrawing(Element*, bool usesDisplayListDrawing, ExceptionCode&);
     257
     258    enum {
     259        // Values need to be kept in sync with Internals.idl.
     260        DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS = 1,
     261    };
     262    String displayListForElement(Element*, unsigned flags, ExceptionCode&);
     263    String displayListForElement(Element*, ExceptionCode&);
     264
    256265    void garbageCollectDocumentResources(ExceptionCode&) const;
    257266
  • trunk/Source/WebCore/testing/Internals.idl

    r194706 r195156  
    225225    [RaisesException] DOMString repaintRectsAsText();
    226226
     227    // These throw if the element does not have a compositing layer.
     228    [RaisesException] void setElementUsesDisplayListDrawing(Element element, boolean usesDisplayListDrawing);
     229
     230    // Flags for displayListForElement.
     231    const unsigned short DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS = 1;
     232    [RaisesException] DOMString displayListForElement(Element element, optional unsigned short flags);
     233
    227234    [RaisesException] void garbageCollectDocumentResources();
    228235
Note: See TracChangeset for help on using the changeset viewer.