From d47bf4e4e549807784f2dad381c6514e4f45ff17 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 19 Aug 2018 18:06:44 +1000 Subject: [PATCH] Fix wuffs_base__frame_config__blend --- cmd/wuffs-c/internal/cgen/base/image-public.h | 2 +- cmd/wuffs-c/internal/cgen/data.go | 6 +++--- release/c/wuffs-unsupported-snapshot.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/wuffs-c/internal/cgen/base/image-public.h b/cmd/wuffs-c/internal/cgen/base/image-public.h index 3c3780af..961c4029 100644 --- a/cmd/wuffs-c/internal/cgen/base/image-public.h +++ b/cmd/wuffs-c/internal/cgen/base/image-public.h @@ -657,7 +657,7 @@ wuffs_base__frame_config__duration(wuffs_base__frame_config* c) { // the transparent pixels of this frame with the existing canvas. static inline wuffs_base__animation_blend // wuffs_base__frame_config__blend(wuffs_base__frame_config* c) { - return c && c->private_impl.blend; + return c ? c->private_impl.blend : 0; } // wuffs_base__frame_config__disposal returns, for an animated image, how to diff --git a/cmd/wuffs-c/internal/cgen/data.go b/cmd/wuffs-c/internal/cgen/data.go index 12d69553..5aa7ae9c 100644 --- a/cmd/wuffs-c/internal/cgen/data.go +++ b/cmd/wuffs-c/internal/cgen/data.go @@ -148,9 +148,9 @@ const baseImagePublicH = "" + "" + "// --------\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__rect_ie_u32 bounds;\n wuffs_base__flicks duration;\n wuffs_base__animation_blend blend;\n wuffs_base__animation_disposal disposal;\n bool palette_changed;\n } private_impl;\n\n#ifdef __cplusplus\n inline void update(wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n wuffs_base__animation_blend blend,\n wuffs_base__animation_disposal disposal,\n bool palette_changed);\n inline wuffs_base__rect_ie_u32 bounds();\n inline uint32_t width();\n inline uint32_t height();\n inline wuffs_base__flicks duration();\n inline wuffs_base__animation_blend blend();\n inline wuffs_base__animation_disposal disposal();\n inline bool palette_changed();\n#endif // __cplusplus\n\n} wuffs_base__frame_config;\n\nstatic inline void //\nwuffs_base__frame_config__up" + "date(wuffs_base__frame_config* c,\n wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n wuffs_base__animation_blend blend,\n wuffs_base__animation_disposal disposal,\n bool palette_changed) {\n if (!c) {\n return;\n }\n\n c->private_impl.bounds = bounds;\n c->private_impl.duration = duration;\n c->private_impl.blend = blend;\n c->private_impl.disposal = disposal;\n c->private_impl.palette_changed = palette_changed;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__frame_config__bounds(wuffs_base__frame_config* c) {\n return c ? c->private_impl.bounds : ((wuffs_base__rect_ie_u32){});\n}\n\nstatic inline uint32_t //\nwuffs_base__frame_config__width(wuffs_base__frame_config* c) {\n return c ? wuffs_base__rect_ie_u32__width(&c->private_impl.bounds) : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__frame_config__height(wuffs_base__frame_config* c)" + - " {\n return c ? wuffs_base__rect_ie_u32__height(&c->private_impl.bounds) : 0;\n}\n\n// wuffs_base__frame_config__duration returns the amount of time to display\n// this frame. Zero means to display forever - a still (non-animated) image.\nstatic inline wuffs_base__flicks //\nwuffs_base__frame_config__duration(wuffs_base__frame_config* c) {\n return c ? c->private_impl.duration : 0;\n}\n\n// wuffs_base__frame_config__blend returns, for an animated image, how to blend\n// the transparent pixels of this frame with the existing canvas.\nstatic inline wuffs_base__animation_blend //\nwuffs_base__frame_config__blend(wuffs_base__frame_config* c) {\n return c && c->private_impl.blend;\n}\n\n// wuffs_base__frame_config__disposal returns, for an animated image, how to\n// dispose of this frame after displaying it.\nstatic inline wuffs_base__animation_disposal //\nwuffs_base__frame_config__disposal(wuffs_base__frame_config* c) {\n return c ? c->private_impl.disposal : 0;\n}\n\n// wuffs_base__frame_config__palette_changed returns whether t" + - "his frame's\n// palette differs from the previous frame. It is conservative and may return\n// false positives (but never false negatives).\nstatic inline bool //\nwuffs_base__frame_config__palette_changed(wuffs_base__frame_config* c) {\n return c && c->private_impl.palette_changed;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__frame_config::update(wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n wuffs_base__animation_blend blend,\n wuffs_base__animation_disposal disposal,\n bool palette_changed) {\n wuffs_base__frame_config__update(this, bounds, duration, blend, disposal,\n palette_changed);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__frame_config::bounds() {\n return wuffs_base__frame_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__frame_config::width() {\n return wuffs_base__frame_config__width(this);\n}\n\ninline uint32_t" + - " //\nwuffs_base__frame_config::height() {\n return wuffs_base__frame_config__height(this);\n}\n\ninline wuffs_base__flicks //\nwuffs_base__frame_config::duration() {\n return wuffs_base__frame_config__duration(this);\n}\n\ninline wuffs_base__animation_blend //\nwuffs_base__frame_config::blend() {\n return wuffs_base__frame_config__blend(this);\n}\n\ninline wuffs_base__animation_disposal //\nwuffs_base__frame_config::disposal() {\n return wuffs_base__frame_config__disposal(this);\n}\n\ninline bool //\nwuffs_base__frame_config::palette_changed() {\n return wuffs_base__frame_config__palette_changed(this);\n}\n\n#endif // __cplusplus\n\n" + + " {\n return c ? wuffs_base__rect_ie_u32__height(&c->private_impl.bounds) : 0;\n}\n\n// wuffs_base__frame_config__duration returns the amount of time to display\n// this frame. Zero means to display forever - a still (non-animated) image.\nstatic inline wuffs_base__flicks //\nwuffs_base__frame_config__duration(wuffs_base__frame_config* c) {\n return c ? c->private_impl.duration : 0;\n}\n\n// wuffs_base__frame_config__blend returns, for an animated image, how to blend\n// the transparent pixels of this frame with the existing canvas.\nstatic inline wuffs_base__animation_blend //\nwuffs_base__frame_config__blend(wuffs_base__frame_config* c) {\n return c ? c->private_impl.blend : 0;\n}\n\n// wuffs_base__frame_config__disposal returns, for an animated image, how to\n// dispose of this frame after displaying it.\nstatic inline wuffs_base__animation_disposal //\nwuffs_base__frame_config__disposal(wuffs_base__frame_config* c) {\n return c ? c->private_impl.disposal : 0;\n}\n\n// wuffs_base__frame_config__palette_changed returns whethe" + + "r this frame's\n// palette differs from the previous frame. It is conservative and may return\n// false positives (but never false negatives).\nstatic inline bool //\nwuffs_base__frame_config__palette_changed(wuffs_base__frame_config* c) {\n return c && c->private_impl.palette_changed;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__frame_config::update(wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n wuffs_base__animation_blend blend,\n wuffs_base__animation_disposal disposal,\n bool palette_changed) {\n wuffs_base__frame_config__update(this, bounds, duration, blend, disposal,\n palette_changed);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__frame_config::bounds() {\n return wuffs_base__frame_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__frame_config::width() {\n return wuffs_base__frame_config__width(this);\n}\n\ninline uint3" + + "2_t //\nwuffs_base__frame_config::height() {\n return wuffs_base__frame_config__height(this);\n}\n\ninline wuffs_base__flicks //\nwuffs_base__frame_config::duration() {\n return wuffs_base__frame_config__duration(this);\n}\n\ninline wuffs_base__animation_blend //\nwuffs_base__frame_config::blend() {\n return wuffs_base__frame_config__blend(this);\n}\n\ninline wuffs_base__animation_disposal //\nwuffs_base__frame_config::disposal() {\n return wuffs_base__frame_config__disposal(this);\n}\n\ninline bool //\nwuffs_base__frame_config::palette_changed() {\n return wuffs_base__frame_config__palette_changed(this);\n}\n\n#endif // __cplusplus\n\n" + "" + "// --------\n\ntypedef struct {\n wuffs_base__pixel_config pixcfg;\n\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__table_u8 planes[WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX];\n uint8_t palette[1024];\n // TODO: color spaces.\n } private_impl;\n\n#ifdef __cplusplus\n inline wuffs_base__status set_from_slice(wuffs_base__pixel_config* pixcfg,\n wuffs_base__slice_u8 pixbuf_memory);\n inline void set_palette(wuffs_base__slice_u8 palette);\n inline wuffs_base__table_u8 plane(uint32_t p);\n inline wuffs_base__slice_u8 palette();\n#endif // __cplusplus\n\n} wuffs_base__pixel_buffer;\n\nstatic inline wuffs_base__status //\nwuffs_base__pixel_buffer__set_from_slice(wuffs_base__pixel_buffer* b,\n wuffs_base__pixel_config* pixcfg,\n wuffs_base__slice_u8 pixbuf_memory) {\n if (!b) {\n return wuffs_base_" + "_error__bad_receiver;\n }\n *b = ((wuffs_base__pixel_buffer){});\n if (!pixcfg) {\n return wuffs_base__error__bad_argument;\n }\n // TODO: don't assume 1 byte per pixel. Don't assume packed.\n uint64_t wh = ((uint64_t)pixcfg->private_impl.width) *\n ((uint64_t)pixcfg->private_impl.height);\n if (wh > pixbuf_memory.len) {\n return wuffs_base__error__bad_argument_length_too_short;\n }\n b->pixcfg = *pixcfg;\n wuffs_base__table_u8* tab = &b->private_impl.planes[0];\n tab->ptr = pixbuf_memory.ptr;\n tab->width = pixcfg->private_impl.width;\n tab->height = pixcfg->private_impl.height;\n tab->stride = pixcfg->private_impl.width;\n return NULL;\n}\n\n// The palette argument is ignored unless its length is exactly 1024.\nstatic inline void //\nwuffs_base__pixel_buffer__set_palette(wuffs_base__pixel_buffer* b,\n wuffs_base__slice_u8 palette) {\n if (b && palette.ptr && (palette.len == 1024)) {\n memmove(b->private_impl.palette, palette.ptr, 1024);\n }\n}\n\nstatic inlin" + diff --git a/release/c/wuffs-unsupported-snapshot.h b/release/c/wuffs-unsupported-snapshot.h index 9a98f5ca..e9045445 100644 --- a/release/c/wuffs-unsupported-snapshot.h +++ b/release/c/wuffs-unsupported-snapshot.h @@ -1753,7 +1753,7 @@ wuffs_base__frame_config__duration(wuffs_base__frame_config* c) { // the transparent pixels of this frame with the existing canvas. static inline wuffs_base__animation_blend // wuffs_base__frame_config__blend(wuffs_base__frame_config* c) { - return c && c->private_impl.blend; + return c ? c->private_impl.blend : 0; } // wuffs_base__frame_config__disposal returns, for an animated image, how to