From 1444e38d8d8e5dd4816a9e65c571ebe61dc29255 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Thu, 24 May 2018 10:00:54 +1000 Subject: [PATCH] Add wuffs_base__image_buffer__dirty_palette --- cmd/wuffs-c/internal/cgen/base-header.h | 11 +++++++++++ cmd/wuffs-c/internal/cgen/data.go | 9 +++++---- gen/c/std/adler32.c | 11 +++++++++++ gen/c/std/crc32.c | 11 +++++++++++ gen/c/std/deflate.c | 11 +++++++++++ gen/c/std/gif.c | 11 +++++++++++ gen/c/std/gzip.c | 11 +++++++++++ gen/c/std/zlib.c | 11 +++++++++++ gen/h/std/adler32.h | 11 +++++++++++ gen/h/std/crc32.h | 11 +++++++++++ gen/h/std/deflate.h | 11 +++++++++++ gen/h/std/gif.h | 11 +++++++++++ gen/h/std/gzip.h | 11 +++++++++++ gen/h/std/zlib.h | 11 +++++++++++ 14 files changed, 148 insertions(+), 4 deletions(-) diff --git a/cmd/wuffs-c/internal/cgen/base-header.h b/cmd/wuffs-c/internal/cgen/base-header.h index 41c6c589..99404df3 100644 --- a/cmd/wuffs-c/internal/cgen/base-header.h +++ b/cmd/wuffs-c/internal/cgen/base-header.h @@ -980,6 +980,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1023,6 +1024,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1030,6 +1032,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1057,6 +1060,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( diff --git a/cmd/wuffs-c/internal/cgen/data.go b/cmd/wuffs-c/internal/cgen/data.go index 7043ff19..fd31db5f 100644 --- a/cmd/wuffs-c/internal/cgen/data.go +++ b/cmd/wuffs-c/internal/cgen/data.go @@ -76,10 +76,11 @@ const baseHeader = "" + "l.num_loops = num_loops;\n return;\n }\n }\n *c = ((wuffs_base__image_config){});\n}\n\nstatic inline void wuffs_base__image_config__invalidate(\n wuffs_base__image_config* c) {\n if (c) {\n *c = ((wuffs_base__image_config){});\n }\n}\n\nstatic inline bool wuffs_base__image_config__is_valid(\n wuffs_base__image_config* c) {\n return c && c->private_impl.pixfmt;\n}\n\nstatic inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(\n wuffs_base__image_config* c) {\n return c ? c->private_impl.pixfmt : 0;\n}\n\nstatic inline wuffs_base__pixel_subsampling\nwuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {\n return c ? c->private_impl.pixsub : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__width(\n wuffs_base__image_config* c) {\n return c ? c->private_impl.width : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__height(\n wuffs_base__image_config* c) {\n return c ? c->private_impl.height : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__num_loops(\n" + " wuffs_base__image_config* c) {\n return c ? c->private_impl.num_loops : 0;\n}\n\n// TODO: this is the right API for planar (not packed) pixbufs? Should it allow\n// decoding into a color model different from the format's intrinsic one? For\n// example, decoding a JPEG image straight to RGBA instead of to YCbCr?\nstatic inline size_t wuffs_base__image_config__pixbuf_size(\n wuffs_base__image_config* c) {\n if (c) {\n uint64_t wh =\n ((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);\n // TODO: handle things other than 1 byte per pixel.\n return (size_t)wh;\n }\n return 0;\n}\n\n" + "" + - "// --------\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 uint8_t palette[1024];\n } private_impl;\n} wuffs_base__image_buffer;\n\nstatic inline void 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;\n }\n *b = ((wuffs_base__image_buffer){});\n b->private_impl.config = config;\n b->private_impl.pixbuf = pixbuf;\n}\n\n// TODO: Should this function return bool? An error type?\nstatic inline void 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;\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;\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}\n\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 uint8_t* palette_ptr,\n size_t palette_len) {\n if (!b) {\n return;\n }\n b->private_impl.dirty_rect = dirty_rect;\n b->private_impl.duration = duration;\n if (palette_ptr) {\n memmove(b->private_impl.palette, palette_ptr,\n palette_len <= 1024 ? palette_len : 1024);\n }\n}\n\n// wuffs_base__im" + - "age_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_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 sti" + - "ll (non-animated) image.\nstatic 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__palette returns the palette that the pixel data\n// can index. The backing array is inside b and has length 1024.\nstatic inline uint8_t* wuffs_base__image_buffer__palette(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.palette : NULL;\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#endif // WUFFS_BASE_HEADER_H\n" + + "// --------\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 bool dirty_palette;\n wuffs_base__rect_ie_u32 dirty_rect;\n wuffs_base__flicks duration;\n uint8_t palette[1024];\n } private_impl;\n} wuffs_base__image_buffer;\n\nstatic inline void 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;\n }\n *b = ((wuffs_base__image_buffer){});\n b->private_impl.config = config;\n b->private_impl.pixbuf = pixbuf;\n}\n\n// TODO: Should this function return bool? An error type?\nstatic inline void wuffs_base__image_buffer__set_from_slice(\n wuffs_base__image_buffer* b,\n wuffs_base__image_config config,\n wuffs_base__sli" + + "ce_u8 pixbuf_memory) {\n if (!b) {\n return;\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;\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}\n\nstatic inline void wuffs_base__image_buffer__update(\n wuffs_base__image_buffer* b,\n bool dirty_palette,\n wuffs_base__rect_ie_u32 dirty_rect,\n wuffs_base__flicks duration,\n uint8_t* palette_ptr,\n size_t palette_len) {\n if (!b) {\n return;\n }\n b->private_impl.dirty_palette = dirty_palette;\n b->private_impl.dirty_rect = dirty_rect;\n b->private_impl.duration = duration;\n if (palette_ptr) {\n memmove(b->private_impl.pale" + + "tte, palette_ptr,\n palette_len <= 1024 ? palette_len : 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_buffer__dirty_palette returns whether this frame's palette\n// differs from the previous frame. It is conservative and may return false\n// positives (but never false negatives).\nstatic inline bool wuffs_base__image_buffer__dirty_palette(\n wuffs_base__image_buffer* b) {\n return b && b->private_impl.dirty_palette;\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.\nstatic 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__palette returns the palette that the pixel data\n// can index. The backing array is inside b and has length 1024.\nstatic inline uint8_t* wuffs_base__image_buffer__palette(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.palette : NULL;\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#endif // WUFFS_BASE_HEADER_H\n" + "" const baseImpl = "" + diff --git a/gen/c/std/adler32.c b/gen/c/std/adler32.c index 01cbc83f..a20c965a 100644 --- a/gen/c/std/adler32.c +++ b/gen/c/std/adler32.c @@ -983,6 +983,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1026,6 +1027,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1033,6 +1035,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1060,6 +1063,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( diff --git a/gen/c/std/crc32.c b/gen/c/std/crc32.c index b99a6918..3d145cf7 100644 --- a/gen/c/std/crc32.c +++ b/gen/c/std/crc32.c @@ -983,6 +983,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1026,6 +1027,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1033,6 +1035,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1060,6 +1063,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( diff --git a/gen/c/std/deflate.c b/gen/c/std/deflate.c index e1fb66fc..5c5f5b28 100644 --- a/gen/c/std/deflate.c +++ b/gen/c/std/deflate.c @@ -983,6 +983,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1026,6 +1027,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1033,6 +1035,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1060,6 +1063,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index 77aa715f..1614909b 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -983,6 +983,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1026,6 +1027,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1033,6 +1035,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1060,6 +1063,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( diff --git a/gen/c/std/gzip.c b/gen/c/std/gzip.c index c5b53923..c4ca11e3 100644 --- a/gen/c/std/gzip.c +++ b/gen/c/std/gzip.c @@ -983,6 +983,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1026,6 +1027,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1033,6 +1035,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1060,6 +1063,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( diff --git a/gen/c/std/zlib.c b/gen/c/std/zlib.c index 2ac24884..c0effd63 100644 --- a/gen/c/std/zlib.c +++ b/gen/c/std/zlib.c @@ -983,6 +983,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1026,6 +1027,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1033,6 +1035,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1060,6 +1063,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( diff --git a/gen/h/std/adler32.h b/gen/h/std/adler32.h index 2d1444d4..0aae3ee0 100644 --- a/gen/h/std/adler32.h +++ b/gen/h/std/adler32.h @@ -983,6 +983,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1026,6 +1027,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1033,6 +1035,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1060,6 +1063,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( diff --git a/gen/h/std/crc32.h b/gen/h/std/crc32.h index 0e5f2c54..a6d50b64 100644 --- a/gen/h/std/crc32.h +++ b/gen/h/std/crc32.h @@ -983,6 +983,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1026,6 +1027,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1033,6 +1035,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1060,6 +1063,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( diff --git a/gen/h/std/deflate.h b/gen/h/std/deflate.h index d9e6cba5..f116b9cc 100644 --- a/gen/h/std/deflate.h +++ b/gen/h/std/deflate.h @@ -983,6 +983,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1026,6 +1027,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1033,6 +1035,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1060,6 +1063,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( diff --git a/gen/h/std/gif.h b/gen/h/std/gif.h index a845afe8..d7129c83 100644 --- a/gen/h/std/gif.h +++ b/gen/h/std/gif.h @@ -983,6 +983,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1026,6 +1027,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1033,6 +1035,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1060,6 +1063,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( diff --git a/gen/h/std/gzip.h b/gen/h/std/gzip.h index 0812f002..cc1bf772 100644 --- a/gen/h/std/gzip.h +++ b/gen/h/std/gzip.h @@ -983,6 +983,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1026,6 +1027,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1033,6 +1035,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1060,6 +1063,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect( diff --git a/gen/h/std/zlib.h b/gen/h/std/zlib.h index f103fafa..5e04dc46 100644 --- a/gen/h/std/zlib.h +++ b/gen/h/std/zlib.h @@ -983,6 +983,7 @@ typedef struct { uint32_t loop_count; // 0-based count of the current loop. wuffs_base__pixel_buffer pixbuf; // TODO: color spaces. + bool dirty_palette; wuffs_base__rect_ie_u32 dirty_rect; wuffs_base__flicks duration; uint8_t palette[1024]; @@ -1026,6 +1027,7 @@ static inline void wuffs_base__image_buffer__set_from_slice( static inline void wuffs_base__image_buffer__update( wuffs_base__image_buffer* b, + bool dirty_palette, wuffs_base__rect_ie_u32 dirty_rect, wuffs_base__flicks duration, uint8_t* palette_ptr, @@ -1033,6 +1035,7 @@ static inline void wuffs_base__image_buffer__update( if (!b) { return; } + b->private_impl.dirty_palette = dirty_palette; b->private_impl.dirty_rect = dirty_rect; b->private_impl.duration = duration; if (palette_ptr) { @@ -1060,6 +1063,14 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) { return false; } +// wuffs_base__image_buffer__dirty_palette returns whether this frame's palette +// differs from the previous frame. It is conservative and may return false +// positives (but never false negatives). +static inline bool wuffs_base__image_buffer__dirty_palette( + wuffs_base__image_buffer* b) { + return b && b->private_impl.dirty_palette; +} + // wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of // this frame's pixels differs from the previous frame. static inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(