mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 16:52:18 +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
@@ -62,16 +62,10 @@ func insertBasePixConvSubmoduleYcckC(buf *buffer) error {
|
||||
"size_t dst_stride = dst->private_impl.planes[0].stride;\n" +
|
||||
"uint8_t* dst_iter =\n" +
|
||||
" dst->private_impl.planes[0].ptr + (dst_stride * ((size_t)y)) + (4 * ((size_t)x));\n"
|
||||
const setColorU32AtSrcIter = "" +
|
||||
"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" +
|
||||
const dstIterPlusEq4 = "" +
|
||||
"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",
|
||||
map[string]string{
|
||||
"wuffs_base__color_ycc__as__color_u32( //\n": "wuffs_base__color_ycc__as__color_u32_abgr(\n",
|
||||
},
|
||||
map[string]string{},
|
||||
}}
|
||||
|
||||
for _, p := range generalHv11Patches {
|
||||
const oldFuncNameLine = "wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__hv11(\n"
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -104,21 +96,23 @@ func insertBasePixConvSubmoduleYcckC(buf *buffer) error {
|
||||
"wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__triangle_filter(\n",
|
||||
map[string]string{
|
||||
"// ¡ 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",
|
||||
map[string]string{
|
||||
"// ¡ 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 {
|
||||
const oldFuncNameLine = "wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter(\n"
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -133,21 +127,23 @@ func insertBasePixConvSubmoduleYcckC(buf *buffer) error {
|
||||
"wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__box_filter(\n",
|
||||
map[string]string{
|
||||
"// ¡ 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",
|
||||
map[string]string{
|
||||
"// ¡ 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 {
|
||||
const oldFuncNameLine = "wuffs_base__pixel_swizzler__swizzle_ycc__general__box_filter(\n"
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -207,7 +203,12 @@ func stripCFuncBangComments(buf *buffer, s string) {
|
||||
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")
|
||||
for src != "" {
|
||||
line := ""
|
||||
|
||||
Reference in new issue
Block a user