FastLED 3.10.8
Loading...
Searching...
No Matches

◆ blurGaussianImpl()

template<int hRadius, int vRadius, typename RGB_T, typename AlphaT>
FL_OPTIMIZE_FUNCTION void fl::gfx::blurGaussianImpl ( Canvas< RGB_T > & canvas,
AlphaT alpha )

Definition at line 1132 of file blur.cpp.hpp.

1132 {
1133 const int w = canvas.width;
1134 const int h = canvas.height;
1135 if (w <= 0 || h <= 0)
1136 return;
1137
1139
1140 // Accumulator: u16 for 8-bit channels (max per-pass sum: 255*256=65280),
1141 // u32 for wider channels.
1142 using acc_t = fl::conditional_t<sizeof(typename RGB_T::fp) == 1, u16, u32>;
1143
1144 const bool applyAlpha = !(alpha == blur_detail::alpha_identity<AlphaT>());
1145
1146 // Handle no-blur case (radius 0 in both dimensions).
1147 if (hRadius == 0 && vRadius == 0) {
1148 if (applyAlpha) {
1149 RGB_T *pixels = canvas.pixels;
1150 for (int i = 0; i < w * h; ++i) {
1151 RGB_T &p = pixels[i];
1152 p = P::make(P::ch(p.r), P::ch(p.g), P::ch(p.b), alpha);
1153 }
1154 }
1155 return;
1156 }
1157
1158 fl::span<RGB_T> padbuf = blur_detail::get_padbuf<RGB_T>(
1160 RGB_T *pad = padbuf.data();
1161 RGB_T *pixels = canvas.pixels;
1162
1163 // ── Horizontal pass ──────────────────────────────────────────────
1164 if (hRadius > 0) {
1165 // Zero the fixed padding regions once (reused for every row).
1166 FL_BUILTIN_MEMSET(pad, 0, hRadius * sizeof(RGB_T));
1167 FL_BUILTIN_MEMSET(pad + hRadius + w, 0, hRadius * sizeof(RGB_T));
1168
1169 for (int y = 0; y < h; ++y) {
1170 RGB_T *row = pixels + y * w;
1171 FL_BUILTIN_MEMCPY(pad + hRadius, row, w * sizeof(RGB_T));
1172
1173 if (vRadius == 0 && applyAlpha)
1175 pad, row, w, alpha);
1176 else
1178 pad, row, w, alpha);
1179 }
1180 }
1181
1182 // ── Vertical pass ──────────────────────────────────────────────────
1183 if (vRadius > 0) {
1184 if (applyAlpha)
1186 pixels, w, h, pad, alpha);
1187 else
1189 pixels, w, h, pad, alpha);
1190 }
1191}
const T * data() const FL_NO_EXCEPT
Definition span.h:486
#define FL_BUILTIN_MEMCPY(dest, src, n)
#define FL_BUILTIN_MEMSET(dest, val, n)
static void vpass_full(RGB_T *pixels, int w, int h, RGB_T *scratch, AlphaT alpha) FL_NO_EXCEPT
static fl::span< RGB_T > get_padbuf(int minSize) FL_NO_EXCEPT
Definition blur.cpp.hpp:350
FL_ALWAYS_INLINE void hpass_row(RGB_T *pad, RGB_T *out, int w, AlphaT alpha) FL_NO_EXCEPT
static int compute_pad_size(int w, int h) FL_NO_EXCEPT
constexpr AlphaT alpha_identity() FL_NO_EXCEPT
typename conditional< B, T, F >::type conditional_t
FASTLED_FORCE_INLINE fl::u8 P(fl::u8 x) FL_NO_EXCEPT
RGB_T * pixels
Definition canvas.h:72

References fl::gfx::blur_detail::alpha_identity(), fl::gfx::blur_detail::compute_pad_size(), fl::span< T, Extent >::data(), FL_BUILTIN_MEMCPY, FL_BUILTIN_MEMSET, fl::FL_NO_EXCEPT, fl::gfx::blur_detail::get_padbuf(), fl::gfx::blur_detail::hpass_row(), fl::P(), fl::gfx::blur_detail::vpass_full(), and fl::y.

Referenced by blurGaussian(), blurGaussian(), and blurGaussianMappedImpl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: