Skip to content

Commit

Permalink
Add tag to DecodedImage
Browse files Browse the repository at this point in the history
  • Loading branch information
fschutt committed Nov 23, 2024
1 parent 5cb0134 commit 3ef428a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions azul-core/src/app_resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ pub enum DecodedImage {
width: usize,
height: usize,
format: RawImageFormat,
/// Sometimes images need to be tagged with extra data
tag: Vec<u8>,
},
// OpenGl texture
Gl(Texture),
Expand Down Expand Up @@ -341,17 +343,20 @@ impl ImageRef {
width,
height,
format,
tag,
} => DecodedImage::NullImage {
width: *width,
height: *height,
format: *format,
tag: tag.clone(),
},
// NOTE: textures cannot be deep-copied yet (since the OpenGL calls for that are missing from the trait),
// so calling clone() on a GL texture will result in an empty image
DecodedImage::Gl(tex) => DecodedImage::NullImage {
width: tex.size.width as usize,
height: tex.size.height as usize,
format: tex.format,
tag: Vec::new(),
},
// WARNING: the data may still be a U8Vec<'static> - the data may still not be
// actually cloned. The data only gets cloned on a write operation
Expand Down Expand Up @@ -430,11 +435,12 @@ impl ImageRef {
ImageRefHash(self.data as usize)
}

pub fn invalid(width: usize, height: usize, format: RawImageFormat) -> Self {
pub fn null_image(width: usize, height: usize, format: RawImageFormat, tag: Vec<u8>) -> Self {
Self::new(DecodedImage::NullImage {
width,
height,
format,
tag,
})
}

Expand Down Expand Up @@ -1332,6 +1338,7 @@ impl GlTextureCache {
width: _,
height: _,
format: _,
tag: _,
} => None,
// Texture callbacks inside of texture callbacks are not rendered
DecodedImage::Callback(_) => None,
Expand Down Expand Up @@ -3176,9 +3183,10 @@ pub fn build_add_image_resource_updates(
))
}
DecodedImage::NullImage {
width,
height,
format,
width: _,
height: _,
format: _,
tag: _,
} => None,
DecodedImage::Callback(_) => None, // Texture callbacks are handled after layout is done
}
Expand Down

0 comments on commit 3ef428a

Please sign in to comment.