Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 222707e7516546a71f05f44449f58374a2bc727c
      
https://github.com/WebKit/WebKit/commit/222707e7516546a71f05f44449f58374a2bc727c
  Author: Said Abou-Hallawa <s...@apple.com>
  Date:   2024-04-25 (Thu, 25 Apr 2024)

  Changed paths:
    A LayoutTests/fast/canvas/canvas-filter-basics-expected.txt
    A LayoutTests/fast/canvas/canvas-filter-basics.html
    A LayoutTests/fast/canvas/canvas-filter-bounding-rect-expected.html
    A LayoutTests/fast/canvas/canvas-filter-bounding-rect.html
    A LayoutTests/fast/canvas/canvas-filter-drawing-expected.html
    A LayoutTests/fast/canvas/canvas-filter-drawing.html
    A LayoutTests/fast/canvas/canvas-filter-repaint-rect-expected.html
    A LayoutTests/fast/canvas/canvas-filter-repaint-rect.html
    A LayoutTests/fast/canvas/canvas-filter-save-restore-expected.html
    A LayoutTests/fast/canvas/canvas-filter-save-restore.html
    A LayoutTests/fast/canvas/resources/100x100-green-rect-filter-blur.svg
    A 
LayoutTests/fast/canvas/resources/100x100-green-rect-filter-drop-shadow.svg
    R 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject-expected.txt
    R 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.blur.exceptions-expected.txt
    R 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.colorMatrix-expected.txt
    R 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.componentTransfer.discrete-expected.txt
    R 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.componentTransfer.gamma-expected.txt
    R 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.componentTransfer.identity-expected.txt
    R 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.componentTransfer.linear-expected.txt
    R 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.componentTransfer.table-expected.txt
    R 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.convolveMatrix.exceptions-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.tentative-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.value-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/reset/2d.reset.state.filter-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.tentative-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.tentative.worker-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/filters/2d.filter.value-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/filters/2d.filter.value.worker-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/reset/2d.reset.state.filter-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/reset/2d.reset.state.filter.worker-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/dom/idlharness.https_exclude=(Document_Window_HTML._)-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/dom/idlharness.worker-expected.txt
    M 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/dom/idlharness.https_exclude=(Document_Window_HTML._)-expected.txt
    M 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/dom/idlharness.worker-expected.txt
    M 
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt
    M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp
    M Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.h
    A Source/WebCore/html/canvas/CanvasFilterTargetSwitcher.cpp
    A Source/WebCore/html/canvas/CanvasFilterTargetSwitcher.h
    M Source/WebCore/html/canvas/CanvasFilters.idl
    M Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
    M Source/WebCore/html/canvas/CanvasRenderingContext2D.h
    M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
    M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h
    M Source/WebCore/platform/RectEdges.h
    M Source/WebCore/platform/graphics/FloatRect.h

  Log Message:
  -----------
  Support CanvasRenderingContext2D.filter
https://bugs.webkit.org/show_bug.cgi?id=198416
rdar://51303686

Reviewed by Simon Fraser.

This implements the canvas filter API. According to the specs, the filter will
be defined as a string very similar to the CSS filter definition. An SVG filter
can be accessed via a URL like this `filter : url(#id);`.

To implement this feature without many changes in the CanvasRenderingContext2D
code, the new class CanvasFilterTargetSwitcher will be added. In its constructor
we are going to switch the rendering context to a source ImageBuffer. The next
draw commands will be drawn to this ImageBuffer. In its destructor, the filter
will be applied to the source ImageBuffer and the result will be composited back
to the original context.

Specs link: https://html.spec.whatwg.org/multipage/canvas.html#canvasfilters

* LayoutTests/fast/canvas/canvas-filter-basics-expected.txt: Added.
* LayoutTests/fast/canvas/canvas-filter-basics.html: Added.
* LayoutTests/fast/canvas/canvas-filter-bounding-rect-expected.html: Added.
* LayoutTests/fast/canvas/canvas-filter-bounding-rect.html: Added.
* LayoutTests/fast/canvas/canvas-filter-drawing-expected.html: Added.
* LayoutTests/fast/canvas/canvas-filter-drawing.html: Added.
* LayoutTests/fast/canvas/canvas-filter-repaint-rect-expected.html: Added.
* LayoutTests/fast/canvas/canvas-filter-repaint-rect.html: Added.
* LayoutTests/fast/canvas/canvas-filter-save-restore-expected.html: Added.
* LayoutTests/fast/canvas/canvas-filter-save-restore.html: Added.
* LayoutTests/fast/canvas/resources/100x100-green-rect-filter-blur.svg: Added.
* LayoutTests/fast/canvas/resources/100x100-green-rect-filter-drop-shadow.svg: 
Added.
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject-expected.txt:
 Removed.
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.blur.exceptions-expected.txt:
 Removed.
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.colorMatrix-expected.txt:
 Removed.
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.componentTransfer.discrete-expected.txt:
 Removed.
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.componentTransfer.gamma-expected.txt:
 Removed.
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.componentTransfer.identity-expected.txt:
 Removed.
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.componentTransfer.linear-expected.txt:
 Removed.
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.componentTransfer.table-expected.txt:
 Removed.
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.convolveMatrix.exceptions-expected.txt:
 Removed.
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.canvasFilterObject.tentative-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/filters/2d.filter.value-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/reset/2d.reset.state.filter-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.tentative-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.tentative.worker-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/filters/2d.filter.value-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/filters/2d.filter.value.worker-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/reset/2d.reset.state.filter-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/reset/2d.reset.state.filter.worker-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/dom/idlharness.https_exclude=(Document_Window_HTML._)-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/dom/idlharness.worker-expected.txt:
* 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/dom/idlharness.https_exclude=(Document_Window_HTML._)-expected.txt:
* 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/dom/idlharness.worker-expected.txt:
* 
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp:
(WebCore::CSSPropertyParserWorkerSafe::parseFilterString):
* Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.h:
* Source/WebCore/html/canvas/CanvasFilterTargetSwitcher.cpp: Added.
(WebCore::CanvasFilterTargetSwitcher::create):
(WebCore::CanvasFilterTargetSwitcher::CanvasFilterTargetSwitcher):
(WebCore::CanvasFilterTargetSwitcher::~CanvasFilterTargetSwitcher):
(WebCore::CanvasFilterTargetSwitcher::outsets const):
* Source/WebCore/html/canvas/CanvasFilterTargetSwitcher.h: Added.
(WebCore::CanvasFilterTargetSwitcher::expandedBounds const):
* Source/WebCore/html/canvas/CanvasFilters.idl:
* Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setFilterStringWithoutUpdatingStyle):
(WebCore::CanvasRenderingContext2D::createFilter const):
(WebCore::CanvasRenderingContext2D::calculateFilterOutsets const):
* Source/WebCore/html/canvas/CanvasRenderingContext2D.h:
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::State::State):
(WebCore::CanvasRenderingContext2DBase::setFilterString):
(WebCore::CanvasRenderingContext2DBase::fillInternal):
(WebCore::CanvasRenderingContext2DBase::strokeInternal):
(WebCore::CanvasRenderingContext2DBase::fillRect):
(WebCore::CanvasRenderingContext2DBase::strokeRect):
(WebCore::CanvasRenderingContext2DBase::drawImage):
(WebCore::CanvasRenderingContext2DBase::drawingContext const):
(WebCore::CanvasRenderingContext2DBase::inflatedStrokeRect const):
(WebCore::CanvasRenderingContext2DBase::drawTextUnchecked):
(WebCore::CanvasRenderingContext2DBase::inflateStrokeRect const): Deleted.
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h:
(WebCore::CanvasRenderingContext2DBase::filterString const):
(WebCore::CanvasRenderingContext2DBase::setFilterStringWithoutUpdatingStyle):
(WebCore::CanvasRenderingContext2DBase::createFilter const):
(WebCore::CanvasRenderingContext2DBase::calculateFilterOutsets const):
(WebCore::CanvasRenderingContext2DBase::setFilterTargetSwitcher):
* Source/WebCore/platform/RectEdges.h:
(WebCore::RectEdges::RectEdges):
* Source/WebCore/platform/graphics/FloatRect.h:
(WebCore::operator+):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to