Changeset 269936 in webkit


Ignore:
Timestamp:
Nov 17, 2020 4:49:46 PM (3 years ago)
Author:
Fujii Hironori
Message:

Use SetForScope to temporarily change members of TextureMapperPaintOptions instead of copying all members
https://bugs.webkit.org/show_bug.cgi?id=219022

Reviewed by Carlos Garcia Campos.

All members of TextureMapperPaintOptions don't need to be copied
just to change some members. Use WTF::SetForScope to temporarily
change members of TextureMapperPaintOptions.

No behavior changes.

  • platform/graphics/texmap/TextureMapperLayer.cpp:

(WebCore::TextureMapperLayer::paintSelf):
(WebCore::TextureMapperLayer::paintSelfAndChildren):
(WebCore::TextureMapperLayer::paintSelfAndChildrenWithReplica):
(WebCore::TextureMapperLayer::paintUsingOverlapRegions):
(WebCore::TextureMapperLayer::applyMask):
(WebCore::TextureMapperLayer::paintIntoSurface):
(WebCore::commitSurface):
(WebCore::TextureMapperLayer::paintWithIntermediateSurface):
(WebCore::TextureMapperLayer::paintRecursive):

  • platform/graphics/texmap/TextureMapperLayer.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r269932 r269936  
     12020-11-17  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        Use SetForScope to temporarily change members of TextureMapperPaintOptions instead of copying all members
     4        https://bugs.webkit.org/show_bug.cgi?id=219022
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        All members of TextureMapperPaintOptions don't need to be copied
     9        just to change some members. Use WTF::SetForScope to temporarily
     10        change members of TextureMapperPaintOptions.
     11
     12        No behavior changes.
     13
     14        * platform/graphics/texmap/TextureMapperLayer.cpp:
     15        (WebCore::TextureMapperLayer::paintSelf):
     16        (WebCore::TextureMapperLayer::paintSelfAndChildren):
     17        (WebCore::TextureMapperLayer::paintSelfAndChildrenWithReplica):
     18        (WebCore::TextureMapperLayer::paintUsingOverlapRegions):
     19        (WebCore::TextureMapperLayer::applyMask):
     20        (WebCore::TextureMapperLayer::paintIntoSurface):
     21        (WebCore::commitSurface):
     22        (WebCore::TextureMapperLayer::paintWithIntermediateSurface):
     23        (WebCore::TextureMapperLayer::paintRecursive):
     24        * platform/graphics/texmap/TextureMapperLayer.h:
     25
    1262020-11-17  Megan Gardner  <megan_gardner@apple.com>
    227
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

    r269837 r269936  
    2525#include "Region.h"
    2626#include <wtf/MathExtras.h>
     27#include <wtf/SetForScope.h>
    2728
    2829namespace WebCore {
     
    152153}
    153154
    154 void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
     155void TextureMapperLayer::paintSelf(TextureMapperPaintOptions& options)
    155156{
    156157    if (!m_state.visible || !m_state.contentsVisible)
     
    219220}
    220221
    221 void TextureMapperLayer::paintSelfAndChildren(const TextureMapperPaintOptions& options)
     222void TextureMapperLayer::paintSelfAndChildren(TextureMapperPaintOptions& options)
    222223{
    223224    if (m_state.backdropLayer && m_state.backdropLayer == options.backdropLayer)
     
    295296}
    296297
    297 void TextureMapperLayer::paintSelfAndChildrenWithReplica(const TextureMapperPaintOptions& options)
     298void TextureMapperLayer::paintSelfAndChildrenWithReplica(TextureMapperPaintOptions& options)
    298299{
    299300    if (m_state.replicaLayer) {
    300         TextureMapperPaintOptions replicaOptions(options);
    301         replicaOptions.transform.multiply(replicaTransform());
    302         paintSelfAndChildren(replicaOptions);
     301        SetForScope<TransformationMatrix> scopedTransform(options.transform, options.transform);
     302        options.transform.multiply(replicaTransform());
     303        paintSelfAndChildren(options);
    303304    }
    304305
     
    368369}
    369370
    370 void TextureMapperLayer::paintUsingOverlapRegions(const TextureMapperPaintOptions& options)
     371void TextureMapperLayer::paintUsingOverlapRegions(TextureMapperPaintOptions& options)
    371372{
    372373    Region overlapRegion;
     
    422423}
    423424
    424 void TextureMapperLayer::applyMask(const TextureMapperPaintOptions& options)
     425void TextureMapperLayer::applyMask(TextureMapperPaintOptions& options)
    425426{
    426427    options.textureMapper.setMaskMode(true);
     
    433434    options.textureMapper.bindSurface(options.surface.get());
    434435    if (m_isBackdrop) {
    435         TextureMapperPaintOptions paintOptions(options);
    436         paintOptions.transform = TransformationMatrix();
    437         paintOptions.backdropLayer = this;
    438         rootLayer().paintSelfAndChildren(paintOptions);
     436        SetForScope<TransformationMatrix> scopedTransform(options.transform, TransformationMatrix());
     437        SetForScope<TextureMapperLayer*> scopedBackdropLayer(options.backdropLayer, this);
     438        rootLayer().paintSelfAndChildren(options);
    439439    } else
    440440        paintSelfAndChildren(options);
     
    445445}
    446446
    447 static void commitSurface(const TextureMapperPaintOptions& options, BitmapTexture& surface, const IntRect& rect, float opacity)
     447static void commitSurface(TextureMapperPaintOptions& options, BitmapTexture& surface, const IntRect& rect, float opacity)
    448448{
    449449    IntRect targetRect(rect);
     
    453453}
    454454
    455 void TextureMapperLayer::paintWithIntermediateSurface(const TextureMapperPaintOptions& options, const IntRect& rect)
    456 {
    457     TextureMapperPaintOptions paintOptions(options);
    458     paintOptions.surface = options.textureMapper.acquireTextureFromPool(rect.size(), BitmapTexture::SupportsAlpha);
    459     paintOptions.offset = -toIntSize(rect.location());
    460     paintOptions.opacity = 1;
    461     if (m_state.replicaLayer) {
    462         paintOptions.transform.multiply(replicaTransform());
    463         paintIntoSurface(paintOptions);
    464         paintOptions.transform = options.transform;
    465         if (m_state.replicaLayer->m_state.maskLayer)
    466             m_state.replicaLayer->m_state.maskLayer->applyMask(paintOptions);
    467     }
    468 
    469     paintIntoSurface(paintOptions);
    470 
    471     commitSurface(options, *paintOptions.surface, rect, options.opacity);
    472 }
    473 
    474 void TextureMapperLayer::paintRecursive(const TextureMapperPaintOptions& options)
     455void TextureMapperLayer::paintWithIntermediateSurface(TextureMapperPaintOptions& options, const IntRect& rect)
     456{
     457    auto surface = options.textureMapper.acquireTextureFromPool(rect.size(), BitmapTexture::SupportsAlpha);
     458    {
     459        SetForScope<RefPtr<BitmapTexture>> scopedSurface(options.surface, surface);
     460        SetForScope<IntSize> scopedOffset(options.offset, -toIntSize(rect.location()));
     461        SetForScope<float> scopedOpacity(options.opacity, 1);
     462        if (m_state.replicaLayer) {
     463            {
     464                SetForScope<TransformationMatrix> scopedTransform(options.transform, options.transform);
     465                options.transform.multiply(replicaTransform());
     466                paintIntoSurface(options);
     467            }
     468            if (m_state.replicaLayer->m_state.maskLayer)
     469                m_state.replicaLayer->m_state.maskLayer->applyMask(options);
     470        }
     471
     472        paintIntoSurface(options);
     473        surface = options.surface;
     474    }
     475
     476    commitSurface(options, *surface, rect, options.opacity);
     477}
     478
     479void TextureMapperLayer::paintRecursive(TextureMapperPaintOptions& options)
    475480{
    476481    if (!isVisible())
    477482        return;
    478483
    479     TextureMapperPaintOptions paintOptions(options);
    480     paintOptions.opacity *= m_currentOpacity;
     484    SetForScope<float> scopedOpacity(options.opacity, options.opacity * m_currentOpacity);
    481485
    482486    if (!shouldBlend()) {
    483         paintSelfAndChildrenWithReplica(paintOptions);
    484         return;
    485     }
    486 
    487     paintUsingOverlapRegions(paintOptions);
     487        paintSelfAndChildrenWithReplica(options);
     488        return;
     489    }
     490
     491    paintUsingOverlapRegions(options);
    488492}
    489493
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h

    r269772 r269936  
    137137    void computeOverlapRegions(ComputeOverlapRegionData&, const TransformationMatrix&, bool includesReplica = true);
    138138
    139     void paintRecursive(const TextureMapperPaintOptions&);
    140     void paintUsingOverlapRegions(const TextureMapperPaintOptions&);
     139    void paintRecursive(TextureMapperPaintOptions&);
     140    void paintUsingOverlapRegions(TextureMapperPaintOptions&);
    141141    void paintIntoSurface(TextureMapperPaintOptions&);
    142     void paintWithIntermediateSurface(const TextureMapperPaintOptions&, const IntRect&);
    143     void paintSelf(const TextureMapperPaintOptions&);
    144     void paintSelfAndChildren(const TextureMapperPaintOptions&);
    145     void paintSelfAndChildrenWithReplica(const TextureMapperPaintOptions&);
    146     void applyMask(const TextureMapperPaintOptions&);
     142    void paintWithIntermediateSurface(TextureMapperPaintOptions&, const IntRect&);
     143    void paintSelf(TextureMapperPaintOptions&);
     144    void paintSelfAndChildren(TextureMapperPaintOptions&);
     145    void paintSelfAndChildrenWithReplica(TextureMapperPaintOptions&);
     146    void applyMask(TextureMapperPaintOptions&);
    147147
    148148    bool isVisible() const;
Note: See TracChangeset for help on using the changeset viewer.