use crate::fonts::atlas::LegacyFontAtlas;
use crate::sys;
use super::FontAtlas;
impl<'atlas> LegacyFontAtlas<'atlas> {
pub fn is_built(&self) -> bool {
unsafe { (*self.atlas.raw()).TexIsBuilt }
}
pub fn texture_id(&self) -> crate::texture::TextureId {
self.atlas.texture_id_internal()
}
pub unsafe fn set_texture_id(&self, tex_id: crate::texture::TextureId) {
unsafe {
let raw = self.atlas.raw();
let texture = (*raw).TexData;
(*raw).TexRef = if texture.is_null() {
sys::ImTextureRef {
_TexData: std::ptr::null_mut(),
_TexID: sys::ImTextureID::from(tex_id),
}
} else {
sys::ImTextureData_SetTexID(texture, sys::ImTextureID::from(tex_id));
sys::ImTextureData_SetStatus(texture, sys::ImTextureStatus_OK);
sys::ImTextureData_GetTexRef(texture)
};
}
}
pub fn tex_data(&self) -> Option<crate::fonts::FontAtlasTexture<'atlas>> {
self.atlas.tex_data_internal()
}
}
impl FontAtlas {
pub(crate) fn texture_id_internal(&self) -> crate::texture::TextureId {
unsafe { crate::texture::effective_texture_id(&(*self.raw()).TexRef) }
}
pub(crate) fn tex_data_internal(&self) -> Option<crate::fonts::FontAtlasTexture<'_>> {
let raw = self.raw();
let texture = unsafe { (*raw).TexData };
unsafe { crate::fonts::FontAtlasTexture::from_raw(raw, texture) }
}
}