⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287967 in webkit


Ignore:
Timestamp:
Jan 12, 2022, 6:17:09 PM (5 years ago)
Author:
Fujii Hironori
Message:

[WinCairo] Tiling scroll support
​https://bugs.webkit.org/show_bug.cgi?id=233676

Reviewed by Don Olmstead.

Source/WebCore:

Added a new class TextureMapperSparseBackingStore that supports
partially tiling the layer and removing tiles outside of the
coverage rect.

  • Headers.cmake:
  • platform/TextureMapper.cmake:
  • platform/graphics/texmap/TextureMapperSparseBackingStore.cpp: Added.

(WebCore::TextureMapperSparseBackingStore::TextureMapperSparseBackingStore):
(WebCore::TextureMapperSparseBackingStore::setSize):
(WebCore::TextureMapperSparseBackingStore::removeUncoveredTiles):
(WebCore::TextureMapperSparseBackingStore::adjustedTransformForRect):
(WebCore::TextureMapperSparseBackingStore::paintToTextureMapper):
(WebCore::TextureMapperSparseBackingStore::drawBorder):
(WebCore::TextureMapperSparseBackingStore::drawRepaintCounter):
(WebCore::TextureMapperSparseBackingStore::tileDimension const):
(WebCore::TextureMapperSparseBackingStore::updateContents):

  • platform/graphics/texmap/TextureMapperSparseBackingStore.h: Added.

Source/WebKit:

Added a new class WCTiledBacking that implements TiledBacking.

Copied computeVisibleAndCoverageRect,
transformByApplyingAnchorPoint and layerTransform from
GraphicsLayerAC.

  • GPUProcess/graphics/wc/WCScene.cpp:

(WebKit::WCScene::update):

  • WebProcess/WebPage/wc/DrawingAreaWC.cpp:

(WebKit::DrawingAreaWC::DrawingAreaWC):
(WebKit::DrawingAreaWC::updatePreferences):
(WebKit::DrawingAreaWC::shouldUseTiledBackingForFrameView const):
(WebKit::DrawingAreaWC::setNeedsDisplayInRect):
(WebKit::DrawingAreaWC::scroll):
(WebKit::flushLayerImageBuffers):
(WebKit::DrawingAreaWC::sendUpdateAC):
(WebKit::DrawingAreaWC::RootLayerClient::RootLayerClient): Deleted.
(WebKit::DrawingAreaWC::RootLayerClient::paintContents): Deleted.
(WebKit::DrawingAreaWC::RootLayerClient::deviceScaleFactor const): Deleted.

  • WebProcess/WebPage/wc/DrawingAreaWC.h:
  • WebProcess/WebPage/wc/GraphicsLayerWC.cpp:

(WebKit::GraphicsLayerWC::GraphicsLayerWC):
(WebKit::GraphicsLayerWC::setNeedsDisplay):
(WebKit::GraphicsLayerWC::setNeedsDisplayInRect):
(WebKit::GraphicsLayerWC::setBackgroundColor):
(WebKit::GraphicsLayerWC::setDrawsContent):
(WebKit::GraphicsLayerWC::noteLayerPropertyChanged):
(WebKit::GraphicsLayerWC::flushCompositingState):
(WebKit::GraphicsLayerWC::flushCompositingStateForThisLayerOnly):
(WebKit::GraphicsLayerWC::tiledBacking const):
(WebKit::GraphicsLayerWC::createImageBuffer):
(WebKit::accumulatesTransform):
(WebKit::GraphicsLayerWC::transformByApplyingAnchorPoint const):
(WebKit::GraphicsLayerWC::layerTransform const):
(WebKit::GraphicsLayerWC::computeVisibleAndCoverageRect const):
(WebKit::GraphicsLayerWC::recursiveCommitChanges):

  • WebProcess/WebPage/wc/GraphicsLayerWC.h:
  • WebProcess/WebPage/wc/WCUpateInfo.h:

(WebKit::WCLayerUpateInfo::encode const):
(WebKit::WCLayerUpateInfo::decode):

Location:
trunk/Source
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287959 r287967  
     12022-01-12  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [WinCairo] Tiling scroll support
     4        https://bugs.webkit.org/show_bug.cgi?id=233676
     5
     6        Reviewed by Don Olmstead.
     7
     8        Added a new class TextureMapperSparseBackingStore that supports
     9        partially tiling the layer and removing tiles outside of the
     10        coverage rect.
     11
     12        * Headers.cmake:
     13        * platform/TextureMapper.cmake:
     14        * platform/graphics/texmap/TextureMapperSparseBackingStore.cpp: Added.
     15        (WebCore::TextureMapperSparseBackingStore::TextureMapperSparseBackingStore):
     16        (WebCore::TextureMapperSparseBackingStore::setSize):
     17        (WebCore::TextureMapperSparseBackingStore::removeUncoveredTiles):
     18        (WebCore::TextureMapperSparseBackingStore::adjustedTransformForRect):
     19        (WebCore::TextureMapperSparseBackingStore::paintToTextureMapper):
     20        (WebCore::TextureMapperSparseBackingStore::drawBorder):
     21        (WebCore::TextureMapperSparseBackingStore::drawRepaintCounter):
     22        (WebCore::TextureMapperSparseBackingStore::tileDimension const):
     23        (WebCore::TextureMapperSparseBackingStore::updateContents):
     24        * platform/graphics/texmap/TextureMapperSparseBackingStore.h: Added.
     25
    1262022-01-12  Megan Gardner  <megan_gardner@apple.com>
    227
  • trunk/Source/WebCore/Headers.cmake

    r287782 r287967  
    16461646    platform/graphics/transforms/TransformOperation.h
    16471647    platform/graphics/transforms/TransformOperations.h
     1648    platform/graphics/transforms/TransformState.h
    16481649    platform/graphics/transforms/TransformationMatrix.h
    16491650    platform/graphics/transforms/TranslateTransformOperation.h
  • trunk/Source/WebCore/platform/TextureMapper.cmake

    r286205 r287967  
    130130    )
    131131endif ()
     132
     133if (USE_GRAPHICS_LAYER_WC)
     134    list(APPEND WebCore_SOURCES
     135        platform/graphics/texmap/TextureMapperSparseBackingStore.cpp
     136    )
     137    list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
     138        platform/graphics/texmap/TextureMapperSparseBackingStore.h
     139    )
     140endif ()
  • trunk/Source/WebKit/ChangeLog

    r287964 r287967  
     12022-01-12  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [WinCairo] Tiling scroll support
     4        https://bugs.webkit.org/show_bug.cgi?id=233676
     5
     6        Reviewed by Don Olmstead.
     7
     8        Added a new class WCTiledBacking that implements TiledBacking.
     9
     10        Copied computeVisibleAndCoverageRect,
     11        transformByApplyingAnchorPoint and layerTransform from
     12        GraphicsLayerAC.
     13
     14        * GPUProcess/graphics/wc/WCScene.cpp:
     15        (WebKit::WCScene::update):
     16        * WebProcess/WebPage/wc/DrawingAreaWC.cpp:
     17        (WebKit::DrawingAreaWC::DrawingAreaWC):
     18        (WebKit::DrawingAreaWC::updatePreferences):
     19        (WebKit::DrawingAreaWC::shouldUseTiledBackingForFrameView const):
     20        (WebKit::DrawingAreaWC::setNeedsDisplayInRect):
     21        (WebKit::DrawingAreaWC::scroll):
     22        (WebKit::flushLayerImageBuffers):
     23        (WebKit::DrawingAreaWC::sendUpdateAC):
     24        (WebKit::DrawingAreaWC::RootLayerClient::RootLayerClient): Deleted.
     25        (WebKit::DrawingAreaWC::RootLayerClient::paintContents): Deleted.
     26        (WebKit::DrawingAreaWC::RootLayerClient::deviceScaleFactor const): Deleted.
     27        * WebProcess/WebPage/wc/DrawingAreaWC.h:
     28        * WebProcess/WebPage/wc/GraphicsLayerWC.cpp:
     29        (WebKit::GraphicsLayerWC::GraphicsLayerWC):
     30        (WebKit::GraphicsLayerWC::setNeedsDisplay):
     31        (WebKit::GraphicsLayerWC::setNeedsDisplayInRect):
     32        (WebKit::GraphicsLayerWC::setBackgroundColor):
     33        (WebKit::GraphicsLayerWC::setDrawsContent):
     34        (WebKit::GraphicsLayerWC::noteLayerPropertyChanged):
     35        (WebKit::GraphicsLayerWC::flushCompositingState):
     36        (WebKit::GraphicsLayerWC::flushCompositingStateForThisLayerOnly):
     37        (WebKit::GraphicsLayerWC::tiledBacking const):
     38        (WebKit::GraphicsLayerWC::createImageBuffer):
     39        (WebKit::accumulatesTransform):
     40        (WebKit::GraphicsLayerWC::transformByApplyingAnchorPoint const):
     41        (WebKit::GraphicsLayerWC::layerTransform const):
     42        (WebKit::GraphicsLayerWC::computeVisibleAndCoverageRect const):
     43        (WebKit::GraphicsLayerWC::recursiveCommitChanges):
     44        * WebProcess/WebPage/wc/GraphicsLayerWC.h:
     45        * WebProcess/WebPage/wc/WCUpateInfo.h:
     46        (WebKit::WCLayerUpateInfo::encode const):
     47        (WebKit::WCLayerUpateInfo::decode):
     48
    1492022-01-12  Ryan Haddad  <ryanhaddad@apple.com>
    250
  • trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp

    r287288 r287967  
    3737#include <WebCore/TextureMapperLayer.h>
    3838#include <WebCore/TextureMapperPlatformLayer.h>
    39 #include <WebCore/TextureMapperTiledBackingStore.h>
     39#include <WebCore/TextureMapperSparseBackingStore.h>
    4040
    4141namespace WebKit {
    … …  
    5353
    5454    WebCore::TextureMapperLayer texmapLayer;
    55     RefPtr<WebCore::TextureMapperTiledBackingStore> backingStore;
     55    std::optional<WebCore::TextureMapperSparseBackingStore> backingStore;
    5656    std::unique_ptr<WebCore::TextureMapperLayer> backdropLayer;
    5757};
    … …  
    123123        if (layerUpdate.changes & WCLayerChange::MasksToBounds)
    124124            layer->texmapLayer.setMasksToBounds(layerUpdate.masksToBounds);
    125         if (layerUpdate.changes & WCLayerChange::BackingStore) {
    126             auto bitmap = layerUpdate.backingStore.bitmap();
    127             if (bitmap) {
    128                 layer->backingStore = WebCore::TextureMapperTiledBackingStore::create();
    129                 auto image = bitmap->createImage();
    130                 layer->backingStore->updateContents(*m_textureMapper, image.get(), bitmap->size(), { { }, bitmap->size() });
    131                 layer->texmapLayer.setBackingStore(layer->backingStore.get());
     125        if (layerUpdate.changes & WCLayerChange::Background) {
     126            if (layerUpdate.hasBackingStore) {
     127                if (!layer->backingStore) {
     128                    const int tileSize = 512;
     129                    layer->backingStore.emplace<WebCore::TextureMapperSparseBackingStore>(tileSize);
     130                    auto& backingStore = *layer->backingStore;
     131                    layer->texmapLayer.setBackgroundColor({ });
     132                    layer->texmapLayer.setBackingStore(&backingStore);
     133                }
     134                auto& backingStore = *layer->backingStore;
     135                backingStore.setSize(WebCore::IntSize(layer->texmapLayer.size()));
     136                backingStore.removeUncoveredTiles(layerUpdate.coverageRect);
     137                auto bitmap = layerUpdate.backingStore.bitmap();
     138                if (bitmap) {
     139                    auto image = bitmap->createImage();
     140                    backingStore.updateContents(*m_textureMapper, *image, layerUpdate.dirtyRect);
     141                }
    132142            } else {
     143                layer->texmapLayer.setBackgroundColor(layerUpdate.backgroundColor);
    133144                layer->texmapLayer.setBackingStore(nullptr);
    134                 layer->backingStore = nullptr;
     145                layer->backingStore = std::nullopt;
    135146            }
    136147        }
    … …  
    141152        if (layerUpdate.changes & WCLayerChange::RepaintCount)
    142153            layer->texmapLayer.setRepaintCounter(layerUpdate.showRepaintCounter, layerUpdate.repaintCount);
    143         if (layerUpdate.changes & WCLayerChange::BackgroundColor)
    144             layer->texmapLayer.setBackgroundColor(layerUpdate.backgroundColor);
    145154        if (layerUpdate.changes & WCLayerChange::Opacity)
    146155            layer->texmapLayer.setOpacity(layerUpdate.opacity);
  • trunk/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.cpp

    r285099 r287967  
    3232#include "RemoteWCLayerTreeHostProxy.h"
    3333#include "UpdateInfo.h"
     34#include "WebFrame.h"
    3435#include "WebPageCreationParameters.h"
    3536#include "WebProcess.h"
    … …  
    4344DrawingAreaWC::DrawingAreaWC(WebPage& webPage, const WebPageCreationParameters& parameters)
    4445    : DrawingArea(DrawingAreaType::WC, parameters.drawingAreaIdentifier, webPage)
    45     , m_rootLayerClient(webPage)
    4646    , m_remoteWCLayerTreeHostProxy(makeUnique<RemoteWCLayerTreeHostProxy>(webPage, *this))
    4747    , m_layerFactory(*this)
    … …  
    5151{
    5252    m_rootLayer->setName(MAKE_STATIC_STRING_IMPL("drawing area root"));
    53     m_rootLayer->setDrawsContent(true);
    54     m_rootLayer->setContentsOpaque(true);
    5553    m_rootLayer->setSize(m_webPage.size());
    56     m_rootLayer->setNeedsDisplay();
    5754}
    5855
    … …  
    9491}
    9592
     93void DrawingAreaWC::updatePreferences(const WebPreferencesStore&)
     94{
     95    Settings& settings = m_webPage.corePage()->settings();
     96    settings.setAcceleratedCompositingForFixedPositionEnabled(settings.acceleratedCompositingEnabled());
     97}
     98
     99bool DrawingAreaWC::shouldUseTiledBackingForFrameView(const WebCore::FrameView& frameView) const
     100{
     101    return frameView.frame().isMainFrame();
     102}
     103
    96104void DrawingAreaWC::setLayerTreeStateIsFrozen(bool isFrozen)
    97105{
    … …  
    123131{
    124132    if (isCompositingMode())
    125         m_rootLayer->setNeedsDisplayInRect(rect);
    126     else
    127         m_dirtyRegion.unite(rect);
     133        return;
     134    m_dirtyRegion.unite(rect);
    128135    triggerRenderingUpdate();
    129136}
    … …  
    132139{
    133140    if (isCompositingMode())
    134         m_rootLayer->setNeedsDisplayInRect(scrollRect);
    135     else {
    136         if (scrollRect != m_scrollRect) {
    137             // Just repaint the entire current scroll rect, we'll scroll the new rect instead.
    138             setNeedsDisplayInRect(m_scrollRect);
    139             m_scrollRect = { };
    140             m_scrollOffset = { };
    141         }
    142         // Get the part of the dirty region that is in the scroll rect.
    143         Region dirtyRegionInScrollRect = intersect(scrollRect, m_dirtyRegion);
    144         if (!dirtyRegionInScrollRect.isEmpty()) {
    145             // There are parts of the dirty region that are inside the scroll rect.
    146             // We need to subtract them from the region, move them and re-add them.
    147             m_dirtyRegion.subtract(scrollRect);
    148             // Move the dirty parts.
    149             Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollDelta), scrollRect);
    150             // And add them back.
    151             m_dirtyRegion.unite(movedDirtyRegionInScrollRect);
    152         }
    153         // Compute the scroll repaint region.
    154         Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta));
    155         m_dirtyRegion.unite(scrollRepaintRegion);
    156         m_scrollRect = scrollRect;
    157         m_scrollOffset += scrollDelta;
    158         triggerRenderingUpdate();
    159     }
     141        return;
     142
     143    if (scrollRect != m_scrollRect) {
     144        // Just repaint the entire current scroll rect, we'll scroll the new rect instead.
     145        setNeedsDisplayInRect(m_scrollRect);
     146        m_scrollRect = { };
     147        m_scrollOffset = { };
     148    }
     149    // Get the part of the dirty region that is in the scroll rect.
     150    Region dirtyRegionInScrollRect = intersect(scrollRect, m_dirtyRegion);
     151    if (!dirtyRegionInScrollRect.isEmpty()) {
     152        // There are parts of the dirty region that are inside the scroll rect.
     153        // We need to subtract them from the region, move them and re-add them.
     154        m_dirtyRegion.subtract(scrollRect);
     155        // Move the dirty parts.
     156        Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollDelta), scrollRect);
     157        // And add them back.
     158        m_dirtyRegion.unite(movedDirtyRegionInScrollRect);
     159    }
     160    // Compute the scroll repaint region.
     161    Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta));
     162    m_dirtyRegion.unite(scrollRepaintRegion);
     163    m_scrollRect = scrollRect;
     164    m_scrollOffset += scrollDelta;
     165    triggerRenderingUpdate();
    160166}
    161167
    … …  
    174180{
    175181    for (auto& layerInfo : info.changedLayers) {
    176         if (layerInfo.changes & WCLayerChange::BackingStore) {
     182        if (layerInfo.changes & WCLayerChange::Background) {
    177183            if (auto image = layerInfo.backingStore.imageBuffer()) {
    178184                if (auto flusher = image->createFlusher())
    … …  
    221227
    222228    // Because our view-relative overlay root layer is not attached to the FrameView's GraphicsLayer tree, we need to flush it manually.
    223     if (m_viewOverlayRootLayer)
    224         m_viewOverlayRootLayer->flushCompositingState({ });
     229    if (m_viewOverlayRootLayer) {
     230        FloatRect visibleRect({ }, m_webPage.size());
     231        m_viewOverlayRootLayer->flushCompositingState(visibleRect);
     232    }
    225233
    226234    m_updateInfo.rootLayer = m_rootLayer->primaryLayerID();
    … …  
    342350}
    343351
    344 DrawingAreaWC::RootLayerClient::RootLayerClient(WebPage& webPage)
    345     : m_webPage(webPage)
    346 {
    347 }
    348 
    349 void DrawingAreaWC::RootLayerClient::paintContents(const GraphicsLayer*, GraphicsContext& context, const FloatRect& rectToPaint, GraphicsLayerPaintBehavior)
    350 {
    351     context.save();
    352     context.clip(rectToPaint);
    353     m_webPage.corePage()->mainFrame().view()->paint(context, enclosingIntRect(rectToPaint));
    354     context.restore();
    355 }
    356 
    357 float DrawingAreaWC::RootLayerClient::deviceScaleFactor() const
    358 {
    359     return m_webPage.corePage()->deviceScaleFactor();
    360 }
    361 
    362352} // namespace WebKit
  • trunk/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.h

    r285099 r287967  
    5858    void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
    5959    void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) override;
     60    void updatePreferences(const WebPreferencesStore&) override;
     61    bool shouldUseTiledBackingForFrameView(const WebCore::FrameView&) const override;
    6062    // GraphicsLayerWC::Observer
    6163    void graphicsLayerAdded(GraphicsLayerWC&) override;
    … …  
    7274    void updateRootLayers();
    7375
    74     class RootLayerClient : public WebCore::GraphicsLayerClient {
    75     public:
    76         RootLayerClient(WebPage&);
    77     private:
    78         void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::FloatRect& rectToPaint, WebCore::GraphicsLayerPaintBehavior) override;
    79         float deviceScaleFactor() const override;
    80         WebPage& m_webPage;
    81     };
    82 
    83     RootLayerClient m_rootLayerClient;
     76    WebCore::GraphicsLayerClient m_rootLayerClient;
    8477    std::unique_ptr<RemoteWCLayerTreeHostProxy> m_remoteWCLayerTreeHostProxy;
    8578    WCLayerFactory m_layerFactory;
  • trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp

    r287288 r287967  
    11/*
     2 * Copyright (C) 2010-2021 Apple Inc. All rights reserved.
    23 * Copyright (C) 2021 Sony Interactive Entertainment Inc.
    34 *
    … …  
    2829
    2930#include "WCPlatformLayerGCGL.h"
     31#include <WebCore/TransformState.h>
    3032
    3133namespace WebKit {
    3234using namespace WebCore;
     35
     36class WCTiledBacking final : public TiledBacking {
     37    WTF_MAKE_FAST_ALLOCATED;
     38public:
     39    WCTiledBacking(GraphicsLayerWC& owner)
     40        : m_owner(owner) { }
     41
     42    bool paintAndFlush(WCLayerUpateInfo& update)
     43    {
     44        update.dirtyRect = enclosingIntRect(m_dirtyRect);
     45        update.coverageRect = m_coverageRect;
     46        m_dirtyRect = { };
     47        auto& imageRect = update.dirtyRect;
     48        if (imageRect.isEmpty())
     49            return false;
     50        auto image = m_owner.createImageBuffer(imageRect.size());
     51        auto& context = image->context();
     52        context.translate(-imageRect.x(), -imageRect.y());
     53        m_owner.paintGraphicsLayerContents(context, update.dirtyRect);
     54        image->flushDrawingContextAsync();
     55        update.backingStore.setImageBuffer(WTFMove(image));
     56        return true;
     57    }
     58
     59    void setDirtyRect(const WebCore::FloatRect& rect)
     60    {
     61        m_dirtyRect.unite(rect);
     62    }
     63
     64    bool hasDirtyRect()
     65    {
     66        return !m_dirtyRect.isEmpty();
     67    }
     68
     69    TiledBacking* tiledBacking() const { return const_cast<WCTiledBacking*>(this); };
     70
     71    IntRect adjustCoverageRect(IntRect coverage)
     72    {
     73        int x = coverage.x() / tileSize().width() * tileSize().width();
     74        int y = coverage.y() / tileSize().height() * tileSize().height();
     75        int maxX = (coverage.maxX() + tileSize().width() - 1) / tileSize().width() * tileSize().width();
     76        int maxY = (coverage.maxY() + tileSize().height() - 1) / tileSize().height() * tileSize().height();
     77        IntRect newCoverage { x, y, maxX - x, maxY - y };
     78        newCoverage.intersect(bounds());
     79        return newCoverage;
     80    }
     81
     82    // TiledBacking override
     83    void setVisibleRect(const FloatRect&) final { }
     84    FloatRect visibleRect() const final { return { }; };
     85    void setLayoutViewportRect(std::optional<FloatRect>) final { }
     86    void setCoverageRect(const FloatRect& rect) final
     87    {
     88        auto newCoverage = adjustCoverageRect(enclosingIntRect(rect));
     89        WebCore::Region region(newCoverage);
     90        region.subtract(m_coverageRect);
     91        setDirtyRect(region.bounds());
     92        m_coverageRect = newCoverage;
     93        m_dirtyRect.intersect(m_coverageRect);
     94    }
     95    FloatRect coverageRect() const final { return { }; };
     96    bool tilesWouldChangeForCoverageRect(const FloatRect&) const final { return false; }
     97    void setTiledScrollingIndicatorPosition(const FloatPoint&) final { }
     98    void setTopContentInset(float) final { }
     99    void setVelocity(const VelocityData&) final { }
     100    void setTileSizeUpdateDelayDisabledForTesting(bool) final { };
     101    void setScrollability(Scrollability) final { }
     102    void prepopulateRect(const FloatRect&) final { }
     103    void setIsInWindow(bool) final { }
     104    bool isInWindow() const final { return m_isInWindow; }
     105    void setTileCoverage(TileCoverage) final { }
     106    TileCoverage tileCoverage() const final { return { }; };
     107    FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) final { return { }; };
     108    FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) final { return { }; };
     109    void willStartLiveResize() final { };
     110    void didEndLiveResize() final { };
     111    IntSize tileSize() const final { return { 512, 512 }; };
     112    void revalidateTiles() final { }
     113    void forceRepaint() final { }
     114    IntRect tileGridExtent() const final { return { }; }
     115    void setScrollingPerformanceTestingEnabled(bool flag) final { }
     116    bool scrollingPerformanceTestingEnabled() const final { return false; };
     117    double retainedTileBackingStoreMemory() const final { return 0; }
     118    IntRect tileCoverageRect() const final { return { }; }
     119    void setScrollingModeIndication(ScrollingModeIndication) final { }
     120    void setHasMargins(bool marginTop, bool marginBottom, bool marginLeft, bool marginRight) final { }
     121    bool hasMargins() const final { return false; };
     122    bool hasHorizontalMargins() const final { return false; };
     123    bool hasVerticalMargins() const final { return false; };
     124    void setMarginSize(int) final { }
     125    int topMarginHeight() const final { return 0; };
     126    int bottomMarginHeight() const final { return 0; };
     127    int leftMarginWidth() const final { return 0; };
     128    int rightMarginWidth() const final { return 0; };
     129    void setZoomedOutContentsScale(float) final { }
     130    float zoomedOutContentsScale() const final { return 1; }
     131    IntRect bounds() const final { return { { }, IntSize(m_owner.size()) }; };
     132    IntRect boundsWithoutMargin() const final { return bounds(); };
     133
     134private:
     135    bool m_isInWindow { false };
     136    WebCore::IntRect m_coverageRect;
     137    WebCore::FloatRect m_dirtyRect;
     138    GraphicsLayerWC& m_owner;
     139};
     140
    33141
    34142GraphicsLayerWC::GraphicsLayerWC(Type layerType, GraphicsLayerClient& client, Observer& observer)
    … …  
    36144    , m_observer(&observer)
    37145{
     146    m_tiledBacking = makeUnique<WCTiledBacking>(*this);
     147    if (layerType == Type::Normal)
     148        client.tiledBackingUsageChanged(this, true);
    38149    m_observer->graphicsLayerAdded(*this);
    39150}
    … …  
    60171void GraphicsLayerWC::setNeedsDisplay()
    61172{
     173    setNeedsDisplayInRect({ { }, m_size }, ClipToLayer);
     174}
     175
     176void GraphicsLayerWC::setNeedsDisplayInRect(const WebCore::FloatRect& rect, ShouldClipToLayer shouldClip)
     177{
    62178    if (!drawsContent())
    63179        return;
    64     noteLayerPropertyChanged(WCLayerChange::BackingStore);
    65     addRepaintRect({ { }, m_size });
    66 }
    67 
    68 void GraphicsLayerWC::setNeedsDisplayInRect(const WebCore::FloatRect& rect, ShouldClipToLayer)
    69 {
    70     if (!drawsContent())
    71         return;
    72     noteLayerPropertyChanged(WCLayerChange::BackingStore);
     180
     181    m_tiledBacking->setDirtyRect(rect);
     182    noteLayerPropertyChanged(WCLayerChange::Background);
    73183    addRepaintRect(rect);
    74184}
    … …  
    222332        return;
    223333    GraphicsLayer::setBackgroundColor(value);
    224     noteLayerPropertyChanged(WCLayerChange::BackgroundColor);
     334    noteLayerPropertyChanged(WCLayerChange::Background);
    225335}
    226336
    … …  
    254364        return;
    255365    GraphicsLayer::setDrawsContent(value);
    256     noteLayerPropertyChanged(WCLayerChange::BackingStore);
     366    noteLayerPropertyChanged(WCLayerChange::Background);
    257367    updateDebugIndicators();
    258368}
    … …  
    375485}
    376486
    377 void GraphicsLayerWC::noteLayerPropertyChanged(OptionSet<WCLayerChange> flags)
     487void GraphicsLayerWC::noteLayerPropertyChanged(OptionSet<WCLayerChange> flags, ScheduleFlushOrNot scheduleFlush)
    378488{
    379489    if (beingDestroyed())
    … …  
    381491    bool needsFlush = !m_uncommittedChanges;
    382492    m_uncommittedChanges.add(flags);
    383     if (needsFlush)
     493    if (needsFlush && scheduleFlush == ScheduleFlush)
    384494        client().notifyFlushRequired(this);
    385495}
    386496
    387 void GraphicsLayerWC::flushCompositingState(const FloatRect& rect)
    388 {
    389     if (auto* mask = maskLayer())
    390         mask->flushCompositingStateForThisLayerOnly();
    391     if (auto* replica = replicaLayer())
    392         replica->flushCompositingStateForThisLayerOnly();
    393     flushCompositingStateForThisLayerOnly();
    394     for (auto& child : children())
    395         child->flushCompositingState(rect);
     497void GraphicsLayerWC::flushCompositingState(const FloatRect& passedVisibleRect)
     498{
     499    // passedVisibleRect doesn't contain the scrollbar area. Inflate it.
     500    FloatRect visibleRect = passedVisibleRect;
     501    visibleRect.inflate(20.f);
     502    TransformState state(TransformState::UnapplyInverseTransformDirection, FloatQuad(visibleRect));
     503    state.setSecondaryQuad(FloatQuad { visibleRect });
     504    recursiveCommitChanges(state);
    396505}
    397506
    … …  
    438547    if (update.changes & WCLayerChange::MasksToBounds)
    439548        update.masksToBounds = masksToBounds();
    440     if (update.changes & WCLayerChange::BackingStore) {
    441         if (drawsContent() && contentsAreVisible() && !size().isEmpty()) {
    442             auto image = m_observer->createImageBuffer(size());
    443             FloatRect clipRect = { { }, size() };
    444             paintGraphicsLayerContents(image->context(), clipRect);
    445             image->flushDrawingContextAsync();
    446             update.backingStore.setImageBuffer(WTFMove(image));
    447 
    448             incrementRepaintCount();
    449             update.changes.add(WCLayerChange::RepaintCount);
    450         }
     549    if (update.changes & WCLayerChange::Background) {
     550        update.backgroundColor = backgroundColor();
     551        if (drawsContent() && contentsAreVisible()) {
     552            update.hasBackingStore = true;
     553            if (m_tiledBacking->paintAndFlush(update)) {
     554                incrementRepaintCount();
     555                update.changes.add(WCLayerChange::RepaintCount);
     556            }
     557        } else
     558            update.hasBackingStore = false;
    451559    }
    452560    if (update.changes & WCLayerChange::SolidColor)
    … …  
    461569        update.repaintCount = repaintCount();
    462570    }
    463     if (update.changes & WCLayerChange::BackgroundColor)
    464         update.backgroundColor = backgroundColor();
    465571    if (update.changes & WCLayerChange::Opacity)
    466572        update.opacity = opacity();
    … …  
    483589}
    484590
     591TiledBacking* GraphicsLayerWC::tiledBacking() const
     592{
     593    return m_tiledBacking->tiledBacking();
     594}
     595
     596RefPtr<WebCore::ImageBuffer> GraphicsLayerWC::createImageBuffer(WebCore::FloatSize size)
     597{
     598    return m_observer->createImageBuffer(size);
     599}
     600
     601static inline bool accumulatesTransform(const GraphicsLayerWC& layer)
     602{
     603    return !layer.masksToBounds() && (layer.preserves3D() || (layer.parent() && layer.parent()->preserves3D()));
     604}
     605
     606TransformationMatrix GraphicsLayerWC::transformByApplyingAnchorPoint(const TransformationMatrix& matrix) const
     607{
     608    if (matrix.isIdentity())
     609        return matrix;
     610
     611    TransformationMatrix result;
     612    FloatPoint3D absoluteAnchorPoint(anchorPoint());
     613    absoluteAnchorPoint.scale(size().width(), size().height(), 1);
     614    result.translate3d(absoluteAnchorPoint.x(), absoluteAnchorPoint.y(), absoluteAnchorPoint.z());
     615    result.multiply(matrix);
     616    result.translate3d(-absoluteAnchorPoint.x(), -absoluteAnchorPoint.y(), -absoluteAnchorPoint.z());
     617    return result;
     618}
     619
     620TransformationMatrix GraphicsLayerWC::layerTransform(const FloatPoint& position, const TransformationMatrix* customTransform) const
     621{
     622    TransformationMatrix transform;
     623    transform.translate(position.x(), position.y());
     624
     625    TransformationMatrix currentTransform;
     626    if (customTransform)
     627        currentTransform = *customTransform;
     628    else if (m_transform)
     629        currentTransform = *m_transform;
     630
     631    transform.multiply(transformByApplyingAnchorPoint(currentTransform));
     632
     633    if (GraphicsLayer* parentLayer = parent()) {
     634        if (parentLayer->hasNonIdentityChildrenTransform()) {
     635            FloatPoint boundsOrigin = parentLayer->boundsOrigin();
     636
     637            FloatPoint3D parentAnchorPoint(parentLayer->anchorPoint());
     638            parentAnchorPoint.scale(parentLayer->size().width(), parentLayer->size().height(), 1);
     639            parentAnchorPoint += boundsOrigin;
     640
     641            transform.translateRight3d(-parentAnchorPoint.x(), -parentAnchorPoint.y(), -parentAnchorPoint.z());
     642            transform = parentLayer->childrenTransform() * transform;
     643            transform.translateRight3d(parentAnchorPoint.x(), parentAnchorPoint.y(), parentAnchorPoint.z());
     644        }
     645    }
     646
     647    return transform;
     648}
     649
     650GraphicsLayerWC::VisibleAndCoverageRects GraphicsLayerWC::computeVisibleAndCoverageRect(TransformState& state, bool preserves3D) const
     651{
     652    FloatPoint position = approximatePosition();
     653    client().customPositionForVisibleRectComputation(this, position);
     654
     655    TransformationMatrix layerTransform;
     656    TransformationMatrix currentTransform;
     657    if (client().getCurrentTransform(this, currentTransform))
     658        layerTransform = this->layerTransform(position, &currentTransform);
     659    else
     660        layerTransform = this->layerTransform(position);
     661
     662    bool applyWasClamped;
     663    TransformState::TransformAccumulation accumulation = preserves3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform;
     664    state.applyTransform(layerTransform, accumulation, &applyWasClamped);
     665
     666    bool mapWasClamped;
     667    FloatRect clipRectForChildren = state.mappedQuad(&mapWasClamped).boundingBox();
     668    FloatPoint boundsOrigin = m_boundsOrigin;
     669    clipRectForChildren.move(boundsOrigin.x(), boundsOrigin.y());
     670   
     671    FloatRect clipRectForSelf(boundsOrigin, m_size);
     672    if (!applyWasClamped && !mapWasClamped)
     673        clipRectForSelf.intersect(clipRectForChildren);
     674
     675    if (masksToBounds()) {
     676        ASSERT(accumulation == TransformState::FlattenTransform);
     677        // Flatten, and replace the quad in the TransformState with one that is clipped to this layer's bounds.
     678        state.flatten();
     679        state.setQuad(clipRectForSelf);
     680        if (state.isMappingSecondaryQuad())
     681            state.setSecondaryQuad(FloatQuad { clipRectForSelf });
     682    }
     683
     684    FloatRect coverageRect = clipRectForSelf;
     685    auto quad = state.mappedSecondaryQuad(&mapWasClamped);
     686    if (quad && !mapWasClamped && !applyWasClamped)
     687        coverageRect = (*quad).boundingBox();
     688
     689    return { clipRectForSelf, coverageRect, currentTransform };
     690}
     691
     692void GraphicsLayerWC::recursiveCommitChanges(const TransformState& state)
     693{
     694    TransformState localState = state;
     695
     696    bool accumulateTransform = accumulatesTransform(*this);
     697    VisibleAndCoverageRects rects = computeVisibleAndCoverageRect(localState, accumulateTransform);
     698    m_tiledBacking->setCoverageRect(rects.coverageRect);
     699    if (m_tiledBacking->hasDirtyRect())
     700        noteLayerPropertyChanged(WCLayerChange::Background, DontScheduleFlush);
     701
     702    flushCompositingStateForThisLayerOnly();
     703    if (auto* mask = maskLayer())
     704        static_cast<GraphicsLayerWC*>(mask)->recursiveCommitChanges(localState);
     705    if (auto* replica = replicaLayer())
     706        static_cast<GraphicsLayerWC*>(replica)->recursiveCommitChanges(localState);
     707    for (auto& child : children())
     708        static_cast<GraphicsLayerWC*>(child.ptr())->recursiveCommitChanges(localState);
     709}
     710
    485711} // namespace WebKit
  • trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h

    r286943 r287967  
    3030#include <wtf/DoublyLinkedList.h>
    3131
     32namespace WebCore {
     33class TransformState;
     34}
     35
    3236namespace WebKit {
     37class WCTiledBacking;
    3338
    3439class GraphicsLayerWC final : public WebCore::GraphicsLayer, public DoublyLinkedListNode<GraphicsLayerWC> {
    … …  
    8994    void flushCompositingState(const WebCore::FloatRect& clipRect) override;
    9095    void flushCompositingStateForThisLayerOnly() override;
     96    WebCore::TiledBacking* tiledBacking() const override;
    9197
     98protected:
     99    friend WCTiledBacking;
     100
     101    RefPtr<WebCore::ImageBuffer> createImageBuffer(WebCore::FloatSize);
     102   
    92103private:
    93     void noteLayerPropertyChanged(OptionSet<WCLayerChange>);
     104    struct VisibleAndCoverageRects {
     105        WTF_MAKE_STRUCT_FAST_ALLOCATED;
     106        WebCore::FloatRect visibleRect;
     107        WebCore::FloatRect coverageRect;
     108        WebCore::TransformationMatrix animatingTransform;
     109    };
     110
     111    enum ScheduleFlushOrNot { ScheduleFlush, DontScheduleFlush };
     112    void noteLayerPropertyChanged(OptionSet<WCLayerChange>, ScheduleFlushOrNot = ScheduleFlush);
     113    WebCore::TransformationMatrix transformByApplyingAnchorPoint(const WebCore::TransformationMatrix&) const;
     114    WebCore::TransformationMatrix layerTransform(const WebCore::FloatPoint&, const WebCore::TransformationMatrix* = nullptr) const;
     115    VisibleAndCoverageRects computeVisibleAndCoverageRect(WebCore::TransformState&, bool preserves3D) const;
     116    void recursiveCommitChanges(const WebCore::TransformState&);
    94117
    95118    static GraphicsLayer::PlatformLayerID generateLayerID();
    … …  
    101124    WebCore::GraphicsLayer::PlatformLayerID m_layerID { generateLayerID() };
    102125    Observer* m_observer;
     126    std::unique_ptr<WCTiledBacking> m_tiledBacking;
    103127    PlatformLayer* m_platformLayer { nullptr };
    104128    WebCore::Color m_solidColor;
  • trunk/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h

    r287288 r287967  
    5151    ContentsClippingRect    = 1 << 12,
    5252    Opacity                 = 1 << 13,
    53     BackingStore            = 1 << 14,
     53    Background              = 1 << 14,
    5454    Transform               = 1 << 15,
    5555    ChildrenTransform       = 1 << 16,
    … …  
    5757    BackdropFilters         = 1 << 18,
    5858    PlatformLayer           = 1 << 19,
    59     BackgroundColor         = 1 << 20,
    6059};
    6160
    … …  
    7776    bool preserves3D;
    7877    bool hasPlatformLayer;
     78    bool hasBackingStore;
    7979    WebCore::Color solidColor;
    8080    WebCore::Color backgroundColor;
    … …  
    8585    WebCore::FloatRect contentsRect;
    8686    WCBackingStore backingStore;
     87    WebCore::IntRect dirtyRect;
     88    WebCore::IntRect coverageRect;
    8789    WebCore::TransformationMatrix transform;
    8890    WebCore::TransformationMatrix childrenTransform;
    … …  
    124126        if (changes & WCLayerChange::ContentsClippingRect)
    125127            encoder << contentsClippingRect;
    126         if (changes & WCLayerChange::BackgroundColor)
    127             encoder << backgroundColor;
    128128        if (changes & WCLayerChange::Opacity)
    129129            encoder << opacity;
    130         if (changes & WCLayerChange::BackingStore)
    131             encoder << backingStore;
     130        if (changes & WCLayerChange::Background)
     131            encoder << backgroundColor << hasBackingStore << backingStore << dirtyRect << coverageRect;
    132132        if (changes & WCLayerChange::Transform)
    133133            encoder << transform;
    … …  
    213213                return false;
    214214        }
    215         if (result.changes & WCLayerChange::BackgroundColor) {
    216             if (!decoder.decode(result.backgroundColor))
    217                 return false;
    218         }
    219215        if (result.changes & WCLayerChange::Opacity) {
    220216            if (!decoder.decode(result.opacity))
    221217                return false;
    222218        }
    223         if (result.changes & WCLayerChange::BackingStore) {
     219        if (result.changes & WCLayerChange::Background) {
     220            if (!decoder.decode(result.backgroundColor))
     221                return false;
     222            if (!decoder.decode(result.hasBackingStore))
     223                return false;
    224224            if (!decoder.decode(result.backingStore))
     225                return false;
     226            if (!decoder.decode(result.dirtyRect))
     227                return false;
     228            if (!decoder.decode(result.coverageRect))
    225229                return false;
    226230        }
    … …  
    304308        WebKit::WCLayerChange::ContentsClippingRect,
    305309        WebKit::WCLayerChange::Opacity,
    306         WebKit::WCLayerChange::BackingStore,
     310        WebKit::WCLayerChange::Background,
    307311        WebKit::WCLayerChange::Transform,
    308312        WebKit::WCLayerChange::ChildrenTransform,
    309313        WebKit::WCLayerChange::Filters,
    310314        WebKit::WCLayerChange::BackdropFilters,
    311         WebKit::WCLayerChange::PlatformLayer,
    312         WebKit::WCLayerChange::BackgroundColor
     315        WebKit::WCLayerChange::PlatformLayer
    313316    >;
    314317};
Note: See TracChangeset for help on using the changeset viewer.