mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 00:38:14 +01:00
Add a utility.make_rect_ie_u32 method
This commit is contained in:
1 parent
92a8bc4641
commit
52feb10ad3
14 files changed
+639
-71
No files matched your search
+16
-24
@@ -79,12 +79,9 @@ pub struct decoder?(
|
||||
// There are 7056000 flicks per centisecond.
|
||||
gc_duration base.u64[..0xFFFF * 7056000],
|
||||
|
||||
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,
|
||||
// TODO: these are just frame_rect fields.
|
||||
dst_x0 base.u32,
|
||||
dst_y0 base.u32,
|
||||
dst_x1 base.u32,
|
||||
@@ -384,21 +381,12 @@ pri func decoder.decode_gc?(src base.io_reader)() {
|
||||
// overall image's width and height also requires decoding the first frame's
|
||||
// bounds (but doesn't require decoding the first frame's pixels).
|
||||
pri func decoder.decode_id_part0?(src base.io_reader)() {
|
||||
var frame_x base.u32 = in.src.read_u16le?() as base.u32
|
||||
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
|
||||
this.dst_x0 = frame_x
|
||||
this.dst_y0 = 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)
|
||||
this.frame_rect.set_max_exclusive_y!(y:frame_y)
|
||||
this.dst_x1 = frame_x
|
||||
this.dst_y1 = frame_y
|
||||
this.dst_x0 = in.src.read_u16le?() as base.u32
|
||||
this.dst_y0 = in.src.read_u16le?() as base.u32
|
||||
this.dst_x1 = this.dst_x0 ~mod+ (in.src.read_u16le?() as base.u32)
|
||||
this.dst_y1 = this.dst_y0 ~mod+ (in.src.read_u16le?() as base.u32)
|
||||
this.dst_x = this.dst_x0
|
||||
this.dst_y = this.dst_y0
|
||||
|
||||
// Set the image's overall width and height to be the maximum of the
|
||||
// nominal image width and height (given in the Logical Screen Descriptor)
|
||||
@@ -406,8 +394,8 @@ pri func decoder.decode_id_part0?(src base.io_reader)() {
|
||||
// test/data/artificial/gif-frame-out-of-bounds.gif.make-artificial.txt for
|
||||
// more discussion.
|
||||
if this.call_sequence == 0 {
|
||||
this.width = this.width.max(x:frame_x)
|
||||
this.height = this.height.max(x:frame_y)
|
||||
this.width = this.width.max(x:this.dst_x1)
|
||||
this.height = this.height.max(x:this.dst_y1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,8 +528,12 @@ pri func decoder.decode_id_part1?(dst ptr base.image_buffer, src base.io_reader)
|
||||
// Both this frame and the previous one used the global palette. No
|
||||
// palette update is necessary.
|
||||
}
|
||||
in.dst.update!(dirty_rect:this.frame_rect, duration:this.gc_duration,
|
||||
blend:true, disposal:this.gc_disposal, palette:palette)
|
||||
in.dst.update!(dirty_rect:this.util.make_rect_ie_u32(
|
||||
min_inclusive_x:this.dst_x0,
|
||||
min_inclusive_y:this.dst_y0,
|
||||
max_exclusive_x:this.dst_x1,
|
||||
max_exclusive_y:this.dst_y1),
|
||||
duration:this.gc_duration, blend:true, disposal:this.gc_disposal, palette:palette)
|
||||
|
||||
this.previous_use_global_palette = not (use_local_palette or this.gc_has_transparent_index)
|
||||
|
||||
@@ -572,7 +564,7 @@ pri func decoder.copy_to_image_buffer?(ib ptr base.image_buffer)() {
|
||||
return error "too much pixel data"
|
||||
}
|
||||
|
||||
// First, copy from src to that part of this.frame_rect that is inside
|
||||
// First, copy from src to that part of the frame rect that is inside
|
||||
// in.ib's bounds.
|
||||
|
||||
dst = tab.row(y:this.dst_y)
|
||||
@@ -607,7 +599,7 @@ pri func decoder.copy_to_image_buffer?(ib ptr base.image_buffer)() {
|
||||
return error "internal error: inconsistent ri/wi"
|
||||
}
|
||||
|
||||
// Second, skip over src for that part of this.frame_rect that is
|
||||
// Second, skip over src for that part of the frame rect that is
|
||||
// outside in.ib's bounds. This second step should be infrequent.
|
||||
|
||||
// Set n to the number of pixels (i.e. the number of bytes) to skip.
|
||||
|
||||
Reference in new issue
Block a user