1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef MOZILLA_GFX_CONVOLUTION_FILTER_H_
8 #define MOZILLA_GFX_CONVOLUTION_FILTER_H_
10 #include "mozilla/UniquePtr.h"
13 class SkConvolutionFilter1D
;
19 class ConvolutionFilter final
{
24 int32_t MaxFilter() const;
25 int32_t NumValues() const;
27 bool GetFilterOffsetAndLength(int32_t aRowIndex
, int32_t* aResultOffset
,
28 int32_t* aResultLength
);
30 void ConvolveHorizontally(const uint8_t* aSrc
, uint8_t* aDst
, bool aHasAlpha
);
31 void ConvolveVertically(uint8_t* const* aSrc
, uint8_t* aDst
,
32 int32_t aRowIndex
, int32_t aRowSize
, bool aHasAlpha
);
34 enum class ResizeMethod
{ BOX
, LANCZOS3
};
36 bool ComputeResizeFilter(ResizeMethod aResizeMethod
, int32_t aSrcSize
,
39 static inline size_t PadBytesForSIMD(size_t aBytes
) {
40 return (aBytes
+ 31) & ~31;
43 const skia::SkConvolutionFilter1D
& GetSkiaFilter() const {
44 return *mFilter
.get();
48 UniquePtr
<skia::SkConvolutionFilter1D
> mFilter
;
52 } // namespace mozilla
54 #endif /* MOZILLA_GFX_CONVOLUTION_FILTER_H_ */