Bug 227748

Summary: [GPU Process] Enable drawing the SVGImage in the GPU Process
Product: WebKit Reporter: Myles C. Maxfield <mmaxfield>
Component: ImagesAssignee: Said Abou-Hallawa <sabouhallawa>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, changseok, dino, esprehn+autocc, ews-watchlist, fmalita, fred.wang, glenn, gyuyoung.kim, Hironori.Fujii, kondapallykalyan, pdr, sabouhallawa, sam, schenney, sergio, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=227519
https://bugs.webkit.org/show_bug.cgi?id=230886
https://bugs.webkit.org/show_bug.cgi?id=231062
https://bugs.webkit.org/show_bug.cgi?id=231001
https://bugs.webkit.org/show_bug.cgi?id=238893
Bug Depends on: 235758    
Bug Blocks: 236508    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

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].