Files
gio-patched/app/internal/window/egl_android.go
T
Elias Naur 9b4176c475 app/internal/egl,app/internal/window: move Lock/Unlock methods
EGL contexts don't need locking, so their Lock and Unlock methods
are empty. Remove them and add them where necessary instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00

55 lines
919 B
Go

// SPDX-License-Identifier: Unlicense OR MIT
package window
/*
#include <EGL/egl.h>
*/
import "C"
import (
"unsafe"
"gioui.org/app/internal/egl"
)
type context struct {
win *window
*egl.Context
}
func (w *window) NewContext() (Context, error) {
ctx, err := egl.NewContext(nil)
if err != nil {
return nil, err
}
return &context{win: w, Context: ctx}, nil
}
func (c *context) Release() {
if c.Context != nil {
c.Context.Release()
c.Context = nil
}
}
func (c *context) MakeCurrent() error {
c.Context.ReleaseSurface()
win, width, height := c.win.nativeWindow(c.Context.VisualID())
if win == nil {
return nil
}
eglSurf := egl.NativeWindowType(unsafe.Pointer(win))
if err := c.Context.CreateSurface(eglSurf, width, height); err != nil {
return err
}
if err := c.Context.MakeCurrent(); err != nil {
return err
}
return nil
}
func (c *context) Lock() {}
func (c *context) Unlock() {}