mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
app: lock explicitly before refreshing contexts
Signed-off-by: Joe Julian <me@joejulian.name>
This commit is contained in:
@@ -115,9 +115,6 @@ func (c *context) Unlock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *context) Refresh() error {
|
func (c *context) Refresh() error {
|
||||||
if C.gio_makeCurrent(c.ctx) == 0 {
|
|
||||||
return errors.New("[EAGLContext setCurrentContext] failed")
|
|
||||||
}
|
|
||||||
if !c.init {
|
if !c.init {
|
||||||
c.init = true
|
c.init = true
|
||||||
c.frameBuffer = c.c.CreateFramebuffer()
|
c.frameBuffer = c.c.CreateFramebuffer()
|
||||||
|
|||||||
@@ -111,8 +111,6 @@ func (c *glContext) Unlock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *glContext) Refresh() error {
|
func (c *glContext) Refresh() error {
|
||||||
c.Lock()
|
|
||||||
defer c.Unlock()
|
|
||||||
C.gio_updateContext(c.ctx)
|
C.gio_updateContext(c.ctx)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,6 +165,8 @@ type frameEvent struct {
|
|||||||
Sync bool
|
Sync bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The caller must hold the context lock while using API, Refresh,
|
||||||
|
// RenderTarget, or Present.
|
||||||
type context interface {
|
type context interface {
|
||||||
API() gpu.API
|
API() gpu.API
|
||||||
RenderTarget() (gpu.RenderTarget, error)
|
RenderTarget() (gpu.RenderTarget, error)
|
||||||
|
|||||||
+6
-6
@@ -149,6 +149,12 @@ func (w *Window) validateAndProcess(size image.Point, sync bool, frame *op.Ops,
|
|||||||
sync = true
|
sync = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if w.ctx != nil {
|
||||||
|
if err := w.ctx.Lock(); err != nil {
|
||||||
|
w.destroyGPU()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
if sync && w.ctx != nil {
|
if sync && w.ctx != nil {
|
||||||
if err := w.ctx.Refresh(); err != nil {
|
if err := w.ctx.Refresh(); err != nil {
|
||||||
if errors.Is(err, errOutOfDate) {
|
if errors.Is(err, errOutOfDate) {
|
||||||
@@ -163,12 +169,6 @@ func (w *Window) validateAndProcess(size image.Point, sync bool, frame *op.Ops,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if w.ctx != nil {
|
|
||||||
if err := w.ctx.Lock(); err != nil {
|
|
||||||
w.destroyGPU()
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if w.gpu == nil && !w.nocontext {
|
if w.gpu == nil && !w.nocontext {
|
||||||
gpu, err := gpu.New(w.ctx.API())
|
gpu, err := gpu.New(w.ctx.API())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user