#[repr(C)]pub struct Texture {
pub gl_context: GlContextPtr,
pub texture_id: GLuint,
pub refcount: *const AtomicUsize,
pub size: PhysicalSizeU32,
pub format: RawImageFormat,
pub background_color: ColorU,
pub flags: TextureFlags,
pub run_destructor: bool,
}Expand description
OpenGL texture, use ReadOnlyWindow::create_texture to create a texture
Fields§
§gl_context: GlContextPtrA reference-counted pointer to the OpenGL context (so that the texture can be deleted in the destructor)
texture_id: GLuintRaw OpenGL texture ID
refcount: *const AtomicUsizeReference count, shared across
size: PhysicalSizeU32Size of this texture (in pixels)
format: RawImageFormatFormat of the texture (rgba8, brga8, etc.)
background_color: ColorUBackground color of this texture
flags: TextureFlagsHints and flags for optimization purposes
run_destructor: boolImplementations§
Source§impl Texture
impl Texture
pub fn create( texture_id: GLuint, flags: TextureFlags, size: PhysicalSizeU32, background_color: ColorU, gl_context: GlContextPtr, format: RawImageFormat, ) -> Self
pub fn allocate_rgba8( gl_context: GlContextPtr, size: PhysicalSizeU32, background: ColorU, ) -> Self
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
§Panics
Panics if no framebuffer/depthbuffer was allocated (the GL object lists are empty).
pub fn get_descriptor(&self) -> ImageDescriptor
Sourcepub fn draw_tesselated_svg_gpu_node(
&mut self,
node: &TessellatedGPUSvgNode,
size: PhysicalSizeU32,
color: ColorU,
transforms: StyleTransformVec,
) -> bool
pub fn draw_tesselated_svg_gpu_node( &mut self, node: &TessellatedGPUSvgNode, size: PhysicalSizeU32, color: ColorU, transforms: StyleTransformVec, ) -> bool
Draws a TessellatedGPUSvgNode with the given color to the texture
Sourcepub fn draw_tesselated_colored_svg_gpu_node(
&mut self,
node: &TessellatedColoredGPUSvgNode,
size: PhysicalSizeU32,
transforms: StyleTransformVec,
) -> bool
pub fn draw_tesselated_colored_svg_gpu_node( &mut self, node: &TessellatedColoredGPUSvgNode, size: PhysicalSizeU32, transforms: StyleTransformVec, ) -> bool
Draws a TessellatedColoredGPUSvgNode to the texture
Source§impl Texture
impl Texture
Sourcepub fn paint_dot(&mut self, cx: f32, cy: f32, brush: Brush)
pub fn paint_dot(&mut self, cx: f32, cy: f32, brush: Brush)
GPU painting: stamp one soft-brush dab centered at (cx, cy) in texture
pixel coordinates (origin top-left, matching RawImage::paint_dot).
No-op if the GL context is unusable – the caller should then use the CPU
RawImage path (GlContextPtr::is_gl_usable).
Sourcepub fn paint_stroke(&mut self, x0: f32, y0: f32, x1: f32, y1: f32, brush: Brush)
pub fn paint_stroke(&mut self, x0: f32, y0: f32, x1: f32, y1: f32, brush: Brush)
GPU painting: stamp dabs along (x0,y0)->(x1,y1) into this texture
via an FBO + the soft-brush shader, alpha-over blended. Same spacing +
falloff as the CPU RawImage::paint_stroke. No-op if GL is unusable.
Sourcepub fn copy_to_raw_image(&self) -> RawImage
pub fn copy_to_raw_image(&self) -> RawImage
Read this texture’s pixels back into an RGBA8 RawImage (top-left origin)
– for exporting the painted canvas to disk. Binds an FBO + glReadPixels.