opegnl: Remove initialization (use Reset instead) (mobile)

This commit is contained in:
Hajime Hoshi 2016-07-04 01:04:27 +09:00
parent 6cfb92c4c4
commit 61ba8dad17
2 changed files with 6 additions and 42 deletions

View File

@ -61,30 +61,13 @@ func init() {
} }
type context struct { type context struct {
gl mgl.Context gl mgl.Context
worker mgl.Worker worker mgl.Worker
initialized chan struct{}
} }
func NewContext() (*Context, error) { func NewContext() (*Context, error) {
c := &Context{ c := &Context{}
locationCache: newLocationCache(),
lastCompositeMode: CompositeModeUnknown,
}
c.gl, c.worker = mgl.NewContext() c.gl, c.worker = mgl.NewContext()
c.initialized = make(chan struct{})
go func() {
// GL calls will just enqueue an task to the worker.
// Since the worker is not available, this enqueuing should be done
// in a goroutine.
// Textures' pixel formats are alpha premultiplied.
c.gl.Enable(mgl.BLEND)
c.BlendFunc(CompositeModeSourceOver)
f := c.gl.GetInteger(mgl.FRAMEBUFFER_BINDING)
c.screenFramebuffer = Framebuffer(mgl.Framebuffer{uint32(f)})
close(c.initialized)
}()
return c, nil return c, nil
} }
@ -102,10 +85,6 @@ func (c *Context) Reset() error {
return nil return nil
} }
func (c *Context) InitializedCh() <-chan struct{} {
return c.initialized
}
func (c *Context) Worker() mgl.Worker { func (c *Context) Worker() mgl.Worker {
return c.worker return c.worker
} }

View File

@ -40,13 +40,6 @@ func Render(chError <-chan error) error {
return errors.New("ui: chError must not be nil") return errors.New("ui: chError must not be nil")
} }
// TODO: Check this is called on the rendering thread // TODO: Check this is called on the rendering thread
if chGLInitialized != nil {
if err := doGLWorks(chError, glContext.InitializedCh()); err != nil {
return err
}
close(chGLInitialized)
<-chGLInitializedEnd
}
select { select {
case chRender <- struct{}{}: case chRender <- struct{}{}:
return doGLWorks(chError, chRenderEnd) return doGLWorks(chError, chRenderEnd)
@ -85,11 +78,9 @@ type userInterface struct {
} }
var ( var (
chRender = make(chan struct{}) chRender = make(chan struct{})
chRenderEnd = make(chan struct{}) chRenderEnd = make(chan struct{})
chGLInitialized = make(chan struct{}) currentUI = &userInterface{
chGLInitializedEnd = make(chan struct{})
currentUI = &userInterface{
sizeChanged: true, sizeChanged: true,
} }
) )
@ -111,12 +102,6 @@ func (u *userInterface) Terminate() error {
} }
func (u *userInterface) Update() (interface{}, error) { func (u *userInterface) Update() (interface{}, error) {
// TODO: Need lock?
if chGLInitialized != nil {
<-chGLInitialized
chGLInitialized = nil
close(chGLInitializedEnd)
}
if u.sizeChanged { if u.sizeChanged {
u.sizeChanged = false u.sizeChanged = false
e := ScreenSizeEvent{ e := ScreenSizeEvent{