Add animation blend and disposal concepts

This commit is contained in:
Nigel Tao committed 2018-06-03 19:27:57 +10:00
1 parent ba05d5beed
commit 6df342c60c
18 files changed
+762 -128

No files matched your search

+50 -8
View File
@@ -1009,6 +1009,24 @@ static inline size_t wuffs_base__image_config__pixbuf_size(
// --------
// wuffs_base__animation_disposal encodes, for an animated image, how to
// dispose of a frame after displaying it:
// - None means to draw the next frame on top of this one.
// - Restore Background means to clear the frame's dirty rectangle to "the
// background color" (in practice, this means transparent black) before
// drawing the next frame.
// - Restore Previous means to undo the current frame, so that the next frame
// is drawn on top of the previous one.
typedef uint8_t wuffs_base__animation_disposal;
#define WUFFS_BASE__ANIMATION_DISPOSAL__NONE ((wuffs_base__animation_disposal)0)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND \
((wuffs_base__animation_disposal)1)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS \
((wuffs_base__animation_disposal)2)
// --------
typedef struct {
// Do not access the private_impl's fields directly. There is no API/ABI
// compatibility or safety guarantee if you do so.
@@ -1019,6 +1037,8 @@ typedef struct {
// TODO: color spaces.
wuffs_base__rect_ie_u32 dirty_rect;
wuffs_base__flicks duration;
bool blend;
wuffs_base__animation_disposal disposal;
bool palette_changed;
uint8_t palette[1024];
} private_impl;
@@ -1064,6 +1084,8 @@ static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration,
bool blend,
wuffs_base__animation_disposal disposal,
wuffs_base__slice_u8 palette) {
if (!b) {
return;
@@ -1077,6 +1099,8 @@ static inline void wuffs_base__image_buffer__update(
b->private_impl.dirty_rect = dirty_rect;
b->private_impl.duration = duration;
b->private_impl.blend = blend;
b->private_impl.disposal = disposal;
b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);
if (b->private_impl.palette_changed) {
memmove(b->private_impl.palette, palette.ptr, 1024);
@@ -1102,19 +1126,12 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
return false;
}
// wuffs_base__image_config returns the overall configuration for this frame.
static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config(
wuffs_base__image_buffer* b) {
return b ? &b->private_impl.config : NULL;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// 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(
@@ -1129,6 +1146,31 @@ static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
return b ? b->private_impl.duration : 0;
}
// wuffs_base__image_buffer__blend returns, for a transparent image, whether to
// blend this frame with the existing canvas.
//
// In Porter-Duff compositing operator terminology, false means "src" and true
// means "src over dst".
static inline bool wuffs_base__image_buffer__blend(
wuffs_base__image_buffer* b) {
return b && b->private_impl.blend;
}
// wuffs_base__image_buffer__disposal returns, for an animated image, how to
// dispose of this frame after displaying it.
static inline wuffs_base__animation_disposal wuffs_base__image_buffer__disposal(
wuffs_base__image_buffer* b) {
return b ? b->private_impl.disposal : 0;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside b and has length 1024.
static inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(
+50 -8
View File
@@ -1009,6 +1009,24 @@ static inline size_t wuffs_base__image_config__pixbuf_size(
// --------
// wuffs_base__animation_disposal encodes, for an animated image, how to
// dispose of a frame after displaying it:
// - None means to draw the next frame on top of this one.
// - Restore Background means to clear the frame's dirty rectangle to "the
// background color" (in practice, this means transparent black) before
// drawing the next frame.
// - Restore Previous means to undo the current frame, so that the next frame
// is drawn on top of the previous one.
typedef uint8_t wuffs_base__animation_disposal;
#define WUFFS_BASE__ANIMATION_DISPOSAL__NONE ((wuffs_base__animation_disposal)0)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND \
((wuffs_base__animation_disposal)1)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS \
((wuffs_base__animation_disposal)2)
// --------
typedef struct {
// Do not access the private_impl's fields directly. There is no API/ABI
// compatibility or safety guarantee if you do so.
@@ -1019,6 +1037,8 @@ typedef struct {
// TODO: color spaces.
wuffs_base__rect_ie_u32 dirty_rect;
wuffs_base__flicks duration;
bool blend;
wuffs_base__animation_disposal disposal;
bool palette_changed;
uint8_t palette[1024];
} private_impl;
@@ -1064,6 +1084,8 @@ static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration,
bool blend,
wuffs_base__animation_disposal disposal,
wuffs_base__slice_u8 palette) {
if (!b) {
return;
@@ -1077,6 +1099,8 @@ static inline void wuffs_base__image_buffer__update(
b->private_impl.dirty_rect = dirty_rect;
b->private_impl.duration = duration;
b->private_impl.blend = blend;
b->private_impl.disposal = disposal;
b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);
if (b->private_impl.palette_changed) {
memmove(b->private_impl.palette, palette.ptr, 1024);
@@ -1102,19 +1126,12 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
return false;
}
// wuffs_base__image_config returns the overall configuration for this frame.
static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config(
wuffs_base__image_buffer* b) {
return b ? &b->private_impl.config : NULL;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// 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(
@@ -1129,6 +1146,31 @@ static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
return b ? b->private_impl.duration : 0;
}
// wuffs_base__image_buffer__blend returns, for a transparent image, whether to
// blend this frame with the existing canvas.
//
// In Porter-Duff compositing operator terminology, false means "src" and true
// means "src over dst".
static inline bool wuffs_base__image_buffer__blend(
wuffs_base__image_buffer* b) {
return b && b->private_impl.blend;
}
// wuffs_base__image_buffer__disposal returns, for an animated image, how to
// dispose of this frame after displaying it.
static inline wuffs_base__animation_disposal wuffs_base__image_buffer__disposal(
wuffs_base__image_buffer* b) {
return b ? b->private_impl.disposal : 0;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside b and has length 1024.
static inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(
+50 -8
View File
@@ -1009,6 +1009,24 @@ static inline size_t wuffs_base__image_config__pixbuf_size(
// --------
// wuffs_base__animation_disposal encodes, for an animated image, how to
// dispose of a frame after displaying it:
// - None means to draw the next frame on top of this one.
// - Restore Background means to clear the frame's dirty rectangle to "the
// background color" (in practice, this means transparent black) before
// drawing the next frame.
// - Restore Previous means to undo the current frame, so that the next frame
// is drawn on top of the previous one.
typedef uint8_t wuffs_base__animation_disposal;
#define WUFFS_BASE__ANIMATION_DISPOSAL__NONE ((wuffs_base__animation_disposal)0)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND \
((wuffs_base__animation_disposal)1)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS \
((wuffs_base__animation_disposal)2)
// --------
typedef struct {
// Do not access the private_impl's fields directly. There is no API/ABI
// compatibility or safety guarantee if you do so.
@@ -1019,6 +1037,8 @@ typedef struct {
// TODO: color spaces.
wuffs_base__rect_ie_u32 dirty_rect;
wuffs_base__flicks duration;
bool blend;
wuffs_base__animation_disposal disposal;
bool palette_changed;
uint8_t palette[1024];
} private_impl;
@@ -1064,6 +1084,8 @@ static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration,
bool blend,
wuffs_base__animation_disposal disposal,
wuffs_base__slice_u8 palette) {
if (!b) {
return;
@@ -1077,6 +1099,8 @@ static inline void wuffs_base__image_buffer__update(
b->private_impl.dirty_rect = dirty_rect;
b->private_impl.duration = duration;
b->private_impl.blend = blend;
b->private_impl.disposal = disposal;
b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);
if (b->private_impl.palette_changed) {
memmove(b->private_impl.palette, palette.ptr, 1024);
@@ -1102,19 +1126,12 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
return false;
}
// wuffs_base__image_config returns the overall configuration for this frame.
static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config(
wuffs_base__image_buffer* b) {
return b ? &b->private_impl.config : NULL;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// 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(
@@ -1129,6 +1146,31 @@ static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
return b ? b->private_impl.duration : 0;
}
// wuffs_base__image_buffer__blend returns, for a transparent image, whether to
// blend this frame with the existing canvas.
//
// In Porter-Duff compositing operator terminology, false means "src" and true
// means "src over dst".
static inline bool wuffs_base__image_buffer__blend(
wuffs_base__image_buffer* b) {
return b && b->private_impl.blend;
}
// wuffs_base__image_buffer__disposal returns, for an animated image, how to
// dispose of this frame after displaying it.
static inline wuffs_base__animation_disposal wuffs_base__image_buffer__disposal(
wuffs_base__image_buffer* b) {
return b ? b->private_impl.disposal : 0;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside b and has length 1024.
static inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(
+50 -8
View File
@@ -1009,6 +1009,24 @@ static inline size_t wuffs_base__image_config__pixbuf_size(
// --------
// wuffs_base__animation_disposal encodes, for an animated image, how to
// dispose of a frame after displaying it:
// - None means to draw the next frame on top of this one.
// - Restore Background means to clear the frame's dirty rectangle to "the
// background color" (in practice, this means transparent black) before
// drawing the next frame.
// - Restore Previous means to undo the current frame, so that the next frame
// is drawn on top of the previous one.
typedef uint8_t wuffs_base__animation_disposal;
#define WUFFS_BASE__ANIMATION_DISPOSAL__NONE ((wuffs_base__animation_disposal)0)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND \
((wuffs_base__animation_disposal)1)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS \
((wuffs_base__animation_disposal)2)
// --------
typedef struct {
// Do not access the private_impl's fields directly. There is no API/ABI
// compatibility or safety guarantee if you do so.
@@ -1019,6 +1037,8 @@ typedef struct {
// TODO: color spaces.
wuffs_base__rect_ie_u32 dirty_rect;
wuffs_base__flicks duration;
bool blend;
wuffs_base__animation_disposal disposal;
bool palette_changed;
uint8_t palette[1024];
} private_impl;
@@ -1064,6 +1084,8 @@ static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration,
bool blend,
wuffs_base__animation_disposal disposal,
wuffs_base__slice_u8 palette) {
if (!b) {
return;
@@ -1077,6 +1099,8 @@ static inline void wuffs_base__image_buffer__update(
b->private_impl.dirty_rect = dirty_rect;
b->private_impl.duration = duration;
b->private_impl.blend = blend;
b->private_impl.disposal = disposal;
b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);
if (b->private_impl.palette_changed) {
memmove(b->private_impl.palette, palette.ptr, 1024);
@@ -1102,19 +1126,12 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
return false;
}
// wuffs_base__image_config returns the overall configuration for this frame.
static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config(
wuffs_base__image_buffer* b) {
return b ? &b->private_impl.config : NULL;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// 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(
@@ -1129,6 +1146,31 @@ static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
return b ? b->private_impl.duration : 0;
}
// wuffs_base__image_buffer__blend returns, for a transparent image, whether to
// blend this frame with the existing canvas.
//
// In Porter-Duff compositing operator terminology, false means "src" and true
// means "src over dst".
static inline bool wuffs_base__image_buffer__blend(
wuffs_base__image_buffer* b) {
return b && b->private_impl.blend;
}
// wuffs_base__image_buffer__disposal returns, for an animated image, how to
// dispose of this frame after displaying it.
static inline wuffs_base__animation_disposal wuffs_base__image_buffer__disposal(
wuffs_base__image_buffer* b) {
return b ? b->private_impl.disposal : 0;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside b and has length 1024.
static inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(
+50 -8
View File
@@ -1009,6 +1009,24 @@ static inline size_t wuffs_base__image_config__pixbuf_size(
// --------
// wuffs_base__animation_disposal encodes, for an animated image, how to
// dispose of a frame after displaying it:
// - None means to draw the next frame on top of this one.
// - Restore Background means to clear the frame's dirty rectangle to "the
// background color" (in practice, this means transparent black) before
// drawing the next frame.
// - Restore Previous means to undo the current frame, so that the next frame
// is drawn on top of the previous one.
typedef uint8_t wuffs_base__animation_disposal;
#define WUFFS_BASE__ANIMATION_DISPOSAL__NONE ((wuffs_base__animation_disposal)0)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND \
((wuffs_base__animation_disposal)1)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS \
((wuffs_base__animation_disposal)2)
// --------
typedef struct {
// Do not access the private_impl's fields directly. There is no API/ABI
// compatibility or safety guarantee if you do so.
@@ -1019,6 +1037,8 @@ typedef struct {
// TODO: color spaces.
wuffs_base__rect_ie_u32 dirty_rect;
wuffs_base__flicks duration;
bool blend;
wuffs_base__animation_disposal disposal;
bool palette_changed;
uint8_t palette[1024];
} private_impl;
@@ -1064,6 +1084,8 @@ static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration,
bool blend,
wuffs_base__animation_disposal disposal,
wuffs_base__slice_u8 palette) {
if (!b) {
return;
@@ -1077,6 +1099,8 @@ static inline void wuffs_base__image_buffer__update(
b->private_impl.dirty_rect = dirty_rect;
b->private_impl.duration = duration;
b->private_impl.blend = blend;
b->private_impl.disposal = disposal;
b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);
if (b->private_impl.palette_changed) {
memmove(b->private_impl.palette, palette.ptr, 1024);
@@ -1102,19 +1126,12 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
return false;
}
// wuffs_base__image_config returns the overall configuration for this frame.
static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config(
wuffs_base__image_buffer* b) {
return b ? &b->private_impl.config : NULL;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// 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(
@@ -1129,6 +1146,31 @@ static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
return b ? b->private_impl.duration : 0;
}
// wuffs_base__image_buffer__blend returns, for a transparent image, whether to
// blend this frame with the existing canvas.
//
// In Porter-Duff compositing operator terminology, false means "src" and true
// means "src over dst".
static inline bool wuffs_base__image_buffer__blend(
wuffs_base__image_buffer* b) {
return b && b->private_impl.blend;
}
// wuffs_base__image_buffer__disposal returns, for an animated image, how to
// dispose of this frame after displaying it.
static inline wuffs_base__animation_disposal wuffs_base__image_buffer__disposal(
wuffs_base__image_buffer* b) {
return b ? b->private_impl.disposal : 0;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside b and has length 1024.
static inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(
+50 -8
View File
@@ -1009,6 +1009,24 @@ static inline size_t wuffs_base__image_config__pixbuf_size(
// --------
// wuffs_base__animation_disposal encodes, for an animated image, how to
// dispose of a frame after displaying it:
// - None means to draw the next frame on top of this one.
// - Restore Background means to clear the frame's dirty rectangle to "the
// background color" (in practice, this means transparent black) before
// drawing the next frame.
// - Restore Previous means to undo the current frame, so that the next frame
// is drawn on top of the previous one.
typedef uint8_t wuffs_base__animation_disposal;
#define WUFFS_BASE__ANIMATION_DISPOSAL__NONE ((wuffs_base__animation_disposal)0)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND \
((wuffs_base__animation_disposal)1)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS \
((wuffs_base__animation_disposal)2)
// --------
typedef struct {
// Do not access the private_impl's fields directly. There is no API/ABI
// compatibility or safety guarantee if you do so.
@@ -1019,6 +1037,8 @@ typedef struct {
// TODO: color spaces.
wuffs_base__rect_ie_u32 dirty_rect;
wuffs_base__flicks duration;
bool blend;
wuffs_base__animation_disposal disposal;
bool palette_changed;
uint8_t palette[1024];
} private_impl;
@@ -1064,6 +1084,8 @@ static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration,
bool blend,
wuffs_base__animation_disposal disposal,
wuffs_base__slice_u8 palette) {
if (!b) {
return;
@@ -1077,6 +1099,8 @@ static inline void wuffs_base__image_buffer__update(
b->private_impl.dirty_rect = dirty_rect;
b->private_impl.duration = duration;
b->private_impl.blend = blend;
b->private_impl.disposal = disposal;
b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);
if (b->private_impl.palette_changed) {
memmove(b->private_impl.palette, palette.ptr, 1024);
@@ -1102,19 +1126,12 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
return false;
}
// wuffs_base__image_config returns the overall configuration for this frame.
static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config(
wuffs_base__image_buffer* b) {
return b ? &b->private_impl.config : NULL;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// 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(
@@ -1129,6 +1146,31 @@ static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
return b ? b->private_impl.duration : 0;
}
// wuffs_base__image_buffer__blend returns, for a transparent image, whether to
// blend this frame with the existing canvas.
//
// In Porter-Duff compositing operator terminology, false means "src" and true
// means "src over dst".
static inline bool wuffs_base__image_buffer__blend(
wuffs_base__image_buffer* b) {
return b && b->private_impl.blend;
}
// wuffs_base__image_buffer__disposal returns, for an animated image, how to
// dispose of this frame after displaying it.
static inline wuffs_base__animation_disposal wuffs_base__image_buffer__disposal(
wuffs_base__image_buffer* b) {
return b ? b->private_impl.disposal : 0;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside b and has length 1024.
static inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(
+50 -8
View File
@@ -1009,6 +1009,24 @@ static inline size_t wuffs_base__image_config__pixbuf_size(
// --------
// wuffs_base__animation_disposal encodes, for an animated image, how to
// dispose of a frame after displaying it:
// - None means to draw the next frame on top of this one.
// - Restore Background means to clear the frame's dirty rectangle to "the
// background color" (in practice, this means transparent black) before
// drawing the next frame.
// - Restore Previous means to undo the current frame, so that the next frame
// is drawn on top of the previous one.
typedef uint8_t wuffs_base__animation_disposal;
#define WUFFS_BASE__ANIMATION_DISPOSAL__NONE ((wuffs_base__animation_disposal)0)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND \
((wuffs_base__animation_disposal)1)
#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS \
((wuffs_base__animation_disposal)2)
// --------
typedef struct {
// Do not access the private_impl's fields directly. There is no API/ABI
// compatibility or safety guarantee if you do so.
@@ -1019,6 +1037,8 @@ typedef struct {
// TODO: color spaces.
wuffs_base__rect_ie_u32 dirty_rect;
wuffs_base__flicks duration;
bool blend;
wuffs_base__animation_disposal disposal;
bool palette_changed;
uint8_t palette[1024];
} private_impl;
@@ -1064,6 +1084,8 @@ static inline void wuffs_base__image_buffer__update(
wuffs_base__image_buffer* b,
wuffs_base__rect_ie_u32 dirty_rect,
wuffs_base__flicks duration,
bool blend,
wuffs_base__animation_disposal disposal,
wuffs_base__slice_u8 palette) {
if (!b) {
return;
@@ -1077,6 +1099,8 @@ static inline void wuffs_base__image_buffer__update(
b->private_impl.dirty_rect = dirty_rect;
b->private_impl.duration = duration;
b->private_impl.blend = blend;
b->private_impl.disposal = disposal;
b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);
if (b->private_impl.palette_changed) {
memmove(b->private_impl.palette, palette.ptr, 1024);
@@ -1102,19 +1126,12 @@ static inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {
return false;
}
// wuffs_base__image_config returns the overall configuration for this frame.
static inline wuffs_base__image_config* wuffs_base__image_buffer__image_config(
wuffs_base__image_buffer* b) {
return b ? &b->private_impl.config : NULL;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// 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(
@@ -1129,6 +1146,31 @@ static inline wuffs_base__flicks wuffs_base__image_buffer__duration(
return b ? b->private_impl.duration : 0;
}
// wuffs_base__image_buffer__blend returns, for a transparent image, whether to
// blend this frame with the existing canvas.
//
// In Porter-Duff compositing operator terminology, false means "src" and true
// means "src over dst".
static inline bool wuffs_base__image_buffer__blend(
wuffs_base__image_buffer* b) {
return b && b->private_impl.blend;
}
// wuffs_base__image_buffer__disposal returns, for an animated image, how to
// dispose of this frame after displaying it.
static inline wuffs_base__animation_disposal wuffs_base__image_buffer__disposal(
wuffs_base__image_buffer* b) {
return b ? b->private_impl.disposal : 0;
}
// wuffs_base__image_buffer__palette_changed 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__palette_changed(
wuffs_base__image_buffer* b) {
return b && b->private_impl.palette_changed;
}
// wuffs_base__image_buffer__palette returns the palette that the pixel data
// can index. The backing array is inside b and has length 1024.
static inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(