ltk

Module gles_render

Source
Expand description

GPU-accelerated rendering backend using EGL + GLES2 / GLES3.

Mirrors the public surface of the software backend so that crate::core::Canvas can route widget draw calls to either backend by match self. The EGL context bootstrap lives in crate::egl_context — this module is just the renderer that runs once a context is current.

Clipping is implemented with glScissor. When GlesCanvas::set_clip_rects receives multiple rects the bounding-box union is used as the scissor — coarse, but the partial-redraw path normally clusters the dirty rects of 1–3 widgets so the union is barely larger than the sum. Disjoint regions would want a stencil-buffer path; not implemented today.

§Submodule layout

  • setupGlesCanvas::{new, sub_canvas, resize, set_font_registry, font_for, dpi/alpha accessors}.
  • framebufferGlesCanvas::{blit, present, activate_target, borrowed_texture, read_rgba_pixels, ensure_aux_*, snapshot_fbo_region, fill_backdrop, invalidate_aux} — everything that manipulates the FBO or auxiliary snapshot textures.
  • clipGlesCanvas::{set_clip_rects, clear_clip, set_scissor, scissor_pixels, fill, clear, clear_rects_transparent}.
  • primitivesGlesCanvas::{fill_rect, fill_linear_gradient_rect, fill_radial_gradient_rect, fill_shadow_outer, fill_shadow_inset, stroke_rect, draw_line}.
  • textGlesCanvas::{draw_text, measure_text}.
  • imageGlesCanvas::draw_image_data.
  • shaders — GLSL ES 1.00 shader sources (const strings).
  • helpers — free functions: ortho_rect, compile_program, alloc_fbo_tex, upload_*_texture, handle extractors, find_font + SYSTEM_FONT_CANDIDATES.
  • raiiFboBinding / ProgramBinding scoped guards for the handful of operations that change global GL state for a scope and must guarantee restoration even on early return / panic (presently only present). The renderer otherwise relies on activate_target’s lazy re-bind at the entry of each draw method — see the module’s own doc for when to use the guards and when not to.

Structs§

Enums§

  • Which GLES profile the active context is. Stored so per-frame fast-paths can be selected without re-querying GL.