source: webkit/trunk/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp

Last change on this file was 288352, checked in by Said Abou-Hallawa, 3 years ago

[Cocoa] Accelerated filters are enabled by the wrong setting
https://bugs.webkit.org/show_bug.cgi?id=235376

Reviewed by Simon Fraser.

Source/WebCore:

This patch does the following:

  1. Delete the setting AcceleratedFiltersEnabled since it has not been enabled by any port.
  2. Delete CoreImageAcceleratedFilterRenderEnabled from the experimental features list because CoreImage filters are not ready to be run in the layout tests.
  3. Add AcceleratedFiltersEnabled as an internal feature and use it to enable CoreImage filters for Cocoa ports. and SourceGraphic::createApplier().
  4. Use "Accelerated" instead of using "CoreImage" in the methods of Filter and FilterEffect. The implementation of these methods will be guarded by #if USE(CORE_IMAGE) for Cocoa ports.
  5. Split the method createApplier() to two methods: createSoftwareApplier() and createAcceleratedApplier() and make FilterEffect::createApplier() decide which one to call.
  • Headers.cmake:
  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSFilterImageValue.cpp:

(WebCore::CSSFilterImageValue::image):

  • page/Page.cpp:

(WebCore::Page::acceleratedFiltersEnabled const):

  • page/Page.h:
  • page/Settings.yaml:
  • platform/graphics/coreimage/FEColorMatrixCoreImageApplier.h:
  • platform/graphics/coreimage/FEComponentTransferCoreImageApplier.h:
  • platform/graphics/coreimage/SourceGraphicCoreImageApplier.h:
  • platform/graphics/filters/FEBlend.cpp:

(WebCore::FEBlend::createSoftwareApplier const):
(WebCore::FEBlend::createApplier const): Deleted.

  • platform/graphics/filters/FEBlend.h:
  • platform/graphics/filters/FEColorMatrix.cpp:

(WebCore::FEColorMatrix::resultIsAlphaImage const):
(WebCore::FEColorMatrix::supportsAcceleratedRendering const):
(WebCore::FEColorMatrix::createAcceleratedApplier const):
(WebCore::FEColorMatrix::createSoftwareApplier const):
(WebCore::FEColorMatrix::supportsCoreImageRendering const): Deleted.
(WebCore::FEColorMatrix::createApplier const): Deleted.

  • platform/graphics/filters/FEColorMatrix.h:
  • platform/graphics/filters/FEComponentTransfer.cpp:

(WebCore::FEComponentTransfer::supportsAcceleratedRendering const):
(WebCore::FEComponentTransfer::createAcceleratedApplier const):
(WebCore::FEComponentTransfer::createSoftwareApplier const):
(WebCore::FEComponentTransfer::supportsCoreImageRendering const): Deleted.
(WebCore::FEComponentTransfer::createApplier const): Deleted.

  • platform/graphics/filters/FEComponentTransfer.h:
  • platform/graphics/filters/FEComposite.cpp:

(WebCore::FEComposite::createSoftwareApplier const):
(WebCore::FEComposite::createApplier const): Deleted.

  • platform/graphics/filters/FEComposite.h:
  • platform/graphics/filters/FEConvolveMatrix.cpp:

(WebCore::FEConvolveMatrix::createSoftwareApplier const):
(WebCore::FEConvolveMatrix::createApplier const): Deleted.

  • platform/graphics/filters/FEConvolveMatrix.h:
  • platform/graphics/filters/FEDisplacementMap.cpp:

(WebCore::FEDisplacementMap::createSoftwareApplier const):
(WebCore::FEDisplacementMap::createApplier const): Deleted.

  • platform/graphics/filters/FEDisplacementMap.h:
  • platform/graphics/filters/FEDropShadow.cpp:

(WebCore::FEDropShadow::createSoftwareApplier const):
(WebCore::FEDropShadow::createApplier const): Deleted.

  • platform/graphics/filters/FEDropShadow.h:
  • platform/graphics/filters/FEFlood.cpp:

(WebCore::FEFlood::createSoftwareApplier const):
(WebCore::FEFlood::createApplier const): Deleted.

  • platform/graphics/filters/FEFlood.h:
  • platform/graphics/filters/FEGaussianBlur.cpp:

(WebCore::FEGaussianBlur::createSoftwareApplier const):
(WebCore::FEGaussianBlur::createApplier const): Deleted.

  • platform/graphics/filters/FEGaussianBlur.h:
  • platform/graphics/filters/FELighting.cpp:

(WebCore::FELighting::createSoftwareApplier const):
(WebCore::FELighting::createApplier const): Deleted.

  • platform/graphics/filters/FELighting.h:
  • platform/graphics/filters/FEMerge.cpp:

(WebCore::FEMerge::createSoftwareApplier const):
(WebCore::FEMerge::createApplier const): Deleted.

  • platform/graphics/filters/FEMerge.h:
  • platform/graphics/filters/FEMorphology.cpp:

(WebCore::FEMorphology::createSoftwareApplier const):
(WebCore::FEMorphology::createApplier const): Deleted.

  • platform/graphics/filters/FEMorphology.h:
  • platform/graphics/filters/FEOffset.cpp:

(WebCore::FEOffset::createSoftwareApplier const):
(WebCore::FEOffset::createApplier const): Deleted.

  • platform/graphics/filters/FEOffset.h:
  • platform/graphics/filters/FETile.cpp:

(WebCore::FETile::createSoftwareApplier const):
(WebCore::FETile::createApplier const): Deleted.

  • platform/graphics/filters/FETile.h:
  • platform/graphics/filters/FETurbulence.cpp:

(WebCore::FETurbulence::createSoftwareApplier const):
(WebCore::FETurbulence::createApplier const): Deleted.

  • platform/graphics/filters/FETurbulence.h:
  • platform/graphics/filters/FilterEffect.cpp:

(WebCore::FilterEffect::createApplier const):

  • platform/graphics/filters/FilterEffect.h:

(WebCore::FilterEffect::createAcceleratedApplier const):

  • platform/graphics/filters/FilterFunction.h:

(WebCore::FilterFunction::supportsAcceleratedRendering const):
(WebCore::FilterFunction::supportsCoreImageRendering const): Deleted.

  • platform/graphics/filters/SourceAlpha.cpp:

(WebCore::SourceAlpha::createSoftwareApplier const):
(WebCore::SourceAlpha::createApplier const): Deleted.

  • platform/graphics/filters/SourceAlpha.h:
  • platform/graphics/filters/SourceGraphic.cpp:

(WebCore::SourceGraphic::supportsAcceleratedRendering const):
(WebCore::SourceGraphic::createAcceleratedApplier const):
(WebCore::SourceGraphic::createSoftwareApplier const):
(WebCore::SourceGraphic::createApplier const): Deleted.

  • platform/graphics/filters/SourceGraphic.h:
  • rendering/CSSFilter.cpp:

(WebCore::CSSFilter::create):
(WebCore::CSSFilter::supportsAcceleratedRendering const):
(WebCore::CSSFilter::supportsCoreImageRendering const): Deleted.

  • rendering/CSSFilter.h:
  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::calculateClipRects const):

  • rendering/svg/RenderSVGResourceFilter.cpp:

(WebCore::RenderSVGResourceFilter::applyResource):

  • svg/graphics/filters/SVGFEImage.cpp:

(WebCore::FEImage::createSoftwareApplier const):
(WebCore::FEImage::createApplier const): Deleted.

  • svg/graphics/filters/SVGFEImage.h:
  • svg/graphics/filters/SVGFilter.cpp:

(WebCore::SVGFilter::create):
(WebCore::SVGFilter::supportsAcceleratedRendering const):
(WebCore::SVGFilter::supportsCoreImageRendering const): Deleted.

  • svg/graphics/filters/SVGFilter.h:

Source/WTF:

Delete ENABLE_CORE_IMAGE_ACCELERATED_FILTER_RENDER and use USE_CORE_IMAGE
instead since CoreImage is only used for filters right now. Besides
CoreImage filters will be enabled by the internal feature control flag
AcceleratedFiltersEnabled.

  • Scripts/Preferences/WebPreferencesExperimental.yaml:
  • Scripts/Preferences/WebPreferencesInternal.yaml:
  • wtf/PlatformEnableCocoa.h:
  • Property svn:eol-style set to native
File size: 5.0 KB
Line 
1/*
2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
6 * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org>
7 * Copyright (C) 2021-2022 Apple Inc. All rights reserved.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
18 *
19 * You should have received a copy of the GNU Library General Public License
20 * along with this library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23 */
24
25#include "config.h"
26#include "FEConvolveMatrix.h"
27
28#include "FEConvolveMatrixSoftwareApplier.h"
29#include "Filter.h"
30#include <wtf/text/TextStream.h>
31
32namespace WebCore {
33
34Ref<FEConvolveMatrix> FEConvolveMatrix::create(const IntSize& kernelSize, float divisor, float bias, const IntPoint& targetOffset, EdgeModeType edgeMode, const FloatPoint& kernelUnitLength, bool preserveAlpha, const Vector<float>& kernelMatrix)
35{
36 return adoptRef(*new FEConvolveMatrix(kernelSize, divisor, bias, targetOffset, edgeMode, kernelUnitLength, preserveAlpha, kernelMatrix));
37}
38
39FEConvolveMatrix::FEConvolveMatrix(const IntSize& kernelSize, float divisor, float bias, const IntPoint& targetOffset, EdgeModeType edgeMode, const FloatPoint& kernelUnitLength, bool preserveAlpha, const Vector<float>& kernelMatrix)
40 : FilterEffect(FilterEffect::Type::FEConvolveMatrix)
41 , m_kernelSize(kernelSize)
42 , m_divisor(divisor)
43 , m_bias(bias)
44 , m_targetOffset(targetOffset)
45 , m_edgeMode(edgeMode)
46 , m_kernelUnitLength(kernelUnitLength)
47 , m_preserveAlpha(preserveAlpha)
48 , m_kernelMatrix(kernelMatrix)
49{
50 ASSERT(m_kernelSize.width() > 0);
51 ASSERT(m_kernelSize.height() > 0);
52}
53
54void FEConvolveMatrix::setKernelSize(const IntSize& kernelSize)
55{
56 ASSERT(kernelSize.width() > 0);
57 ASSERT(kernelSize.height() > 0);
58 m_kernelSize = kernelSize;
59}
60
61void FEConvolveMatrix::setKernel(const Vector<float>& kernel)
62{
63 m_kernelMatrix = kernel;
64}
65
66bool FEConvolveMatrix::setDivisor(float divisor)
67{
68 ASSERT(divisor);
69 if (m_divisor == divisor)
70 return false;
71 m_divisor = divisor;
72 return true;
73}
74
75bool FEConvolveMatrix::setBias(float bias)
76{
77 if (m_bias == bias)
78 return false;
79 m_bias = bias;
80 return true;
81}
82
83bool FEConvolveMatrix::setTargetOffset(const IntPoint& targetOffset)
84{
85 if (m_targetOffset == targetOffset)
86 return false;
87 m_targetOffset = targetOffset;
88 return true;
89}
90
91bool FEConvolveMatrix::setEdgeMode(EdgeModeType edgeMode)
92{
93 if (m_edgeMode == edgeMode)
94 return false;
95 m_edgeMode = edgeMode;
96 return true;
97}
98
99bool FEConvolveMatrix::setKernelUnitLength(const FloatPoint& kernelUnitLength)
100{
101 ASSERT(kernelUnitLength.x() > 0);
102 ASSERT(kernelUnitLength.y() > 0);
103 if (m_kernelUnitLength == kernelUnitLength)
104 return false;
105 m_kernelUnitLength = kernelUnitLength;
106 return true;
107}
108
109bool FEConvolveMatrix::setPreserveAlpha(bool preserveAlpha)
110{
111 if (m_preserveAlpha == preserveAlpha)
112 return false;
113 m_preserveAlpha = preserveAlpha;
114 return true;
115}
116
117FloatRect FEConvolveMatrix::calculateImageRect(const Filter& filter, const FilterImageVector&, const FloatRect& primitiveSubregion) const
118{
119 return filter.maxEffectRect(primitiveSubregion);
120}
121
122std::unique_ptr<FilterEffectApplier> FEConvolveMatrix::createSoftwareApplier() const
123{
124 return FilterEffectApplier::create<FEConvolveMatrixSoftwareApplier>(*this);
125}
126
127static TextStream& operator<<(TextStream& ts, const EdgeModeType& type)
128{
129 switch (type) {
130 case EdgeModeType::Unknown:
131 ts << "UNKNOWN";
132 break;
133 case EdgeModeType::Duplicate:
134 ts << "DUPLICATE";
135 break;
136 case EdgeModeType::Wrap:
137 ts << "WRAP";
138 break;
139 case EdgeModeType::None:
140 ts << "NONE";
141 break;
142 }
143 return ts;
144}
145
146TextStream& FEConvolveMatrix::externalRepresentation(TextStream& ts, FilterRepresentation representation) const
147{
148 ts << indent << "[feConvolveMatrix";
149 FilterEffect::externalRepresentation(ts, representation);
150
151 ts << " order=\"" << m_kernelSize << "\"";
152 ts << " kernelMatrix=\"" << m_kernelMatrix << "\"";
153 ts << " divisor=\"" << m_divisor << "\"";
154 ts << " bias=\"" << m_bias << "\"";
155 ts << " target=\"" << m_targetOffset << "\"";
156 ts << " edgeMode=\"" << m_edgeMode << "\"";
157 ts << " kernelUnitLength=\"" << m_kernelUnitLength << "\"";
158 ts << " preserveAlpha=\"" << m_preserveAlpha << "\"";
159
160 ts << "]\n";
161 return ts;
162}
163
164}; // namespace WebCore
Note: See TracBrowser for help on using the repository browser.