diff --git a/cmd/wuffs-c/internal/cgen/base/base-public.h b/cmd/wuffs-c/internal/cgen/base/base-public.h index c3424582..b3d7cf89 100644 --- a/cmd/wuffs-c/internal/cgen/base/base-public.h +++ b/cmd/wuffs-c/internal/cgen/base/base-public.h @@ -1180,7 +1180,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/cmd/wuffs-c/internal/cgen/data.go b/cmd/wuffs-c/internal/cgen/data.go index f9ce50cd..8a694fb0 100644 --- a/cmd/wuffs-c/internal/cgen/data.go +++ b/cmd/wuffs-c/internal/cgen/data.go @@ -87,9 +87,9 @@ const basePublicH = "" + "// --------\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__image_config config;\n uint32_t loop_count; // 0-based count of the current loop.\n wuffs_base__pixel_buffer pixbuf;\n // TODO: color spaces.\n wuffs_base__rect_ie_u32 dirty_rect;\n wuffs_base__flicks duration;\n bool blend;\n wuffs_base__animation_disposal disposal;\n bool palette_changed;\n uint8_t palette[1024];\n } private_impl;\n} wuffs_base__image_buffer;\n\nstatic inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(\n wuffs_base__image_buffer* b,\n wuffs_base__image_config config,\n wuffs_base__pixel_buffer pixbuf) {\n if (!b) {\n return WUFFS_BASE__ERROR_BAD_RECEIVER;\n }\n *b = ((wuffs_base__image_buffer){});\n b->private_impl.config = config;\n b->private_impl.pixbuf = pixbuf;\n return WUFFS_BASE__STATUS_OK;\n}\n\nstatic inline wuffs_base__status wuffs_base__image_buffer__set_from_" + "slice(\n wuffs_base__image_buffer* b,\n wuffs_base__image_config config,\n wuffs_base__slice_u8 pixbuf_memory) {\n if (!b) {\n return WUFFS_BASE__ERROR_BAD_RECEIVER;\n }\n *b = ((wuffs_base__image_buffer){});\n // TODO: don't assume 1 byte per pixel. Don't assume packed.\n uint64_t wh = ((uint64_t)config.private_impl.width) *\n ((uint64_t)config.private_impl.height);\n if (wh > pixbuf_memory.len) {\n return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;\n }\n b->private_impl.config = config;\n wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];\n tab->ptr = pixbuf_memory.ptr;\n tab->width = config.private_impl.width;\n tab->height = config.private_impl.height;\n tab->stride = config.private_impl.width;\n return WUFFS_BASE__STATUS_OK;\n}\n\n// The palette argument is ignored unless its length is exactly 1024.\nstatic inline void wuffs_base__image_buffer__update(\n wuffs_base__image_buffer* b,\n wuffs_base__rect_ie_u32 dirty_rect,\n wuffs_base__flicks duration,\n bool bl" + "end,\n wuffs_base__animation_disposal disposal,\n wuffs_base__slice_u8 palette) {\n if (!b) {\n return;\n }\n\n // Clip the dirty_rect to the image bounds.\n dirty_rect.max_excl_x = wuffs_base__u32__min(\n dirty_rect.max_excl_x, b->private_impl.config.private_impl.width);\n dirty_rect.max_excl_y = wuffs_base__u32__min(\n dirty_rect.max_excl_y, b->private_impl.config.private_impl.height);\n b->private_impl.dirty_rect = dirty_rect;\n\n b->private_impl.duration = duration;\n b->private_impl.blend = blend;\n b->private_impl.disposal = disposal;\n b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);\n if (b->private_impl.palette_changed) {\n memmove(b->private_impl.palette, palette.ptr, 1024);\n }\n}\n\n// wuffs_base__image_buffer__loop returns whether the image decoder should loop\n// back to the beginning of the animation, assuming that we've reached the end\n// of the encoded stream. If so, it increments b's count of the animation loops\n// played so far.\nstatic inline bool wuffs_base" + - "__image_buffer__loop(wuffs_base__image_buffer* b) {\n if (!b) {\n return false;\n }\n uint32_t n = b->private_impl.config.private_impl.num_loops;\n if (n == 0) {\n return true;\n }\n if (b->private_impl.loop_count < n - 1) {\n b->private_impl.loop_count++;\n return true;\n }\n return false;\n}\n\n// wuffs_base__image_config returns the overall configuration for this frame.\nstatic inline wuffs_base__image_config* wuffs_base__image_buffer__image_config(\n wuffs_base__image_buffer* b) {\n return b ? &b->private_impl.config : NULL;\n}\n\n// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of\n// this frame's pixels differs from the previous frame.\nstatic inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});\n}\n\n// wuffs_base__image_buffer__duration returns the amount of time to display\n// this frame. Zero means to display forever - a still (non-animated) image.\nsta" + - "tic inline wuffs_base__flicks wuffs_base__image_buffer__duration(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.duration : 0;\n}\n\n// wuffs_base__image_buffer__blend returns, for a transparent image, whether to\n// blend this frame with the existing canvas.\n//\n// In Porter-Duff compositing operator terminology, false means \"src\" and true\n// means \"src over dst\".\nstatic inline bool wuffs_base__image_buffer__blend(\n wuffs_base__image_buffer* b) {\n return b && b->private_impl.blend;\n}\n\n// wuffs_base__image_buffer__disposal returns, for an animated image, how to\n// dispose of this frame after displaying it.\nstatic inline wuffs_base__animation_disposal wuffs_base__image_buffer__disposal(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.disposal : 0;\n}\n\n// wuffs_base__image_buffer__palette_changed returns whether 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 wuffs_base__i" + - "mage_buffer__palette_changed(\n wuffs_base__image_buffer* b) {\n return b && b->private_impl.palette_changed;\n}\n\n// wuffs_base__image_buffer__palette returns the palette that the pixel data\n// can index. The backing array is inside b and has length 1024.\nstatic inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(\n wuffs_base__image_buffer* b) {\n return b ? ((wuffs_base__slice_u8){.ptr = b->private_impl.palette,\n .len = 1024})\n : ((wuffs_base__slice_u8){});\n}\n\nstatic inline wuffs_base__table_u8 wuffs_base__image_buffer__plane(\n wuffs_base__image_buffer* b,\n uint32_t p) {\n return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))\n ? b->private_impl.pixbuf.planes[p]\n : ((wuffs_base__table_u8){});\n}\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n#endif // WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n" + + "__image_buffer__loop(wuffs_base__image_buffer* b) {\n if (!b) {\n return false;\n }\n uint32_t n = b->private_impl.config.private_impl.num_loops;\n if (n == 0) {\n return true;\n }\n if (b->private_impl.loop_count < n - 1) {\n b->private_impl.loop_count++;\n return true;\n }\n return false;\n}\n\n// wuffs_base__image_config returns the overall configuration for this frame.\nstatic inline wuffs_base__image_config* wuffs_base__image_buffer__image_config(\n wuffs_base__image_buffer* b) {\n return b ? &b->private_impl.config : NULL;\n}\n\n// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of\n// this frame's pixels differs from the previous frame.\nstatic inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){});\n}\n\n// wuffs_base__image_buffer__duration returns the amount of time to display\n// this frame. Zero means to display forever - a still (non-animated) image.\nstat" + + "ic inline wuffs_base__flicks wuffs_base__image_buffer__duration(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.duration : 0;\n}\n\n// wuffs_base__image_buffer__blend returns, for a transparent image, whether to\n// blend this frame with the existing canvas.\n//\n// In Porter-Duff compositing operator terminology, false means \"src\" and true\n// means \"src over dst\".\nstatic inline bool wuffs_base__image_buffer__blend(\n wuffs_base__image_buffer* b) {\n return b && b->private_impl.blend;\n}\n\n// wuffs_base__image_buffer__disposal returns, for an animated image, how to\n// dispose of this frame after displaying it.\nstatic inline wuffs_base__animation_disposal wuffs_base__image_buffer__disposal(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.disposal : 0;\n}\n\n// wuffs_base__image_buffer__palette_changed returns whether 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 wuffs_base__im" + + "age_buffer__palette_changed(\n wuffs_base__image_buffer* b) {\n return b && b->private_impl.palette_changed;\n}\n\n// wuffs_base__image_buffer__palette returns the palette that the pixel data\n// can index. The backing array is inside b and has length 1024.\nstatic inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(\n wuffs_base__image_buffer* b) {\n return b ? ((wuffs_base__slice_u8){.ptr = b->private_impl.palette,\n .len = 1024})\n : ((wuffs_base__slice_u8){});\n}\n\nstatic inline wuffs_base__table_u8 wuffs_base__image_buffer__plane(\n wuffs_base__image_buffer* b,\n uint32_t p) {\n return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))\n ? b->private_impl.pixbuf.planes[p]\n : ((wuffs_base__table_u8){});\n}\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n#endif // WUFFS_INCLUDE_GUARD__BASE_PUBLIC\n" + "" const basePrivateH = "" + diff --git a/gen/c/base.c b/gen/c/base.c index 49fe3b5a..a61c4678 100644 --- a/gen/c/base.c +++ b/gen/c/base.c @@ -1211,7 +1211,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/c/std/adler32.c b/gen/c/std/adler32.c index 467dc4c3..18b11044 100644 --- a/gen/c/std/adler32.c +++ b/gen/c/std/adler32.c @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/c/std/crc32.c b/gen/c/std/crc32.c index 264621ad..1f752206 100644 --- a/gen/c/std/crc32.c +++ b/gen/c/std/crc32.c @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/c/std/deflate.c b/gen/c/std/deflate.c index 0105e19a..ab6da326 100644 --- a/gen/c/std/deflate.c +++ b/gen/c/std/deflate.c @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index a6f66d6a..8d39db88 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/c/std/gzip.c b/gen/c/std/gzip.c index 08087fa1..24bc04b7 100644 --- a/gen/c/std/gzip.c +++ b/gen/c/std/gzip.c @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/c/std/lzw.c b/gen/c/std/lzw.c index e984822b..f29b3dcc 100644 --- a/gen/c/std/lzw.c +++ b/gen/c/std/lzw.c @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/c/std/zlib.c b/gen/c/std/zlib.c index 9001f715..69e3a94a 100644 --- a/gen/c/std/zlib.c +++ b/gen/c/std/zlib.c @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/h/std/adler32.h b/gen/h/std/adler32.h index beb2db88..7dd317c5 100644 --- a/gen/h/std/adler32.h +++ b/gen/h/std/adler32.h @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/h/std/crc32.h b/gen/h/std/crc32.h index a7699c2c..9e3bf0b3 100644 --- a/gen/h/std/crc32.h +++ b/gen/h/std/crc32.h @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/h/std/deflate.h b/gen/h/std/deflate.h index 15e74507..ed7f3651 100644 --- a/gen/h/std/deflate.h +++ b/gen/h/std/deflate.h @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/h/std/gif.h b/gen/h/std/gif.h index 0b0f7bee..7bfeae8f 100644 --- a/gen/h/std/gif.h +++ b/gen/h/std/gif.h @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/h/std/gzip.h b/gen/h/std/gzip.h index 3dd88119..b71d06e3 100644 --- a/gen/h/std/gzip.h +++ b/gen/h/std/gzip.h @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/h/std/lzw.h b/gen/h/std/lzw.h index 32b0fb73..3238418a 100644 --- a/gen/h/std/lzw.h +++ b/gen/h/std/lzw.h @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display diff --git a/gen/h/std/zlib.h b/gen/h/std/zlib.h index 4921848b..6080f737 100644 --- a/gen/h/std/zlib.h +++ b/gen/h/std/zlib.h @@ -1200,7 +1200,7 @@ static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config( // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( wuffs_base__image_buffer* b) { - return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0}); + return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){}); } // wuffs_base__image_buffer__duration returns the amount of time to display