blob: 24d6c08da79c177cad8717af8c9d2229c2defe81 [file] [log] [blame]
/*
* Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
* Copyright (C) 2005 Eric Seidel <eric@webkit.org>
* Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org>
* Copyright (C) 2021 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include "FilterEffectApplier.h"
#include <wtf/Vector.h>
namespace WebCore {
class FEConvolveMatrix;
enum class EdgeModeType;
class FEConvolveMatrixSoftwareApplier : public FilterEffectConcreteApplier<FEConvolveMatrix> {
using Base = FilterEffectConcreteApplier<FEConvolveMatrix>;
public:
using Base::Base;
bool apply(const Filter&, const FilterEffectVector& inputEffects) override;
private:
struct PaintingData {
const Uint8ClampedArray& srcPixelArray;
Uint8ClampedArray& dstPixelArray;
int width;
int height;
IntSize kernelSize;
float divisor;
float bias;
IntPoint targetOffset;
EdgeModeType edgeMode;
bool preserveAlpha;
Vector<float> kernelMatrix;
};
static inline uint8_t clampRGBAValue(float channel, uint8_t max = 255);
static inline void setDestinationPixels(const Uint8ClampedArray& sourcePixels, Uint8ClampedArray& destPixels, int& pixel, float* totals, float divisor, float bias, bool preserveAlphaValues);
static inline int getPixelValue(const PaintingData&, int x, int y);
static inline void setInteriorPixels(PaintingData&, int clipRight, int clipBottom, int yStart, int yEnd);
static inline void setOuterPixels(PaintingData&, int x1, int y1, int x2, int y2);
void applyPlatform(PaintingData&) const;
};
} // namespace WebCore