app,app/headless: expose Backends from window and headless contexts

This is a refactoring change to prepare for another gpu.Backend
implementations.

Notably, app/loop.go no longer imports gpu/gl.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-15 18:29:14 +01:00
parent f62725ea77
commit 94fdc26cb5
9 changed files with 42 additions and 19 deletions
+3 -2
View File
@@ -17,6 +17,7 @@ import (
"fmt"
"gioui.org/app/internal/glimpl"
"gioui.org/gpu"
"gioui.org/gpu/gl"
)
@@ -50,8 +51,8 @@ func newContext(w *window) (*context, error) {
return c, nil
}
func (c *context) Functions() *glimpl.Functions {
return c.c
func (c *context) Backend() (gpu.Backend, error) {
return gl.NewBackend(c.c)
}
func (c *context) Release() {
+4 -2
View File
@@ -8,6 +8,8 @@ import (
"gioui.org/app/internal/glimpl"
"gioui.org/app/internal/srgb"
"gioui.org/gpu"
"gioui.org/gpu/gl"
)
type context struct {
@@ -45,8 +47,8 @@ func newContext(w *window) (*context, error) {
return c, nil
}
func (c *context) Functions() *glimpl.Functions {
return c.f
func (c *context) Backend() (gpu.Backend, error) {
return gl.NewBackend(c.f)
}
func (c *context) Release() {
+4 -2
View File
@@ -6,6 +6,8 @@ package window
import (
"gioui.org/app/internal/glimpl"
"gioui.org/gpu"
"gioui.org/gpu/gl"
)
/*
@@ -40,8 +42,8 @@ func newContext(w *window) (*context, error) {
return c, nil
}
func (c *context) Functions() *glimpl.Functions {
return c.c
func (c *context) Backend() (gpu.Backend, error) {
return gl.NewBackend(c.c)
}
func (c *context) Release() {
+2 -2
View File
@@ -9,7 +9,7 @@ import (
"math"
"time"
"gioui.org/app/internal/glimpl"
"gioui.org/gpu"
"gioui.org/io/event"
"gioui.org/io/system"
"gioui.org/unit"
@@ -32,7 +32,7 @@ type Callbacks interface {
}
type Context interface {
Functions() *glimpl.Functions
Backend() (gpu.Backend, error)
Present() error
MakeCurrent() error
Release()