gpu: expose the rendering implementation

The rendering implementation is needed for using Gio UI with external
window libraries such as GLFW. Expose it in the new package gpu.

Updates #26

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-07 21:16:03 +01:00
parent 34c6a2f735
commit 3b6646933d
25 changed files with 42 additions and 35 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"image"
"runtime"
"gioui.org/app/internal/gl"
"gioui.org/app/internal/gpu"
"gioui.org/gpu"
"gioui.org/gpu/gl"
"gioui.org/op"
)
+5 -3
View File
@@ -2,8 +2,10 @@
package headless
import "gioui.org/app/internal/gl"
import "gioui.org/app/internal/gl/impl"
import (
"gioui.org/app/internal/glimpl"
"gioui.org/gpu/gl"
)
/*
#cgo CFLAGS: -DGL_SILENCE_DEPRECATION -Werror -Wno-deprecated-declarations -fmodules -fobjc-arc -x objective-c
@@ -21,7 +23,7 @@ type nsContext struct {
func newContext() (context, error) {
ctx := C.gio_headless_newContext()
return &nsContext{ctx: ctx, c: new(impl.Functions)}, nil
return &nsContext{ctx: ctx, c: new(glimpl.Functions)}, nil
}
func (c *nsContext) MakeCurrent() error {
+3 -3
View File
@@ -6,8 +6,8 @@ import (
"errors"
"syscall/js"
"gioui.org/app/internal/gl"
"gioui.org/app/internal/gl/impl"
"gioui.org/gpu/gl"
"gioui.org/app/internal/glimpl"
)
type jsContext struct {
@@ -27,7 +27,7 @@ func newContext() (*jsContext, error) {
if ctx.IsNull() {
return nil, errors.New("headless: webgl is not supported")
}
f := &impl.Functions{Ctx: ctx}
f := &glimpl.Functions{Ctx: ctx}
if err := f.Init(version); err != nil {
return nil, err
}
+3 -3
View File
@@ -10,8 +10,8 @@ import (
"runtime"
"strings"
"gioui.org/app/internal/gl"
"gioui.org/app/internal/gl/impl"
"gioui.org/app/internal/glimpl"
"gioui.org/gpu/gl"
)
type Context struct {
@@ -110,7 +110,7 @@ func NewContext(disp NativeDisplayType) (*Context, error) {
c := &Context{
disp: eglDisp,
eglCtx: eglCtx,
c: new(impl.Functions),
c: new(glimpl.Functions),
}
return c, nil
}
+3 -3
View File
@@ -10,8 +10,8 @@ import (
syscall "golang.org/x/sys/windows"
"gioui.org/app/internal/gl"
"gioui.org/app/internal/gl/impl"
"gioui.org/gpu/gl"
"gioui.org/app/internal/glimpl"
)
type (
@@ -57,7 +57,7 @@ func loadDLLs() error {
if err := loadDLL(libEGL, "libEGL.dll"); err != nil {
return err
}
if err := loadDLL(impl.LibGLESv2, "libGLESv2.dll"); err != nil {
if err := loadDLL(glimpl.LibGLESv2, "libGLESv2.dll"); err != nil {
return err
}
// d3dcompiler_47.dll is needed internally for shader compilation to function.
@@ -2,14 +2,14 @@
// +build darwin linux freebsd openbsd
package impl
package glimpl
import (
"runtime"
"strings"
"unsafe"
"gioui.org/app/internal/gl"
"gioui.org/gpu/gl"
)
/*
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: Unlicense OR MIT
package impl
package glimpl
import (
"errors"
"strings"
"syscall/js"
"gioui.org/app/internal/gl"
"gioui.org/gpu/gl"
)
type Functions struct {
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Unlicense OR MIT
package impl
package glimpl
import (
"math"
@@ -10,7 +10,7 @@ import (
"golang.org/x/sys/windows"
"gioui.org/app/internal/gl"
"gioui.org/gpu/gl"
)
var (
+3 -3
View File
@@ -16,8 +16,8 @@ import (
"errors"
"fmt"
"gioui.org/app/internal/gl"
"gioui.org/app/internal/gl/impl"
"gioui.org/gpu/gl"
"gioui.org/app/internal/glimpl"
)
type context struct {
@@ -45,7 +45,7 @@ func newContext(w *window) (*context, error) {
ctx: ctx,
owner: w,
layer: C.CFTypeRef(w.contextLayer()),
c: new(impl.Functions),
c: new(glimpl.Functions),
}
return c, nil
}
+3 -3
View File
@@ -6,8 +6,8 @@ import (
"errors"
"syscall/js"
"gioui.org/app/internal/gl"
"gioui.org/app/internal/gl/impl"
"gioui.org/gpu/gl"
"gioui.org/app/internal/glimpl"
)
type context struct {
@@ -33,7 +33,7 @@ func newContext(w *window) (*context, error) {
if ctx.IsNull() {
return nil, errors.New("app: webgl is not supported")
}
f := &impl.Functions{Ctx: ctx}
f := &glimpl.Functions{Ctx: ctx}
if err := f.Init(version); err != nil {
return nil, err
}
+3 -3
View File
@@ -5,8 +5,8 @@
package window
import (
"gioui.org/app/internal/gl"
"gioui.org/app/internal/gl/impl"
"gioui.org/gpu/gl"
"gioui.org/app/internal/glimpl"
)
/*
@@ -35,7 +35,7 @@ func newContext(w *window) (*context, error) {
ctx := C.gio_contextForView(view)
c := &context{
ctx: ctx,
c: new(impl.Functions),
c: new(glimpl.Functions),
view: view,
}
return c, nil
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"math"
"time"
"gioui.org/app/internal/gl"
"gioui.org/gpu/gl"
"gioui.org/io/event"
"gioui.org/io/system"
"gioui.org/unit"
+1 -1
View File
@@ -6,8 +6,8 @@ import (
"image"
"runtime"
"gioui.org/app/internal/gpu"
"gioui.org/app/internal/window"
"gioui.org/gpu"
"gioui.org/op"
)
@@ -6,7 +6,7 @@ import (
"errors"
"strings"
"gioui.org/app/internal/gl"
"gioui.org/gpu/gl"
)
type context struct {
+6 -1
View File
@@ -1,5 +1,10 @@
// SPDX-License-Identifier: Unlicense OR MIT
/*
Package gpu implements the rendering of Gio drawing operations. It
is used by package app and package app/headless and is otherwise not
useful except for integrating with external window implementations.
*/
package gpu
import (
@@ -12,8 +17,8 @@ import (
"time"
"unsafe"
"gioui.org/app/internal/gl"
"gioui.org/f32"
"gioui.org/gpu/gl"
"gioui.org/internal/opconst"
"gioui.org/internal/ops"
"gioui.org/internal/path"
+1 -1
View File
@@ -9,8 +9,8 @@ import (
"image"
"unsafe"
"gioui.org/app/internal/gl"
"gioui.org/f32"
"gioui.org/gpu/gl"
"gioui.org/internal/path"
)
+1 -1
View File
@@ -5,7 +5,7 @@ package gpu
import (
"time"
"gioui.org/app/internal/gl"
"gioui.org/gpu/gl"
)
type timers struct {