Add a (table T).row method

This commit is contained in:
Nigel Tao committed 2018-05-26 11:32:54 +10:00
1 parent 00c3f7ef1e
commit f43afd8236
6 files changed
+38 -8

No files matched your search

+9
View File
@@ -332,6 +332,15 @@ func (g *gen) writeBuiltinTable(b *buffer, recv *a.Expr, method t.ID, args []*a.
}
b.writeb(')')
return nil
case t.IDRow:
// TODO: don't assume that the table is a table of base.u8.
b.writes("wuffs_base__table_u8__row(")
if err := g.writeExpr(b, recv, rp, depth); err != nil {
return err
}
b.writeb(',')
return g.writeArgs(b, args, rp, depth)
}
if field != "" {
+10 -3
View File
@@ -1283,6 +1283,8 @@ typedef struct {
uint8_t f_gc_disposal;
uint64_t f_gc_duration;
wuffs_base__rect_ie_u32 f_frame_rect;
uint32_t f_dst_x;
uint32_t f_dst_y;
uint32_t f_uncompressed_ri;
uint32_t f_uncompressed_wi;
uint8_t f_uncompressed[4096];
@@ -3185,6 +3187,8 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id_part0(
&self->private_impl.f_frame_rect, v_frame_x);
wuffs_base__rect_ie_u32__set_min_inclusive_y(
&self->private_impl.f_frame_rect, v_frame_y);
self->private_impl.f_dst_x = v_frame_x;
self->private_impl.f_dst_y = v_frame_y;
{
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
uint16_t t_5;
@@ -3609,14 +3613,17 @@ short_read_src:
static void wuffs_gif__decoder__copy_to_image_buffer(
wuffs_gif__decoder* self,
wuffs_base__image_buffer* a_ib) {
wuffs_base__slice_u8 v_dst;
wuffs_base__table_u8 v_tab;
wuffs_base__slice_u8 v_pixel_data;
v_dst = ((wuffs_base__slice_u8){});
v_tab = wuffs_base__image_buffer__plane(a_ib, 0);
if (((uint64_t)(v_tab.width)) == ((uint64_t)(v_tab.stride))) {
v_pixel_data = wuffs_base__table_u8__linearize(v_tab);
if (((uint64_t)(v_pixel_data.len)) == 0) {
v_dst = wuffs_base__table_u8__linearize(v_tab);
if (((uint64_t)(v_dst.len)) == 0) {
}
} else {
v_dst = wuffs_base__table_u8__row(v_tab, self->private_impl.f_dst_y);
}
}
+2
View File
@@ -1283,6 +1283,8 @@ typedef struct {
uint8_t f_gc_disposal;
uint64_t f_gc_duration;
wuffs_base__rect_ie_u32 f_frame_rect;
uint32_t f_dst_x;
uint32_t f_dst_y;
uint32_t f_uncompressed_ri;
uint32_t f_uncompressed_wi;
uint8_t f_uncompressed[4096];
+1
View File
@@ -200,4 +200,5 @@ var TableFuncs = []string{
"T2.width()(ret u64)",
"T2.linearize()(ret T1)",
"T2.row(y u32)(ret T1)",
}
+5 -3
View File
@@ -491,9 +491,10 @@ const (
IDLength = ID(0x242)
IDLinearize = ID(0x243)
IDPrefix = ID(0x244)
IDStride = ID(0x245)
IDSuffix = ID(0x246)
IDWidth = ID(0x247)
IDRow = ID(0x245)
IDStride = ID(0x246)
IDSuffix = ID(0x247)
IDWidth = ID(0x248)
)
var builtInsByID = [nBuiltInIDs]string{
@@ -713,6 +714,7 @@ var builtInsByID = [nBuiltInIDs]string{
IDLength: "length",
IDLinearize: "linearize",
IDPrefix: "prefix",
IDRow: "row",
IDStride: "stride",
IDSuffix: "suffix",
IDWidth: "width",
+11 -2
View File
@@ -57,6 +57,10 @@ pub struct decoder?(
frame_rect base.rect_ie_u32,
// The dst_etc fields are the output cursor during copy_to_image_buffer.
dst_x base.u32,
dst_y base.u32,
uncompressed_ri base.u32[..4096],
uncompressed_wi base.u32[..4096],
uncompressed array[4096] base.u8,
@@ -329,6 +333,9 @@ pri func decoder.decode_id_part0?(src base.io_reader)() {
var frame_y base.u32 = in.src.read_u16le?() as base.u32
this.frame_rect.set_min_inclusive_x!(x:frame_x)
this.frame_rect.set_min_inclusive_y!(y:frame_y)
this.dst_x = frame_x
this.dst_y = frame_y
frame_x ~mod+= in.src.read_u16le?() as base.u32
frame_y ~mod+= in.src.read_u16le?() as base.u32
this.frame_rect.set_max_exclusive_x!(x:frame_x)
@@ -491,13 +498,15 @@ pri func decoder.decode_id_part1?(ib ptr base.image_buffer, dst base.io_writer,
pri func decoder.copy_to_image_buffer(ib ptr base.image_buffer)() {
// TODO: don't assume a packed pixel format.
var dst slice base.u8
var tab table base.u8 = in.ib.plane(p:0)
if tab.width() == tab.stride() {
var pixel_data slice base.u8 = tab.linearize()
if pixel_data.length() == 0 {
dst = tab.linearize()
if dst.length() == 0 {
// TODO.
}
} else {
dst = tab.row(y:this.dst_y)
// TODO.
}
}