Documentation
¶
Index ¶
- Variables
- func CachedRenderer(wid core.Widget) (core.WidgetRenderer, bool)
- func Clean(canvasRefreshed bool)
- func CleanCanvas(canvas core.Canvas)
- func DeleteTextTexturesFor(canvas core.Canvas)
- func DeleteTexture(obj core.CanvasObject)
- func DestroyRenderer(wid core.Widget)
- func GetCanvasForObject(obj core.CanvasObject) core.Canvas
- func GetFontMetrics(text string, fontSize float32, style bellui.TextStyle, source bellui.Resource) (size geo.Size, base float32)
- func GetSvg(name string, o core.CanvasObject, w int, h int) *image.NRGBA
- func IsRendered(wid core.Widget) bool
- func IsValid(texture TextureType) bool
- func OverrideTheme(o core.CanvasObject, th bellui.Theme)
- func OverrideThemeMatchingScope(o, parent core.CanvasObject) bool
- func RangeExpiredTexturesFor(canvas core.Canvas, f func(core.CanvasObject))
- func RangeTexturesFor(canvas core.Canvas, f func(core.CanvasObject))
- func Renderer(wid core.Widget) core.WidgetRenderer
- func ResetThemeCaches()
- func SetCanvasForObject(obj core.CanvasObject, c core.Canvas, setup func())
- func SetFontMetrics(text string, fontSize float32, style bellui.TextStyle, source bellui.Resource, ...)
- func SetSvg(name string, o core.CanvasObject, pix *image.NRGBA, w int, h int)
- func SetTextTexture(ent FontCacheEntry, texture TextureType, canvas core.Canvas, free func())
- func SetTexture(obj core.CanvasObject, texture TextureType, canvas core.Canvas)
- func ThemeCacheGeneration() uint64
- func WidgetScopeID(o core.CanvasObject) string
- func WidgetTheme(o core.CanvasObject) bellui.Theme
- type FontCacheEntry
- type TextureType
Constants ¶
This section is empty.
Variables ¶
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() )
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 ¶
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 ¶
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 ¶
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 IsRendered ¶
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: 2.5
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 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 (#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.
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.