mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Add a ! effect to copy_from_slice
This commit is contained in:
1 parent
68e553f305
commit
ead965c61f
3 files changed
+7
-8
No files matched your search
@@ -268,8 +268,7 @@ const (
|
||||
)
|
||||
|
||||
var SliceFuncs = []string{
|
||||
// TODO: should copy_from_slice be a ! method?
|
||||
"T1.copy_from_slice(s T1) u64",
|
||||
"T1.copy_from_slice!(s T1) u64",
|
||||
"T1.length() u64",
|
||||
"T1.prefix(up_to u64) T1",
|
||||
"T1.suffix(up_to u64) T1",
|
||||
|
||||
@@ -138,12 +138,12 @@ pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
||||
// previous value of history_index, as we will overwrite the whole
|
||||
// ringbuffer.
|
||||
written = written.suffix(up_to:0x8000)
|
||||
this.history[:].copy_from_slice(s:written)
|
||||
this.history[:].copy_from_slice!(s:written)
|
||||
this.history_index = 0x8000
|
||||
} else {
|
||||
// Otherwise, append written to the history ringbuffer starting at
|
||||
// the previous history_index (modulo 0x8000).
|
||||
var n_copied base.u64 = this.history[this.history_index & 0x7FFF:].copy_from_slice(s:written)
|
||||
var n_copied base.u64 = this.history[this.history_index & 0x7FFF:].copy_from_slice!(s:written)
|
||||
if n_copied < written.length() {
|
||||
// a_slice.copy_from(s:b_slice) returns the minimum of the two
|
||||
// slice lengths. If that value is less than b_slice.length(),
|
||||
@@ -153,7 +153,7 @@ pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
||||
// to wrap around and copy the remainder of written over the
|
||||
// start of the history ringbuffer.
|
||||
written = written[n_copied:]
|
||||
n_copied = this.history[:].copy_from_slice(s:written)
|
||||
n_copied = this.history[:].copy_from_slice!(s:written)
|
||||
// Set history_index (modulo 0x8000) to the length of this
|
||||
// remainder. The &0x7FFF is redundant, but proves to the
|
||||
// compiler that the conversion to u32 will not overflow. The
|
||||
|
||||
@@ -547,7 +547,7 @@ pri func decoder.decode_id_part1!??(dst ptr base.pixel_buffer, src base.io_reade
|
||||
i += 1
|
||||
}
|
||||
} else if this.gc_has_transparent_index {
|
||||
this.palettes[1][:].copy_from_slice(s:this.palettes[0][:])
|
||||
this.palettes[1][:].copy_from_slice!(s:this.palettes[0][:])
|
||||
} else {
|
||||
this.which_palette = 0
|
||||
}
|
||||
@@ -560,7 +560,7 @@ 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
|
||||
}
|
||||
|
||||
args.dst.palette().copy_from_slice(s:this.palettes[this.which_palette][:])
|
||||
args.dst.palette().copy_from_slice!(s:this.palettes[this.which_palette][:])
|
||||
|
||||
// Other GIF implementations accept GIF files that aren't completely spec
|
||||
// compliant. For example, the test/data/gifplayer-muybridge.gif file
|
||||
@@ -666,7 +666,7 @@ pri func decoder.copy_to_image_buffer!??(pb ptr base.pixel_buffer) {
|
||||
} else {
|
||||
dst = dst[this.dst_x as base.u64:]
|
||||
}
|
||||
n = (dst.copy_from_slice(s:src) & 0xFFFFFFFF) as base.u32
|
||||
n = (dst.copy_from_slice!(s:src) & 0xFFFFFFFF) as base.u32
|
||||
|
||||
new_ri = this.uncompressed_ri ~sat+ n
|
||||
this.uncompressed_ri = new_ri.min(x:4096)
|
||||
|
||||
Reference in new issue
Block a user