Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6b45e20e451f2610bac08657b24de4439e40f2c0
      
https://github.com/WebKit/WebKit/commit/6b45e20e451f2610bac08657b24de4439e40f2c0
  Author: Simon Fraser <[email protected]>
  Date:   2025-12-22 (Mon, 22 Dec 2025)

  Changed paths:
    M Source/WebCore/platform/graphics/GraphicsContext.cpp
    M Source/WebCore/platform/graphics/coreimage/FEFloodCoreImageApplier.mm
    M Source/WebCore/platform/graphics/coreimage/FilterImageCoreImage.mm
    M Source/WebCore/platform/graphics/filters/Filter.cpp
    M Source/WebCore/platform/graphics/filters/Filter.h
    M Source/WebCore/platform/graphics/filters/FilterImage.cpp
    M Source/WebCore/platform/graphics/filters/FilterImage.h
    M 
WebKitLibraries/SDKs/watchos26.0-additions.sdk/System/Library/Frameworks/CoreImage.framework/CoreImage.tbd
    M 
WebKitLibraries/SDKs/watchsimulator26.0-additions.sdk/System/Library/Frameworks/CoreImage.framework/CoreImage.tbd

  Log Message:
  -----------
  [CI Filters] Implement filter regions
https://bugs.webkit.org/show_bug.cgi?id=304629
rdar://167058188

Reviewed by Mike Wyrzykowski.

At each step in the filter chain, we potentially have to set geometry based on 
the filter
primitive subregion.

Core Image uses flipped coordinates, and only resolves those coordinates once 
we do the
final render to an IOSurface. The existing code, using `[CIContext
render:toIOSurface:bounds:colorSpace]`, uses the IOSurface size to resolve 
coordinates,
but that's just the size of the last filter output, not necessarily the 
`filterRegion`
size of the `<filter>`. The `bounds` parameter is not used to resolve these 
coordinates
either.

To fix this shortcoming, use `[CIContext startTaskToRender:fromRect:...]` 
instead, where
the `fromRect` does what we need: we supply the size of the `filterRegion`. 
That allows us
to specify the extents of intermediate CIImages by using the filterRegion as 
input to
flipping math.

The `Filter` was not accessible to `FilterImage::imageBuffer()`, which is where 
the Core
Image implementation needs to get `filterRegion`, so wrap the fetching of the 
final
ImageBuffer in `Filter::filterResultBuffer()` which can pass in the 
filterRegion, scaled
to absolute coordinates.

`FEFloodCoreImageApplier::apply` is fixed to do this filter primitive subregion
computation, setting the extent of the CIImage. There will be other sites that 
need to do
this in future.

* Source/WebCore/platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::drawFilteredImageBuffer):
* Source/WebCore/platform/graphics/coreimage/FEFloodCoreImageApplier.mm:
(WebCore::FEFloodCoreImageApplier::apply const):
* Source/WebCore/platform/graphics/coreimage/FilterImageCoreImage.mm:
(WebCore::FilterImage::filterResultImageBuffer):
(WebCore::FilterImage::imageBufferFromCIImage): Deleted.
* Source/WebCore/platform/graphics/filters/Filter.cpp:
(WebCore::Filter::filterResultBuffer const):
* Source/WebCore/platform/graphics/filters/Filter.h:
* Source/WebCore/platform/graphics/filters/FilterImage.cpp:
(WebCore::FilterImage::imageBuffer):
* Source/WebCore/platform/graphics/filters/FilterImage.h:
* 
WebKitLibraries/SDKs/watchos26.0-additions.sdk/System/Library/Frameworks/CoreImage.framework/CoreImage.tbd:
 Make watchOS build.
* 
WebKitLibraries/SDKs/watchsimulator26.0-additions.sdk/System/Library/Frameworks/CoreImage.framework/CoreImage.tbd:

Canonical link: https://commits.webkit.org/304893@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to