mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
graphics: Better name functions
This commit is contained in:
parent
1f4c78c41c
commit
75916490b7
14
image.go
14
image.go
@ -52,11 +52,11 @@ func (i *images) remove(img *Image) {
|
|||||||
runtime.SetFinalizer(img, nil)
|
runtime.SetFinalizer(img, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *images) resetHistoryIfNeeded(target *Image, context *opengl.Context) error {
|
func (i *images) flushPixelsIfNeeded(target *Image, context *opengl.Context) error {
|
||||||
i.m.Lock()
|
i.m.Lock()
|
||||||
defer i.m.Unlock()
|
defer i.m.Unlock()
|
||||||
for img := range i.images {
|
for img := range i.images {
|
||||||
if err := img.resetHistoryIfNeeded(target, context); err != nil {
|
if err := img.flushPixelsIfNeeded(target, context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ func (i *Image) Size() (width, height int) {
|
|||||||
//
|
//
|
||||||
// This function is concurrent-safe.
|
// This function is concurrent-safe.
|
||||||
func (i *Image) Clear() error {
|
func (i *Image) Clear() error {
|
||||||
if err := theImagesForRestoring.resetHistoryIfNeeded(i, ui.GLContext()); err != nil {
|
if err := theImagesForRestoring.flushPixelsIfNeeded(i, ui.GLContext()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return i.impl.Fill(color.Transparent)
|
return i.impl.Fill(color.Transparent)
|
||||||
@ -140,7 +140,7 @@ func (i *Image) Clear() error {
|
|||||||
//
|
//
|
||||||
// This function is concurrent-safe.
|
// This function is concurrent-safe.
|
||||||
func (i *Image) Fill(clr color.Color) error {
|
func (i *Image) Fill(clr color.Color) error {
|
||||||
if err := theImagesForRestoring.resetHistoryIfNeeded(i, ui.GLContext()); err != nil {
|
if err := theImagesForRestoring.flushPixelsIfNeeded(i, ui.GLContext()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return i.impl.Fill(clr)
|
return i.impl.Fill(clr)
|
||||||
@ -163,7 +163,7 @@ func (i *Image) Fill(clr color.Color) error {
|
|||||||
//
|
//
|
||||||
// This function is concurrent-safe.
|
// This function is concurrent-safe.
|
||||||
func (i *Image) DrawImage(image *Image, options *DrawImageOptions) error {
|
func (i *Image) DrawImage(image *Image, options *DrawImageOptions) error {
|
||||||
if err := theImagesForRestoring.resetHistoryIfNeeded(i, ui.GLContext()); err != nil {
|
if err := theImagesForRestoring.flushPixelsIfNeeded(i, ui.GLContext()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return i.impl.DrawImage(image, options)
|
return i.impl.DrawImage(image, options)
|
||||||
@ -201,7 +201,7 @@ func (i *Image) At(x, y int) color.Color {
|
|||||||
//
|
//
|
||||||
// This function is concurrent-safe.
|
// This function is concurrent-safe.
|
||||||
func (i *Image) Dispose() error {
|
func (i *Image) Dispose() error {
|
||||||
if err := theImagesForRestoring.resetHistoryIfNeeded(i, ui.GLContext()); err != nil {
|
if err := theImagesForRestoring.flushPixelsIfNeeded(i, ui.GLContext()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if i.impl.isDisposed() {
|
if i.impl.isDisposed() {
|
||||||
@ -218,7 +218,7 @@ func (i *Image) Dispose() error {
|
|||||||
//
|
//
|
||||||
// This function is concurrent-safe.
|
// This function is concurrent-safe.
|
||||||
func (i *Image) ReplacePixels(p []uint8) error {
|
func (i *Image) ReplacePixels(p []uint8) error {
|
||||||
if err := theImagesForRestoring.resetHistoryIfNeeded(i, ui.GLContext()); err != nil {
|
if err := theImagesForRestoring.flushPixelsIfNeeded(i, ui.GLContext()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return i.impl.ReplacePixels(p)
|
return i.impl.ReplacePixels(p)
|
||||||
|
@ -199,13 +199,13 @@ func (i *imageImpl) At(x, y int, context *opengl.Context) color.Color {
|
|||||||
return clr
|
return clr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *imageImpl) resetHistoryIfNeeded(target *Image, context *opengl.Context) error {
|
func (i *imageImpl) flushPixelsIfNeeded(target *Image, context *opengl.Context) error {
|
||||||
i.m.Lock()
|
i.m.Lock()
|
||||||
defer i.m.Unlock()
|
defer i.m.Unlock()
|
||||||
if i.disposed {
|
if i.disposed {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err := i.pixels.resetHistoryIfNeeded(i.image, target, context); err != nil {
|
if err := i.pixels.flushIfNeeded(i.image, target, context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -91,7 +91,7 @@ func (p *pixels) hasHistoryWith(target *Image) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pixels) resetHistoryIfNeeded(image *graphics.Image, target *Image, context *opengl.Context) error {
|
func (p *pixels) flushIfNeeded(image *graphics.Image, target *Image, context *opengl.Context) error {
|
||||||
if p.drawImageHistory == nil {
|
if p.drawImageHistory == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user