Add I/O positions

This commit is contained in:
Nigel Tao committed 2018-08-26 16:31:19 +10:00
1 parent 0c18c064b8
commit 7798beaa8c
14 files changed
+258 -25

No files matched your search

+4 -1
View File
@@ -990,7 +990,8 @@ typedef struct {
} wuffs_base__io_writer;
// wuffs_base__io_buffer is a 1-dimensional buffer (a pointer and length), plus
// additional indexes into that buffer, plus an opened / closed flag.
// additional indexes into that buffer, plus a buffer position and an opened /
// closed flag.
//
// A value with all fields NULL or zero is a valid, empty buffer.
typedef struct wuffs_base__io_buffer__struct {
@@ -998,6 +999,7 @@ typedef struct wuffs_base__io_buffer__struct {
size_t len; // Length.
size_t wi; // Write index. Invariant: wi <= len.
size_t ri; // Read index. Invariant: ri <= wi.
uint64_t pos; // Position of the buffer start relative to the stream start.
bool closed; // No further writes are expected.
#ifdef __cplusplus
@@ -1015,6 +1017,7 @@ wuffs_base__io_buffer__compact(wuffs_base__io_buffer* buf) {
if (!buf || (buf->ri == 0)) {
return;
}
buf->pos = wuffs_base__u64__sat_add(buf->pos, buf->ri);
size_t n = buf->wi - buf->ri;
if (n != 0) {
memmove(buf->ptr, buf->ptr + buf->ri, n);
+38 -1
View File
@@ -591,6 +591,8 @@ typedef struct {
struct {
wuffs_base__rect_ie_u32 bounds;
wuffs_base__flicks duration;
uint64_t index;
uint64_t io_position;
wuffs_base__animation_blend blend;
wuffs_base__animation_disposal disposal;
bool palette_changed;
@@ -599,6 +601,8 @@ typedef struct {
#ifdef __cplusplus
inline void update(wuffs_base__rect_ie_u32 bounds,
wuffs_base__flicks duration,
uint64_t index,
uint64_t io_position,
wuffs_base__animation_blend blend,
wuffs_base__animation_disposal disposal,
bool palette_changed);
@@ -606,6 +610,8 @@ typedef struct {
inline uint32_t width();
inline uint32_t height();
inline wuffs_base__flicks duration();
inline uint64_t index();
inline uint64_t io_position();
inline wuffs_base__animation_blend blend();
inline wuffs_base__animation_disposal disposal();
inline bool palette_changed();
@@ -617,6 +623,8 @@ static inline void //
wuffs_base__frame_config__update(wuffs_base__frame_config* c,
wuffs_base__rect_ie_u32 bounds,
wuffs_base__flicks duration,
uint64_t index,
uint64_t io_position,
wuffs_base__animation_blend blend,
wuffs_base__animation_disposal disposal,
bool palette_changed) {
@@ -626,6 +634,8 @@ wuffs_base__frame_config__update(wuffs_base__frame_config* c,
c->private_impl.bounds = bounds;
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.palette_changed = palette_changed;
@@ -653,6 +663,20 @@ wuffs_base__frame_config__duration(wuffs_base__frame_config* c) {
return c ? c->private_impl.duration : 0;
}
// wuffs_base__frame_config__index returns the index of this frame. The first
// frame in an image has index 0, the second frame has index 1, and so on.
static inline uint64_t //
wuffs_base__frame_config__index(wuffs_base__frame_config* c) {
return c ? c->private_impl.index : 0;
}
// wuffs_base__frame_config__io_position returns the I/O stream position after
// the frame config but before the frame's pixel data.
static inline uint64_t //
wuffs_base__frame_config__io_position(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 //
@@ -680,10 +704,13 @@ 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,
uint64_t index,
uint64_t io_position,
wuffs_base__animation_blend blend,
wuffs_base__animation_disposal disposal,
bool palette_changed) {
wuffs_base__frame_config__update(this, bounds, duration, blend, disposal,
wuffs_base__frame_config__update(this, bounds, duration, index,
io_position, blend, disposal,
palette_changed);
}
@@ -707,6 +734,16 @@ wuffs_base__frame_config::duration() {
return wuffs_base__frame_config__duration(this);
}
inline uint64_t //
wuffs_base__frame_config::index() {
return wuffs_base__frame_config__index(this);
}
inline uint64_t //
wuffs_base__frame_config::io_position() {
return wuffs_base__frame_config__io_position(this);
}
inline wuffs_base__animation_blend //
wuffs_base__frame_config::blend() {
return wuffs_base__frame_config__blend(this);