mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
Make blend an enum, not just a bool
This commit is contained in:
1 parent
9367cd800b
commit
fbb8bd44b8
5 files changed
+94
-34
No files matched your search
@@ -547,6 +547,26 @@ wuffs_base__image_config::first_frame_is_opaque() {
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__animation_blend encodes, for an animated image, how to blend the
|
||||
// transparent pixels of this frame with the existing canvas. In Porter-Duff
|
||||
// compositing operator terminology:
|
||||
// - 0 means the frame may be transparent, and should be blended "src over
|
||||
// dst", also known as just "over".
|
||||
// - 1 means the frame may be transparent, and should be blended "src".
|
||||
// - 2 means the frame is completely opaque, so that "src over dst" and "src"
|
||||
// are equivalent.
|
||||
//
|
||||
// These semantics are conservative. It is valid for a completely opaque frame
|
||||
// to have a blend value other than 2.
|
||||
typedef uint8_t wuffs_base__animation_blend;
|
||||
|
||||
#define WUFFS_BASE__ANIMATION_BLEND__SRC_OVER_DST \
|
||||
((wuffs_base__animation_blend)0)
|
||||
#define WUFFS_BASE__ANIMATION_BLEND__SRC ((wuffs_base__animation_blend)1)
|
||||
#define WUFFS_BASE__ANIMATION_BLEND__OPAQUE ((wuffs_base__animation_blend)2)
|
||||
|
||||
// --------
|
||||
|
||||
// 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.
|
||||
@@ -571,7 +591,7 @@ typedef struct {
|
||||
struct {
|
||||
wuffs_base__rect_ie_u32 bounds;
|
||||
wuffs_base__flicks duration;
|
||||
bool blend;
|
||||
wuffs_base__animation_blend blend;
|
||||
wuffs_base__animation_disposal disposal;
|
||||
bool palette_changed;
|
||||
} private_impl;
|
||||
@@ -579,14 +599,14 @@ typedef struct {
|
||||
#ifdef __cplusplus
|
||||
inline void update(wuffs_base__rect_ie_u32 bounds,
|
||||
wuffs_base__flicks duration,
|
||||
bool blend,
|
||||
wuffs_base__animation_blend blend,
|
||||
wuffs_base__animation_disposal disposal,
|
||||
bool palette_changed);
|
||||
inline wuffs_base__rect_ie_u32 bounds();
|
||||
inline uint32_t width();
|
||||
inline uint32_t height();
|
||||
inline wuffs_base__flicks duration();
|
||||
inline bool blend();
|
||||
inline wuffs_base__animation_blend blend();
|
||||
inline wuffs_base__animation_disposal disposal();
|
||||
inline bool palette_changed();
|
||||
#endif // __cplusplus
|
||||
@@ -597,7 +617,7 @@ static inline void //
|
||||
wuffs_base__frame_config__update(wuffs_base__frame_config* c,
|
||||
wuffs_base__rect_ie_u32 bounds,
|
||||
wuffs_base__flicks duration,
|
||||
bool blend,
|
||||
wuffs_base__animation_blend blend,
|
||||
wuffs_base__animation_disposal disposal,
|
||||
bool palette_changed) {
|
||||
if (!c) {
|
||||
@@ -633,12 +653,9 @@ wuffs_base__frame_config__duration(wuffs_base__frame_config* c) {
|
||||
return c ? c->private_impl.duration : 0;
|
||||
}
|
||||
|
||||
// wuffs_base__frame_config__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__frame_config__blend returns, for an animated image, how to blend
|
||||
// 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;
|
||||
}
|
||||
@@ -663,7 +680,7 @@ wuffs_base__frame_config__palette_changed(wuffs_base__frame_config* c) {
|
||||
inline void //
|
||||
wuffs_base__frame_config::update(wuffs_base__rect_ie_u32 bounds,
|
||||
wuffs_base__flicks duration,
|
||||
bool blend,
|
||||
wuffs_base__animation_blend blend,
|
||||
wuffs_base__animation_disposal disposal,
|
||||
bool palette_changed) {
|
||||
wuffs_base__frame_config__update(this, bounds, duration, blend, disposal,
|
||||
@@ -690,7 +707,7 @@ wuffs_base__frame_config::duration() {
|
||||
return wuffs_base__frame_config__duration(this);
|
||||
}
|
||||
|
||||
inline bool //
|
||||
inline wuffs_base__animation_blend //
|
||||
wuffs_base__frame_config::blend() {
|
||||
return wuffs_base__frame_config__blend(this);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user