forked from joejulian/gio
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d9b0c8c1c5 |
+21
-10
@@ -154,6 +154,10 @@ func (w *Window) validateAndProcess(size image.Point, sync bool, frame *op.Ops,
|
||||
sync = true
|
||||
}
|
||||
}
|
||||
if err := w.lockContext(); err != nil {
|
||||
w.destroyGPU()
|
||||
return err
|
||||
}
|
||||
if sync && w.ctx != nil {
|
||||
if err := w.ctx.Refresh(); err != nil {
|
||||
if errors.Is(err, errOutOfDate) {
|
||||
@@ -167,14 +171,11 @@ func (w *Window) validateAndProcess(size image.Point, sync bool, frame *op.Ops,
|
||||
}
|
||||
return err
|
||||
}
|
||||
w.ctxNeedsLock = true
|
||||
}
|
||||
if w.ctx != nil && w.ctxNeedsLock {
|
||||
if err := w.ctx.Lock(); err != nil {
|
||||
w.unlockContext()
|
||||
if err := w.lockContext(); err != nil {
|
||||
w.destroyGPU()
|
||||
return err
|
||||
}
|
||||
w.ctxNeedsLock = false
|
||||
}
|
||||
if w.gpu == nil && !w.nocontext {
|
||||
gpu, err := gpu.New(w.ctx.API())
|
||||
@@ -509,6 +510,17 @@ func (c *callbacks) ActionAt(p f32.Point) (system.Action, bool) {
|
||||
return c.w.queue.ActionAt(p)
|
||||
}
|
||||
|
||||
func (w *Window) lockContext() error {
|
||||
if w.ctx == nil || !w.ctxNeedsLock {
|
||||
return nil
|
||||
}
|
||||
if err := w.ctx.Lock(); err != nil {
|
||||
return err
|
||||
}
|
||||
w.ctxNeedsLock = false
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *Window) unlockContext() {
|
||||
if w.ctx == nil || w.ctxNeedsLock {
|
||||
return
|
||||
@@ -519,9 +531,9 @@ func (w *Window) unlockContext() {
|
||||
|
||||
func (w *Window) destroyGPU() {
|
||||
if w.gpu != nil {
|
||||
if err := w.ctx.Lock(); err == nil {
|
||||
if err := w.lockContext(); err == nil {
|
||||
w.gpu.Release()
|
||||
w.ctx.Unlock()
|
||||
w.unlockContext()
|
||||
}
|
||||
w.gpu = nil
|
||||
}
|
||||
@@ -671,12 +683,11 @@ func (w *Window) processEvent(e event.Event) bool {
|
||||
w.coalesced.destroy = &e2
|
||||
case ViewEvent:
|
||||
if !e2.Valid() && w.gpu != nil {
|
||||
if err := w.ctx.Lock(); err == nil {
|
||||
if err := w.lockContext(); err == nil {
|
||||
w.gpu.Release()
|
||||
w.ctx.Unlock()
|
||||
w.unlockContext()
|
||||
}
|
||||
w.gpu = nil
|
||||
w.ctxNeedsLock = true
|
||||
}
|
||||
w.coalesced.view = &e2
|
||||
case ConfigEvent:
|
||||
|
||||
Reference in New Issue
Block a user