wuffsfmt: double-indents hanging lines

This commit is contained in:
Nigel Tao committed 2023-04-09 15:22:25 +10:00
1 parent d910658bce
commit 9c03b8c71d
40 files changed
+2579 -2571

No files matched your search

+80 -80
View File
@@ -20,36 +20,36 @@ pub status "#unsupported TGA file"
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0
pub struct decoder? implements base.image_decoder(
width : base.u32[..= 0xFFFF],
height : base.u32[..= 0xFFFF],
width : base.u32[..= 0xFFFF],
height : base.u32[..= 0xFFFF],
// The call sequence state machine is discussed in
// (/doc/std/image-decoders-call-sequence.md).
call_sequence : base.u8,
// The call sequence state machine is discussed in
// (/doc/std/image-decoders-call-sequence.md).
call_sequence : base.u8,
header_id_length : base.u8,
header_color_map_type : base.u8,
header_image_type : base.u8,
header_color_map_first_entry_index : base.u16,
header_color_map_length : base.u16,
header_color_map_entry_size : base.u8,
header_pixel_depth : base.u8,
header_image_descriptor : base.u8,
header_id_length : base.u8,
header_color_map_type : base.u8,
header_image_type : base.u8,
header_color_map_first_entry_index : base.u16,
header_color_map_length : base.u16,
header_color_map_entry_size : base.u8,
header_pixel_depth : base.u8,
header_image_descriptor : base.u8,
opaque : base.bool,
opaque : base.bool,
scratch_bytes_per_pixel : base.u32[..= 4],
src_bytes_per_pixel : base.u32[..= 4],
src_pixfmt : base.u32,
scratch_bytes_per_pixel : base.u32[..= 4],
src_bytes_per_pixel : base.u32[..= 4],
src_pixfmt : base.u32,
frame_config_io_position : base.u64,
frame_config_io_position : base.u64,
swizzler : base.pixel_swizzler,
util : base.utility,
swizzler : base.pixel_swizzler,
util : base.utility,
)(
dst_palette : array[4 * 256] base.u8,
src_palette : array[4 * 256] base.u8,
scratch : array[4] base.u8,
dst_palette : array[4 * 256] base.u8,
src_palette : array[4 * 256] base.u8,
scratch : array[4] base.u8,
)
pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
@@ -84,11 +84,11 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
this.header_image_type = args.src.read_u8?()
if (this.header_image_type == 0x01) or
(this.header_image_type == 0x02) or
(this.header_image_type == 0x03) or
(this.header_image_type == 0x09) or
(this.header_image_type == 0x0A) or
(this.header_image_type == 0x0B) {
(this.header_image_type == 0x02) or
(this.header_image_type == 0x03) or
(this.header_image_type == 0x09) or
(this.header_image_type == 0x0A) or
(this.header_image_type == 0x0B) {
// No-op.
} else {
// TODO: 0x20 and 0x21 are invalid, according to the spec, but are
@@ -102,19 +102,19 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
if this.header_color_map_type <> 0 {
// We have a color-mapped image (in Wuffs, an indexed pixel format).
if (this.header_color_map_first_entry_index <> 0) or
(this.header_color_map_length > 0x100) {
(this.header_color_map_length > 0x100) {
return "#unsupported TGA file"
} else if (this.header_color_map_entry_size <> 0x0F) and
(this.header_color_map_entry_size <> 0x10) and
(this.header_color_map_entry_size <> 0x18) and
(this.header_color_map_entry_size <> 0x20) {
(this.header_color_map_entry_size <> 0x10) and
(this.header_color_map_entry_size <> 0x18) and
(this.header_color_map_entry_size <> 0x20) {
return "#bad header"
}
} else {
// The color-map fields must be zero.
if (this.header_color_map_first_entry_index <> 0) or
(this.header_color_map_length <> 0) or
(this.header_color_map_entry_size <> 0) {
(this.header_color_map_length <> 0) or
(this.header_color_map_entry_size <> 0) {
return "#bad header"
}
}
@@ -127,11 +127,11 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
this.header_pixel_depth = args.src.read_u8?()
if (this.header_pixel_depth <> 0x01) and
(this.header_pixel_depth <> 0x08) and
(this.header_pixel_depth <> 0x0F) and
(this.header_pixel_depth <> 0x10) and
(this.header_pixel_depth <> 0x18) and
(this.header_pixel_depth <> 0x20) {
(this.header_pixel_depth <> 0x08) and
(this.header_pixel_depth <> 0x0F) and
(this.header_pixel_depth <> 0x10) and
(this.header_pixel_depth <> 0x18) and
(this.header_pixel_depth <> 0x20) {
return "#bad header"
}
@@ -140,12 +140,12 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
this.src_bytes_per_pixel = 1
this.src_pixfmt = base.PIXEL_FORMAT__INDEXED__BGRA_NONPREMUL
this.opaque =
(this.header_color_map_entry_size == 0x0F) or
(this.header_color_map_entry_size == 0x18)
(this.header_color_map_entry_size == 0x0F) or
(this.header_color_map_entry_size == 0x18)
} else if (this.header_image_type | 8) == 0x0A {
if (this.header_pixel_depth == 0x0F) or
(this.header_pixel_depth == 0x10) {
(this.header_pixel_depth == 0x10) {
// Wuffs' base.pixel_swizzler doesn't support BGRX5551, so
// scratch_bytes_per_pixel and src_bytes_per_pixel are different.
this.scratch_bytes_per_pixel = 4
@@ -227,12 +227,12 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
if args.dst <> nullptr {
args.dst.set!(
pixfmt: this.src_pixfmt,
pixsub: 0,
width: this.width,
height: this.height,
first_frame_io_position: this.frame_config_io_position,
first_frame_is_opaque: this.opaque)
pixfmt: this.src_pixfmt,
pixsub: 0,
width: this.width,
height: this.height,
first_frame_io_position: this.frame_config_io_position,
first_frame_is_opaque: this.opaque)
}
this.call_sequence = 0x20
@@ -268,17 +268,17 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.
if args.dst <> nullptr {
args.dst.set!(bounds: this.util.make_rect_ie_u32(
min_incl_x: 0,
min_incl_y: 0,
max_excl_x: this.width,
max_excl_y: this.height),
duration: 0,
index: 0,
io_position: this.frame_config_io_position,
disposal: 0,
opaque_within_bounds: this.opaque,
overwrite_instead_of_blend: false,
background_color: 0xFF00_0000)
min_incl_x: 0,
min_incl_y: 0,
max_excl_x: this.width,
max_excl_y: this.height),
duration: 0,
index: 0,
io_position: this.frame_config_io_position,
disposal: 0,
opaque_within_bounds: this.opaque,
overwrite_instead_of_blend: false,
background_color: 0xFF00_0000)
}
this.call_sequence = 0x40
@@ -330,11 +330,11 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
src_palette = this.src_palette[..]
}
status = this.swizzler.prepare!(
dst_pixfmt: args.dst.pixel_format(),
dst_palette: args.dst.palette_or_else(fallback: this.dst_palette[..]),
src_pixfmt: this.util.make_pixel_format(repr: this.src_pixfmt),
src_palette: src_palette,
blend: args.blend)
dst_pixfmt: args.dst.pixel_format(),
dst_palette: args.dst.palette_or_else(fallback: this.dst_palette[..]),
src_pixfmt: this.util.make_pixel_format(repr: this.src_pixfmt),
src_palette: src_palette,
blend: args.blend)
if not status.is_ok() {
return status
}
@@ -382,9 +382,9 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
num_src_bytes = num_pixels32 * this.src_bytes_per_pixel
args.src.skip_u32?(n: num_src_bytes)
this.swizzler.swizzle_interleaved_from_slice!(
dst: dst,
dst_palette: dst_palette,
src: args.src.since(mark: mark))
dst: dst,
dst_palette: dst_palette,
src: args.src.since(mark: mark))
if num_dst_bytes <= dst.length() {
dst = dst[num_dst_bytes ..]
} else {
@@ -400,9 +400,9 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
} else if run_length > 0 {
run_length -= 1
this.swizzler.swizzle_interleaved_from_slice!(
dst: dst,
dst_palette: dst_palette,
src: this.scratch[.. this.scratch_bytes_per_pixel])
dst: dst,
dst_palette: dst_palette,
src: this.scratch[.. this.scratch_bytes_per_pixel])
if dst_bytes_per_pixel <= dst.length() {
dst = dst[dst_bytes_per_pixel ..]
}
@@ -487,9 +487,9 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
// TODO: can the alpha value be zero (BGRA5551 not BGRX5551)?
this.scratch[3] = 0xFF
this.swizzler.swizzle_interleaved_from_slice!(
dst: dst,
dst_palette: dst_palette,
src: this.scratch[.. 4])
dst: dst,
dst_palette: dst_palette,
src: this.scratch[.. 4])
if dst_bytes_per_pixel <= dst.length() {
dst = dst[dst_bytes_per_pixel ..]
}
@@ -499,9 +499,9 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
} else if run_length > 0 {
run_length -= 1
this.swizzler.swizzle_interleaved_from_slice!(
dst: dst,
dst_palette: dst_palette,
src: this.scratch[.. this.scratch_bytes_per_pixel])
dst: dst,
dst_palette: dst_palette,
src: this.scratch[.. this.scratch_bytes_per_pixel])
if dst_bytes_per_pixel <= dst.length() {
dst = dst[dst_bytes_per_pixel ..]
}
@@ -566,10 +566,10 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
pub func decoder.frame_dirty_rect() base.rect_ie_u32 {
return this.util.make_rect_ie_u32(
min_incl_x: 0,
min_incl_y: 0,
max_excl_x: this.width,
max_excl_y: this.height)
min_incl_x: 0,
min_incl_y: 0,
max_excl_x: this.width,
max_excl_y: this.height)
}
pub func decoder.num_animation_loops() base.u32 {