| 46 | |
| 47 | impl Clone for DynamicRows<'_, '_> { |
| 48 | fn clone(&self) -> Self { |
| 49 | Self { |
| 50 | width: self.width, |
| 51 | height: self.height, |
| 52 | f_pixels: self.f_pixels.clone(), |
| 53 | pixels: match &self.pixels { |
| 54 | PixelsSource::Pixels { rows, pixels } => PixelsSource::Pixels { |
| 55 | rows: rows.clone(), |
| 56 | pixels: pixels.clone(), |
| 57 | }, |
| 58 | PixelsSource::Callback(_) => { |
| 59 | let area = self.width as usize * self.height as usize; |
| 60 | let mut out = Vec::with_capacity(area); |
| 61 | let out_rows = out.spare_capacity_mut()[..area].chunks_exact_mut(self.width as usize); |
| 62 | for (i, row) in out_rows.enumerate() { |
| 63 | self.row_rgba(row, i); |
| 64 | } |
| 65 | unsafe { |
| 66 | out.set_len(area); |
| 67 | } |
| 68 | let pixels = SeaCow::boxed(out.into_boxed_slice()); |
| 69 | PixelsSource::for_pixels(pixels, self.width, self.height, self.width).unwrap() |
| 70 | }, |
| 71 | }, |
| 72 | gamma: self.gamma, |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | pub(crate) struct DynamicRowsIter<'parent, 'pixels, 'rows> { |