backend/internal/system/system.go

38 lines
1.0 KiB
Go
Raw Normal View History

2024-06-01 14:39:14 -06:00
package system
2024-06-02 11:34:11 -06:00
import "io"
2024-06-01 14:39:14 -06:00
import "image"
import "git.tebibyte.media/tomo/tomo/canvas"
2024-06-02 11:23:03 -06:00
// System is coupled to a tomo.Backend implementation, and manages Hierarchies
// and Boxes.
2024-06-01 14:39:14 -06:00
type System struct {
link BackendLink
}
2024-06-02 11:33:59 -06:00
// BackendLink allows the System to call up into the tomo.Backend implementation
2024-06-02 11:23:03 -06:00
// which contains it in order to do things such as create new textures.
2024-06-01 14:39:14 -06:00
type BackendLink interface {
2024-06-02 11:33:59 -06:00
// NewTexture creates a new texture from an image.
2024-06-01 14:39:14 -06:00
NewTexture (image.Image) canvas.TextureCloser
2024-06-02 11:33:59 -06:00
// NewCanvas creates a new blank canvas with the specified bounds.
2024-06-01 14:39:14 -06:00
NewCanvas (image.Rectangle) canvas.Canvas
2024-06-02 11:33:59 -06:00
// NewSurface creates a new surface with the specified bounds.
NewSurface (image.Rectangle) (SurfaceLink, error)
2024-06-01 14:39:14 -06:00
}
2024-06-02 11:23:03 -06:00
// SurfaceLink wraps a Surface created by the backend implementation, allowing
// the System a higher level of control over it.
2024-06-01 14:39:14 -06:00
type SurfaceLink interface {
2024-06-02 11:34:11 -06:00
io.Closer
2024-06-01 14:39:14 -06:00
GetSurface () any
SetSize (image.Rectangle)
}
2024-06-02 11:23:03 -06:00
// New creates a new System.
2024-06-01 14:39:14 -06:00
func New (link BackendLink) *System {
return &System {
link: link,
}
}