RESOLVED FIXED Bug 232457
[GPU Process] [Filters 3/23] Make SVGFilter and CSSFilter work in the same coordinate system
https://bugs.webkit.org/show_bug.cgi?id=232457
Summary [GPU Process] [Filters 3/23] Make SVGFilter and CSSFilter work in the same co...
Said Abou-Hallawa
Reported 2021-10-28 15:09:07 PDT
Currently SVGFilter sets the following members of Filter 1. AffineTransform m_absoluteTransform: this is the scaling part from the transformation from the target element to the outermost coordinate system 2. FloatSize m_filterResolution: this is the clamping scale if the size of the result ImageBuffers exceeds MaxClampedArea And the CSSFilter sets the following member of Filter: 1. float m_filterScale: this is the document().deviceScaleFactor() The discrepancy happens also when creating the result ImageBuffers. For SVGFilter, we create them with scaleFactor=1. This means the logicalSize == backendSize. But for CSSFilter we create them with scaleFactor = m_filterScale. This means the logicalSize != backendSize in this case. We need to unify the coordinates system for both filters. We need also to replace the three members by a single FloatSize called "m_filterScale".
Attachments
Patch (108.15 KB, patch)
2021-10-28 15:17 PDT, Said Abou-Hallawa
ews-feeder: commit-queue-
Patch for review (49.08 KB, patch)
2021-10-28 15:19 PDT, Said Abou-Hallawa
simon.fraser: review+
Patch (52.50 KB, patch)
2021-11-09 19:40 PST, Said Abou-Hallawa
no flags
Patch (52.87 KB, patch)
2021-11-09 20:08 PST, Said Abou-Hallawa
no flags
Patch (55.31 KB, patch)
2021-11-09 21:58 PST, Said Abou-Hallawa
no flags
Patch (55.71 KB, patch)
2021-11-10 01:25 PST, Said Abou-Hallawa
ews-feeder: commit-queue-
Patch (58.41 KB, patch)
2021-11-10 06:50 PST, Said Abou-Hallawa
ews-feeder: commit-queue-
Patch (58.41 KB, patch)
2021-11-10 10:47 PST, Said Abou-Hallawa
no flags
Said Abou-Hallawa
Comment 1 2021-10-28 15:17:09 PDT
Said Abou-Hallawa
Comment 2 2021-10-28 15:19:02 PDT
Created attachment 442750 [details] Patch for review
Radar WebKit Bug Importer
Comment 3 2021-11-04 15:10:19 PDT
Said Abou-Hallawa
Comment 4 2021-11-09 19:40:18 PST
Said Abou-Hallawa
Comment 5 2021-11-09 20:08:16 PST
Said Abou-Hallawa
Comment 6 2021-11-09 21:58:16 PST
Said Abou-Hallawa
Comment 7 2021-11-10 01:25:30 PST
Said Abou-Hallawa
Comment 8 2021-11-10 06:50:56 PST
EWS
Comment 9 2021-11-10 10:44:44 PST
ChangeLog entry in LayoutTests/ChangeLog contains OOPS!.
Said Abou-Hallawa
Comment 10 2021-11-10 10:47:46 PST
EWS
Comment 11 2021-11-10 11:21:24 PST
Committed r285597 (244103@main): <https://commits.webkit.org/244103@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 443837 [details].
Darin Adler
Comment 12 2021-11-10 13:31:53 PST
Comment on attachment 443837 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=443837&action=review A few coding style tweak thoughts > Source/WebCore/platform/graphics/coreimage/FilterEffectRendererCoreImage.mm:258 > IntSize destSize = lastEffect.absolutePaintRect().size(); > - destSize.scale(lastEffect.filter().filterScale()); > FloatRect destRect = FloatRect(FloatPoint(), destSize); > return destRect; Could refactor this to this one-liner, which I think would be easier to read: return { { }, lastEffect.absolutePaintRect().size() }; > Source/WebCore/platform/graphics/filters/FEMorphology.cpp:279 > + paintingData.width = ceilf(effectDrawingRect.width()); > + paintingData.height = ceilf(effectDrawingRect.height()); > + paintingData.radiusX = ceilf(radiusX); > + paintingData.radiusY = ceilf(radiusY); Wasteful to call ceilf on integers. Should remove these ceilf calls. > Source/WebCore/platform/graphics/filters/FilterEffect.cpp:287 > IntSize scaledSize(rect.size()); Should remove "scaledSize" and just use rect.size(). > Source/WebCore/platform/graphics/filters/FilterEffect.cpp:301 > IntSize scaledSize(rect.size()); Should remove "scaledSize" and just use rect.size(). > Source/WebCore/platform/graphics/filters/FilterEffect.cpp:315 > IntRect scaledRect(rect); Should remove "scaledRect" and just use rect. > Source/WebCore/platform/graphics/filters/FilterEffect.cpp:316 > IntSize scaledPaintSize(m_absolutePaintRect.size()); Should probably either remove this, or rename it. It’s not scaled. > Source/WebCore/platform/graphics/filters/SourceGraphic.cpp:38 > Filter& filter = this->filter(); > FloatRect paintRect = filter.sourceImageRect(); > - paintRect.scale(filter.filterResolution().width(), filter.filterResolution().height()); > setAbsolutePaintRect(enclosingIntRect(paintRect)); Should change this to a one-liner: setAbsolutePaintRect(enclosingIntRect(filter().sourceImageRect())); > Source/WebCore/rendering/CSSFilter.h:65 > + CSSFilter(float scaleFactor); Maybe put "explicit" here. > Source/WebCore/rendering/RenderLayerFilters.cpp:121 > + // FIXME: this rebuilds the entire effects chain even if the filter style didn't change. We capitalize sentences in FIXME comments. > Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp:193 > + AffineTransform effectiveTransform = AffineTransform(filterScale.width(), 0, 0, filterScale.height(), 0, 0); I suggest using "auto" instead of writing AffineTransform twice.
Said Abou-Hallawa
Comment 13 2021-12-10 01:31:47 PST
Comment on attachment 443837 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=443837&action=review >> Source/WebCore/platform/graphics/coreimage/FilterEffectRendererCoreImage.mm:258 >> return destRect; > > Could refactor this to this one-liner, which I think would be easier to read: > > return { { }, lastEffect.absolutePaintRect().size() }; The whole class was removed. >> Source/WebCore/platform/graphics/filters/FEMorphology.cpp:279 >> + paintingData.radiusY = ceilf(radiusY); > > Wasteful to call ceilf on integers. Should remove these ceilf calls. This will be addressed in bug 234130. >> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:287 >> IntSize scaledSize(rect.size()); > > Should remove "scaledSize" and just use rect.size(). The function FilterEffect::unmultipliedResult() was moved to FilterImage::getPixelBuffer(). This unnecessary local variable was removed. >> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:301 >> IntSize scaledSize(rect.size()); > > Should remove "scaledSize" and just use rect.size(). The functions FilterEffect::premultipliedResult() and the FilterEffect::unmultipliedResult() were merged and moved to FilterImage::getPixelBuffer(). This unnecessary local variable was removed. >> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:315 >> IntRect scaledRect(rect); > > Should remove "scaledRect" and just use rect. This function was moved to FilterImage.cpp and it now takes PixelBuffers for the source and the destination. This unnecessary local variable was removed. >> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:316 >> IntSize scaledPaintSize(m_absolutePaintRect.size()); > > Should probably either remove this, or rename it. It’s not scaled. This unnecessary local variable was removed. >> Source/WebCore/platform/graphics/filters/SourceGraphic.cpp:38 >> setAbsolutePaintRect(enclosingIntRect(paintRect)); > > Should change this to a one-liner: > > setAbsolutePaintRect(enclosingIntRect(filter().sourceImageRect())); This function was completely removed and the base class method FilterEffect::calculateImageRect() is used instead. Also no scaling is required to calculate the imageRect. All imageRects are now in filter coordinates. >> Source/WebCore/rendering/CSSFilter.h:65 >> + CSSFilter(float scaleFactor); > > Maybe put "explicit" here. The constructor of CSSFilter was changed and it takes more than one argument. So no need to "explicit". >> Source/WebCore/rendering/RenderLayerFilters.cpp:121 >> + // FIXME: this rebuilds the entire effects chain even if the filter style didn't change. > > We capitalize sentences in FIXME comments. This will be addressed in bug 234130. >> Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp:193 >> + AffineTransform effectiveTransform = AffineTransform(filterScale.width(), 0, 0, filterScale.height(), 0, 0); > > I suggest using "auto" instead of writing AffineTransform twice. This will be addressed in bug 234130.
Note You need to log in before you can comment on or make changes to this bug.