app: rename EndDraw to EndPaint.
Change-Id: I3e38df0e21be2246dd16886fa00c9360d42db145 Reviewed-on: https://go-review.googlesource.com/12282 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
460bd28e6c
commit
b43065626f
16
app/app.go
16
app/app.go
@ -39,8 +39,8 @@ type App interface {
|
||||
// Send sends an event on the events channel. It does not block.
|
||||
Send(event interface{})
|
||||
|
||||
// EndDraw flushes any pending OpenGL commands or buffers to the screen.
|
||||
EndDraw()
|
||||
// EndPaint flushes any pending OpenGL commands or buffers to the screen.
|
||||
EndPaint()
|
||||
}
|
||||
|
||||
var (
|
||||
@ -49,7 +49,7 @@ var (
|
||||
|
||||
eventsOut = make(chan interface{})
|
||||
eventsIn = pump(eventsOut)
|
||||
endDraw = make(chan struct{}, 1)
|
||||
endPaint = make(chan struct{}, 1)
|
||||
)
|
||||
|
||||
func sendLifecycle(to lifecycle.Stage) {
|
||||
@ -73,18 +73,18 @@ func (app) Send(event interface{}) {
|
||||
eventsIn <- event
|
||||
}
|
||||
|
||||
func (app) EndDraw() {
|
||||
func (app) EndPaint() {
|
||||
// gl.Flush is a lightweight (on modern GL drivers) blocking call
|
||||
// that ensures all GL functions pending in the gl package have
|
||||
// been passed onto the GL driver before the app package attempts
|
||||
// to swap the screen buffer.
|
||||
//
|
||||
// This enforces that the final receive (for this draw cycle) on
|
||||
// gl.WorkAvailable happens before the send on endDraw.
|
||||
// This enforces that the final receive (for this paint cycle) on
|
||||
// gl.WorkAvailable happens before the send on endPaint.
|
||||
gl.Flush()
|
||||
|
||||
select {
|
||||
case endDraw <- struct{}{}:
|
||||
case endPaint <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
@ -184,7 +184,7 @@ func Run(cb Callbacks) {
|
||||
if cb.Draw != nil {
|
||||
cb.Draw(c)
|
||||
}
|
||||
a.EndDraw()
|
||||
a.EndPaint()
|
||||
case touch.Event:
|
||||
if cb.Touch != nil {
|
||||
cb.Touch(e, c)
|
||||
|
@ -84,7 +84,7 @@ func loop(ctx C.GLintptr) {
|
||||
select {
|
||||
case <-gl.WorkAvailable:
|
||||
gl.DoWork()
|
||||
case <-endDraw:
|
||||
case <-endPaint:
|
||||
C.CGLFlushDrawable(C.CGLGetCurrentContext())
|
||||
break loop1
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ func drawgl(ctx uintptr) {
|
||||
select {
|
||||
case <-gl.WorkAvailable:
|
||||
gl.DoWork()
|
||||
case <-endDraw:
|
||||
case <-endPaint:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ function exits, the app exits.
|
||||
// ...
|
||||
case paint.Event:
|
||||
log.Print("Call OpenGL here.")
|
||||
a.EndDraw()
|
||||
a.EndPaint()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -129,7 +129,7 @@ func windowDraw(w *C.ANativeWindow, queue *C.AInputQueue, donec chan struct{}) (
|
||||
return false
|
||||
case <-gl.WorkAvailable:
|
||||
gl.DoWork()
|
||||
case <-endDraw:
|
||||
case <-endPaint:
|
||||
// eglSwapBuffers blocks until vsync.
|
||||
C.eglSwapBuffers(C.display, C.surface)
|
||||
eventsIn <- paint.Event{}
|
||||
|
@ -63,7 +63,7 @@ func main(f func(App)) {
|
||||
return
|
||||
case <-gl.WorkAvailable:
|
||||
gl.DoWork()
|
||||
case <-endDraw:
|
||||
case <-endPaint:
|
||||
C.swapBuffers()
|
||||
tc = ticker.C
|
||||
case <-tc:
|
||||
|
@ -7,11 +7,6 @@
|
||||
// See the golang.org/x/mobile/event package for details on the event model.
|
||||
package paint // import "golang.org/x/mobile/event/paint"
|
||||
|
||||
// TODO: rename App.EndDraw to App.EndPaint.
|
||||
//
|
||||
// This is "package paint", not "package draw", to avoid conflicting with the
|
||||
// standard library's "image/draw" package.
|
||||
|
||||
// Event indicates that the app is ready to paint the next frame of the GUI. A
|
||||
// frame is completed by calling the App's EndDraw method.
|
||||
// frame is completed by calling the App's EndPaint method.
|
||||
type Event struct{}
|
||||
|
@ -70,8 +70,8 @@ func main() {
|
||||
c = e
|
||||
touchLoc = geom.Point{c.Width / 2, c.Height / 2}
|
||||
case paint.Event:
|
||||
onDraw(c)
|
||||
a.EndDraw()
|
||||
onPaint(c)
|
||||
a.EndPaint()
|
||||
case touch.Event:
|
||||
touchLoc = e.Loc
|
||||
}
|
||||
@ -104,7 +104,7 @@ func onStop() {
|
||||
gl.DeleteBuffer(buf)
|
||||
}
|
||||
|
||||
func onDraw(c config.Event) {
|
||||
func onPaint(c config.Event) {
|
||||
gl.ClearColor(1, 0, 0, 1)
|
||||
gl.Clear(gl.COLOR_BUFFER_BIT)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user