cache

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ValidDuration = 1 * time.Minute

	// CleanHooks are additional cleanup functions called during each Clean() cycle.
	// Used to allow packages like painter to register cache sweeps without circular imports.
	CleanHooks []func()
)
View Source
var NoTexture = TextureType(0)

Functions

func CachedRenderer

func CachedRenderer(wid core.Widget) (core.WidgetRenderer, bool)

CachedRenderer looks up the cached render implementation for a widget If a renderer does not exist in the cache, it returns nil, false.

func Clean

func Clean(canvasRefreshed bool)

Clean run cache clean task, it should be called on paint events.

func CleanCanvas

func CleanCanvas(canvas core.Canvas)

CleanCanvas performs a complete remove of all the objects that belong to the specified canvas. Usually used to free all objects from a closing window. Also sweeps any expired renderers to avoid GPU resource leaks from widgets whose canvas entries expired before the canvas was closed.

func DeleteTextTexturesFor

func DeleteTextTexturesFor(canvas core.Canvas)

DeleteTextTexturesFor deletes all text textures for the given canvas.

func DeleteTexture

func DeleteTexture(obj core.CanvasObject)

DeleteTexture deletes the texture from the cache map.

func DestroyRenderer

func DestroyRenderer(wid core.Widget)

DestroyRenderer frees a render implementation for a widget. This is typically for internal use only.

func GetCanvasForObject

func GetCanvasForObject(obj core.CanvasObject) core.Canvas

GetCanvasForObject returns the canvas for the specified object.

func GetFontMetrics

func GetFontMetrics(text string, fontSize float32, style bellui.TextStyle, source bellui.Resource) (size geo.Size, base float32)

GetFontMetrics looks up a calculated size and baseline required for the specified text parameters.

func GetSvg

func GetSvg(name string, o core.CanvasObject, w int, h int) *image.NRGBA

GetSvg gets svg image from cache if it exists.

func IsRendered

func IsRendered(wid core.Widget) bool

IsRendered returns true of the widget currently has a renderer. One will be created the first time a widget is shown but may be removed after it is hidden.

func IsValid

func IsValid(texture TextureType) bool

IsValid will return true if the passed texture is potentially a texture.

func OverrideTheme

func OverrideTheme(o core.CanvasObject, th bellui.Theme)

OverrideTheme allows an app to specify that a single object should use a different theme to the app. This should be used sparingly to avoid a jarring user experience. If the object is a container it will theme the children, if it is a canvas primitive it will do nothing.

Since: 1.0

func OverrideThemeMatchingScope

func OverrideThemeMatchingScope(o, parent core.CanvasObject) bool

func RangeExpiredTexturesFor

func RangeExpiredTexturesFor(canvas core.Canvas, f func(core.CanvasObject))

RangeExpiredTexturesFor range over the expired textures for the specified canvas.

Note: If this is used to free textures, then it should be called inside a current gl context to ensure textures are deleted from gl.

func RangeTexturesFor

func RangeTexturesFor(canvas core.Canvas, f func(core.CanvasObject))

RangeTexturesFor range over the textures for the specified canvas. It will not return the texture for a `canvas.Text` as their render lifecycle is handled separately.

Note: If this is used to free textures, then it should be called inside a current gl context to ensure textures are deleted from gl.

func Renderer

func Renderer(wid core.Widget) core.WidgetRenderer

Renderer looks up the render implementation for a widget. If one does not exist, it creates and caches a renderer for the widget. If two goroutines race to create the renderer, the loser's renderer is destroyed to prevent leaks.

func ResetThemeCaches

func ResetThemeCaches()

ResetThemeCaches clears all the svg and text size cache maps

func SetCanvasForObject

func SetCanvasForObject(obj core.CanvasObject, c core.Canvas, setup func())

SetCanvasForObject sets the canvas for the specified object. The passed function will be called if the item was not previously attached to this canvas

func SetFontMetrics

func SetFontMetrics(text string, fontSize float32, style bellui.TextStyle, source bellui.Resource, size geo.Size, base float32)

SetFontMetrics stores a calculated font size and baseline for parameters that were missing from the cache.

func SetSvg

func SetSvg(name string, o core.CanvasObject, pix *image.NRGBA, w int, h int)

SetSvg sets a svg into the cache map.

func SetTextTexture

func SetTextTexture(ent FontCacheEntry, texture TextureType, canvas core.Canvas, free func())

SetTextTexture sets cached texture for a text run.

func SetTexture

func SetTexture(obj core.CanvasObject, texture TextureType, canvas core.Canvas)

SetTexture sets cached texture.

func ThemeCacheGeneration

func ThemeCacheGeneration() uint64

ThemeCacheGeneration returns a counter bumped each time the theme/font caches are reset (ResetThemeCaches). A widget-level measurement memo compares this against the generation it was built under and drops itself when it differs, so it stays consistent with the authoritative global metrics cache (pre-rebrand tracker #896).

func WidgetScopeID

func WidgetScopeID(o core.CanvasObject) string

func WidgetTheme

func WidgetTheme(o core.CanvasObject) bellui.Theme

Types

type FontCacheEntry

type FontCacheEntry struct {
	Canvas core.Canvas
	Color  color.Color
	// contains filtered or unexported fields
}

FontCacheEntry is the cache key for rendered text textures.

func NewFontCacheEntry

func NewFontCacheEntry(text string, fontSize float32, style bellui.TextStyle, source string, canvas core.Canvas, col color.Color) FontCacheEntry

NewFontCacheEntry builds a FontCacheEntry from a text object's properties.

type TextureType

type TextureType = uint32

TextureType is an opaque WebGPU texture handle under the `webgpu` build: a uint32 registry key into the webgpu painter's texture table (internal/painter/ webgpu/texture.go), used uniformly on every platform (desktop/wasm/mobile) instead of the GL-specific gl.Texture types. The desktop GL path already used uint32 here, so this only changes wasm/mobile webgpu builds.

func GetTextTexture

func GetTextTexture(ent FontCacheEntry) (TextureType, bool)

GetTextTexture gets cached texture for a text run.

func GetTexture

func GetTexture(obj core.CanvasObject) (TextureType, bool)

GetTexture gets cached texture.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL