mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
app: optimize window context locking
Avoids unnecessary eglMakeCurrent and thread locking calls to enhance performance. Fixes: https://todo.sr.ht/~eliasnaur/gio/658 Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
This commit is contained in:
committed by
Elias Naur
parent
b2b12d6288
commit
3e601e73c4
+5
-9
@@ -142,8 +142,11 @@ func (w *Window) validateAndProcess(size image.Point, sync bool, frame *op.Ops,
|
|||||||
if w.gpu == nil && !w.nocontext {
|
if w.gpu == nil && !w.nocontext {
|
||||||
var err error
|
var err error
|
||||||
if w.ctx == nil {
|
if w.ctx == nil {
|
||||||
w.ctx, err = w.driver.NewContext()
|
if w.ctx, err = w.driver.NewContext(); err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
|
}
|
||||||
|
if err = w.ctx.Lock(); err != nil {
|
||||||
|
w.destroyGPU()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sync = true
|
sync = true
|
||||||
@@ -163,12 +166,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 {
|
||||||
@@ -200,7 +197,6 @@ func (w *Window) validateAndProcess(size image.Point, sync bool, frame *op.Ops,
|
|||||||
var err error
|
var err error
|
||||||
if w.gpu != nil {
|
if w.gpu != nil {
|
||||||
err = w.ctx.Present()
|
err = w.ctx.Present()
|
||||||
w.ctx.Unlock()
|
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user