Relocate the old Decoder::new method to mod test
The old `Decoder::new()` method would not pull the image header out of the iterator. This was fine for the design then, but I've just decided that I want to collect this info and store it in the Decoder struct. I've moved the old method down into the test module so that I can still use it to test the decoder parts alone. Same philosophy as the `new_with_previous_pixel()` and `new_with_backbuffer()` methods.
This commit is contained in:
@@ -89,20 +89,6 @@ where
|
|||||||
run_len: 0,
|
run_len: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(bytes: I) -> Self {
|
|
||||||
Self {
|
|
||||||
back_buffer: [PixelRGBA::zero(); 64],
|
|
||||||
prev_pixel: PixelRGBA {
|
|
||||||
r: 0,
|
|
||||||
g: 0,
|
|
||||||
b: 0,
|
|
||||||
a: 255,
|
|
||||||
},
|
|
||||||
bytes,
|
|
||||||
run_len: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'input, I> Iterator for Decoder<I>
|
impl<'input, I> Iterator for Decoder<I>
|
||||||
@@ -230,6 +216,23 @@ mod test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The decoder includes image metadata, now, and construction attempts
|
||||||
|
// to extract it from the input iterator. For the decoder tests, this
|
||||||
|
// needs to be skipped. Thus, we get *another* magic constructor
|
||||||
|
// available only to the test module.
|
||||||
|
fn new_with_no_metadata(bytes: I) -> Self {
|
||||||
|
Self {
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
channels: 4,
|
||||||
|
colorspace: 0,
|
||||||
|
back_buffer: [PixelRGBA::zero(); 64],
|
||||||
|
prev_pixel: PixelRGBA { r: 0, g: 0, b: 0, a: 255 },
|
||||||
|
bytes,
|
||||||
|
run_len: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn peek_prev_pixel(&self) -> &PixelRGBA {
|
fn peek_prev_pixel(&self) -> &PixelRGBA {
|
||||||
&self.prev_pixel
|
&self.prev_pixel
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user