示例#1
0
//// Helper
func redraw(display *Display) {
	col = uint8(int8(col) + add)
	if col == 255 {
		add = -1
	} else if col == 0 {
		add = 1
	}

	for i, _ := range display.data {
		display.data[i] = byte(col)
	}

	display.surface.Damage(0, 0, 250, 250)
	cb := gowl.NewCallback()
	done := make(chan gowl.CallbackDone)
	cb.AddDoneListener(done)
	display.surface.Frame(cb)
	display.surface.Commit()
	func() {
		for {
			select {
			case <-done:
				redraw(display)
			default:
				display.display.Iterate()
				c := time.Tick(time.Second / 100)
				<-c
			}
		}
	}()
}
示例#2
0
func waitForSync(display *gowl.Display) {
	cb := gowl.NewCallback()
	done := make(chan gowl.CallbackDone)
	cb.AddDoneListener(done)
	display.Sync(cb)
	func() {
		for {
			select {
			case <-done:
				return
			default:
				display.Iterate()
			}
		}
	}()
}
示例#3
0
func (w *Window) FlushImage(bounds ...image.Rectangle) {
	w.surface.Attach(w.buffer, 0, 0)

	for _, b := range bounds {
		w.surface.Damage(int32(b.Min.X), int32(b.Min.Y), int32(b.Dx()), int32(b.Dy()))
	}

	// Wait for redraw to finish
	cb := gowl.NewCallback()
	done := make(chan interface{})
	cb.AddDoneListener(done)
	w.surface.Frame(cb)
	func() {
		for {
			select {
			case <-done:
				return
			default:
				w.display.Iterate()
			}
		}
	}()
}