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

Changeset 271472 in webkit


Ignore:
Timestamp:
Jan 13, 2021, 4:07:24 PM (6 years ago)
Author:
Said Abou-Hallawa
Message:

Move the space transform outside the Gradient class
https://bugs.webkit.org/show_bug.cgi?id=220079

Reviewed by Simon Fraser.

Move the SpaceTransform from the Gradient class to the GraphicsContextState.
The client will set it when calling GraphicsContext::setFillGradient()
and GraphicsContext::setFillGradient().

  • platform/graphics/Gradient.cpp:

(WebCore::Gradient::hash const):
(WebCore::Gradient::setGradientSpaceTransform): Deleted.

  • platform/graphics/Gradient.h:

(WebCore::Gradient::encode const):
(WebCore::Gradient::decode):
(WebCore::Gradient::gradientSpaceTransform const): Deleted.

  • platform/graphics/GradientImage.h:

Need to initialize m_cachedGeneratorHash.

  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContextStateChange::apply const):
(WebCore::GraphicsContext::setStrokeGradient):
(WebCore::GraphicsContext::setFillGradient):

  • platform/graphics/GraphicsContext.h:

(WebCore::GraphicsContext::setStrokeGradient):
(WebCore::GraphicsContext::setFillGradient):
Clients of GraphicsContext have to send the Gradient and SpaceTransform
to setStrokeGradient() and setFillGradient().

  • platform/graphics/cairo/CairoOperations.cpp:

(WebCore::Cairo::FillSource::FillSource):
(WebCore::Cairo::StrokeSource::StrokeSource):

  • platform/graphics/cairo/GradientCairo.cpp:

(WebCore::Gradient::createPattern):
(WebCore::Gradient::fill):

  • platform/graphics/cairo/GraphicsContextImplCairo.cpp:

(WebCore::GraphicsContextImplCairo::fillRect):
For Cairo ports, Gradient::createPattern() will take SpaceTransform as
a new argument. Clients will get it from the GraphicsContextState since
the Gradient and the SpaceTransform are set in it in the same call.

  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::strokeRect):

  • platform/graphics/displaylists/DisplayListDrawGlyphsRecorder.h:
  • platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp:

(WebCore::DisplayList::DrawGlyphsRecorder::populateInternalState):
(WebCore::DisplayList::DrawGlyphsRecorder::populateInternalContext):

  • platform/graphics/displaylists/DisplayListItems.cpp:

(WebCore::DisplayList::SetInlineFillGradient::SetInlineFillGradient):
(WebCore::DisplayList::SetInlineFillGradient::gradient const):
(WebCore::DisplayList::SetInlineFillGradient::apply const):

  • platform/graphics/displaylists/DisplayListItems.h:
  • platform/graphics/displaylists/DisplayListRecorder.cpp:

(WebCore::DisplayList::Recorder::appendStateChangeItem):

  • platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp:

(Nicosia::CairoOperationRecorder::fillRect):

  • rendering/svg/RenderSVGPath.cpp:

(WebCore::useStrokeStyleToFill):

  • rendering/svg/RenderSVGResourceGradient.cpp:

(WebCore::RenderSVGResourceGradient::applyResource):
(WebCore::RenderSVGResourceGradient::postApplyResource):
userspaceTransform is calculated inside the lambda of m_gradientMap.ensure().
It is stored in GradientData. It is retrieved later to setStrokeGradient()
and setFillGradient().

Location:
trunk/Source/WebCore
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r271471 r271472  
     12021-01-13  Said Abou-Hallawa  <said@apple.com>
     2
     3        Move the space transform outside the Gradient class
     4        https://bugs.webkit.org/show_bug.cgi?id=220079
     5
     6        Reviewed by Simon Fraser.
     7
     8        Move the SpaceTransform from the Gradient class to the GraphicsContextState.
     9        The client will set it when calling GraphicsContext::setFillGradient()
     10        and GraphicsContext::setFillGradient().
     11
     12        * platform/graphics/Gradient.cpp:
     13        (WebCore::Gradient::hash const):
     14        (WebCore::Gradient::setGradientSpaceTransform): Deleted.
     15        * platform/graphics/Gradient.h:
     16        (WebCore::Gradient::encode const):
     17        (WebCore::Gradient::decode):
     18        (WebCore::Gradient::gradientSpaceTransform const): Deleted.
     19        * platform/graphics/GradientImage.h:
     20        Need to initialize m_cachedGeneratorHash.
     21
     22        * platform/graphics/GraphicsContext.cpp:
     23        (WebCore::GraphicsContextStateChange::apply const):
     24        (WebCore::GraphicsContext::setStrokeGradient):
     25        (WebCore::GraphicsContext::setFillGradient):
     26        * platform/graphics/GraphicsContext.h:
     27        (WebCore::GraphicsContext::setStrokeGradient):
     28        (WebCore::GraphicsContext::setFillGradient):
     29        Clients of GraphicsContext have to send the Gradient and SpaceTransform
     30        to setStrokeGradient() and setFillGradient().
     31
     32        * platform/graphics/cairo/CairoOperations.cpp:
     33        (WebCore::Cairo::FillSource::FillSource):
     34        (WebCore::Cairo::StrokeSource::StrokeSource):
     35        * platform/graphics/cairo/GradientCairo.cpp:
     36        (WebCore::Gradient::createPattern):
     37        (WebCore::Gradient::fill):
     38        * platform/graphics/cairo/GraphicsContextImplCairo.cpp:
     39        (WebCore::GraphicsContextImplCairo::fillRect):
     40        For Cairo ports, Gradient::createPattern() will take SpaceTransform as
     41        a new argument. Clients will get it from the GraphicsContextState since
     42        the Gradient and the SpaceTransform are set in it in the same call.
     43
     44        * platform/graphics/cg/GraphicsContextCG.cpp:
     45        (WebCore::GraphicsContext::fillPath):
     46        (WebCore::GraphicsContext::strokePath):
     47        (WebCore::GraphicsContext::fillRect):
     48        (WebCore::GraphicsContext::strokeRect):
     49        * platform/graphics/displaylists/DisplayListDrawGlyphsRecorder.h:
     50        * platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp:
     51        (WebCore::DisplayList::DrawGlyphsRecorder::populateInternalState):
     52        (WebCore::DisplayList::DrawGlyphsRecorder::populateInternalContext):
     53        * platform/graphics/displaylists/DisplayListItems.cpp:
     54        (WebCore::DisplayList::SetInlineFillGradient::SetInlineFillGradient):
     55        (WebCore::DisplayList::SetInlineFillGradient::gradient const):
     56        (WebCore::DisplayList::SetInlineFillGradient::apply const):
     57        * platform/graphics/displaylists/DisplayListItems.h:
     58        * platform/graphics/displaylists/DisplayListRecorder.cpp:
     59        (WebCore::DisplayList::Recorder::appendStateChangeItem):
     60        * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp:
     61        (Nicosia::CairoOperationRecorder::fillRect):
     62        * rendering/svg/RenderSVGPath.cpp:
     63        (WebCore::useStrokeStyleToFill):
     64
     65        * rendering/svg/RenderSVGResourceGradient.cpp:
     66        (WebCore::RenderSVGResourceGradient::applyResource):
     67        (WebCore::RenderSVGResourceGradient::postApplyResource):
     68        userspaceTransform is calculated inside the lambda of m_gradientMap.ensure().
     69        It is stored in GradientData. It is retrieved later to setStrokeGradient()
     70        and setFillGradient().
     71
    1722021-01-13  Jer Noble  <jer.noble@apple.com>
    273
  • trunk/Source/WebCore/platform/graphics/Gradient.cpp

    r264280 r271472  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
    44 *
     
    4646{
    4747}
    48 
    49 Gradient::~Gradient() = default;
    5048
    5149void Gradient::adjustParametersForTiledDrawing(FloatSize& size, FloatRect& srcRect, const FloatSize& spacing)
     
    128126}
    129127
    130 void Gradient::setGradientSpaceTransform(const AffineTransform& gradientSpaceTransformation)
    131 {
    132     if (m_gradientSpaceTransformation == gradientSpaceTransformation)
    133         return;
    134     m_gradientSpaceTransformation = gradientSpaceTransformation;
    135     m_cachedHash = 0;
    136 }
    137 
    138128// FIXME: Instead of these add(Hasher) functions, consider using encode functions to compute the hash.
    139129
     
    147137{
    148138    add(hasher, point.x(), point.y());
    149 }
    150 
    151 static void add(Hasher& hasher, const AffineTransform& transform)
    152 {
    153     add(hasher, transform.a(), transform.b(), transform.c(), transform.d(), transform.e(), transform.f());
    154139}
    155140
     
    178163    if (!m_cachedHash) {
    179164        sortStops();
    180         m_cachedHash = computeHash(m_data, m_spreadMethod, m_gradientSpaceTransformation, m_stops);
     165        m_cachedHash = computeHash(m_data, m_spreadMethod, m_stops);
    181166    }
    182167    return m_cachedHash;
  • trunk/Source/WebCore/platform/graphics/Gradient.h

    r264510 r271472  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2011, 2012, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
    44 * Copyright (C) 2008 Torch Mobile, Inc.
     
    105105    WEBCORE_EXPORT static Ref<Gradient> create(Data&&);
    106106
    107     WEBCORE_EXPORT ~Gradient();
    108 
    109107    bool isZeroSize() const;
    110108
     
    119117    GradientSpreadMethod spreadMethod() const { return m_spreadMethod; }
    120118
    121     WEBCORE_EXPORT void setGradientSpaceTransform(const AffineTransform& gradientSpaceTransformation);
    122     const AffineTransform& gradientSpaceTransform() const { return m_gradientSpaceTransformation; }
    123 
    124119    void fill(GraphicsContext&, const FloatRect&);
    125120    void adjustParametersForTiledDrawing(FloatSize&, FloatRect&, const FloatSize& spacing);
     
    128123
    129124#if USE(CAIRO)
    130     RefPtr<cairo_pattern_t> createPattern(float globalAlpha);
     125    RefPtr<cairo_pattern_t> createPattern(float globalAlpha, const AffineTransform&);
    131126#endif
    132127
     
    158153    GradientSpreadMethod m_spreadMethod { GradientSpreadMethod::Pad };
    159154    mutable unsigned m_cachedHash { 0 };
    160     AffineTransform m_gradientSpaceTransformation;
    161155
    162156#if USE(CG)
     
    277271    encoder << m_stopsSorted;
    278272    encoder << m_spreadMethod;
    279     encoder << m_gradientSpaceTransformation;
    280273}
    281274
     
    308301    gradient->setSpreadMethod(spreadMethod);
    309302
    310     Optional<AffineTransform> gradientSpaceTransformation;
    311     decoder >> gradientSpaceTransformation;
    312     if (!gradientSpaceTransformation)
    313         return WTF::nullopt;
    314     gradient->setGradientSpaceTransform(WTFMove(*gradientSpaceTransformation));
    315 
    316303    return gradient;
    317304}
  • trunk/Source/WebCore/platform/graphics/GradientImage.h

    r249217 r271472  
    5555    RefPtr<Image> m_cachedImage;
    5656    FloatSize m_cachedAdjustedSize;
    57     unsigned m_cachedGeneratorHash;
     57    unsigned m_cachedGeneratorHash { 0 };
    5858    FloatSize m_cachedScaleFactor;
    5959};
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r271295 r271472  
    212212{
    213213    if (m_changeFlags.contains(GraphicsContextState::StrokeGradientChange))
    214         context.setStrokeGradient(*m_state.strokeGradient);
     214        context.setStrokeGradient(*m_state.strokeGradient, m_state.strokeGradientSpaceTransform);
    215215
    216216    if (m_changeFlags.contains(GraphicsContextState::StrokePatternChange))
     
    218218
    219219    if (m_changeFlags.contains(GraphicsContextState::FillGradientChange))
    220         context.setFillGradient(*m_state.fillGradient);
     220        context.setFillGradient(*m_state.fillGradient, m_state.fillGradientSpaceTransform);
    221221
    222222    if (m_changeFlags.contains(GraphicsContextState::FillPatternChange))
     
    621621}
    622622
    623 void GraphicsContext::setStrokeGradient(Ref<Gradient>&& gradient)
     623void GraphicsContext::setStrokeGradient(Ref<Gradient>&& gradient, const AffineTransform& strokeGradientSpaceTransform)
    624624{
    625625    m_state.strokeColor = { };
    626626    m_state.strokeGradient = WTFMove(gradient);
     627    m_state.strokeGradientSpaceTransform = strokeGradientSpaceTransform;
    627628    m_state.strokePattern = nullptr;
    628629    if (m_impl)
     
    637638}
    638639
    639 void GraphicsContext::setFillGradient(Ref<Gradient>&& gradient)
     640void GraphicsContext::setFillGradient(Ref<Gradient>&& gradient, const AffineTransform& fillGradientSpaceTransform)
    640641{
    641642    m_state.fillColor = { };
    642643    m_state.fillGradient = WTFMove(gradient);
     644    m_state.fillGradientSpaceTransform = fillGradientSpaceTransform;
    643645    m_state.fillPattern = nullptr;
    644646    if (m_impl)
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r270221 r271472  
    213213    Color shadowColor;
    214214
     215    AffineTransform strokeGradientSpaceTransform;
     216    AffineTransform fillGradientSpaceTransform;
     217   
    215218    StrokeStyle strokeStyle { SolidStroke };
    216219    WindRule fillRule { WindRule::NonZero };
     
    304307    Pattern* strokePattern() const { return m_state.strokePattern.get(); }
    305308
    306     void setStrokeGradient(Ref<Gradient>&&);
     309    void setStrokeGradient(Ref<Gradient>&&, const AffineTransform& = { });
    307310    Gradient* strokeGradient() const { return m_state.strokeGradient.get(); }
    308311
     
    316319    Pattern* fillPattern() const { return m_state.fillPattern.get(); }
    317320
    318     WEBCORE_EXPORT void setFillGradient(Ref<Gradient>&&);
     321    WEBCORE_EXPORT void setFillGradient(Ref<Gradient>&&, const AffineTransform& = { });
    319322    Gradient* fillGradient() const { return m_state.fillGradient.get(); }
    320323
  • trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp

    r269614 r271472  
    573573        pattern.repeatY = state.fillPattern->repeatY();
    574574    } else if (state.fillGradient) {
    575         gradient.base = state.fillGradient->createPattern(1);
     575        gradient.base = state.fillGradient->createPattern(1, state.fillGradientSpaceTransform);
    576576        if (state.alpha != 1)
    577             gradient.alphaAdjusted = state.fillGradient->createPattern(state.alpha);
     577            gradient.alphaAdjusted = state.fillGradient->createPattern(state.alpha, state.fillGradientSpaceTransform);
    578578    } else
    579579        color = state.fillColor;
     
    586586        pattern = adoptRef(state.strokePattern->createPlatformPattern(AffineTransform()));
    587587    else if (state.strokeGradient) {
    588         gradient.base = state.strokeGradient->createPattern(1);
     588        gradient.base = state.strokeGradient->createPattern(1, state.strokeGradientSpaceTransform);
    589589        if (state.alpha != 1)
    590             gradient.alphaAdjusted = state.strokeGradient->createPattern(state.alpha);
     590            gradient.alphaAdjusted = state.strokeGradient->createPattern(state.alpha, state.strokeGradientSpaceTransform);
    591591    } else
    592592        color = state.strokeColor;
  • trunk/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp

    r264449 r271472  
    159159}
    160160
    161 RefPtr<cairo_pattern_t> Gradient::createPattern(float globalAlpha)
     161RefPtr<cairo_pattern_t> Gradient::createPattern(float globalAlpha, const AffineTransform& gradientSpaceTransform)
    162162{
    163163    auto gradient = WTF::switchOn(m_data,
     
    196196    }
    197197
    198     cairo_matrix_t matrix = toCairoMatrix(m_gradientSpaceTransformation);
     198    cairo_matrix_t matrix = toCairoMatrix(gradientSpaceTransform);
    199199    cairo_matrix_invert(&matrix);
    200200    cairo_pattern_set_matrix(gradient.get(), &matrix);
     
    205205void Gradient::fill(GraphicsContext& context, const FloatRect& rect)
    206206{
    207     auto pattern = createPattern(1.0);
     207    auto pattern = createPattern(1.0, context.state().fillGradientSpaceTransform);
    208208    if (!pattern)
    209209        return;
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp

    r269753 r271472  
    155155void GraphicsContextImplCairo::fillRect(const FloatRect& rect, Gradient& gradient)
    156156{
    157     auto pattern = gradient.createPattern(1.0);
     157    auto& state = graphicsContext().state();
     158    auto pattern = gradient.createPattern(1.0, state.fillGradientSpaceTransform);
    158159    if (!pattern)
    159160        return;
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r271089 r271472  
    683683            CGContextBeginPath(layerContext);
    684684            CGContextAddPath(layerContext, path.platformPath());
    685             CGContextConcatCTM(layerContext, m_state.fillGradient->gradientSpaceTransform());
     685            CGContextConcatCTM(layerContext, m_state.fillGradientSpaceTransform);
    686686
    687687            if (fillRule() == WindRule::EvenOdd)
     
    697697            CGContextAddPath(context, path.platformPath());
    698698            CGContextStateSaver stateSaver(context);
    699             CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform());
     699            CGContextConcatCTM(context, m_state.fillGradientSpaceTransform);
    700700
    701701            if (fillRule() == WindRule::EvenOdd)
     
    761761            CGContextReplacePathWithStrokedPath(layerContext);
    762762            CGContextClip(layerContext);
    763             CGContextConcatCTM(layerContext, m_state.strokeGradient->gradientSpaceTransform());
     763            CGContextConcatCTM(layerContext, m_state.strokeGradientSpaceTransform);
    764764            m_state.strokeGradient->paint(layerContext);
    765765
     
    774774            CGContextReplacePathWithStrokedPath(context);
    775775            CGContextClip(context);
    776             CGContextConcatCTM(context, m_state.strokeGradient->gradientSpaceTransform());
     776            CGContextConcatCTM(context, m_state.strokeGradientSpaceTransform);
    777777            m_state.strokeGradient->paint(*this);
    778778        }
     
    826826            CGContextClip(layerContext);
    827827
    828             CGContextConcatCTM(layerContext, m_state.fillGradient->gradientSpaceTransform());
     828            CGContextConcatCTM(layerContext, m_state.fillGradientSpaceTransform);
    829829            m_state.fillGradient->paint(layerContext);
    830830            CGContextDrawLayerInRect(context, rect, layer);
     
    832832        } else {
    833833            CGContextClipToRect(context, rect);
    834             CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform());
     834            CGContextConcatCTM(context, m_state.fillGradientSpaceTransform);
    835835            m_state.fillGradient->paint(*this);
    836836        }
     
    12441244            CGContextReplacePathWithStrokedPath(layerContext);
    12451245            CGContextClip(layerContext);
    1246             CGContextConcatCTM(layerContext, m_state.strokeGradient->gradientSpaceTransform());
     1246            CGContextConcatCTM(layerContext, m_state.strokeGradientSpaceTransform);
    12471247            m_state.strokeGradient->paint(layerContext);
    12481248
     
    12571257            CGContextReplacePathWithStrokedPath(context);
    12581258            CGContextClip(context);
    1259             CGContextConcatCTM(context, m_state.strokeGradient->gradientSpaceTransform());
     1259            CGContextConcatCTM(context, m_state.strokeGradientSpaceTransform);
    12601260            m_state.strokeGradient->paint(*this);
    12611261        }
  • trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorder.h

    r269497 r271472  
    9999            Color color;
    100100            RefPtr<Gradient> gradient;
     101            AffineTransform gradientSpaceTransform;
    101102            RefPtr<Pattern> pattern;
    102103        };
  • trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp

    r270725 r271472  
    9999    m_originalState.fillStyle.color = contextState.fillColor;
    100100    m_originalState.fillStyle.gradient = contextState.fillGradient;
     101    m_originalState.fillStyle.gradientSpaceTransform = contextState.fillGradientSpaceTransform;
    101102    m_originalState.fillStyle.pattern = contextState.fillPattern;
    102103
    103104    m_originalState.strokeStyle.color = contextState.strokeColor;
    104105    m_originalState.strokeStyle.gradient = contextState.strokeGradient;
     106    m_originalState.strokeStyle.gradientSpaceTransform = contextState.strokeGradientSpaceTransform;
    105107    m_originalState.strokeStyle.pattern = contextState.strokePattern;
    106108
     
    120122        m_internalContext.setFillColor(m_originalState.fillStyle.color);
    121123    else if (m_originalState.fillStyle.gradient)
    122         m_internalContext.setFillGradient(*m_originalState.fillStyle.gradient);
     124        m_internalContext.setFillGradient(*m_originalState.fillStyle.gradient, m_originalState.fillStyle.gradientSpaceTransform);
    123125    else {
    124126        ASSERT(m_originalState.fillStyle.pattern);
     
    130132        m_internalContext.setStrokeColor(m_originalState.strokeStyle.color);
    131133    else if (m_originalState.strokeStyle.gradient)
    132         m_internalContext.setStrokeGradient(*m_originalState.strokeStyle.gradient);
     134        m_internalContext.setStrokeGradient(*m_originalState.strokeStyle.gradient, m_originalState.strokeStyle.gradientSpaceTransform);
    133135    else {
    134136        ASSERT(m_originalState.strokeStyle.pattern);
  • trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp

    r270725 r271472  
    116116}
    117117
    118 SetInlineFillGradient::SetInlineFillGradient(const Gradient& gradient)
     118SetInlineFillGradient::SetInlineFillGradient(const Gradient& gradient, const AffineTransform& gradientSpaceTransform)
    119119    : m_data(gradient.data())
    120     , m_gradientSpaceTransformation(gradient.gradientSpaceTransform())
     120    , m_gradientSpaceTransform(gradientSpaceTransform)
    121121    , m_spreadMethod(gradient.spreadMethod())
    122122    , m_colorStopCount(static_cast<uint8_t>(gradient.stops().size()))
     
    129129}
    130130
    131 Ref<Gradient> SetInlineFillGradient::gradient() const
    132 {
    133     auto gradient = Gradient::create(Gradient::Data(m_data));
    134     for (uint8_t i = 0; i < m_colorStopCount; ++i)
    135         gradient->addColorStop({ m_offsets[i], Color(m_colors[i]) });
    136     gradient->setSpreadMethod(m_spreadMethod);
    137     gradient->setGradientSpaceTransform(m_gradientSpaceTransformation);
    138     return gradient;
    139 }
    140 
    141 SetInlineFillGradient::SetInlineFillGradient(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], const Gradient::Data& data, const AffineTransform& gradientSpaceTransformation, GradientSpreadMethod spreadMethod, uint8_t colorStopCount)
     131SetInlineFillGradient::SetInlineFillGradient(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], const Gradient::Data& data, const AffineTransform& gradientSpaceTransform, GradientSpreadMethod spreadMethod, uint8_t colorStopCount)
    142132    : m_data(data)
    143     , m_gradientSpaceTransformation(gradientSpaceTransformation)
     133    , m_gradientSpaceTransform(gradientSpaceTransform)
    144134    , m_spreadMethod(spreadMethod)
    145135    , m_colorStopCount(colorStopCount)
     
    152142}
    153143
     144Ref<Gradient> SetInlineFillGradient::gradient() const
     145{
     146    auto gradient = Gradient::create(Gradient::Data(m_data));
     147    for (uint8_t i = 0; i < m_colorStopCount; ++i)
     148        gradient->addColorStop({ m_offsets[i], Color(m_colors[i]) });
     149    gradient->setSpreadMethod(m_spreadMethod);
     150    return gradient;
     151}
     152
    154153void SetInlineFillGradient::apply(GraphicsContext& context) const
    155154{
    156155    if (m_colorStopCount <= maxColorStopCount)
    157         context.setFillGradient(gradient());
     156        context.setFillGradient(gradient(), m_gradientSpaceTransform);
    158157}
    159158
  • trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h

    r270725 r271472  
    175175    static constexpr uint8_t maxColorStopCount = 4;
    176176
    177     SetInlineFillGradient(const Gradient&);
    178     WEBCORE_EXPORT SetInlineFillGradient(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], const Gradient::Data&,
    179         const AffineTransform& gradientSpaceTransformation, GradientSpreadMethod, uint8_t colorStopCount);
     177    SetInlineFillGradient(const Gradient&, const AffineTransform& gradientSpaceTransform);
     178    WEBCORE_EXPORT SetInlineFillGradient(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], const Gradient::Data&, const AffineTransform& gradientSpaceTransform, GradientSpreadMethod, uint8_t colorStopCount);
    180179
    181180    static bool isInline(const Gradient&);
     
    188187    SRGBA<uint8_t> m_colors[maxColorStopCount];
    189188    Gradient::Data m_data;
    190     AffineTransform m_gradientSpaceTransformation;
     189    AffineTransform m_gradientSpaceTransform;
    191190    GradientSpreadMethod m_spreadMethod { GradientSpreadMethod::Pad };
    192191    uint8_t m_colorStopCount { 0 };
  • trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp

    r271415 r271472  
    103103
    104104    if (changeFlags.contains(GraphicsContextState::FillGradientChange))
    105         append<SetInlineFillGradient>(*changes.m_state.fillGradient);
     105        append<SetInlineFillGradient>(*changes.m_state.fillGradient, changes.m_state.fillGradientSpaceTransform);
    106106}
    107107
  • trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp

    r269753 r271472  
    293293    };
    294294
    295     append(createCommand<FillRect>(rect, gradient.createPattern(1.0)));
     295    auto& state = graphicsContext().state();
     296    append(createCommand<FillRect>(rect, gradient.createPattern(1.0, state.fillGradientSpaceTransform)));
    296297}
    297298
  • trunk/Source/WebCore/rendering/svg/RenderSVGPath.cpp

    r264333 r271472  
    7070{
    7171    if (auto gradient = context.strokeGradient())
    72         context.setFillGradient(*gradient);
     72        context.setFillGradient(*gradient, context.state().strokeGradientSpaceTransform);
    7373    else if (Pattern* pattern = context.strokePattern())
    7474        context.setFillPattern(*pattern);
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp

    r269323 r271472  
    146146        }
    147147
    148         gradient->setGradientSpaceTransform(userspaceTransform);
    149 
    150148        return { WTFMove(gradient), userspaceTransform };
    151149    }).iterator->value;
     
    165163
    166164    auto& svgStyle = style.svgStyle();
     165    auto userspaceTransform = gradientData.userspaceTransform;
    167166
    168167    if (resourceMode.contains(RenderSVGResourceMode::ApplyToFill)) {
    169168        context->setAlpha(svgStyle.fillOpacity());
    170         context->setFillGradient(*gradientData.gradient);
     169        context->setFillGradient(*gradientData.gradient, userspaceTransform);
    171170        context->setFillRule(svgStyle.fillRule());
    172171    } else if (resourceMode.contains(RenderSVGResourceMode::ApplyToStroke)) {
    173172        if (svgStyle.vectorEffect() == VectorEffect::NonScalingStroke)
    174             gradientData.gradient->setGradientSpaceTransform(transformOnNonScalingStroke(&renderer, gradientData.userspaceTransform));
     173            userspaceTransform = transformOnNonScalingStroke(&renderer, gradientData.userspaceTransform);
    175174        context->setAlpha(svgStyle.strokeOpacity());
    176         context->setStrokeGradient(*gradientData.gradient);
     175        context->setStrokeGradient(*gradientData.gradient, userspaceTransform);
    177176        SVGRenderSupport::applyStrokeStyleToContext(context, style, renderer);
    178177    }
     
    198197
    199198                FloatRect targetRect;
    200                 gradient.setGradientSpaceTransform(clipToTextMask(*context, m_imageBuffer, targetRect, &renderer, gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX, gradientTransform()));
    201 
    202                 context->setFillGradient(gradient);
     199                AffineTransform userspaceTransform = clipToTextMask(*context, m_imageBuffer, targetRect, &renderer, gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX, gradientTransform());
     200
     201                context->setFillGradient(gradient, userspaceTransform);
    203202                context->fillRect(targetRect);
    204203
Note: See TracChangeset for help on using the changeset viewer.