diff --git a/app/app.go b/app/app.go index 512f81b..e36066c 100644 --- a/app/app.go +++ b/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) diff --git a/app/darwin_amd64.go b/app/darwin_amd64.go index 1da8c29..706927f 100644 --- a/app/darwin_amd64.go +++ b/app/darwin_amd64.go @@ -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 } diff --git a/app/darwin_armx.go b/app/darwin_armx.go index f666563..8169025 100644 --- a/app/darwin_armx.go +++ b/app/darwin_armx.go @@ -171,7 +171,7 @@ func drawgl(ctx uintptr) { select { case <-gl.WorkAvailable: gl.DoWork() - case <-endDraw: + case <-endPaint: return } } diff --git a/app/doc.go b/app/doc.go index b2ae070..757c8bc 100644 --- a/app/doc.go +++ b/app/doc.go @@ -55,7 +55,7 @@ function exits, the app exits. // ... case paint.Event: log.Print("Call OpenGL here.") - a.EndDraw() + a.EndPaint() } } }) diff --git a/app/loop_android.go b/app/loop_android.go index de0f34d..3f684fb 100644 --- a/app/loop_android.go +++ b/app/loop_android.go @@ -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{} diff --git a/app/x11.go b/app/x11.go index 089329e..1f461f9 100644 --- a/app/x11.go +++ b/app/x11.go @@ -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: diff --git a/event/paint/paint.go b/event/paint/paint.go index 532fc49..3c4d8a2 100644 --- a/event/paint/paint.go +++ b/event/paint/paint.go @@ -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{} diff --git a/example/basic/main.go b/example/basic/main.go index b116bd4..c7d0e4f 100644 --- a/example/basic/main.go +++ b/example/basic/main.go @@ -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)