Diff
Modified: trunk/Source/WebCore/ChangeLog (271471 => 271472)
--- trunk/Source/WebCore/ChangeLog 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/ChangeLog 2021-01-14 00:07:24 UTC (rev 271472)
@@ -1,3 +1,74 @@
+2021-01-13 Said Abou-Hallawa <[email protected]>
+
+ 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().
+
2021-01-13 Jer Noble <[email protected]>
[HANG] 496ms to 1360ms in WebCore::AVAudioSessionCaptureDeviceManager::refreshAudioCaptureDevices()
Modified: trunk/Source/WebCore/platform/graphics/Gradient.cpp (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/Gradient.cpp 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/Gradient.cpp 2021-01-14 00:07:24 UTC (rev 271472)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
* Copyright (C) 2007 Alp Toker <[email protected]>
*
* Redistribution and use in source and binary forms, with or without
@@ -46,8 +46,6 @@
{
}
-Gradient::~Gradient() = default;
-
void Gradient::adjustParametersForTiledDrawing(FloatSize& size, FloatRect& srcRect, const FloatSize& spacing)
{
if (srcRect.isEmpty())
@@ -127,14 +125,6 @@
m_cachedHash = 0;
}
-void Gradient::setGradientSpaceTransform(const AffineTransform& gradientSpaceTransformation)
-{
- if (m_gradientSpaceTransformation == gradientSpaceTransformation)
- return;
- m_gradientSpaceTransformation = gradientSpaceTransformation;
- m_cachedHash = 0;
-}
-
// FIXME: Instead of these add(Hasher) functions, consider using encode functions to compute the hash.
static void add(Hasher& hasher, const Color& color)
@@ -148,11 +138,6 @@
add(hasher, point.x(), point.y());
}
-static void add(Hasher& hasher, const AffineTransform& transform)
-{
- add(hasher, transform.a(), transform.b(), transform.c(), transform.d(), transform.e(), transform.f());
-}
-
static void add(Hasher& hasher, const Gradient::ColorStop& stop)
{
add(hasher, stop.offset, stop.color);
@@ -177,7 +162,7 @@
{
if (!m_cachedHash) {
sortStops();
- m_cachedHash = computeHash(m_data, m_spreadMethod, m_gradientSpaceTransformation, m_stops);
+ m_cachedHash = computeHash(m_data, m_spreadMethod, m_stops);
}
return m_cachedHash;
}
Modified: trunk/Source/WebCore/platform/graphics/Gradient.h (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/Gradient.h 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/Gradient.h 2021-01-14 00:07:24 UTC (rev 271472)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008, 2011, 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
* Copyright (C) 2007 Alp Toker <[email protected]>
* Copyright (C) 2008 Torch Mobile, Inc.
*
@@ -104,8 +104,6 @@
WEBCORE_EXPORT static Ref<Gradient> create(Data&&);
- WEBCORE_EXPORT ~Gradient();
-
bool isZeroSize() const;
const Data& data() const { return m_data; }
@@ -118,9 +116,6 @@
WEBCORE_EXPORT void setSpreadMethod(GradientSpreadMethod);
GradientSpreadMethod spreadMethod() const { return m_spreadMethod; }
- WEBCORE_EXPORT void setGradientSpaceTransform(const AffineTransform& gradientSpaceTransformation);
- const AffineTransform& gradientSpaceTransform() const { return m_gradientSpaceTransformation; }
-
void fill(GraphicsContext&, const FloatRect&);
void adjustParametersForTiledDrawing(FloatSize&, FloatRect&, const FloatSize& spacing);
@@ -127,7 +122,7 @@
unsigned hash() const;
#if USE(CAIRO)
- RefPtr<cairo_pattern_t> createPattern(float globalAlpha);
+ RefPtr<cairo_pattern_t> createPattern(float globalAlpha, const AffineTransform&);
#endif
#if USE(CG)
@@ -157,7 +152,6 @@
mutable bool m_stopsSorted { false };
GradientSpreadMethod m_spreadMethod { GradientSpreadMethod::Pad };
mutable unsigned m_cachedHash { 0 };
- AffineTransform m_gradientSpaceTransformation;
#if USE(CG)
RetainPtr<CGGradientRef> m_gradient;
@@ -276,7 +270,6 @@
encoder << m_stops;
encoder << m_stopsSorted;
encoder << m_spreadMethod;
- encoder << m_gradientSpaceTransformation;
}
template<typename Decoder> Optional<Ref<Gradient>> Gradient::decode(Decoder& decoder)
@@ -307,12 +300,6 @@
return WTF::nullopt;
gradient->setSpreadMethod(spreadMethod);
- Optional<AffineTransform> gradientSpaceTransformation;
- decoder >> gradientSpaceTransformation;
- if (!gradientSpaceTransformation)
- return WTF::nullopt;
- gradient->setGradientSpaceTransform(WTFMove(*gradientSpaceTransformation));
-
return gradient;
}
Modified: trunk/Source/WebCore/platform/graphics/GradientImage.h (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/GradientImage.h 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/GradientImage.h 2021-01-14 00:07:24 UTC (rev 271472)
@@ -54,7 +54,7 @@
Ref<Gradient> m_gradient;
RefPtr<Image> m_cachedImage;
FloatSize m_cachedAdjustedSize;
- unsigned m_cachedGeneratorHash;
+ unsigned m_cachedGeneratorHash { 0 };
FloatSize m_cachedScaleFactor;
};
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2021-01-14 00:07:24 UTC (rev 271472)
@@ -211,13 +211,13 @@
void GraphicsContextStateChange::apply(GraphicsContext& context) const
{
if (m_changeFlags.contains(GraphicsContextState::StrokeGradientChange))
- context.setStrokeGradient(*m_state.strokeGradient);
+ context.setStrokeGradient(*m_state.strokeGradient, m_state.strokeGradientSpaceTransform);
if (m_changeFlags.contains(GraphicsContextState::StrokePatternChange))
context.setStrokePattern(*m_state.strokePattern);
if (m_changeFlags.contains(GraphicsContextState::FillGradientChange))
- context.setFillGradient(*m_state.fillGradient);
+ context.setFillGradient(*m_state.fillGradient, m_state.fillGradientSpaceTransform);
if (m_changeFlags.contains(GraphicsContextState::FillPatternChange))
context.setFillPattern(*m_state.fillPattern);
@@ -620,10 +620,11 @@
m_impl->updateState(m_state, GraphicsContextState::FillPatternChange);
}
-void GraphicsContext::setStrokeGradient(Ref<Gradient>&& gradient)
+void GraphicsContext::setStrokeGradient(Ref<Gradient>&& gradient, const AffineTransform& strokeGradientSpaceTransform)
{
m_state.strokeColor = { };
m_state.strokeGradient = WTFMove(gradient);
+ m_state.strokeGradientSpaceTransform = strokeGradientSpaceTransform;
m_state.strokePattern = nullptr;
if (m_impl)
m_impl->updateState(m_state, GraphicsContextState::StrokeGradientChange);
@@ -636,10 +637,11 @@
m_impl->updateState(m_state, GraphicsContextState::FillRuleChange);
}
-void GraphicsContext::setFillGradient(Ref<Gradient>&& gradient)
+void GraphicsContext::setFillGradient(Ref<Gradient>&& gradient, const AffineTransform& fillGradientSpaceTransform)
{
m_state.fillColor = { };
m_state.fillGradient = WTFMove(gradient);
+ m_state.fillGradientSpaceTransform = fillGradientSpaceTransform;
m_state.fillPattern = nullptr;
if (m_impl)
m_impl->updateState(m_state, GraphicsContextState::FillGradientChange); // FIXME: also fill pattern?
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2021-01-14 00:07:24 UTC (rev 271472)
@@ -212,6 +212,9 @@
Color fillColor { Color::black };
Color shadowColor;
+ AffineTransform strokeGradientSpaceTransform;
+ AffineTransform fillGradientSpaceTransform;
+
StrokeStyle strokeStyle { SolidStroke };
WindRule fillRule { WindRule::NonZero };
@@ -303,7 +306,7 @@
void setStrokePattern(Ref<Pattern>&&);
Pattern* strokePattern() const { return m_state.strokePattern.get(); }
- void setStrokeGradient(Ref<Gradient>&&);
+ void setStrokeGradient(Ref<Gradient>&&, const AffineTransform& = { });
Gradient* strokeGradient() const { return m_state.strokeGradient.get(); }
void setFillRule(WindRule);
@@ -315,7 +318,7 @@
void setFillPattern(Ref<Pattern>&&);
Pattern* fillPattern() const { return m_state.fillPattern.get(); }
- WEBCORE_EXPORT void setFillGradient(Ref<Gradient>&&);
+ WEBCORE_EXPORT void setFillGradient(Ref<Gradient>&&, const AffineTransform& = { });
Gradient* fillGradient() const { return m_state.fillGradient.get(); }
void setShadowsIgnoreTransforms(bool);
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2021-01-14 00:07:24 UTC (rev 271472)
@@ -572,9 +572,9 @@
pattern.repeatX = state.fillPattern->repeatX();
pattern.repeatY = state.fillPattern->repeatY();
} else if (state.fillGradient) {
- gradient.base = state.fillGradient->createPattern(1);
+ gradient.base = state.fillGradient->createPattern(1, state.fillGradientSpaceTransform);
if (state.alpha != 1)
- gradient.alphaAdjusted = state.fillGradient->createPattern(state.alpha);
+ gradient.alphaAdjusted = state.fillGradient->createPattern(state.alpha, state.fillGradientSpaceTransform);
} else
color = state.fillColor;
}
@@ -585,9 +585,9 @@
if (state.strokePattern)
pattern = adoptRef(state.strokePattern->createPlatformPattern(AffineTransform()));
else if (state.strokeGradient) {
- gradient.base = state.strokeGradient->createPattern(1);
+ gradient.base = state.strokeGradient->createPattern(1, state.strokeGradientSpaceTransform);
if (state.alpha != 1)
- gradient.alphaAdjusted = state.strokeGradient->createPattern(state.alpha);
+ gradient.alphaAdjusted = state.strokeGradient->createPattern(state.alpha, state.strokeGradientSpaceTransform);
} else
color = state.strokeColor;
}
Modified: trunk/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp 2021-01-14 00:07:24 UTC (rev 271472)
@@ -158,7 +158,7 @@
return gradient;
}
-RefPtr<cairo_pattern_t> Gradient::createPattern(float globalAlpha)
+RefPtr<cairo_pattern_t> Gradient::createPattern(float globalAlpha, const AffineTransform& gradientSpaceTransform)
{
auto gradient = WTF::switchOn(m_data,
[&] (const LinearData& data) {
@@ -195,7 +195,7 @@
break;
}
- cairo_matrix_t matrix = toCairoMatrix(m_gradientSpaceTransformation);
+ cairo_matrix_t matrix = toCairoMatrix(gradientSpaceTransform);
cairo_matrix_invert(&matrix);
cairo_pattern_set_matrix(gradient.get(), &matrix);
@@ -204,7 +204,7 @@
void Gradient::fill(GraphicsContext& context, const FloatRect& rect)
{
- auto pattern = createPattern(1.0);
+ auto pattern = createPattern(1.0, context.state().fillGradientSpaceTransform);
if (!pattern)
return;
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp 2021-01-14 00:07:24 UTC (rev 271472)
@@ -154,7 +154,8 @@
void GraphicsContextImplCairo::fillRect(const FloatRect& rect, Gradient& gradient)
{
- auto pattern = gradient.createPattern(1.0);
+ auto& state = graphicsContext().state();
+ auto pattern = gradient.createPattern(1.0, state.fillGradientSpaceTransform);
if (!pattern)
return;
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2021-01-14 00:07:24 UTC (rev 271472)
@@ -682,7 +682,7 @@
CGContextTranslateCTM(layerContext, -rect.x(), -rect.y());
CGContextBeginPath(layerContext);
CGContextAddPath(layerContext, path.platformPath());
- CGContextConcatCTM(layerContext, m_state.fillGradient->gradientSpaceTransform());
+ CGContextConcatCTM(layerContext, m_state.fillGradientSpaceTransform);
if (fillRule() == WindRule::EvenOdd)
CGContextEOClip(layerContext);
@@ -696,7 +696,7 @@
CGContextBeginPath(context);
CGContextAddPath(context, path.platformPath());
CGContextStateSaver stateSaver(context);
- CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform());
+ CGContextConcatCTM(context, m_state.fillGradientSpaceTransform);
if (fillRule() == WindRule::EvenOdd)
CGContextEOClip(context);
@@ -760,7 +760,7 @@
CGContextAddPath(layerContext, path.platformPath());
CGContextReplacePathWithStrokedPath(layerContext);
CGContextClip(layerContext);
- CGContextConcatCTM(layerContext, m_state.strokeGradient->gradientSpaceTransform());
+ CGContextConcatCTM(layerContext, m_state.strokeGradientSpaceTransform);
m_state.strokeGradient->paint(layerContext);
float destinationX = roundf(rect.x() - lineWidth);
@@ -773,7 +773,7 @@
CGContextAddPath(context, path.platformPath());
CGContextReplacePathWithStrokedPath(context);
CGContextClip(context);
- CGContextConcatCTM(context, m_state.strokeGradient->gradientSpaceTransform());
+ CGContextConcatCTM(context, m_state.strokeGradientSpaceTransform);
m_state.strokeGradient->paint(*this);
}
return;
@@ -825,13 +825,13 @@
CGContextAddRect(layerContext, rect);
CGContextClip(layerContext);
- CGContextConcatCTM(layerContext, m_state.fillGradient->gradientSpaceTransform());
+ CGContextConcatCTM(layerContext, m_state.fillGradientSpaceTransform);
m_state.fillGradient->paint(layerContext);
CGContextDrawLayerInRect(context, rect, layer);
CGLayerRelease(layer);
} else {
CGContextClipToRect(context, rect);
- CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform());
+ CGContextConcatCTM(context, m_state.fillGradientSpaceTransform);
m_state.fillGradient->paint(*this);
}
return;
@@ -1243,7 +1243,7 @@
CGContextAddRect(layerContext, rect);
CGContextReplacePathWithStrokedPath(layerContext);
CGContextClip(layerContext);
- CGContextConcatCTM(layerContext, m_state.strokeGradient->gradientSpaceTransform());
+ CGContextConcatCTM(layerContext, m_state.strokeGradientSpaceTransform);
m_state.strokeGradient->paint(layerContext);
const float destinationX = roundf(rect.x() - lineWidth);
@@ -1256,7 +1256,7 @@
CGContextAddRect(context, rect);
CGContextReplacePathWithStrokedPath(context);
CGContextClip(context);
- CGContextConcatCTM(context, m_state.strokeGradient->gradientSpaceTransform());
+ CGContextConcatCTM(context, m_state.strokeGradientSpaceTransform);
m_state.strokeGradient->paint(*this);
}
return;
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorder.h (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorder.h 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorder.h 2021-01-14 00:07:24 UTC (rev 271472)
@@ -98,6 +98,7 @@
struct Style {
Color color;
RefPtr<Gradient> gradient;
+ AffineTransform gradientSpaceTransform;
RefPtr<Pattern> pattern;
};
Style fillStyle;
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp 2021-01-14 00:07:24 UTC (rev 271472)
@@ -98,10 +98,12 @@
{
m_originalState.fillStyle.color = contextState.fillColor;
m_originalState.fillStyle.gradient = contextState.fillGradient;
+ m_originalState.fillStyle.gradientSpaceTransform = contextState.fillGradientSpaceTransform;
m_originalState.fillStyle.pattern = contextState.fillPattern;
m_originalState.strokeStyle.color = contextState.strokeColor;
m_originalState.strokeStyle.gradient = contextState.strokeGradient;
+ m_originalState.strokeStyle.gradientSpaceTransform = contextState.strokeGradientSpaceTransform;
m_originalState.strokeStyle.pattern = contextState.strokePattern;
m_originalState.ctm = m_owner.currentState().ctm; // FIXME: Deal with base CTM.
@@ -119,7 +121,7 @@
if (m_originalState.fillStyle.color.isValid())
m_internalContext.setFillColor(m_originalState.fillStyle.color);
else if (m_originalState.fillStyle.gradient)
- m_internalContext.setFillGradient(*m_originalState.fillStyle.gradient);
+ m_internalContext.setFillGradient(*m_originalState.fillStyle.gradient, m_originalState.fillStyle.gradientSpaceTransform);
else {
ASSERT(m_originalState.fillStyle.pattern);
if (m_originalState.fillStyle.pattern)
@@ -129,7 +131,7 @@
if (m_originalState.strokeStyle.color.isValid())
m_internalContext.setStrokeColor(m_originalState.strokeStyle.color);
else if (m_originalState.strokeStyle.gradient)
- m_internalContext.setStrokeGradient(*m_originalState.strokeStyle.gradient);
+ m_internalContext.setStrokeGradient(*m_originalState.strokeStyle.gradient, m_originalState.strokeStyle.gradientSpaceTransform);
else {
ASSERT(m_originalState.strokeStyle.pattern);
if (m_originalState.strokeStyle.pattern)
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2021-01-14 00:07:24 UTC (rev 271472)
@@ -115,9 +115,9 @@
return ts;
}
-SetInlineFillGradient::SetInlineFillGradient(const Gradient& gradient)
+SetInlineFillGradient::SetInlineFillGradient(const Gradient& gradient, const AffineTransform& gradientSpaceTransform)
: m_data(gradient.data())
- , m_gradientSpaceTransformation(gradient.gradientSpaceTransform())
+ , m_gradientSpaceTransform(gradientSpaceTransform)
, m_spreadMethod(gradient.spreadMethod())
, m_colorStopCount(static_cast<uint8_t>(gradient.stops().size()))
{
@@ -128,19 +128,9 @@
}
}
-Ref<Gradient> SetInlineFillGradient::gradient() const
-{
- auto gradient = Gradient::create(Gradient::Data(m_data));
- for (uint8_t i = 0; i < m_colorStopCount; ++i)
- gradient->addColorStop({ m_offsets[i], Color(m_colors[i]) });
- gradient->setSpreadMethod(m_spreadMethod);
- gradient->setGradientSpaceTransform(m_gradientSpaceTransformation);
- return gradient;
-}
-
-SetInlineFillGradient::SetInlineFillGradient(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], const Gradient::Data& data, const AffineTransform& gradientSpaceTransformation, GradientSpreadMethod spreadMethod, uint8_t colorStopCount)
+SetInlineFillGradient::SetInlineFillGradient(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], const Gradient::Data& data, const AffineTransform& gradientSpaceTransform, GradientSpreadMethod spreadMethod, uint8_t colorStopCount)
: m_data(data)
- , m_gradientSpaceTransformation(gradientSpaceTransformation)
+ , m_gradientSpaceTransform(gradientSpaceTransform)
, m_spreadMethod(spreadMethod)
, m_colorStopCount(colorStopCount)
{
@@ -151,10 +141,19 @@
}
}
+Ref<Gradient> SetInlineFillGradient::gradient() const
+{
+ auto gradient = Gradient::create(Gradient::Data(m_data));
+ for (uint8_t i = 0; i < m_colorStopCount; ++i)
+ gradient->addColorStop({ m_offsets[i], Color(m_colors[i]) });
+ gradient->setSpreadMethod(m_spreadMethod);
+ return gradient;
+}
+
void SetInlineFillGradient::apply(GraphicsContext& context) const
{
if (m_colorStopCount <= maxColorStopCount)
- context.setFillGradient(gradient());
+ context.setFillGradient(gradient(), m_gradientSpaceTransform);
}
bool SetInlineFillGradient::isInline(const Gradient& gradient)
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h 2021-01-14 00:07:24 UTC (rev 271472)
@@ -174,9 +174,8 @@
static constexpr bool isDrawingItem = false;
static constexpr uint8_t maxColorStopCount = 4;
- SetInlineFillGradient(const Gradient&);
- WEBCORE_EXPORT SetInlineFillGradient(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], const Gradient::Data&,
- const AffineTransform& gradientSpaceTransformation, GradientSpreadMethod, uint8_t colorStopCount);
+ SetInlineFillGradient(const Gradient&, const AffineTransform& gradientSpaceTransform);
+ WEBCORE_EXPORT SetInlineFillGradient(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], const Gradient::Data&, const AffineTransform& gradientSpaceTransform, GradientSpreadMethod, uint8_t colorStopCount);
static bool isInline(const Gradient&);
Ref<Gradient> gradient() const;
@@ -187,7 +186,7 @@
float m_offsets[maxColorStopCount];
SRGBA<uint8_t> m_colors[maxColorStopCount];
Gradient::Data m_data;
- AffineTransform m_gradientSpaceTransformation;
+ AffineTransform m_gradientSpaceTransform;
GradientSpreadMethod m_spreadMethod { GradientSpreadMethod::Pad };
uint8_t m_colorStopCount { 0 };
};
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2021-01-14 00:07:24 UTC (rev 271472)
@@ -102,7 +102,7 @@
append<SetInlineFillColor>(changes.m_state.fillColor.asInline());
if (changeFlags.contains(GraphicsContextState::FillGradientChange))
- append<SetInlineFillGradient>(*changes.m_state.fillGradient);
+ append<SetInlineFillGradient>(*changes.m_state.fillGradient, changes.m_state.fillGradientSpaceTransform);
}
void Recorder::willAppendItemOfType(ItemType type)
Modified: trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp (271471 => 271472)
--- trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp 2021-01-14 00:07:24 UTC (rev 271472)
@@ -292,7 +292,8 @@
}
};
- append(createCommand<FillRect>(rect, gradient.createPattern(1.0)));
+ auto& state = graphicsContext().state();
+ append(createCommand<FillRect>(rect, gradient.createPattern(1.0, state.fillGradientSpaceTransform)));
}
void CairoOperationRecorder::fillRect(const FloatRect& rect, const Color& color, CompositeOperator compositeOperator, BlendMode blendMode)
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGPath.cpp (271471 => 271472)
--- trunk/Source/WebCore/rendering/svg/RenderSVGPath.cpp 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGPath.cpp 2021-01-14 00:07:24 UTC (rev 271472)
@@ -69,7 +69,7 @@
static void useStrokeStyleToFill(GraphicsContext& context)
{
if (auto gradient = context.strokeGradient())
- context.setFillGradient(*gradient);
+ context.setFillGradient(*gradient, context.state().strokeGradientSpaceTransform);
else if (Pattern* pattern = context.strokePattern())
context.setFillPattern(*pattern);
else
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp (271471 => 271472)
--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp 2021-01-14 00:01:37 UTC (rev 271471)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp 2021-01-14 00:07:24 UTC (rev 271472)
@@ -145,8 +145,6 @@
userspaceTransform *= additionalTextTransform;
}
- gradient->setGradientSpaceTransform(userspaceTransform);
-
return { WTFMove(gradient), userspaceTransform };
}).iterator->value;
@@ -164,16 +162,17 @@
}
auto& svgStyle = style.svgStyle();
+ auto userspaceTransform = gradientData.userspaceTransform;
if (resourceMode.contains(RenderSVGResourceMode::ApplyToFill)) {
context->setAlpha(svgStyle.fillOpacity());
- context->setFillGradient(*gradientData.gradient);
+ context->setFillGradient(*gradientData.gradient, userspaceTransform);
context->setFillRule(svgStyle.fillRule());
} else if (resourceMode.contains(RenderSVGResourceMode::ApplyToStroke)) {
if (svgStyle.vectorEffect() == VectorEffect::NonScalingStroke)
- gradientData.gradient->setGradientSpaceTransform(transformOnNonScalingStroke(&renderer, gradientData.userspaceTransform));
+ userspaceTransform = transformOnNonScalingStroke(&renderer, gradientData.userspaceTransform);
context->setAlpha(svgStyle.strokeOpacity());
- context->setStrokeGradient(*gradientData.gradient);
+ context->setStrokeGradient(*gradientData.gradient, userspaceTransform);
SVGRenderSupport::applyStrokeStyleToContext(context, style, renderer);
}
@@ -197,9 +196,9 @@
context = std::exchange(m_savedContext, nullptr);
FloatRect targetRect;
- gradient.setGradientSpaceTransform(clipToTextMask(*context, m_imageBuffer, targetRect, &renderer, gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX, gradientTransform()));
+ AffineTransform userspaceTransform = clipToTextMask(*context, m_imageBuffer, targetRect, &renderer, gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX, gradientTransform());
- context->setFillGradient(gradient);
+ context->setFillGradient(gradient, userspaceTransform);
context->fillRect(targetRect);
m_imageBuffer = nullptr;