Add base.pixel_buffer.palette_or_else

This commit is contained in:
Nigel Tao committed 2020-12-02 22:13:35 +11:00
1 parent 2cf0252453
commit 8482161c91
6 files changed
+62 -52

No files matched your search

+4 -16
View File
@@ -313,8 +313,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
}
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var dst_palette : slice base.u8
var status : base.status
var status : base.status
if this.call_sequence < 2 {
this.decode_frame_config?(dst: nullptr, src: args.src)
@@ -338,14 +337,9 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
this.dst_y_inc = 0xFFFF_FFFF // -1 as a base.u32.
}
dst_palette = args.dst.palette()
if dst_palette.length() == 0 {
dst_palette = this.scratch[1024 ..]
}
status = this.swizzler.prepare!(
dst_pixfmt: args.dst.pixel_format(),
dst_palette: dst_palette,
dst_palette: args.dst.palette_or_else(fallback: this.scratch[1024 ..]),
src_pixfmt: this.util.make_pixel_format(repr: this.src_pixfmt),
src_palette: this.src_palette[..],
blend: args.blend)
@@ -392,10 +386,7 @@ pri func decoder.swizzle_compress0!(dst: ptr base.pixel_buffer, src: base.io_rea
}
dst_bytes_per_pixel = (dst_bits_per_pixel / 8) as base.u64
dst_bytes_per_row = (this.width as base.u64) * dst_bytes_per_pixel
dst_palette = args.dst.palette()
if dst_palette.length() == 0 {
dst_palette = this.scratch[1024 ..]
}
dst_palette = args.dst.palette_or_else(fallback: this.scratch[1024 ..])
tab = args.dst.plane(p: 0)
while.outer true {
@@ -472,10 +463,7 @@ pri func decoder.swizzle_compress3!(dst: ptr base.pixel_buffer, src: base.io_rea
}
dst_bytes_per_pixel = (dst_bits_per_pixel / 8) as base.u64
dst_bytes_per_row = (this.width as base.u64) * dst_bytes_per_pixel
dst_palette = args.dst.palette()
if dst_palette.length() == 0 {
dst_palette = this.scratch[1024 ..]
}
dst_palette = args.dst.palette_or_else(fallback: this.scratch[1024 ..])
tab = args.dst.plane(p: 0)
while.outer true {
+1 -7
View File
@@ -819,7 +819,6 @@ pri func decoder.decode_id_part1?(dst: ptr base.pixel_buffer, src: base.io_reade
var num_palette_entries : base.u32[..= 256]
var i : base.u32
var argb : base.u32
var dst_palette : slice base.u8
var status : base.status
var lw : base.u8
@@ -871,14 +870,9 @@ pri func decoder.decode_id_part1?(dst: ptr base.pixel_buffer, src: base.io_reade
this.palettes[1][(4 * (this.gc_transparent_index as base.u32)) + 3] = 0x00
}
dst_palette = args.dst.palette()
if dst_palette.length() == 0 {
dst_palette = this.dst_palette[..]
}
status = this.swizzler.prepare!(
dst_pixfmt: args.dst.pixel_format(),
dst_palette: dst_palette,
dst_palette: args.dst.palette_or_else(fallback: this.dst_palette[..]),
src_pixfmt: this.util.make_pixel_format(repr: base.PIXEL_FORMAT__INDEXED__BGRA_BINARY),
src_palette: this.palettes[which_palette][..],
blend: args.blend)