[webkit-changes] [WebKit/WebKit] 265f43: General cleanup of FilterOperations

Sam Weinig noreply at github.com
Wed May 29 20:08:06 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 265f430df9e58c0d9c2ebcea32a2d4da4f047d59
      https://github.com/WebKit/WebKit/commit/265f430df9e58c0d9c2ebcea32a2d4da4f047d59
  Author: Sam Weinig <weinig at apple.com>
  Date:   2024-05-29 (Wed, 29 May 2024)

  Changed paths:
    M Source/WebCore/animation/CSSPropertyAnimation.cpp
    M Source/WebCore/css/ComputedStyleExtractor.cpp
    M Source/WebCore/editing/ReplaceSelectionCommand.cpp
    M Source/WebCore/platform/animation/AcceleratedEffect.cpp
    M Source/WebCore/platform/animation/AcceleratedEffectValues.cpp
    M Source/WebCore/platform/graphics/GraphicsLayer.cpp
    M Source/WebCore/platform/graphics/GraphicsLayer.h
    M Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
    M Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
    M Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h
    M Source/WebCore/platform/graphics/ca/PlatformCAFilters.h
    M Source/WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.h
    M Source/WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm
    M Source/WebCore/platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm
    M Source/WebCore/platform/graphics/filters/FilterOperations.cpp
    M Source/WebCore/platform/graphics/filters/FilterOperations.h
    M Source/WebCore/platform/graphics/nicosia/NicosiaAnimation.cpp
    M Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
    M Source/WebCore/platform/graphics/texmap/TextureMapper.cpp
    M Source/WebCore/platform/graphics/texmap/TextureMapper.h
    M Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
    M Source/WebCore/rendering/CSSFilter.cpp
    M Source/WebCore/rendering/ReferencedSVGResources.cpp
    M Source/WebCore/rendering/RenderLayerFilters.cpp
    M Source/WebCore/rendering/style/RenderStyle.h
    M Source/WebCore/rendering/style/RenderStyleInlines.h
    M Source/WebCore/rendering/style/RenderStyleSetters.h
    M Source/WebCore/rendering/style/StyleFilterImage.cpp
    M Source/WebCore/style/FilterOperationsBuilder.cpp
    M Source/WebCore/style/StyleBuilderCustom.h
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
    M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h
    M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm
    M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemoteProperties.h
    M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemoteProperties.serialization.in
    M Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp

  Log Message:
  -----------
  General cleanup of FilterOperations
https://bugs.webkit.org/show_bug.cgi?id=274781

Reviewed by Darin Adler.

Makes some small improvements to the FilterOperations type:

- Use Ref instead of RefPtr in operations vector.
- Made immutable. All construction already happened in one shot in the builder
  or blend functions, or was a full replacement, so this just meant removing
  non-const accessors and removing the clear() function.
- Expose iterators directly to avoid clients accessing the underlying vector.

The fallout of using Ref for the operations vector led to some fallout requiring
more use of Ref or reference types to indicate non-null state.

* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::ComputedStyleExtractor::valueForFilter):
    - Use isEmpty() from FilterOperations directly, and update for Ref values
      during iteration.

* Source/WebCore/platform/animation/AcceleratedEffectValues.cpp:
(WebCore::AcceleratedEffectValues::AcceleratedEffectValues):
(WebCore::AcceleratedEffectValues::clone const):
    - Use clone() helper and copy construction.

* Source/WebCore/platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::validateFilterOperations):
     - Use isEmpty() from FilterOperations directly.

* Source/WebCore/platform/graphics/GraphicsLayer.h:
(WebCore::FilterAnimationValue::FilterAnimationValue):
    - Use clone() helper.

(WebCore::GraphicsLayer::clearFilters):
(WebCore::GraphicsLayer::clearBackdropFilters):
    - Re-initialize the whole type rather than clearing internal state.

* Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::createFilterAnimationsFromKeyframes):
(WebCore::GraphicsLayerCA::setFilterAnimationEndpoints):
(WebCore::GraphicsLayerCA::setFilterAnimationKeyframes):
    - Update to account for Ref FilterOperations.

* Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h:
* Source/WebCore/platform/graphics/ca/PlatformCAFilters.h:
* Source/WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.h:
* Source/WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm:
* Source/WebCore/platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm:
    - Update to use FilterOperation& and Ref<FilterOperation> parameters. All
      implementations already assumed the values were non-null, so now the types
      also know it.

* Source/WebCore/platform/graphics/filters/FilterOperations.cpp:
(WebCore::FilterOperations::FilterOperations):
(WebCore::FilterOperations::operator== const):
(WebCore::FilterOperations::operationsMatch const):
    - Update to account for Ref values in m_operations.

(WebCore::FilterOperations::hasReferenceFilter const):
    - Use new hasFilterOfType<T> helper.

(WebCore::FilterOperations::outsets const):
    - Update to account for Ref values in m_operations.

(WebCore::FilterOperations::hasFilterThatAffectsOpacity const):
(WebCore::FilterOperations::hasFilterThatMovesPixels const):
(WebCore::FilterOperations::hasFilterThatShouldBeRestrictedBySecurityOrigin const):
    - Use WTF::anyOf rather than explicit loop.

(WebCore::FilterOperations::blend const):
    - Use explicit Vector<Ref<FilterOperation>> for constructing blended results,
      allowing for the use of reserveInitialCapacity optimization.

(WebCore::operator<<):
    - Remove now unnecessary null-check and use existing container serializer
      instead of re-implementing.

* Source/WebCore/platform/graphics/filters/FilterOperations.h:
(WebCore::FilterOperations::FilterOperations):
    - Add copy and move constructors/assignment operators.

(WebCore::FilterOperations::clone const):
    - Add helper to create a clone() of each operation.

(WebCore::FilterOperations::operations const):
    - Remove non-const overloads.

(WebCore::FilterOperations::at const):
    - Update to account for Ref in m_operations.

(WebCore::FilterOperations::hasFilterOfType const):
    - Helper which can check if any operation is a particular type.

(WebCore::FilterOperations::clear): Deleted.
(WebCore::FilterOperations::operations): Deleted.
(WebCore::FilterOperations::setOperations): Deleted.
    - Remove member functions that mutated the underlying vector.

* Source/WebCore/style/FilterOperationsBuilder.cpp:
(WebCore::Style::createFilterOperations):
    - Use explicit Vector<Ref<FilterOperation>> for constructing results
      and shrinkToFit at the end.

* Source/WebCore/rendering/CSSFilter.cpp:
* Source/WebCore/rendering/ReferencedSVGResources.cpp:
* Source/WebCore/rendering/RenderLayerFilters.cpp:
* Source/WebCore/rendering/style/StyleFilterImage.cpp:
    - Update to account for Ref in m_operations.

* Source/WebCore/rendering/style/RenderStyleInlines.h:
(WebCore::RenderStyle::hasAppleColorFilter const):
(WebCore::RenderStyle::hasFilter const):
(WebCore::RenderStyle::hasBackdropFilter const):
    - Use isEmpty() directly on FilterOperations.

* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
    - Update to account for Ref in m_operations.

* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::updatePageBackgroundLayers):
    - Construct FilterOperations directly rather than using temporary vector.

* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h:
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm:
(WebKit::PlatformCAAnimationRemote::setFromValue):
(WebKit::PlatformCAAnimationRemote::setToValue):
(WebKit::PlatformCAAnimationRemote::setValues):
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemoteProperties.h:
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemoteProperties.serialization.in:
    - Update for use of Ref and reference types for FilterOperation.

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



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


More information about the webkit-changes mailing list