| 1 |
/* |
| 2 |
* Copyright 2024 Google LLC |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef SkMatrixConvolutionImageFilter_DEFINED |
| 9 |
#define SkMatrixConvolutionImageFilter_DEFINED |
| 10 |
|
| 11 |
namespace MatrixConvolutionImageFilter { |
| 12 |
|
| 13 |
// The matrix convolution image filter applies the convolution naively, it does not use any DFT to |
| 14 |
// convert the input images into the frequency domain. As such, kernels can quickly become too |
| 15 |
// slow to run in a reasonable amount of time (and anyone using a giant kernel should not be |
| 16 |
// relying on Skia to perform the calculations). 256 as a limit on the kernel size is somewhat |
| 17 |
// arbitrary but should, hopefully, not cause existing clients/websites to fail when historically |
| 18 |
// there was no upper limit. |
| 19 |
// Note: SkSL balks (w/ a "program is too large" error) whenever the number of kernel values |
| 20 |
// is >= 2048 (e.g., 8x256, 16x128, ...) so that should be a pretty good upper limit for what |
| 21 |
// is being seen in the wild. |
| 22 |
static constexpr int kLargeKernelSize = 256; |
| 23 |
|
| 24 |
// The texture-based implementation has two levels: a small size version and one at the |
| 25 |
// maximum kernel size. In either case, the texture is a 1D array that can hold any |
| 26 |
// width/height combination that fits within it. |
| 27 |
static constexpr int kSmallKernelSize = 64; |
| 28 |
|
| 29 |
// The uniform-based kernel shader can store 28 values in any order layout (28x1, 1x25, 5x5, and |
| 30 |
// smaller orders like 3x3 or 5x4, etc.), but must be a multiple of 4 for better packing in std140. |
| 31 |
static constexpr int kMaxUniformKernelSize = 28; |
| 32 |
|
| 33 |
} // namespace MatrixConvolutionImageFilter |
| 34 |
|
| 35 |
#endif // SkMatrixConvolutionImageFilter_DEFINED |