graphics: Better function and variable names

This commit is contained in:
Hajime Hoshi 2016-05-08 04:55:27 +09:00
parent 7f09402bd9
commit acca1c2480
2 changed files with 18 additions and 18 deletions

View File

@ -29,18 +29,18 @@ import (
var imageM sync.Mutex var imageM sync.Mutex
var ( var (
imageCommandQueue = []func() error{} lazyImageProcesses = []func() error{}
) )
func execBufferedImageCommands() error { func execDelayedImageProcesses() error {
imageM.Lock() imageM.Lock()
defer imageM.Unlock() defer imageM.Unlock()
for _, f := range imageCommandQueue { for _, f := range lazyImageProcesses {
if err := f(); err != nil { if err := f(); err != nil {
return err return err
} }
} }
imageCommandQueue = nil lazyImageProcesses = nil
return nil return nil
} }
@ -93,8 +93,8 @@ func (i *Image) fill(clr color.Color) (err error) {
i.pixels = nil i.pixels = nil
return i.framebuffer.Fill(glContext, clr) return i.framebuffer.Fill(glContext, clr)
} }
if imageCommandQueue != nil { if lazyImageProcesses != nil {
imageCommandQueue = append(imageCommandQueue, f) lazyImageProcesses = append(lazyImageProcesses, f)
return return
} }
return f() return f()
@ -155,8 +155,8 @@ func (i *Image) DrawImage(image *Image, options *DrawImageOptions) (err error) {
m := opengl.CompositeMode(options.CompositeMode) m := opengl.CompositeMode(options.CompositeMode)
return i.framebuffer.DrawTexture(glContext, image.texture, vertices[:16*n], &options.GeoM, &options.ColorM, m) return i.framebuffer.DrawTexture(glContext, image.texture, vertices[:16*n], &options.GeoM, &options.ColorM, m)
} }
if imageCommandQueue != nil { if lazyImageProcesses != nil {
imageCommandQueue = append(imageCommandQueue, f) lazyImageProcesses = append(lazyImageProcesses, f)
return nil return nil
} }
return f() return f()
@ -187,7 +187,7 @@ func (i *Image) At(x, y int) color.Color {
// TODO: What if At is called internaly (like from image parts?) // TODO: What if At is called internaly (like from image parts?)
imageM.Lock() imageM.Lock()
defer imageM.Unlock() defer imageM.Unlock()
if imageCommandQueue != nil { if lazyImageProcesses != nil {
panic("ebiten: At can't be called when the GL context is not initialized (this panic happens as of version 1.4.0-alpha)") panic("ebiten: At can't be called when the GL context is not initialized (this panic happens as of version 1.4.0-alpha)")
} }
if i.isDisposed() { if i.isDisposed() {
@ -236,8 +236,8 @@ func (i *Image) Dispose() error {
runtime.SetFinalizer(i, nil) runtime.SetFinalizer(i, nil)
return nil return nil
} }
if imageCommandQueue != nil { if lazyImageProcesses != nil {
imageCommandQueue = append(imageCommandQueue, f) lazyImageProcesses = append(lazyImageProcesses, f)
return nil return nil
} }
return f() return f()
@ -268,8 +268,8 @@ func (i *Image) ReplacePixels(p []uint8) error {
} }
return i.framebuffer.ReplacePixels(glContext, i.texture, p) return i.framebuffer.ReplacePixels(glContext, i.texture, p)
} }
if imageCommandQueue != nil { if lazyImageProcesses != nil {
imageCommandQueue = append(imageCommandQueue, f) lazyImageProcesses = append(lazyImageProcesses, f)
return nil return nil
} }
return f() return f()
@ -319,8 +319,8 @@ func NewImage(width, height int, filter Filter) (*Image, error) {
} }
return nil return nil
} }
if imageCommandQueue != nil { if lazyImageProcesses != nil {
imageCommandQueue = append(imageCommandQueue, f) lazyImageProcesses = append(lazyImageProcesses, f)
return image, nil return image, nil
} }
if err := f(); err != nil { if err := f(); err != nil {
@ -361,8 +361,8 @@ func NewImageFromImage(img image.Image, filter Filter) (*Image, error) {
runtime.SetFinalizer(image, (*Image).Dispose) runtime.SetFinalizer(image, (*Image).Dispose)
return nil return nil
} }
if imageCommandQueue != nil { if lazyImageProcesses != nil {
imageCommandQueue = append(imageCommandQueue, f) lazyImageProcesses = append(lazyImageProcesses, f)
return image, nil return image, nil
} }
if err := f(); err != nil { if err := f(); err != nil {

2
run.go
View File

@ -189,7 +189,7 @@ func run(f func(*Image) error, width, height, scale int, title string) error {
return err return err
} }
if err := execBufferedImageCommands(); err != nil { if err := execDelayedImageProcesses(); err != nil {
return err return err
} }