Bug 227748 - [GPU Process] Enable drawing the SVGImage in the GPU Process
Summary: [GPU Process] Enable drawing the SVGImage in the GPU Process
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on: 235758
Blocks: 236508
  Show dependency treegraph
 
Reported: 2021-07-07 09:57 PDT by Myles C. Maxfield
Modified: 2022-04-18 15:45 PDT (History)
18 users (show)

See Also:


Attachments
Patch (107.01 KB, patch)
2022-02-07 17:19 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (22.96 KB, patch)
2022-02-10 00:12 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (22.87 KB, patch)
2022-02-14 00:22 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (29.94 KB, patch)
2022-02-16 11:45 PST, 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 Myles C. Maxfield 2021-07-07 09:57:05 PDT
Reverts https://bugs.webkit.org/show_bug.cgi?id=227519
Comment 1 Radar WebKit Bug Importer 2021-07-14 09:58:22 PDT
<rdar://problem/80582699>
Comment 2 Said Abou-Hallawa 2022-02-07 15:30:16 PST
We need to revert all these changes:

r279722
r284740
r283531
Comment 3 Said Abou-Hallawa 2022-02-07 15:32:10 PST
The intermediate ImageBuffers of the SVGImage need to be "really" compatible with the underlying ImageBuffer of the GraphicsContext. This is tracked by bug 235758.
Comment 4 Said Abou-Hallawa 2022-02-07 17:19:40 PST
Created attachment 451181 [details]
Patch
Comment 5 Said Abou-Hallawa 2022-02-10 00:12:48 PST
Created attachment 451502 [details]
Patch
Comment 6 Said Abou-Hallawa 2022-02-14 00:22:53 PST
Created attachment 451869 [details]
Patch
Comment 7 Sam Weinig 2022-02-14 13:03:06 PST
Comment on attachment 451869 [details]
Patch

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

> Source/WebCore/svg/graphics/SVGImage.cpp:206
> +    auto imageBuffer = ImageBuffer::create(size(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);

Why is this being hard coded to SRGB?
Comment 8 Said Abou-Hallawa 2022-02-16 11:45:09 PST
Created attachment 452221 [details]
Patch
Comment 9 Simon Fraser (smfr) 2022-02-16 13:19:04 PST
Comment on attachment 452221 [details]
Patch

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

> Source/WebCore/svg/graphics/SVGImage.cpp:213
> +    auto imageBuffer = ImageBuffer::create(size(), renderingMode, ShouldUseDisplayList::No, RenderingPurpose::DOM, 1, colorSpace, PixelFormat::BGRA8, hostWindow);

Why isn't this createCompatibleBuffer()?
Comment 10 Said Abou-Hallawa 2022-02-16 13:28:17 PST
Comment on attachment 452221 [details]
Patch

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

>> Source/WebCore/svg/graphics/SVGImage.cpp:213
>> +    auto imageBuffer = ImageBuffer::create(size(), renderingMode, ShouldUseDisplayList::No, RenderingPurpose::DOM, 1, colorSpace, PixelFormat::BGRA8, hostWindow);
> 
> Why isn't this createCompatibleBuffer()?

Because it is hard to a GraphicsContext for all the callers. Here are a few examples:

- (void)getPreviewSnapshotImage:(CGImageRef*)cgImage andRects:(NSArray **)rects
+ (CGImageRef)imageForURL:(NSURL *)url
- (WebUITextIndicatorData *)initWithImage:(CGImageRef)image textIndicatorData:(const WebCore::TextIndicatorData&)indicatorData scale:(CGFloat)scale
static RetainPtr<UIImage> uiImageForImage(Image* image)
Comment 11 Said Abou-Hallawa 2022-02-16 13:29:44 PST
Comment on attachment 452221 [details]
Patch

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

>>> Source/WebCore/svg/graphics/SVGImage.cpp:213
>>> +    auto imageBuffer = ImageBuffer::create(size(), renderingMode, ShouldUseDisplayList::No, RenderingPurpose::DOM, 1, colorSpace, PixelFormat::BGRA8, hostWindow);
>> 
>> Why isn't this createCompatibleBuffer()?
> 
> Because it is hard to a GraphicsContext for all the callers. Here are a few examples:
> 
> - (void)getPreviewSnapshotImage:(CGImageRef*)cgImage andRects:(NSArray **)rects
> + (CGImageRef)imageForURL:(NSURL *)url
> - (WebUITextIndicatorData *)initWithImage:(CGImageRef)image textIndicatorData:(const WebCore::TextIndicatorData&)indicatorData scale:(CGFloat)scale
> static RetainPtr<UIImage> uiImageForImage(Image* image)

Because it is hard to *get* a GraphicsContext ...
Comment 12 Simon Fraser (smfr) 2022-02-16 14:07:59 PST
Comment on attachment 452221 [details]
Patch

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

>>>> Source/WebCore/svg/graphics/SVGImage.cpp:213
>>>> +    auto imageBuffer = ImageBuffer::create(size(), renderingMode, ShouldUseDisplayList::No, RenderingPurpose::DOM, 1, colorSpace, PixelFormat::BGRA8, hostWindow);
>>> 
>>> Why isn't this createCompatibleBuffer()?
>> 
>> Because it is hard to a GraphicsContext for all the callers. Here are a few examples:
>> 
>> - (void)getPreviewSnapshotImage:(CGImageRef*)cgImage andRects:(NSArray **)rects
>> + (CGImageRef)imageForURL:(NSURL *)url
>> - (WebUITextIndicatorData *)initWithImage:(CGImageRef)image textIndicatorData:(const WebCore::TextIndicatorData&)indicatorData scale:(CGFloat)scale
>> static RetainPtr<UIImage> uiImageForImage(Image* image)
> 
> Because it is hard to *get* a GraphicsContext ...

I see. This is just getting a NativeImage from an SVGImage without any notion of what the caller will do with it. In that case it might be risky to sometimes return an Accelerated image.

For the code paths involving the GPUP, it might make more sense to create a version of this that takes the destination context.
Comment 13 Said Abou-Hallawa 2022-02-16 14:56:00 PST
Comment on attachment 452221 [details]
Patch

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

>>>>> Source/WebCore/svg/graphics/SVGImage.cpp:213
>>>>> +    auto imageBuffer = ImageBuffer::create(size(), renderingMode, ShouldUseDisplayList::No, RenderingPurpose::DOM, 1, colorSpace, PixelFormat::BGRA8, hostWindow);
>>>> 
>>>> Why isn't this createCompatibleBuffer()?
>>> 
>>> Because it is hard to a GraphicsContext for all the callers. Here are a few examples:
>>> 
>>> - (void)getPreviewSnapshotImage:(CGImageRef*)cgImage andRects:(NSArray **)rects
>>> + (CGImageRef)imageForURL:(NSURL *)url
>>> - (WebUITextIndicatorData *)initWithImage:(CGImageRef)image textIndicatorData:(const WebCore::TextIndicatorData&)indicatorData scale:(CGFloat)scale
>>> static RetainPtr<UIImage> uiImageForImage(Image* image)
>> 
>> Because it is hard to *get* a GraphicsContext ...
> 
> I see. This is just getting a NativeImage from an SVGImage without any notion of what the caller will do with it. In that case it might be risky to sometimes return an Accelerated image.
> 
> For the code paths involving the GPUP, it might make more sense to create a version of this that takes the destination context.

I can add the new version for nativeImage in a separate patch. Or maybe I can pass an optional pointer to GraphicsContext to the existing one.
Comment 14 EWS 2022-02-16 16:12:51 PST
Committed r289981 (247367@main): <https://commits.webkit.org/247367@main>

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