| 1 | #![allow (unused_variables)] |
| 2 | |
| 3 | use imgref::ImgVec; |
| 4 | use rgb::RGBA8; |
| 5 | |
| 6 | use crate::{ErrorKind, ImageInfo, ImageSource, ImageStore}; |
| 7 | |
| 8 | use super::{Command, ImageId, Renderer, Vertex}; |
| 9 | |
| 10 | /// Void renderer used for testing |
| 11 | pub struct Void; |
| 12 | |
| 13 | impl Renderer for Void { |
| 14 | type Image = VoidImage; |
| 15 | type NativeTexture = (); |
| 16 | type Surface = (); |
| 17 | type CommandBuffer = (); |
| 18 | |
| 19 | fn set_size(&mut self, width: u32, height: u32, dpi: f32) {} |
| 20 | |
| 21 | fn render( |
| 22 | &mut self, |
| 23 | _surface: &Self::Surface, |
| 24 | images: &mut ImageStore<VoidImage>, |
| 25 | verts: &[Vertex], |
| 26 | commands: Vec<Command>, |
| 27 | ) { |
| 28 | } |
| 29 | |
| 30 | fn alloc_image(&mut self, info: ImageInfo) -> Result<Self::Image, ErrorKind> { |
| 31 | Ok(VoidImage { info }) |
| 32 | } |
| 33 | |
| 34 | fn create_image_from_native_texture( |
| 35 | &mut self, |
| 36 | _native_texture: Self::NativeTexture, |
| 37 | _info: ImageInfo, |
| 38 | ) -> Result<Self::Image, ErrorKind> { |
| 39 | Err(ErrorKind::UnsupportedImageFormat) |
| 40 | } |
| 41 | |
| 42 | fn update_image( |
| 43 | &mut self, |
| 44 | image: &mut Self::Image, |
| 45 | data: ImageSource, |
| 46 | x: usize, |
| 47 | y: usize, |
| 48 | ) -> Result<(), ErrorKind> { |
| 49 | let size = data.dimensions(); |
| 50 | |
| 51 | if x + size.width > image.info.width() { |
| 52 | return Err(ErrorKind::ImageUpdateOutOfBounds); |
| 53 | } |
| 54 | |
| 55 | if y + size.height > image.info.height() { |
| 56 | return Err(ErrorKind::ImageUpdateOutOfBounds); |
| 57 | } |
| 58 | |
| 59 | Ok(()) |
| 60 | } |
| 61 | |
| 62 | fn delete_image(&mut self, image: Self::Image, _image_id: ImageId) {} |
| 63 | |
| 64 | fn screenshot(&mut self) -> Result<ImgVec<RGBA8>, ErrorKind> { |
| 65 | Ok(ImgVec::new(Vec::new(), 0, 0)) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | pub struct VoidImage { |
| 70 | info: ImageInfo, |
| 71 | } |
| 72 | |