Bug 213403 - [CG] REGRESSION (r256892): Luminance SVG mask is not applied when accelerated drawing is enabled
Summary: [CG] REGRESSION (r256892): Luminance SVG mask is not applied when accelerated...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-06-19 13:30 PDT by Said Abou-Hallawa
Modified: 2020-06-19 17:00 PDT (History)
5 users (show)

See Also:


Attachments
test case (490 bytes, text/html)
2020-06-19 13:30 PDT, Said Abou-Hallawa
no flags Details
Patch (3.52 KB, patch)
2020-06-19 13:41 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (3.48 KB, patch)
2020-06-19 14:17 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2020-06-19 13:30:30 PDT
Created attachment 402317 [details]
test case

Open the attached test case.

Result: A 200x200 green rectangle
Expected: A 200x200 green rectangle with a 100x100 white hole in the middle.
Comment 1 Said Abou-Hallawa 2020-06-19 13:34:21 PDT
This is a regression of r256892. Before this change

void ImageBuffer::genericConvertToLuminanceMask()
{
    auto srcPixelArray = getUnmultipliedImageData(luminanceRect);
    ...
}

RefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, IntSize* pixelArrayDimensions, CoordinateSystem coordinateSystem) const
{
    if (context().isAcceleratedContext())
        flushContext();
}

After this change:

void ConcreteImageBuffer::convertToLuminanceMask() override
{
    if (auto* backend = ensureBackendCreated()) {
        flushDrawingContext();
        backend->convertToLuminanceMask();
    }
}

And ImageBufferBackend::convertToLuminanceMask() does not do any flushing. Notice flushDrawingContext() flushes only the drawing items in the display list if they exist.

If the ImageBuffer is backed by an IOSurface, convertToLuminanceMask() will act on non up-to-date backend. So we need to call ConcreteImageBuffer::flushContext() instead.
Comment 2 Said Abou-Hallawa 2020-06-19 13:38:52 PDT
<rdar://problem/64489419>
Comment 3 Said Abou-Hallawa 2020-06-19 13:41:47 PDT
Created attachment 402318 [details]
Patch
Comment 4 Darin Adler 2020-06-19 14:00:54 PDT
Comment on attachment 402318 [details]
Patch

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

> Source/WebCore/platform/graphics/ConcreteImageBuffer.h:183
> +            const_cast<ConcreteImageBuffer&>(*this).flushContext();

This is not a const member function — why is the const_cast needed?
Comment 5 Simon Fraser (smfr) 2020-06-19 14:10:06 PDT
Comment on attachment 402318 [details]
Patch

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

> Source/WebCore/platform/graphics/ConcreteImageBuffer.h:184
>              backend->convertToLuminanceMask();

Why doesn't the backend flush inside convertToLuminanceMask()?
Comment 6 Said Abou-Hallawa 2020-06-19 14:17:09 PDT
Created attachment 402324 [details]
Patch
Comment 7 Said Abou-Hallawa 2020-06-19 14:36:42 PDT
Comment on attachment 402318 [details]
Patch

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

>> Source/WebCore/platform/graphics/ConcreteImageBuffer.h:183
>> +            const_cast<ConcreteImageBuffer&>(*this).flushContext();
> 
> This is not a const member function — why is the const_cast needed?

Copy/paste mistake. Fixed.

>> Source/WebCore/platform/graphics/ConcreteImageBuffer.h:184
>>              backend->convertToLuminanceMask();
> 
> Why doesn't the backend flush inside convertToLuminanceMask()?

ConcreteImageBuffer::flushContext() may call DisplayList::ImageBuffer::flushDrawingContext() which replays back the display items before calling ImageBufferBackend::flushContext(). If I move the call to flushContext() to ImageBufferBackend::convertToLuminanceMask(), replaying the display items back will not be possible.
Comment 8 EWS 2020-06-19 17:00:06 PDT
Committed r263297: <https://trac.webkit.org/changeset/263297>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 402324 [details].