2 * Copyright (C) 2011 University of Szeged
3 * Copyright (C) 2011 Zoltan Herczeg
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #ifndef FEGaussianBlurNEON_h
28 #define FEGaussianBlurNEON_h
30 #include <wtf/Platform.h>
32 #if CPU(ARM_NEON) && CPU(ARM_TRADITIONAL) && COMPILER(GCC)
34 #include "FEGaussianBlur.h"
38 struct FEGaussianBlurPaintingDataForNeon {
46 float invertedKernelSize;
47 unsigned char* paintingConstants;
50 unsigned char* feGaussianBlurConstantsForNeon();
53 void neonDrawAllChannelGaussianBlur(unsigned char* source, unsigned char* destination, FEGaussianBlurPaintingDataForNeon*);
54 void neonDrawAlphaChannelGaussianBlur(unsigned char* source, unsigned char* destination, FEGaussianBlurPaintingDataForNeon*);
57 inline void FEGaussianBlur::platformApplyNeon(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize)
59 const int widthMultipliedByFour = 4 * paintSize.width();
60 FEGaussianBlurPaintingDataForNeon argumentsX = {
62 widthMultipliedByFour,
63 widthMultipliedByFour,
64 (isAlphaImage() ? ((paintSize.height() >> 2) << 2) : paintSize.height()) * widthMultipliedByFour,
65 isAlphaImage() ? (paintSize.height() & 0x3) : 0,
69 isAlphaImage() ? 0 : feGaussianBlurConstantsForNeon()
71 FEGaussianBlurPaintingDataForNeon argumentsY = {
72 widthMultipliedByFour,
73 widthMultipliedByFour * paintSize.height(),
75 (isAlphaImage() ? ((paintSize.width() >> 2) << 2) : paintSize.width()) * 4,
76 isAlphaImage() ? (paintSize.width() & 0x3) : 0,
80 isAlphaImage() ? 0 : feGaussianBlurConstantsForNeon()
83 for (int i = 0; i < 3; ++i) {
85 kernelPosition(i, kernelSizeX, argumentsX.distanceLeft, argumentsX.distanceRight);
86 argumentsX.invertedKernelSize = 1 / static_cast<float>(kernelSizeX);
88 neonDrawAlphaChannelGaussianBlur(srcPixelArray->data(), tmpPixelArray->data(), &argumentsX);
90 neonDrawAllChannelGaussianBlur(srcPixelArray->data(), tmpPixelArray->data(), &argumentsX);
92 Uint8ClampedArray* auxPixelArray = tmpPixelArray;
93 tmpPixelArray = srcPixelArray;
94 srcPixelArray = auxPixelArray;
98 kernelPosition(i, kernelSizeY, argumentsY.distanceLeft, argumentsY.distanceRight);
99 argumentsY.invertedKernelSize = 1 / static_cast<float>(kernelSizeY);
101 neonDrawAlphaChannelGaussianBlur(tmpPixelArray->data(), srcPixelArray->data(), &argumentsY);
103 neonDrawAllChannelGaussianBlur(tmpPixelArray->data(), srcPixelArray->data(), &argumentsY);
105 Uint8ClampedArray* auxPixelArray = tmpPixelArray;
106 tmpPixelArray = srcPixelArray;
107 srcPixelArray = auxPixelArray;
112 } // namespace WebCore
114 #endif // CPU(ARM_NEON) && COMPILER(GCC)
116 #endif // FEGaussianBlurNEON_h