Skip to content

Commit 49d8856

Browse files
shallawapgorszkowski-igalia
authored andcommitted
Implement FECompositeNeonArithmeticApplier
https://bugs.webkit.org/show_bug.cgi?id=243432 Reviewed by NOBODY (OOPS!). Move the software arithmetic FEComposite applier to a separate applier. Move the FEComposite NEON code to a new applier named FECompositeNeonArithmeticApplier. Make FEComposite::createSoftwareApplier() decide which applier to create. * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/platform/graphics/cpu/arm/filters/FECompositeNeonArithmeticApplier.cpp: Renamed from Source/WebCore/platform/graphics/cpu/arm/filters/FECompositeArithmeticNEON.h. (WebCore::FECompositeNeonArithmeticApplier::FECompositeNeonArithmeticApplier): (WebCore::FECompositeNeonArithmeticApplier::computePixels): (WebCore::FECompositeNeonArithmeticApplier::applyPlatform): (WebCore::FECompositeNeonArithmeticApplier::apply const): * Source/WebCore/platform/graphics/cpu/arm/filters/FECompositeNeonArithmeticApplier.h: Added. * Source/WebCore/platform/graphics/filters/FEComposite.cpp: (WebCore::FEComposite::createSoftwareApplier const): * Source/WebCore/platform/graphics/filters/software/FECompositeSoftwareApplier.cpp: (WebCore::FECompositeSoftwareApplier::FECompositeSoftwareApplier): (WebCore::FECompositeSoftwareApplier::apply const): (WebCore::FECompositeSoftwareApplier::clampByte): Deleted. (WebCore::FECompositeSoftwareApplier::computeArithmeticPixels): Deleted. (WebCore::FECompositeSoftwareApplier::computeArithmeticPixelsUnclamped): Deleted. (WebCore::FECompositeSoftwareApplier::applyPlatformArithmetic): Deleted. (WebCore::FECompositeSoftwareApplier::applyArithmetic const): Deleted. (WebCore::FECompositeSoftwareApplier::applyNonArithmetic const): Deleted. * Source/WebCore/platform/graphics/filters/software/FECompositeSoftwareApplier.h: * Source/WebCore/platform/graphics/filters/software/FECompositeSoftwareArithmeticApplier.cpp: Added. (WebCore::FECompositeSoftwareArithmeticApplier::FECompositeSoftwareArithmeticApplier): (WebCore::FECompositeSoftwareArithmeticApplier::clampByte): (WebCore::FECompositeSoftwareArithmeticApplier::computePixels): (WebCore::FECompositeSoftwareArithmeticApplier::computePixelsUnclamped): (WebCore::FECompositeSoftwareArithmeticApplier::applyPlatform): (WebCore::FECompositeSoftwareArithmeticApplier::apply const): * Source/WebCore/platform/graphics/filters/software/FECompositeSoftwareArithmeticApplier.h: Copied from Source/WebCore/platform/graphics/filters/software/FECompositeSoftwareApplier.h.
1 parent a7b82b0 commit 49d8856

9 files changed

Lines changed: 345 additions & 152 deletions

Source/WebCore/Sources.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,6 +2139,8 @@ platform/graphics/WebMResourceClient.cpp
21392139
platform/graphics/WOFFFileFormat.cpp
21402140
platform/graphics/WidthIterator.cpp
21412141
platform/graphics/cpu/arm/filters/FEBlendNeonApplier.cpp
2142+
platform/graphics/cpu/arm/filters/FECompositeNeonArithmeticApplier.cpp
2143+
platform/graphics/cpu/arm/filters/FELightingNEON.cpp
21422144
platform/graphics/displaylists/DisplayList.cpp
21432145
platform/graphics/displaylists/DisplayListDrawingContext.cpp
21442146
platform/graphics/displaylists/DisplayListItems.cpp
@@ -2182,6 +2184,7 @@ platform/graphics/filters/SpotLightSource.cpp
21822184
platform/graphics/filters/software/FEBlendSoftwareApplier.cpp
21832185
platform/graphics/filters/software/FEColorMatrixSoftwareApplier.cpp
21842186
platform/graphics/filters/software/FEComponentTransferSoftwareApplier.cpp
2187+
platform/graphics/filters/software/FECompositeSoftwareArithmeticApplier.cpp
21852188
platform/graphics/filters/software/FECompositeSoftwareApplier.cpp
21862189
platform/graphics/filters/software/FEConvolveMatrixSoftwareApplier.cpp
21872190
platform/graphics/filters/software/FEDisplacementMapSoftwareApplier.cpp

Source/WebCore/WebCore.xcodeproj/project.pbxproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11534,6 +11534,9 @@
1153411534
722AF2E327E1CF110078D997 /* TextBoxIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextBoxIterator.h; sourceTree = "<group>"; };
1153511535
722AF2E527E1D09E0078D997 /* CGContextStateSaver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGContextStateSaver.h; sourceTree = "<group>"; };
1153611536
7241361A28985069007B3FCD /* FEBlendNeonApplier.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FEBlendNeonApplier.cpp; sourceTree = "<group>"; };
11537+
7241361F289863AC007B3FCD /* FECompositeNeonArithmeticApplier.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FECompositeNeonArithmeticApplier.cpp; sourceTree = "<group>"; };
11538+
724136202898652A007B3FCD /* FECompositeSoftwareArithmeticApplier.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FECompositeSoftwareArithmeticApplier.cpp; sourceTree = "<group>"; };
11539+
724136212898652A007B3FCD /* FECompositeSoftwareArithmeticApplier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FECompositeSoftwareArithmeticApplier.h; sourceTree = "<group>"; };
1153711540
72435EF4273D07670005E7EE /* FilterImage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FilterImage.h; sourceTree = "<group>"; };
1153811541
72435EF5273D07670005E7EE /* FilterImage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FilterImage.cpp; sourceTree = "<group>"; };
1153911542
724DCF1B284853650026ACF4 /* ImageBufferAllocator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBufferAllocator.cpp; sourceTree = "<group>"; };
@@ -12953,7 +12956,7 @@
1295312956
93309EA1099EB78C0056E581 /* Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Timer.cpp; sourceTree = "<group>"; };
1295412957
9332AB3D16515D7700D827EC /* GraphicsContextGLNEON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLNEON.h; sourceTree = "<group>"; };
1295512958
9332AB871653A97900D827EC /* FEBlendNeonApplier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FEBlendNeonApplier.h; sourceTree = "<group>"; };
12956-
9332AB881653A97900D827EC /* FECompositeArithmeticNEON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FECompositeArithmeticNEON.h; sourceTree = "<group>"; };
12959+
9332AB881653A97900D827EC /* FECompositeNeonArithmeticApplier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FECompositeNeonArithmeticApplier.h; sourceTree = "<group>"; };
1295712960
9332AB891653A97900D827EC /* FEGaussianBlurNEON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FEGaussianBlurNEON.h; sourceTree = "<group>"; };
1295812961
9332AB8A1653A97900D827EC /* FELightingNEON.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FELightingNEON.cpp; sourceTree = "<group>"; };
1295912962
9332AB8B1653A97900D827EC /* FELightingNEON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FELightingNEON.h; sourceTree = "<group>"; };
@@ -25300,6 +25303,8 @@
2530025303
72A13AB9274DDEC000E2A88E /* FEComponentTransferSoftwareApplier.h */,
2530125304
72A13ABA274DE01200E2A88E /* FECompositeSoftwareApplier.cpp */,
2530225305
72A13ABB274DE01200E2A88E /* FECompositeSoftwareApplier.h */,
25306+
724136202898652A007B3FCD /* FECompositeSoftwareArithmeticApplier.cpp */,
25307+
724136212898652A007B3FCD /* FECompositeSoftwareArithmeticApplier.h */,
2530325308
72A13ABE274DE33F00E2A88E /* FEConvolveMatrixSoftwareApplier.cpp */,
2530425309
72A13ABF274DE33F00E2A88E /* FEConvolveMatrixSoftwareApplier.h */,
2530525310
72A13AC0274DE35900E2A88E /* FEDisplacementMapSoftwareApplier.cpp */,
@@ -25935,7 +25940,8 @@
2593525940
children = (
2593625941
7241361A28985069007B3FCD /* FEBlendNeonApplier.cpp */,
2593725942
9332AB871653A97900D827EC /* FEBlendNeonApplier.h */,
25938-
9332AB881653A97900D827EC /* FECompositeArithmeticNEON.h */,
25943+
7241361F289863AC007B3FCD /* FECompositeNeonArithmeticApplier.cpp */,
25944+
9332AB881653A97900D827EC /* FECompositeNeonArithmeticApplier.h */,
2593925945
9332AB891653A97900D827EC /* FEGaussianBlurNEON.h */,
2594025946
9332AB8A1653A97900D827EC /* FELightingNEON.cpp */,
2594125947
9332AB8B1653A97900D827EC /* FELightingNEON.h */,

Source/WebCore/platform/graphics/cpu/arm/filters/FECompositeArithmeticNEON.h renamed to Source/WebCore/platform/graphics/cpu/arm/filters/FECompositeNeonArithmeticApplier.cpp

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Copyright (C) 2011 University of Szeged
33
* Copyright (C) 2011 Felician Marton
4+
* Copyright (C) 2022 Apple Inc. All rights reserved.
45
*
56
* Redistribution and use in source and binary forms, with or without
67
* modification, are permitted provided that the following conditions
@@ -24,8 +25,8 @@
2425
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2526
*/
2627

27-
#ifndef FECompositeArithmeticNEON_h
28-
#define FECompositeArithmeticNEON_h
28+
#include "config.h"
29+
#include "FECompositeNeonArithmeticApplier.h"
2930

3031
#if HAVE(ARM_NEON_INTRINSICS)
3132

@@ -35,8 +36,14 @@
3536

3637
namespace WebCore {
3738

39+
FECompositeNeonArithmeticApplier::FECompositeNeonArithmeticApplier(const FEComposite& effect)
40+
: Base(effect)
41+
{
42+
ASSERT(m_effect.operation() == FECOMPOSITE_OPERATOR_ARITHMETIC);
43+
}
44+
3845
template <int b1, int b4>
39-
inline void FEComposite::computeArithmeticPixelsNeon(const uint8_t* source, uint8_t* destination, unsigned pixelArrayLength, float k1, float k2, float k3, float k4)
46+
inline void FECompositeNeonArithmeticApplier::computePixels(const uint8_t* source, uint8_t* destination, unsigned pixelArrayLength, float k1, float k2, float k3, float k4)
4047
{
4148
float32x4_t k1x4 = vdupq_n_f32(k1 / 255);
4249
float32x4_t k2x4 = vdupq_n_f32(k2);
@@ -67,27 +74,52 @@ inline void FEComposite::computeArithmeticPixelsNeon(const uint8_t* source, uint
6774
}
6875
}
6976

70-
inline void FEComposite::platformArithmeticNeon(const uint8_t* source, uint8_t* destination, unsigned pixelArrayLength, float k1, float k2, float k3, float k4)
77+
inline void FECompositeNeonArithmeticApplier::applyPlatform(const uint8_t* source, uint8_t* destination, unsigned pixelArrayLength, float k1, float k2, float k3, float k4)
7178
{
7279
if (!k4) {
7380
if (!k1) {
74-
computeArithmeticPixelsNeon<0, 0>(source, destination, pixelArrayLength, k1, k2, k3, k4);
81+
computePixels<0, 0>(source, destination, pixelArrayLength, k1, k2, k3, k4);
7582
return;
7683
}
7784

78-
computeArithmeticPixelsNeon<1, 0>(source, destination, pixelArrayLength, k1, k2, k3, k4);
85+
computePixels<1, 0>(source, destination, pixelArrayLength, k1, k2, k3, k4);
7986
return;
8087
}
8188

8289
if (!k1) {
83-
computeArithmeticPixelsNeon<0, 1>(source, destination, pixelArrayLength, k1, k2, k3, k4);
90+
computePixels<0, 1>(source, destination, pixelArrayLength, k1, k2, k3, k4);
8491
return;
8592
}
86-
computeArithmeticPixelsNeon<1, 1>(source, destination, pixelArrayLength, k1, k2, k3, k4);
93+
computePixels<1, 1>(source, destination, pixelArrayLength, k1, k2, k3, k4);
94+
}
95+
96+
bool FECompositeNeonArithmeticApplier::apply(const Filter&, const FilterImageVector& inputs, FilterImage& result) const
97+
{
98+
auto& input = inputs[0].get();
99+
auto& input2 = inputs[1].get();
100+
101+
auto destinationPixelBuffer = result.pixelBuffer(AlphaPremultiplication::Premultiplied);
102+
if (!destinationPixelBuffer)
103+
return false;
104+
105+
IntRect effectADrawingRect = result.absoluteImageRectRelativeTo(input);
106+
auto sourcePixelBuffer = input.getPixelBuffer(AlphaPremultiplication::Premultiplied, effectADrawingRect, m_effect.operatingColorSpace());
107+
if (!sourcePixelBuffer)
108+
return false;
109+
110+
IntRect effectBDrawingRect = result.absoluteImageRectRelativeTo(input2);
111+
input2.copyPixelBuffer(*destinationPixelBuffer, effectBDrawingRect);
112+
113+
auto* sourcePixelBytes = sourcePixelBuffer->bytes();
114+
auto* destinationPixelBytes = destinationPixelBuffer->bytes();
115+
116+
auto length = sourcePixelBuffer->sizeInBytes();
117+
ASSERT(length == destinationPixelBuffer->sizeInBytes());
118+
119+
applyPlatform(sourcePixelBytes, destinationPixelBytes, length, m_effect.k1(), m_effect.k2(), m_effect.k3(), m_effect.k4());
120+
return true;
87121
}
88122

89123
} // namespace WebCore
90124

91125
#endif // HAVE(ARM_NEON_INTRINSICS)
92-
93-
#endif // FECompositeArithmeticNEON_h
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (C) 2011 University of Szeged
3+
* Copyright (C) 2011 Felician Marton
4+
* Copyright (C) 2022 Apple Inc. All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions
8+
* are met:
9+
* 1. Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
16+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
19+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
#pragma once
29+
30+
#if HAVE(ARM_NEON_INTRINSICS)
31+
32+
#include "FilterEffectApplier.h"
33+
34+
namespace WebCore {
35+
36+
class FEComposite;
37+
38+
class FECompositeNeonArithmeticApplier final : public FilterEffectConcreteApplier<FEComposite> {
39+
WTF_MAKE_FAST_ALLOCATED;
40+
using Base = FilterEffectConcreteApplier<FEComposite>;
41+
42+
public:
43+
FECompositeNeonArithmeticApplier(const FEComposite&);
44+
45+
private:
46+
template <int b1, int b4>
47+
static inline void computePixels(const uint8_t* source, uint8_t* destination, unsigned pixelArrayLength, float k1, float k2, float k3, float k4);
48+
49+
static inline void applyPlatform(const uint8_t* source, uint8_t* destination, unsigned pixelArrayLength, float k1, float k2, float k3, float k4);
50+
51+
bool apply(const Filter&, const FilterImageVector& inputs, FilterImage& result) const final;
52+
};
53+
54+
} // namespace WebCore
55+
56+
#endif // HAVE(ARM_NEON_INTRINSICS)

Source/WebCore/platform/graphics/filters/FEComposite.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
#include "config.h"
2626
#include "FEComposite.h"
2727

28+
#include "FECompositeNeonArithmeticApplier.h"
2829
#include "FECompositeSoftwareApplier.h"
30+
#include "FECompositeSoftwareArithmeticApplier.h"
2931
#include "Filter.h"
3032
#include <wtf/text/TextStream.h>
3133

@@ -108,7 +110,13 @@ FloatRect FEComposite::calculateImageRect(const Filter& filter, const FilterImag
108110

109111
std::unique_ptr<FilterEffectApplier> FEComposite::createSoftwareApplier() const
110112
{
111-
return FilterEffectApplier::create<FECompositeSoftwareApplier>(*this);
113+
if (m_type != FECOMPOSITE_OPERATOR_ARITHMETIC)
114+
return FilterEffectApplier::create<FECompositeSoftwareApplier>(*this);
115+
#if HAVE(ARM_NEON_INTRINSICS)
116+
return FilterEffectApplier::create<FECompositeNeonArithmeticApplier>(*this);
117+
#else
118+
return FilterEffectApplier::create<FECompositeSoftwareArithmeticApplier>(*this);
119+
#endif
112120
}
113121

114122
static TextStream& operator<<(TextStream& ts, const CompositeOperationType& type)

Source/WebCore/platform/graphics/filters/software/FECompositeSoftwareApplier.cpp

Lines changed: 6 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -33,126 +33,17 @@
3333

3434
namespace WebCore {
3535

36-
uint8_t FECompositeSoftwareApplier::clampByte(int c)
36+
FECompositeSoftwareApplier::FECompositeSoftwareApplier(const FEComposite& effect)
37+
: Base(effect)
3738
{
38-
uint8_t buff[] = { static_cast<uint8_t>(c), 255, 0 };
39-
unsigned uc = static_cast<unsigned>(c);
40-
return buff[!!(uc & ~0xff) + !!(uc & ~(~0u >> 1))];
39+
ASSERT(m_effect.operation() != FECOMPOSITE_OPERATOR_ARITHMETIC);
4140
}
4241

43-
template <int b1, int b4>
44-
inline void FECompositeSoftwareApplier::computeArithmeticPixels(unsigned char* source, unsigned char* destination, int pixelArrayLength, float k1, float k2, float k3, float k4)
45-
{
46-
float scaledK1;
47-
float scaledK4;
48-
if (b1)
49-
scaledK1 = k1 / 255.0f;
50-
if (b4)
51-
scaledK4 = k4 * 255.0f;
52-
53-
while (--pixelArrayLength >= 0) {
54-
unsigned char i1 = *source;
55-
unsigned char i2 = *destination;
56-
float result = k2 * i1 + k3 * i2;
57-
if (b1)
58-
result += scaledK1 * i1 * i2;
59-
if (b4)
60-
result += scaledK4;
61-
62-
*destination = clampByte(result);
63-
++source;
64-
++destination;
65-
}
66-
}
67-
68-
// computeArithmeticPixelsUnclamped is a faster version of computeArithmeticPixels for the common case where clamping
69-
// is not necessary. This enables aggresive compiler optimizations such as auto-vectorization.
70-
template <int b1, int b4>
71-
inline void FECompositeSoftwareApplier::computeArithmeticPixelsUnclamped(unsigned char* source, unsigned char* destination, int pixelArrayLength, float k1, float k2, float k3, float k4)
72-
{
73-
float scaledK1;
74-
float scaledK4;
75-
if (b1)
76-
scaledK1 = k1 / 255.0f;
77-
if (b4)
78-
scaledK4 = k4 * 255.0f;
79-
80-
while (--pixelArrayLength >= 0) {
81-
unsigned char i1 = *source;
82-
unsigned char i2 = *destination;
83-
float result = k2 * i1 + k3 * i2;
84-
if (b1)
85-
result += scaledK1 * i1 * i2;
86-
if (b4)
87-
result += scaledK4;
88-
89-
*destination = result;
90-
++source;
91-
++destination;
92-
}
93-
}
94-
95-
#if !HAVE(ARM_NEON_INTRINSICS)
96-
inline void FECompositeSoftwareApplier::applyPlatformArithmetic(unsigned char* source, unsigned char* destination, int pixelArrayLength, float k1, float k2, float k3, float k4)
97-
{
98-
float upperLimit = std::max(0.0f, k1) + std::max(0.0f, k2) + std::max(0.0f, k3) + k4;
99-
float lowerLimit = std::min(0.0f, k1) + std::min(0.0f, k2) + std::min(0.0f, k3) + k4;
100-
if ((k4 >= 0.0f && k4 <= 1.0f) && (upperLimit >= 0.0f && upperLimit <= 1.0f) && (lowerLimit >= 0.0f && lowerLimit <= 1.0f)) {
101-
if (k4) {
102-
if (k1)
103-
computeArithmeticPixelsUnclamped<1, 1>(source, destination, pixelArrayLength, k1, k2, k3, k4);
104-
else
105-
computeArithmeticPixelsUnclamped<0, 1>(source, destination, pixelArrayLength, k1, k2, k3, k4);
106-
} else {
107-
if (k1)
108-
computeArithmeticPixelsUnclamped<1, 0>(source, destination, pixelArrayLength, k1, k2, k3, k4);
109-
else
110-
computeArithmeticPixelsUnclamped<0, 0>(source, destination, pixelArrayLength, k1, k2, k3, k4);
111-
}
112-
return;
113-
}
114-
115-
if (k4) {
116-
if (k1)
117-
computeArithmeticPixels<1, 1>(source, destination, pixelArrayLength, k1, k2, k3, k4);
118-
else
119-
computeArithmeticPixels<0, 1>(source, destination, pixelArrayLength, k1, k2, k3, k4);
120-
} else {
121-
if (k1)
122-
computeArithmeticPixels<1, 0>(source, destination, pixelArrayLength, k1, k2, k3, k4);
123-
else
124-
computeArithmeticPixels<0, 0>(source, destination, pixelArrayLength, k1, k2, k3, k4);
125-
}
126-
}
127-
#endif
128-
129-
bool FECompositeSoftwareApplier::applyArithmetic(FilterImage& input, FilterImage& input2, FilterImage& result) const
42+
bool FECompositeSoftwareApplier::apply(const Filter&, const FilterImageVector& inputs, FilterImage& result) const
13043
{
131-
auto destinationPixelBuffer = result.pixelBuffer(AlphaPremultiplication::Premultiplied);
132-
if (!destinationPixelBuffer)
133-
return false;
134-
135-
IntRect effectADrawingRect = result.absoluteImageRectRelativeTo(input);
136-
auto sourcePixelBuffer = input.getPixelBuffer(AlphaPremultiplication::Premultiplied, effectADrawingRect, m_effect.operatingColorSpace());
137-
if (!sourcePixelBuffer)
138-
return false;
139-
140-
IntRect effectBDrawingRect = result.absoluteImageRectRelativeTo(input2);
141-
input2.copyPixelBuffer(*destinationPixelBuffer, effectBDrawingRect);
142-
143-
auto* sourcePixelBytes = sourcePixelBuffer->bytes();
144-
auto* destinationPixelBytes = destinationPixelBuffer->bytes();
145-
146-
auto length = sourcePixelBuffer->sizeInBytes();
147-
ASSERT(length == destinationPixelBuffer->sizeInBytes());
148-
#if !HAVE(ARM_NEON_INTRINSICS)
149-
applyPlatformArithmetic(sourcePixelBytes, destinationPixelBytes, length, m_effect.k1(), m_effect.k2(), m_effect.k3(), m_effect.k4());
150-
#endif
151-
return true;
152-
}
44+
auto& input = inputs[0].get();
45+
auto& input2 = inputs[1].get();
15346

154-
bool FECompositeSoftwareApplier::applyNonArithmetic(FilterImage& input, FilterImage& input2, FilterImage& result) const
155-
{
15647
auto resultImage = result.imageBuffer();
15748
if (!resultImage)
15849
return false;
@@ -218,14 +109,4 @@ bool FECompositeSoftwareApplier::applyNonArithmetic(FilterImage& input, FilterIm
218109
return true;
219110
}
220111

221-
bool FECompositeSoftwareApplier::apply(const Filter&, const FilterImageVector& inputs, FilterImage& result) const
222-
{
223-
auto& input = inputs[0].get();
224-
auto& input2 = inputs[1].get();
225-
226-
if (m_effect.operation() == FECOMPOSITE_OPERATOR_ARITHMETIC)
227-
return applyArithmetic(input, input2, result);
228-
return applyNonArithmetic(input, input2, result);
229-
}
230-
231112
} // namespace WebCore

0 commit comments

Comments
 (0)