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

Changeset 286046 in webkit


Ignore:
Timestamp:
Nov 18, 2021, 10:26:43 PM (5 years ago)
Author:
Fujii Hironori
Message:

[TextureMapper][GraphicsLayerTextureMapper][GraphicsLayerWC] setBackgroundColor support
https://bugs.webkit.org/show_bug.cgi?id=233244

Reviewed by Don Olmstead.

Source/WebCore:

TextureMapper, GraphicsLayerTextureMapper and GraphicsLayerWC
didn't support setBackgroundColor. setBackgroundColor is used for
"painting flush" feature of Web Inspector Elements tab.

Added a new class TextureMapperSolidColorLayer to draw a solid
layer for the primary layer and contents layer.

  • platform/TextureMapper.cmake:
  • platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:

(WebCore::GraphicsLayerTextureMapper::setBackgroundColor): Added.
(WebCore::GraphicsLayerTextureMapper::setContentsToSolidColor):
(WebCore::GraphicsLayerTextureMapper::commitLayerChanges):

  • platform/graphics/texmap/GraphicsLayerTextureMapper.h:
  • platform/graphics/texmap/TextureMapperLayer.cpp:

(WebCore::TextureMapperLayer::paintSelf):
(WebCore::TextureMapperLayer::setBackgroundColor):
(WebCore::blendWithOpacity): Deleted.

  • platform/graphics/texmap/TextureMapperLayer.h:
  • platform/graphics/texmap/TextureMapperSolidColorLayer.h: Added.

(WebCore::TextureMapperSolidColorLayer::setColor):

Source/WebKit:

  • GPUProcess/graphics/wc/WCScene.cpp:

(WebKit::WCScene::update):

  • WebProcess/WebPage/wc/GraphicsLayerWC.cpp:

(WebKit::GraphicsLayerWC::setBackgroundColor):
(WebKit::GraphicsLayerWC::flushCompositingStateForThisLayerOnly):

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

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

Location:
trunk/Source
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286044 r286046  
     12021-11-18  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [TextureMapper][GraphicsLayerTextureMapper][GraphicsLayerWC] setBackgroundColor support
     4        https://bugs.webkit.org/show_bug.cgi?id=233244
     5
     6        Reviewed by Don Olmstead.
     7
     8        TextureMapper, GraphicsLayerTextureMapper and GraphicsLayerWC
     9        didn't support setBackgroundColor. setBackgroundColor is used for
     10        "painting flush" feature of Web Inspector Elements tab.
     11
     12        Added a new class TextureMapperSolidColorLayer to draw a solid
     13        layer for the primary layer and contents layer.
     14
     15        * platform/TextureMapper.cmake:
     16        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
     17        (WebCore::GraphicsLayerTextureMapper::setBackgroundColor): Added.
     18        (WebCore::GraphicsLayerTextureMapper::setContentsToSolidColor):
     19        (WebCore::GraphicsLayerTextureMapper::commitLayerChanges):
     20        * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
     21        * platform/graphics/texmap/TextureMapperLayer.cpp:
     22        (WebCore::TextureMapperLayer::paintSelf):
     23        (WebCore::TextureMapperLayer::setBackgroundColor):
     24        (WebCore::blendWithOpacity): Deleted.
     25        * platform/graphics/texmap/TextureMapperLayer.h:
     26        * platform/graphics/texmap/TextureMapperSolidColorLayer.h: Added.
     27        (WebCore::TextureMapperSolidColorLayer::setColor):
     28
    1292021-11-18  Ben Nham  <nham@apple.com>
    230
  • trunk/Source/WebCore/platform/TextureMapper.cmake

    r284920 r286046  
    3636    platform/graphics/texmap/TextureMapperPlatformLayerProxy.h
    3737    platform/graphics/texmap/TextureMapperPlatformLayerProxyProvider.h
     38    platform/graphics/texmap/TextureMapperSolidColorLayer.h
    3839    platform/graphics/texmap/TextureMapperTile.h
    3940    platform/graphics/texmap/TextureMapperTiledBackingStore.h
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp

    r270071 r286046  
    256256}
    257257
     258void GraphicsLayerTextureMapper::setBackgroundColor(const Color& value)
     259{
     260    if (value == backgroundColor())
     261        return;
     262    GraphicsLayer::setBackgroundColor(value);
     263    notifyChange(BackgroundColorChange);
     264}
     265
    258266void GraphicsLayerTextureMapper::setOpacity(float value)
    259267{
     
    287295
    288296    m_solidColor = color;
    289     notifyChange(BackgroundColorChange);
     297    notifyChange(SolidColorChange);
    290298}
    291299
     
    476484        m_layer.setBackfaceVisibility(backfaceVisibility());
    477485
     486    if (m_changeMask & BackgroundColorChange)
     487        m_layer.setBackgroundColor(backgroundColor());
     488
    478489    if (m_changeMask & OpacityChange)
    479490        m_layer.setOpacity(opacity());
    480491
    481     if (m_changeMask & BackgroundColorChange)
     492    if (m_changeMask & SolidColorChange)
    482493        m_layer.setSolidColor(m_solidColor);
    483494
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h

    r270071 r286046  
    6060    void setContentsOpaque(bool) override;
    6161    void setBackfaceVisibility(bool) override;
     62    void setBackgroundColor(const Color&) override;
    6263    void setOpacity(float) override;
    6364    bool setFilters(const FilterOperations&) override;
     
    150151        AnimationStarted =          (1L << 26),
    151152        BackdropLayerChange =       (1L << 27),
     153        SolidColorChange =          (1L << 28),
    152154    };
    153155    void notifyChange(ChangeMask);
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

    r284093 r286046  
    145145}
    146146
    147 static Color blendWithOpacity(const Color& color, float opacity)
    148 {
    149     if (color.isOpaque() && opacity == 1.)
    150         return color;
    151 
    152     return color.colorWithAlphaMultipliedBy(opacity);
    153 }
    154 
    155147void TextureMapperLayer::paintSelf(TextureMapperPaintOptions& options)
    156148{
    157149    if (!m_state.visible || !m_state.contentsVisible)
     150        return;
     151    auto targetRect = layerRect();
     152    if (targetRect.isEmpty())
    158153        return;
    159154
     
    164159    transform.multiply(m_layerTransforms.combined);
    165160
    166     if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty() && m_state.solidColor.isVisible()) {
    167         options.textureMapper.drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, options.opacity), true);
    168         if (m_state.showDebugBorders)
    169             options.textureMapper.drawBorder(m_state.debugBorderColor, m_state.debugBorderWidth, layerRect(), transform);
    170         return;
     161    TextureMapperSolidColorLayer solidColorLayer;
     162    TextureMapperBackingStore* backingStore = m_backingStore;
     163    if (m_state.backgroundColor.isValid()) {
     164        solidColorLayer.setColor(m_state.backgroundColor);
     165        backingStore = &solidColorLayer;
    171166    }
    172167
     
    174169    options.textureMapper.setPatternTransform(TransformationMatrix());
    175170
    176     if (m_backingStore) {
    177         FloatRect targetRect = layerRect();
    178         ASSERT(!targetRect.isEmpty());
    179         m_backingStore->paintToTextureMapper(options.textureMapper, targetRect, transform, options.opacity);
     171    if (backingStore) {
     172        backingStore->paintToTextureMapper(options.textureMapper, targetRect, transform, options.opacity);
    180173        if (m_state.showDebugBorders)
    181             m_backingStore->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, targetRect, transform);
     174            backingStore->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, targetRect, transform);
    182175        // Only draw repaint count for the main backing store.
    183176        if (m_state.showRepaintCounter)
    184             m_backingStore->drawRepaintCounter(options.textureMapper, m_state.repaintCount, m_state.debugBorderColor, targetRect, transform);
    185     }
    186 
    187     if (!m_contentsLayer)
     177            backingStore->drawRepaintCounter(options.textureMapper, m_state.repaintCount, m_state.debugBorderColor, targetRect, transform);
     178    }
     179
     180    TextureMapperPlatformLayer* contentsLayer = m_contentsLayer;
     181    if (m_state.solidColor.isValid() && m_state.solidColor.isVisible()) {
     182        solidColorLayer.setColor(m_state.solidColor);
     183        contentsLayer = &solidColorLayer;
     184    }
     185    if (!contentsLayer)
    188186        return;
    189187
     
    196194    }
    197195
    198     ASSERT(!layerRect().isEmpty());
    199 
    200196    bool shouldClip = m_state.contentsClippingRect.isRounded() || !m_state.contentsClippingRect.rect().contains(m_state.contentsRect);
    201197    if (shouldClip) {
     
    203199    }
    204200
    205     m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, options.opacity);
     201    contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, options.opacity);
    206202
    207203    if (shouldClip)
     
    209205
    210206    if (m_state.showDebugBorders)
    211         m_contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform);
     207        contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform);
    212208}
    213209
     
    680676}
    681677
     678void TextureMapperLayer::setBackgroundColor(const Color& color)
     679{
     680    m_state.backgroundColor = color;
     681}
     682
    682683void TextureMapperLayer::setFilters(const FilterOperations& filters)
    683684{
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h

    r270698 r286046  
    2424#include "NicosiaAnimation.h"
    2525#include "TextureMapper.h"
    26 #include "TextureMapperBackingStore.h"
     26#include "TextureMapperSolidColorLayer.h"
    2727#include <wtf/WeakPtr.h>
    2828
     
    7878    void setOpacity(float);
    7979    void setSolidColor(const Color&);
     80    void setBackgroundColor(const Color&);
    8081    void setContentsTileSize(const FloatSize&);
    8182    void setContentsTilePhase(const FloatSize&);
     
    179180        FloatRoundedRect backdropFiltersRect;
    180181        Color solidColor;
     182        Color backgroundColor;
    181183        FilterOperations filters;
    182184        Color debugBorderColor;
  • trunk/Source/WebKit/ChangeLog

    r286041 r286046  
     12021-11-18  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [TextureMapper][GraphicsLayerTextureMapper][GraphicsLayerWC] setBackgroundColor support
     4        https://bugs.webkit.org/show_bug.cgi?id=233244
     5
     6        Reviewed by Don Olmstead.
     7
     8        * GPUProcess/graphics/wc/WCScene.cpp:
     9        (WebKit::WCScene::update):
     10        * WebProcess/WebPage/wc/GraphicsLayerWC.cpp:
     11        (WebKit::GraphicsLayerWC::setBackgroundColor):
     12        (WebKit::GraphicsLayerWC::flushCompositingStateForThisLayerOnly):
     13        * WebProcess/WebPage/wc/GraphicsLayerWC.h:
     14        * WebProcess/WebPage/wc/WCUpateInfo.h:
     15        (WebKit::WCLayerUpateInfo::encode const):
     16        (WebKit::WCLayerUpateInfo::decode):
     17
    1182021-11-18  Alex Christensen  <achristensen@webkit.org>
    219
  • trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp

    r285099 r286046  
    138138        if (layerUpdate.changes & WCLayerChange::RepaintCount)
    139139            layer->texmapLayer.setRepaintCounter(layerUpdate.showRepaintCounter, layerUpdate.repaintCount);
     140        if (layerUpdate.changes & WCLayerChange::BackgroundColor)
     141            layer->texmapLayer.setBackgroundColor(layerUpdate.backgroundColor);
    140142        if (layerUpdate.changes & WCLayerChange::Opacity)
    141143            layer->texmapLayer.setOpacity(layerUpdate.opacity);
  • trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp

    r285798 r286046  
    217217}
    218218
     219void GraphicsLayerWC::setBackgroundColor(const WebCore::Color& value)
     220{
     221    if (value == backgroundColor())
     222        return;
     223    GraphicsLayer::setBackgroundColor(value);
     224    noteLayerPropertyChanged(WCLayerChange::BackgroundColor);
     225}
     226
    219227void GraphicsLayerWC::setOpacity(float value)
    220228{
     
    447455        update.repaintCount = repaintCount();
    448456    }
     457    if (update.changes & WCLayerChange::BackgroundColor)
     458        update.backgroundColor = backgroundColor();
    449459    if (update.changes & WCLayerChange::Opacity)
    450460        update.opacity = opacity();
  • trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h

    r285099 r286046  
    6868    void setPreserves3D(bool) override;
    6969    void setMasksToBounds(bool) override;
     70    void setBackgroundColor(const WebCore::Color&) override;
    7071    void setOpacity(float) override;
    7172    void setContentsRect(const WebCore::FloatRect&) override;
  • trunk/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h

    r285099 r286046  
    5656    BackdropFilters         = 1 << 18,
    5757    PlatformLayer           = 1 << 19,
     58    BackgroundColor         = 1 << 20,
    5859};
    5960
     
    7576    bool preserves3D;
    7677    WebCore::Color solidColor;
     78    WebCore::Color backgroundColor;
    7779    WebCore::Color debugBorderColor;
    7880    float opacity;
     
    120122        if (changes & WCLayerChange::ContentsClippingRect)
    121123            encoder << contentsClippingRect;
     124        if (changes & WCLayerChange::BackgroundColor)
     125            encoder << backgroundColor;
    122126        if (changes & WCLayerChange::Opacity)
    123127            encoder << opacity;
     
    205209        if (result.changes & WCLayerChange::ContentsClippingRect) {
    206210            if (!decoder.decode(result.contentsClippingRect))
     211                return false;
     212        }
     213        if (result.changes & WCLayerChange::BackgroundColor) {
     214            if (!decoder.decode(result.backgroundColor))
    207215                return false;
    208216        }
     
    297305        WebKit::WCLayerChange::Filters,
    298306        WebKit::WCLayerChange::BackdropFilters,
    299         WebKit::WCLayerChange::PlatformLayer
     307        WebKit::WCLayerChange::PlatformLayer,
     308        WebKit::WCLayerChange::BackgroundColor
    300309    >;
    301310};
Note: See TracChangeset for help on using the changeset viewer.