104 constexpr int BM_WORDSIZE =
int(
sizeof(potrace_word));
105 constexpr int BM_WORDBITS = 8 * BM_WORDSIZE;
106 constexpr potrace_word BM_HIBIT = potrace_word(1) << (BM_WORDBITS - 1);
109 const int num_words =
bm->dy *
bm->h;
110 const int words_per_scanline =
bm->dy;
120 constexpr bool is_float_color_fn =
121 std::is_invocable_r_v<void, ThresholdFn, const ColorGeometry4f &>;
122 for (const int y : range) {
123 MutableSpan<potrace_word> scanline_words = words.slice(
124 IndexRange(words_per_scanline * y, words_per_scanline));
125 const Span<ColorGeometry4f> scanline_colors = colors.slice(IndexRange(y * ibuf.x, ibuf.x));
126 for (int x = 0; x < ibuf.x; x++) {
127 potrace_word &word = scanline_words[x / BM_WORDBITS];
128 const potrace_word mask = BM_HIBIT >> (x & (BM_WORDBITS - 1));
130 const ColorGeometry4f &fcolor = scanline_colors[x];
132 if constexpr (!is_float_color_fn) {
134 ColorGeometry4b(fcolor.r * 255, fcolor.g * 255, fcolor.b * 255, fcolor.a * 255));
137 is_foreground = fn(fcolor);
156 constexpr bool is_float_color_fn =
157 std::is_invocable_r_v<void, ThresholdFn, const ColorGeometry4f &>;
158 for (const int y : range) {
159 MutableSpan<potrace_word> scanline_words = words.slice(
160 IndexRange(words_per_scanline * y, words_per_scanline));
161 const Span<ColorGeometry4b> scanline_colors = colors.slice(IndexRange(y * ibuf.x, ibuf.x));
162 for (uint32_t x = 0; x < ibuf.x; x++) {
163 potrace_word &word = scanline_words[x / BM_WORDBITS];
164 const potrace_word mask = BM_HIBIT >> (x & (BM_WORDBITS - 1));
166 const ColorGeometry4b bcolor = scanline_colors[x];
168 if constexpr (is_float_color_fn) {
169 is_foreground = fn(ColorGeometry4f(
170 bcolor.r / 255.0f, bcolor.r / 255.0f, bcolor.r / 255.0f, bcolor.r / 255.0f));
173 is_foreground = fn(bcolor);
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int