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