mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 00:55:11 +01:00
cgen: refactor patch_pixconv's set_color_u32_at
This commit is contained in:
1 parent
43d9c604a2
commit
7511bda9e5
3 files changed
+59
-52
No files matched your search
@@ -406,10 +406,10 @@ wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter_edge_row(
|
|||||||
(total_src_len2 >= half_width_for_2to1));
|
(total_src_len2 >= half_width_for_2to1));
|
||||||
|
|
||||||
for (; x < end; x++) {
|
for (; x < end; x++) {
|
||||||
wuffs_base__pixel_buffer__set_color_u32_at(
|
uint32_t color = //
|
||||||
dst, x, y, //
|
|
||||||
wuffs_base__color_ycc__as__color_u32( //
|
wuffs_base__color_ycc__as__color_u32( //
|
||||||
*up0++, *up1++, *up2++));
|
*up0++, *up1++, *up2++);
|
||||||
|
wuffs_base__pixel_buffer__set_color_u32_at(dst, x, y, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -527,12 +527,13 @@ wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter(
|
|||||||
// ¡ dst_iter = etc
|
// ¡ dst_iter = etc
|
||||||
|
|
||||||
for (; x < end; x++) {
|
for (; x < end; x++) {
|
||||||
// ¡ BEGIN set_color_u32_at
|
uint32_t color = //
|
||||||
wuffs_base__pixel_buffer__set_color_u32_at(
|
|
||||||
dst, x, y, //
|
|
||||||
wuffs_base__color_ycc__as__color_u32( //
|
wuffs_base__color_ycc__as__color_u32( //
|
||||||
*up0++, *up1++, *up2++));
|
*up0++, *up1++, *up2++);
|
||||||
|
// ¡ BEGIN set_color_u32_at
|
||||||
|
wuffs_base__pixel_buffer__set_color_u32_at(dst, x, y, color);
|
||||||
// ¡ END set_color_u32_at
|
// ¡ END set_color_u32_at
|
||||||
|
// ¡ dst_iter += 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,12 +599,13 @@ wuffs_base__pixel_swizzler__swizzle_ycc__general__box_filter(
|
|||||||
uint32_t ix2 = 0u;
|
uint32_t ix2 = 0u;
|
||||||
uint32_t x = 0u;
|
uint32_t x = 0u;
|
||||||
while (true) {
|
while (true) {
|
||||||
// ¡ BEGIN set_color_u32_at
|
uint32_t color = //
|
||||||
wuffs_base__pixel_buffer__set_color_u32_at(
|
|
||||||
dst, x, y, //
|
|
||||||
wuffs_base__color_ycc__as__color_u32( //
|
wuffs_base__color_ycc__as__color_u32( //
|
||||||
*src_iter0, *src_iter1, *src_iter2));
|
*src_iter0, *src_iter1, *src_iter2);
|
||||||
|
// ¡ BEGIN set_color_u32_at
|
||||||
|
wuffs_base__pixel_buffer__set_color_u32_at(dst, x, y, color);
|
||||||
// ¡ END set_color_u32_at
|
// ¡ END set_color_u32_at
|
||||||
|
// ¡ dst_iter += 4
|
||||||
|
|
||||||
if ((x + 1u) == width) {
|
if ((x + 1u) == width) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -62,16 +62,10 @@ func insertBasePixConvSubmoduleYcckC(buf *buffer) error {
|
|||||||
"size_t dst_stride = dst->private_impl.planes[0].stride;\n" +
|
"size_t dst_stride = dst->private_impl.planes[0].stride;\n" +
|
||||||
"uint8_t* dst_iter =\n" +
|
"uint8_t* dst_iter =\n" +
|
||||||
" dst->private_impl.planes[0].ptr + (dst_stride * ((size_t)y)) + (4 * ((size_t)x));\n"
|
" dst->private_impl.planes[0].ptr + (dst_stride * ((size_t)y)) + (4 * ((size_t)x));\n"
|
||||||
const setColorU32AtSrcIter = "" +
|
const dstIterPlusEq4 = "" +
|
||||||
"wuffs_base__poke_u32le__no_bounds_check(\n" +
|
|
||||||
" dst_iter, wuffs_base__color_ycc__as__color_u32_FLAVOR(\n" +
|
|
||||||
" *src_iter0, *src_iter1, *src_iter2));\n" +
|
|
||||||
"dst_iter += 4;\n"
|
|
||||||
const setColorU32AtUp = "" +
|
|
||||||
"wuffs_base__poke_u32le__no_bounds_check(\n" +
|
|
||||||
" dst_iter, wuffs_base__color_ycc__as__color_u32_FLAVOR(\n" +
|
|
||||||
" *up0++, *up1++, *up2++));\n" +
|
|
||||||
"dst_iter += 4;\n"
|
"dst_iter += 4;\n"
|
||||||
|
const setColorU32At = "" +
|
||||||
|
"wuffs_base__poke_u32le__no_bounds_check(dst_iter, color);\n"
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
|
|
||||||
@@ -81,15 +75,13 @@ func insertBasePixConvSubmoduleYcckC(buf *buffer) error {
|
|||||||
}{{
|
}{{
|
||||||
|
|
||||||
"wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__hv11(\n",
|
"wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__hv11(\n",
|
||||||
map[string]string{
|
map[string]string{},
|
||||||
"wuffs_base__color_ycc__as__color_u32( //\n": "wuffs_base__color_ycc__as__color_u32_abgr(\n",
|
|
||||||
},
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
for _, p := range generalHv11Patches {
|
for _, p := range generalHv11Patches {
|
||||||
const oldFuncNameLine = "wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__hv11(\n"
|
const oldFuncNameLine = "wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__hv11(\n"
|
||||||
p.patchMap[oldFuncNameLine] = p.newFuncNameLine
|
p.patchMap[oldFuncNameLine] = p.newFuncNameLine
|
||||||
if err := patchCFunc(buf, bgrxHv11, oldFuncNameLine, p.patchMap); err != nil {
|
if err := patchCFunc(buf, bgrxHv11, p.newFuncNameLine, p.patchMap); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,21 +96,23 @@ func insertBasePixConvSubmoduleYcckC(buf *buffer) error {
|
|||||||
"wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__triangle_filter(\n",
|
"wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__triangle_filter(\n",
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"// ¡ dst_iter = etc\n": dstIterWithX,
|
"// ¡ dst_iter = etc\n": dstIterWithX,
|
||||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32AtUp, "_FLAVOR", "", 1),
|
"// ¡ dst_iter += 4\n": dstIterPlusEq4,
|
||||||
|
"// ¡ BEGIN set_color_u32_at\n": setColorU32At,
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
|
|
||||||
"wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__triangle_filter(\n",
|
"wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__triangle_filter(\n",
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"// ¡ dst_iter = etc\n": dstIterWithX,
|
"// ¡ dst_iter = etc\n": dstIterWithX,
|
||||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32AtUp, "_FLAVOR", "_abgr", 1),
|
"// ¡ dst_iter += 4\n": dstIterPlusEq4,
|
||||||
|
"// ¡ BEGIN set_color_u32_at\n": setColorU32At,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
for _, p := range generalTriangleFilterPatches {
|
for _, p := range generalTriangleFilterPatches {
|
||||||
const oldFuncNameLine = "wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter(\n"
|
const oldFuncNameLine = "wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter(\n"
|
||||||
p.patchMap[oldFuncNameLine] = p.newFuncNameLine
|
p.patchMap[oldFuncNameLine] = p.newFuncNameLine
|
||||||
if err := patchCFunc(buf, generalTriangleFilter, oldFuncNameLine, p.patchMap); err != nil {
|
if err := patchCFunc(buf, generalTriangleFilter, p.newFuncNameLine, p.patchMap); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,21 +127,23 @@ func insertBasePixConvSubmoduleYcckC(buf *buffer) error {
|
|||||||
"wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__box_filter(\n",
|
"wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__box_filter(\n",
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"// ¡ dst_iter = etc\n": dstIterEtcSansX,
|
"// ¡ dst_iter = etc\n": dstIterEtcSansX,
|
||||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32AtSrcIter, "_FLAVOR", "", 1),
|
"// ¡ dst_iter += 4\n": dstIterPlusEq4,
|
||||||
|
"// ¡ BEGIN set_color_u32_at\n": setColorU32At,
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
|
|
||||||
"wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__box_filter(\n",
|
"wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__box_filter(\n",
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"// ¡ dst_iter = etc\n": dstIterEtcSansX,
|
"// ¡ dst_iter = etc\n": dstIterEtcSansX,
|
||||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32AtSrcIter, "_FLAVOR", "_abgr", 1),
|
"// ¡ dst_iter += 4\n": dstIterPlusEq4,
|
||||||
|
"// ¡ BEGIN set_color_u32_at\n": setColorU32At,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
for _, p := range generalBoxFilterPatches {
|
for _, p := range generalBoxFilterPatches {
|
||||||
const oldFuncNameLine = "wuffs_base__pixel_swizzler__swizzle_ycc__general__box_filter(\n"
|
const oldFuncNameLine = "wuffs_base__pixel_swizzler__swizzle_ycc__general__box_filter(\n"
|
||||||
p.patchMap[oldFuncNameLine] = p.newFuncNameLine
|
p.patchMap[oldFuncNameLine] = p.newFuncNameLine
|
||||||
if err := patchCFunc(buf, generalBoxFilter, oldFuncNameLine, p.patchMap); err != nil {
|
if err := patchCFunc(buf, generalBoxFilter, p.newFuncNameLine, p.patchMap); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,7 +203,12 @@ func stripCFuncBangComments(buf *buffer, s string) {
|
|||||||
buf.writes(s)
|
buf.writes(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func patchCFunc(buf *buffer, src string, oldFuncNameLine string, patchMap map[string]string) error {
|
func patchCFunc(buf *buffer, src string, newFuncNameLine string, patchMap map[string]string) error {
|
||||||
|
if strings.Contains(newFuncNameLine, "swizzle_ycc__rgbx__") {
|
||||||
|
patchMap["wuffs_base__color_ycc__as__color_u32( //\n"] =
|
||||||
|
"wuffs_base__color_ycc__as__color_u32_abgr(\n"
|
||||||
|
}
|
||||||
|
|
||||||
buf.writes("// Generated by internal/cgen/patch_pixconv.go\n")
|
buf.writes("// Generated by internal/cgen/patch_pixconv.go\n")
|
||||||
for src != "" {
|
for src != "" {
|
||||||
line := ""
|
line := ""
|
||||||
|
|||||||
@@ -23130,10 +23130,10 @@ wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter_edge_row(
|
|||||||
(total_src_len2 >= half_width_for_2to1));
|
(total_src_len2 >= half_width_for_2to1));
|
||||||
|
|
||||||
for (; x < end; x++) {
|
for (; x < end; x++) {
|
||||||
wuffs_base__pixel_buffer__set_color_u32_at(
|
uint32_t color = //
|
||||||
dst, x, y, //
|
|
||||||
wuffs_base__color_ycc__as__color_u32( //
|
wuffs_base__color_ycc__as__color_u32( //
|
||||||
*up0++, *up1++, *up2++));
|
*up0++, *up1++, *up2++);
|
||||||
|
wuffs_base__pixel_buffer__set_color_u32_at(dst, x, y, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23249,10 +23249,10 @@ wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter(
|
|||||||
(total_src_len2 >= half_width_for_2to1));
|
(total_src_len2 >= half_width_for_2to1));
|
||||||
|
|
||||||
for (; x < end; x++) {
|
for (; x < end; x++) {
|
||||||
wuffs_base__pixel_buffer__set_color_u32_at(
|
uint32_t color = //
|
||||||
dst, x, y, //
|
|
||||||
wuffs_base__color_ycc__as__color_u32( //
|
wuffs_base__color_ycc__as__color_u32( //
|
||||||
*up0++, *up1++, *up2++));
|
*up0++, *up1++, *up2++);
|
||||||
|
wuffs_base__pixel_buffer__set_color_u32_at(dst, x, y, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23316,10 +23316,10 @@ wuffs_base__pixel_swizzler__swizzle_ycc__general__box_filter(
|
|||||||
uint32_t ix2 = 0u;
|
uint32_t ix2 = 0u;
|
||||||
uint32_t x = 0u;
|
uint32_t x = 0u;
|
||||||
while (true) {
|
while (true) {
|
||||||
wuffs_base__pixel_buffer__set_color_u32_at(
|
uint32_t color = //
|
||||||
dst, x, y, //
|
|
||||||
wuffs_base__color_ycc__as__color_u32( //
|
wuffs_base__color_ycc__as__color_u32( //
|
||||||
*src_iter0, *src_iter1, *src_iter2));
|
*src_iter0, *src_iter1, *src_iter2);
|
||||||
|
wuffs_base__pixel_buffer__set_color_u32_at(dst, x, y, color);
|
||||||
|
|
||||||
if ((x + 1u) == width) {
|
if ((x + 1u) == width) {
|
||||||
break;
|
break;
|
||||||
@@ -23633,9 +23633,10 @@ wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__triangle_filter(
|
|||||||
dst->private_impl.planes[0].ptr + (dst_stride * ((size_t)y)) + (4 * ((size_t)x));
|
dst->private_impl.planes[0].ptr + (dst_stride * ((size_t)y)) + (4 * ((size_t)x));
|
||||||
|
|
||||||
for (; x < end; x++) {
|
for (; x < end; x++) {
|
||||||
wuffs_base__poke_u32le__no_bounds_check(
|
uint32_t color = //
|
||||||
dst_iter, wuffs_base__color_ycc__as__color_u32(
|
wuffs_base__color_ycc__as__color_u32( //
|
||||||
*up0++, *up1++, *up2++));
|
*up0++, *up1++, *up2++);
|
||||||
|
wuffs_base__poke_u32le__no_bounds_check(dst_iter, color);
|
||||||
dst_iter += 4;
|
dst_iter += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23771,9 +23772,10 @@ wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__triangle_filter(
|
|||||||
dst->private_impl.planes[0].ptr + (dst_stride * ((size_t)y)) + (4 * ((size_t)x));
|
dst->private_impl.planes[0].ptr + (dst_stride * ((size_t)y)) + (4 * ((size_t)x));
|
||||||
|
|
||||||
for (; x < end; x++) {
|
for (; x < end; x++) {
|
||||||
wuffs_base__poke_u32le__no_bounds_check(
|
uint32_t color = //
|
||||||
dst_iter, wuffs_base__color_ycc__as__color_u32_abgr(
|
wuffs_base__color_ycc__as__color_u32_abgr(
|
||||||
*up0++, *up1++, *up2++));
|
*up0++, *up1++, *up2++);
|
||||||
|
wuffs_base__poke_u32le__no_bounds_check(dst_iter, color);
|
||||||
dst_iter += 4;
|
dst_iter += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23841,9 +23843,10 @@ wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__box_filter(
|
|||||||
uint32_t ix2 = 0u;
|
uint32_t ix2 = 0u;
|
||||||
uint32_t x = 0u;
|
uint32_t x = 0u;
|
||||||
while (true) {
|
while (true) {
|
||||||
wuffs_base__poke_u32le__no_bounds_check(
|
uint32_t color = //
|
||||||
dst_iter, wuffs_base__color_ycc__as__color_u32(
|
wuffs_base__color_ycc__as__color_u32( //
|
||||||
*src_iter0, *src_iter1, *src_iter2));
|
*src_iter0, *src_iter1, *src_iter2);
|
||||||
|
wuffs_base__poke_u32le__no_bounds_check(dst_iter, color);
|
||||||
dst_iter += 4;
|
dst_iter += 4;
|
||||||
|
|
||||||
if ((x + 1u) == width) {
|
if ((x + 1u) == width) {
|
||||||
@@ -23935,9 +23938,10 @@ wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__box_filter(
|
|||||||
uint32_t ix2 = 0u;
|
uint32_t ix2 = 0u;
|
||||||
uint32_t x = 0u;
|
uint32_t x = 0u;
|
||||||
while (true) {
|
while (true) {
|
||||||
wuffs_base__poke_u32le__no_bounds_check(
|
uint32_t color = //
|
||||||
dst_iter, wuffs_base__color_ycc__as__color_u32_abgr(
|
wuffs_base__color_ycc__as__color_u32_abgr(
|
||||||
*src_iter0, *src_iter1, *src_iter2));
|
*src_iter0, *src_iter1, *src_iter2);
|
||||||
|
wuffs_base__poke_u32le__no_bounds_check(dst_iter, color);
|
||||||
dst_iter += 4;
|
dst_iter += 4;
|
||||||
|
|
||||||
if ((x + 1u) == width) {
|
if ((x + 1u) == width) {
|
||||||
|
|||||||
Reference in new issue
Block a user