[webkit-reviews] review granted: [Bug 212649] Multiple SVG Filters Unexpectedly lightens image using linearRGB : [Attachment 401496] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jun 10 11:35:34 PDT 2020


Darin Adler <darin at apple.com> has granted guowei_yang at apple.com's request for
review:
Bug 212649: Multiple SVG Filters Unexpectedly lightens image using linearRGB
https://bugs.webkit.org/show_bug.cgi?id=212649

Attachment 401496: Patch

https://bugs.webkit.org/attachment.cgi?id=401496&action=review




--- Comment #44 from Darin Adler <darin at apple.com> ---
Comment on attachment 401496
  --> https://bugs.webkit.org/attachment.cgi?id=401496
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=401496&action=review

r=me as is; some ideas for further improvement, and still keeping in mind
Simon’s suggestion that we fine a better long term solution without using #if
CG to compensate for the fact that we didn’t make a good enough abstraction.

> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:443
> +    auto inputImgBuffer = ImageBuffer::create(clampedSize,
m_filter.renderingMode(), m_filter.filterScale(), operatingColorSpace());

WebKit coding style discourages using abbreviations like "img". I suggest just
naming this local "buffer". I don’t think a longer name is important to help a
reader understand the code or disambiguate anything.

> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:447
> +    return convertImageBufferToColorSpace(targetColorSpace,
*inputImgBuffer.get(), outputFormat);

Should not need the ".get()" here.

> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:472
> +	       if (requiresAdditionalColorSpaceConversion(colorSpace)) {

Seems we could factor this slightly better. It’s the same code as below in this
function and as the code in copyPremultipliedResult.

> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:473
> +		   auto convertedImageData =
convertImageBufferToColorSpace(colorSpace.value(), *m_imageBufferResult.get(),
AlphaPremultiplication::Unpremultiplied);

Should not need the ".get()" here.

Also, not sure if others have the same preference, but I prefer the
"*colorSpace" syntax to the "colorSpace.value()" syntax.

> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:500
> +    RefPtr<ImageData> convertedImageData;
> +    if (requiresAdditionalColorSpaceConversion(colorSpace))
> +	   convertedImageData =
convertImageDataToColorSpace(colorSpace.value(), *m_unmultipliedImageResult,
AlphaPremultiplication::Unpremultiplied);
> +    else
> +	   convertedImageData = m_unmultipliedImageResult;
> +    if (!convertedImageData)
> +	   return;
> +    copyImageBytes(*convertedImageData->data(), destination, rect);

Seems that we could factor this better. This is the same epilogue as in
copyPremultipliedResult just below.

> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:518
> +	       if (requiresAdditionalColorSpaceConversion(colorSpace)) {
> +		   auto convertedImageData =
convertImageBufferToColorSpace(colorSpace.value(), *m_imageBufferResult.get(),
AlphaPremultiplication::Premultiplied);
> +		   if (!convertedImageData)
> +		       return;
> +		   copyImageBytes(*convertedImageData->data(), destination,
rect);
> +		   return;
> +	       }

Ditto.

> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:540
> +    RefPtr<ImageData> convertedImageData;
> +    if (requiresAdditionalColorSpaceConversion(colorSpace))
> +	   convertedImageData =
convertImageDataToColorSpace(colorSpace.value(), *m_premultipliedImageResult,
AlphaPremultiplication::Premultiplied);
> +    else
> +	   convertedImageData = m_premultipliedImageResult;
> +    if (!convertedImageData)
> +	   return;
> +    copyImageBytes(*convertedImageData->data(), destination, rect);

Ditto.

> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:597
> +    if (!dstColorSpace || resultColorSpace() == dstColorSpace.value())
> +	   return false;
> +    return true;

I would have written:

    return dstColorSpace && resultColorSpace() != *dstColorSpace;


More information about the webkit-reviews mailing list