Remove wuffs_base__frame_config__blend

This commit is contained in:
Nigel Tao committed 2020-01-15 10:42:36 +11:00
1 parent 1a791217de
commit 2be1f63806
6 files changed
+136 -65

No files matched your search

+58 -21
View File
@@ -660,8 +660,9 @@ typedef struct {
wuffs_base__flicks duration;
uint64_t index;
uint64_t io_position;
wuffs_base__animation_blend blend;
wuffs_base__animation_disposal disposal;
bool opaque_within_bounds;
bool overwrite_instead_of_blend;
wuffs_base__color_u32_argb_premul background_color;
} private_impl;
@@ -670,8 +671,9 @@ typedef struct {
wuffs_base__flicks duration,
uint64_t index,
uint64_t io_position,
wuffs_base__animation_blend blend,
wuffs_base__animation_disposal disposal,
bool opaque_within_bounds,
bool overwrite_instead_of_blend,
wuffs_base__color_u32_argb_premul background_color);
inline wuffs_base__rect_ie_u32 bounds() const;
inline uint32_t width() const;
@@ -679,8 +681,9 @@ typedef struct {
inline wuffs_base__flicks duration() const;
inline uint64_t index() const;
inline uint64_t io_position() const;
inline wuffs_base__animation_blend blend() const;
inline wuffs_base__animation_disposal disposal() const;
inline bool opaque_within_bounds() const;
inline bool overwrite_instead_of_blend() const;
inline wuffs_base__color_u32_argb_premul background_color() const;
#endif // __cplusplus
@@ -693,8 +696,9 @@ wuffs_base__null_frame_config() {
ret.private_impl.duration = 0;
ret.private_impl.index = 0;
ret.private_impl.io_position = 0;
ret.private_impl.blend = 0;
ret.private_impl.disposal = 0;
ret.private_impl.opaque_within_bounds = false;
ret.private_impl.overwrite_instead_of_blend = false;
return ret;
}
@@ -705,8 +709,9 @@ wuffs_base__frame_config__update(
wuffs_base__flicks duration,
uint64_t index,
uint64_t io_position,
wuffs_base__animation_blend blend,
wuffs_base__animation_disposal disposal,
bool opaque_within_bounds,
bool overwrite_instead_of_blend,
wuffs_base__color_u32_argb_premul background_color) {
if (!c) {
return;
@@ -716,8 +721,9 @@ wuffs_base__frame_config__update(
c->private_impl.duration = duration;
c->private_impl.index = index;
c->private_impl.io_position = io_position;
c->private_impl.blend = blend;
c->private_impl.disposal = disposal;
c->private_impl.opaque_within_bounds = opaque_within_bounds;
c->private_impl.overwrite_instead_of_blend = overwrite_instead_of_blend;
c->private_impl.background_color = background_color;
}
@@ -766,13 +772,6 @@ wuffs_base__frame_config__io_position(const wuffs_base__frame_config* c) {
return c ? c->private_impl.io_position : 0;
}
// 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(const wuffs_base__frame_config* c) {
return c ? c->private_impl.blend : 0;
}
// wuffs_base__frame_config__disposal returns, for an animated image, how to
// dispose of this frame after displaying it.
static inline wuffs_base__animation_disposal //
@@ -780,6 +779,37 @@ wuffs_base__frame_config__disposal(const wuffs_base__frame_config* c) {
return c ? c->private_impl.disposal : 0;
}
// wuffs_base__frame_config__opaque_within_bounds returns whether all pixels
// within the frame's bounds are fully opaque. It makes no claim about pixels
// outside the frame bounds but still inside the overall image. The two
// bounding rectangles can differ for animated images.
//
// Its semantics are conservative. It is valid for a fully opaque frame to have
// this value be false: a false negative.
//
// If true, drawing the frame with WUFFS_BASE__PIXEL_BLEND__SRC and
// WUFFS_BASE__PIXEL_BLEND__SRC_OVER should be equivalent, in terms of
// resultant pixels, but the former may be faster.
static inline bool //
wuffs_base__frame_config__opaque_within_bounds(
const wuffs_base__frame_config* c) {
return c && c->private_impl.opaque_within_bounds;
}
// wuffs_base__frame_config__overwrite_instead_of_blend returns, for an
// animated image, whether to ignore the previous image state (within the frame
// bounds) when drawing this incremental frame. Equivalently, whether to use
// WUFFS_BASE__PIXEL_BLEND__SRC instead of WUFFS_BASE__PIXEL_BLEND__SRC_OVER.
//
// The WebP spec (https://developers.google.com/speed/webp/docs/riff_container)
// calls this the "Blending method" bit. WebP's "Do not blend" corresponds to
// Wuffs' "overwrite_instead_of_blend".
static inline bool //
wuffs_base__frame_config__overwrite_instead_of_blend(
const wuffs_base__frame_config* c) {
return c && c->private_impl.overwrite_instead_of_blend;
}
static inline wuffs_base__color_u32_argb_premul //
wuffs_base__frame_config__background_color(const wuffs_base__frame_config* c) {
return c ? c->private_impl.background_color : 0;
@@ -793,11 +823,13 @@ wuffs_base__frame_config::update(
wuffs_base__flicks duration,
uint64_t index,
uint64_t io_position,
wuffs_base__animation_blend blend,
wuffs_base__animation_disposal disposal,
bool opaque_within_bounds,
bool overwrite_instead_of_blend,
wuffs_base__color_u32_argb_premul background_color) {
wuffs_base__frame_config__update(this, bounds, duration, index, io_position,
blend, disposal, background_color);
wuffs_base__frame_config__update(
this, bounds, duration, index, io_position, disposal,
opaque_within_bounds, overwrite_instead_of_blend, background_color);
}
inline wuffs_base__rect_ie_u32 //
@@ -830,16 +862,21 @@ wuffs_base__frame_config::io_position() const {
return wuffs_base__frame_config__io_position(this);
}
inline wuffs_base__animation_blend //
wuffs_base__frame_config::blend() const {
return wuffs_base__frame_config__blend(this);
}
inline wuffs_base__animation_disposal //
wuffs_base__frame_config::disposal() const {
return wuffs_base__frame_config__disposal(this);
}
inline bool //
wuffs_base__frame_config::opaque_within_bounds() const {
return wuffs_base__frame_config__opaque_within_bounds(this);
}
inline bool //
wuffs_base__frame_config::overwrite_instead_of_blend() const {
return wuffs_base__frame_config__overwrite_instead_of_blend(this);
}
inline wuffs_base__color_u32_argb_premul //
wuffs_base__frame_config::background_color() const {
return wuffs_base__frame_config__background_color(this);