Diff
Modified: trunk/Source/WebCore/ChangeLog (226980 => 226981)
--- trunk/Source/WebCore/ChangeLog 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/ChangeLog 2018-01-16 18:59:09 UTC (rev 226981)
@@ -1,3 +1,52 @@
+2018-01-16 Simon Fraser <simon.fra...@apple.com>
+
+ Rename applyHorizontalScale/applyVerticalScale in SVG filters, and related cleanup
+ https://bugs.webkit.org/show_bug.cgi?id=181684
+
+ Reviewed by Alex Christensen.
+
+ Rename the confusing applyHorizontalScale/applyVerticalScale to scaledByFilterResolution(),
+ and have it take and return a FloatSize. Change callers to do math in terms of FloatSizes.
+
+ Add inflate(size) to each of the rect classes.
+
+ * platform/graphics/FloatRect.h:
+ (WebCore::FloatRect::inflate):
+ * platform/graphics/IntRect.h:
+ (WebCore::IntRect::inflate):
+ * platform/graphics/LayoutRect.h:
+ (WebCore::LayoutRect::inflate):
+ * platform/graphics/filters/FEDisplacementMap.cpp:
+ (WebCore::FEDisplacementMap::platformApplySoftware):
+ * platform/graphics/filters/FEDropShadow.cpp:
+ (WebCore::FEDropShadow::determineAbsolutePaintRect):
+ (WebCore::FEDropShadow::platformApplySoftware):
+ * platform/graphics/filters/FEGaussianBlur.cpp:
+ (WebCore::FEGaussianBlur::calculateUnscaledKernelSize):
+ (WebCore::FEGaussianBlur::calculateKernelSize):
+ (WebCore::FEGaussianBlur::determineAbsolutePaintRect):
+ (WebCore::FEGaussianBlur::platformApplySoftware):
+ * platform/graphics/filters/FEGaussianBlur.h:
+ * platform/graphics/filters/FEMorphology.cpp:
+ (WebCore::FEMorphology::determineAbsolutePaintRect):
+ (WebCore::FEMorphology::platformApplySoftware):
+ * platform/graphics/filters/FEOffset.cpp:
+ (WebCore::FEOffset::determineAbsolutePaintRect):
+ (WebCore::FEOffset::platformApplySoftware):
+ * platform/graphics/filters/Filter.h:
+ (WebCore::Filter::setSourceImage):
+ (WebCore::Filter::scaledByFilterResolution const):
+ (WebCore::Filter::applyHorizontalScale const): Deleted.
+ (WebCore::Filter::applyVerticalScale const): Deleted.
+ * platform/graphics/filters/FilterOperations.cpp:
+ (WebCore::outsetSizeForBlur):
+ * rendering/FilterEffectRenderer.h:
+ * svg/graphics/filters/SVGFilter.cpp:
+ (WebCore::SVGFilter::scaledByFilterResolution const):
+ (WebCore::SVGFilter::applyHorizontalScale const): Deleted.
+ (WebCore::SVGFilter::applyVerticalScale const): Deleted.
+ * svg/graphics/filters/SVGFilter.h:
+
2018-01-16 Fujii Hironori <hironori.fu...@sony.com>
[CMake][Mac] Fix the build errors
Modified: trunk/Source/WebCore/platform/graphics/FloatRect.h (226980 => 226981)
--- trunk/Source/WebCore/platform/graphics/FloatRect.h 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.h 2018-01-16 18:59:09 UTC (rev 226981)
@@ -164,6 +164,8 @@
m_size.setHeight(m_size.height() + dy + dy);
}
void inflate(float d) { inflateX(d); inflateY(d); }
+ void inflate(FloatSize size) { inflateX(size.width()); inflateY(size.height()); }
+
void scale(float s) { scale(s, s); }
WEBCORE_EXPORT void scale(float sx, float sy);
void scale(FloatSize size) { scale(size.width(), size.height()); }
Modified: trunk/Source/WebCore/platform/graphics/IntRect.h (226980 => 226981)
--- trunk/Source/WebCore/platform/graphics/IntRect.h 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/platform/graphics/IntRect.h 2018-01-16 18:59:09 UTC (rev 226981)
@@ -169,6 +169,7 @@
m_size.setHeight(m_size.height() + dy + dy);
}
void inflate(int d) { inflateX(d); inflateY(d); }
+ void inflate(IntSize size) { inflateX(size.width()); inflateY(size.height()); }
WEBCORE_EXPORT void scale(float s);
IntSize differenceToPoint(const IntPoint&) const;
Modified: trunk/Source/WebCore/platform/graphics/LayoutRect.h (226980 => 226981)
--- trunk/Source/WebCore/platform/graphics/LayoutRect.h 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/platform/graphics/LayoutRect.h 2018-01-16 18:59:09 UTC (rev 226981)
@@ -160,6 +160,7 @@
m_size.setHeight(m_size.height() + dy + dy);
}
void inflate(LayoutUnit d) { inflateX(d); inflateY(d); }
+ void inflate(LayoutSize size) { inflateX(size.width()); inflateY(size.height()); }
WEBCORE_EXPORT void scale(float);
void scale(float xScale, float yScale);
Modified: trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp (226980 => 226981)
--- trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp 2018-01-16 18:59:09 UTC (rev 226981)
@@ -112,12 +112,11 @@
Filter& filter = this->filter();
IntSize paintSize = absolutePaintRect().size();
- float scaleX = filter.applyHorizontalScale(m_scale);
- float scaleY = filter.applyVerticalScale(m_scale);
- float scaleForColorX = scaleX / 255.0;
- float scaleForColorY = scaleY / 255.0;
- float scaledOffsetX = 0.5 - scaleX * 0.5;
- float scaledOffsetY = 0.5 - scaleY * 0.5;
+ FloatSize scale = filter.scaledByFilterResolution({ m_scale, m_scale });
+ float scaleForColorX = scale.width() / 255.0;
+ float scaleForColorY = scale.height() / 255.0;
+ float scaledOffsetX = 0.5 - scale.width() * 0.5;
+ float scaledOffsetY = 0.5 - scale.height() * 0.5;
int displacementChannelX = xChannelIndex();
int displacementChannelY = yChannelIndex();
Modified: trunk/Source/WebCore/platform/graphics/filters/FEDropShadow.cpp (226980 => 226981)
--- trunk/Source/WebCore/platform/graphics/filters/FEDropShadow.cpp 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/platform/graphics/filters/FEDropShadow.cpp 2018-01-16 18:59:09 UTC (rev 226981)
@@ -52,10 +52,10 @@
FloatRect absolutePaintRect = inputEffect(0)->absolutePaintRect();
FloatRect absoluteOffsetPaintRect(absolutePaintRect);
- absoluteOffsetPaintRect.move(filter.applyHorizontalScale(m_dx), filter.applyVerticalScale(m_dy));
+ absoluteOffsetPaintRect.move(filter.scaledByFilterResolution({ m_dx, m_dy }));
absolutePaintRect.unite(absoluteOffsetPaintRect);
- IntSize kernelSize = FEGaussianBlur::calculateKernelSize(filter, FloatPoint(m_stdX, m_stdY));
+ IntSize kernelSize = FEGaussianBlur::calculateKernelSize(filter, { m_stdX, m_stdY });
// We take the half kernel size and multiply it with three, because we run box blur three times.
absolutePaintRect.inflateX(3 * kernelSize.width() * 0.5f);
@@ -78,9 +78,10 @@
return;
Filter& filter = this->filter();
- FloatSize blurRadius(2 * filter.applyHorizontalScale(m_stdX), 2 * filter.applyVerticalScale(m_stdY));
+
+ FloatSize blurRadius = 2 * filter.scaledByFilterResolution({ m_stdX, m_stdY });
blurRadius.scale(filter.filterScale());
- FloatSize offset(filter.applyHorizontalScale(m_dx), filter.applyVerticalScale(m_dy));
+ FloatSize offset = filter.scaledByFilterResolution({ m_dx, m_dy });
FloatRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
FloatRect drawingRegionWithOffset(drawingRegion);
Modified: trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp (226980 => 226981)
--- trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp 2018-01-16 18:59:09 UTC (rev 226981)
@@ -468,29 +468,28 @@
return clampTo<int>(std::min(size, static_cast<unsigned>(gMaxKernelSize)));
}
-IntSize FEGaussianBlur::calculateUnscaledKernelSize(const FloatPoint& stdDeviation)
+IntSize FEGaussianBlur::calculateUnscaledKernelSize(FloatSize stdDeviation)
{
- ASSERT(stdDeviation.x() >= 0 && stdDeviation.y() >= 0);
+ ASSERT(stdDeviation.width() >= 0 && stdDeviation.height() >= 0);
IntSize kernelSize;
- if (stdDeviation.x())
- kernelSize.setWidth(clampedToKernelSize(stdDeviation.x()));
+ if (stdDeviation.width())
+ kernelSize.setWidth(clampedToKernelSize(stdDeviation.width()));
- if (stdDeviation.y())
- kernelSize.setHeight(clampedToKernelSize(stdDeviation.y()));
+ if (stdDeviation.height())
+ kernelSize.setHeight(clampedToKernelSize(stdDeviation.height()));
return kernelSize;
}
-IntSize FEGaussianBlur::calculateKernelSize(const Filter& filter, const FloatPoint& stdDeviation)
+IntSize FEGaussianBlur::calculateKernelSize(const Filter& filter, FloatSize stdDeviation)
{
- FloatPoint stdFilterScaled(filter.applyHorizontalScale(stdDeviation.x()), filter.applyVerticalScale(stdDeviation.y()));
- return calculateUnscaledKernelSize(stdFilterScaled);
+ return calculateUnscaledKernelSize(filter.scaledByFilterResolution(stdDeviation));
}
void FEGaussianBlur::determineAbsolutePaintRect()
{
- IntSize kernelSize = calculateKernelSize(filter(), FloatPoint(m_stdX, m_stdY));
+ IntSize kernelSize = calculateKernelSize(filter(), { m_stdX, m_stdY });
FloatRect absolutePaintRect = inputEffect(0)->absolutePaintRect();
// Edge modes other than 'none' do not inflate the affected paint rect.
@@ -527,7 +526,7 @@
if (!m_stdX && !m_stdY)
return;
- IntSize kernelSize = calculateKernelSize(filter(), FloatPoint(m_stdX, m_stdY));
+ IntSize kernelSize = calculateKernelSize(filter(), { m_stdX, m_stdY });
kernelSize.scale(filter().filterScale());
IntSize paintSize = absolutePaintRect().size();
Modified: trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h (226980 => 226981)
--- trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h 2018-01-16 18:59:09 UTC (rev 226981)
@@ -40,8 +40,8 @@
EdgeModeType edgeMode() const { return m_edgeMode; }
void setEdgeMode(EdgeModeType);
- static IntSize calculateKernelSize(const Filter&, const FloatPoint& stdDeviation);
- static IntSize calculateUnscaledKernelSize(const FloatPoint& stdDeviation);
+ static IntSize calculateKernelSize(const Filter&, FloatSize stdDeviation);
+ static IntSize calculateUnscaledKernelSize(FloatSize stdDeviation);
private:
FEGaussianBlur(Filter&, float, float, EdgeModeType);
Modified: trunk/Source/WebCore/platform/graphics/filters/FEMorphology.cpp (226980 => 226981)
--- trunk/Source/WebCore/platform/graphics/filters/FEMorphology.cpp 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/platform/graphics/filters/FEMorphology.cpp 2018-01-16 18:59:09 UTC (rev 226981)
@@ -75,8 +75,7 @@
{
FloatRect paintRect = inputEffect(0)->absolutePaintRect();
Filter& filter = this->filter();
- paintRect.inflateX(filter.applyHorizontalScale(m_radiusX));
- paintRect.inflateY(filter.applyVerticalScale(m_radiusY));
+ paintRect.inflate(filter.scaledByFilterResolution({ m_radiusX, m_radiusY }));
if (clipsToBounds())
paintRect.intersect(maxEffectRect());
else
@@ -254,10 +253,9 @@
if (!srcPixelArray)
return;
- int radiusX = static_cast<int>(floorf(filter.applyHorizontalScale(m_radiusX)));
- int radiusY = static_cast<int>(floorf(filter.applyVerticalScale(m_radiusY)));
- radiusX = std::min(effectDrawingRect.width() - 1, radiusX);
- radiusY = std::min(effectDrawingRect.height() - 1, radiusY);
+ IntSize radius = flooredIntSize(filter.scaledByFilterResolution({ m_radiusX, m_radiusY }));
+ int radiusX = std::min(effectDrawingRect.width() - 1, radius.width());
+ int radiusY = std::min(effectDrawingRect.height() - 1, radius.height());
if (platformApplyDegenerate(*dstPixelArray, effectDrawingRect, radiusX, radiusY))
return;
Modified: trunk/Source/WebCore/platform/graphics/filters/FEOffset.cpp (226980 => 226981)
--- trunk/Source/WebCore/platform/graphics/filters/FEOffset.cpp 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/platform/graphics/filters/FEOffset.cpp 2018-01-16 18:59:09 UTC (rev 226981)
@@ -56,7 +56,7 @@
{
FloatRect paintRect = inputEffect(0)->absolutePaintRect();
Filter& filter = this->filter();
- paintRect.move(filter.applyHorizontalScale(m_dx), filter.applyVerticalScale(m_dy));
+ paintRect.move(filter.scaledByFilterResolution({ m_dx, m_dy }));
if (clipsToBounds())
paintRect.intersect(maxEffectRect());
else
@@ -77,7 +77,7 @@
FloatRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
Filter& filter = this->filter();
- drawingRegion.move(filter.applyHorizontalScale(m_dx), filter.applyVerticalScale(m_dy));
+ drawingRegion.move(filter.scaledByFilterResolution({ m_dx, m_dy }));
resultImage->context().drawImageBuffer(*inBuffer, drawingRegion);
}
Modified: trunk/Source/WebCore/platform/graphics/filters/Filter.h (226980 => 226981)
--- trunk/Source/WebCore/platform/graphics/filters/Filter.h 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/platform/graphics/filters/Filter.h 2018-01-16 18:59:09 UTC (rev 226981)
@@ -33,7 +33,7 @@
{ }
virtual ~Filter() = default;
- void setSourceImage(std::unique_ptr<ImageBuffer> sourceImage) { m_sourceImage = WTFMove(sourceImage); }
+ void setSourceImage(std::unique_ptr<ImageBuffer>&& sourceImage) { m_sourceImage = WTFMove(sourceImage); }
ImageBuffer* sourceImage() { return m_sourceImage.get(); }
FloatSize filterResolution() const { return m_filterResolution; }
@@ -49,8 +49,7 @@
virtual bool isSVGFilter() const { return false; }
- virtual float applyHorizontalScale(float value) const { return value * m_filterResolution.width(); }
- virtual float applyVerticalScale(float value) const { return value * m_filterResolution.height(); }
+ virtual FloatSize scaledByFilterResolution(FloatSize size) const { return size * m_filterResolution; }
virtual FloatRect sourceImageRect() const = 0;
virtual FloatRect filterRegion() const = 0;
Modified: trunk/Source/WebCore/platform/graphics/filters/FilterOperations.cpp (226980 => 226981)
--- trunk/Source/WebCore/platform/graphics/filters/FilterOperations.cpp 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterOperations.cpp 2018-01-16 18:59:09 UTC (rev 226981)
@@ -35,7 +35,7 @@
static inline IntSize outsetSizeForBlur(float stdDeviation)
{
- auto kernelSize = FEGaussianBlur::calculateUnscaledKernelSize(FloatPoint(stdDeviation, stdDeviation));
+ auto kernelSize = FEGaussianBlur::calculateUnscaledKernelSize({ stdDeviation, stdDeviation });
// We take the half kernel size and multiply it with three, because we run box blur three times.
return {
Modified: trunk/Source/WebCore/rendering/FilterEffectRenderer.h (226980 => 226981)
--- trunk/Source/WebCore/rendering/FilterEffectRenderer.h 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/rendering/FilterEffectRenderer.h 2018-01-16 18:59:09 UTC (rev 226981)
@@ -67,6 +67,7 @@
bool m_startedFilterEffect { false };
};
+// This is used to render filters for the CSS filter: property, and the filter() image function.
class FilterEffectRenderer final : public Filter {
WTF_MAKE_FAST_ALLOCATED;
public:
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFilter.cpp (226980 => 226981)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFilter.cpp 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFilter.cpp 2018-01-16 18:59:09 UTC (rev 226981)
@@ -34,18 +34,12 @@
m_absoluteFilterRegion = absoluteTransform.mapRect(filterRegion);
}
-float SVGFilter::applyHorizontalScale(float value) const
+FloatSize SVGFilter::scaledByFilterResolution(FloatSize size) const
{
if (m_effectBBoxMode)
- value *= m_targetBoundingBox.width();
- return Filter::applyHorizontalScale(value) * m_absoluteFilterRegion.width() / m_filterRegion.width();
-}
+ size = size * m_targetBoundingBox.size();
-float SVGFilter::applyVerticalScale(float value) const
-{
- if (m_effectBBoxMode)
- value *= m_targetBoundingBox.height();
- return Filter::applyVerticalScale(value) * m_absoluteFilterRegion.height() / m_filterRegion.height();
+ return Filter::scaledByFilterResolution(size) * m_absoluteFilterRegion.size() / m_filterRegion.size();
}
Ref<SVGFilter> SVGFilter::create(const AffineTransform& absoluteTransform, const FloatRect& absoluteSourceDrawingRegion, const FloatRect& targetBoundingBox, const FloatRect& filterRegion, bool effectBBoxMode)
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h (226980 => 226981)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h 2018-01-16 18:58:47 UTC (rev 226980)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h 2018-01-16 18:59:09 UTC (rev 226981)
@@ -36,8 +36,7 @@
FloatRect filterRegionInUserSpace() const { return m_filterRegion; }
FloatRect filterRegion() const final { return m_absoluteFilterRegion; }
- float applyHorizontalScale(float value) const final;
- float applyVerticalScale(float value) const final;
+ FloatSize scaledByFilterResolution(FloatSize) const final;
FloatRect sourceImageRect() const final { return m_absoluteSourceDrawingRegion; }
FloatRect targetBoundingBox() const { return m_targetBoundingBox; }