pixels: Rename s/flush/reset/

This commit is contained in:
Hajime Hoshi 2016-07-25 09:10:51 +09:00
parent 95dae4ad45
commit c0eb01d69e
4 changed files with 16 additions and 16 deletions

View File

@ -95,7 +95,7 @@ func (c *graphicsContext) initializeIfNeeded(context *opengl.Context) error {
if err := graphics.Reset(context); err != nil {
return err
}
if err := theImagesForRestoring.flushPixels(context); err != nil {
if err := theImagesForRestoring.resetPixels(context); err != nil {
return err
}
atomic.StoreInt32(&c.initialized, 1)

View File

@ -63,22 +63,22 @@ func (i *images) remove(img *Image) {
runtime.SetFinalizer(img, nil)
}
func (i *images) flushPixels(context *opengl.Context) error {
func (i *images) resetPixels(context *opengl.Context) error {
i.m.Lock()
defer i.m.Unlock()
for img := range i.images {
if err := img.flushPixels(context); err != nil {
if err := img.resetPixels(context); err != nil {
return err
}
}
return nil
}
func (i *images) flushPixelsIfNeeded(target *Image, context *opengl.Context) error {
func (i *images) resetPixelsIfNeeded(target *Image, context *opengl.Context) error {
i.m.Lock()
defer i.m.Unlock()
for img := range i.images {
if err := img.flushPixelsIfNeeded(target.impl, context); err != nil {
if err := img.resetPixelsIfNeeded(target.impl, context); err != nil {
return err
}
}
@ -152,7 +152,7 @@ func (i *Image) Size() (width, height int) {
//
// This function is concurrent-safe.
func (i *Image) Clear() error {
if err := theImagesForRestoring.flushPixelsIfNeeded(i, glContext()); err != nil {
if err := theImagesForRestoring.resetPixelsIfNeeded(i, glContext()); err != nil {
return err
}
return i.impl.Fill(color.Transparent)
@ -162,7 +162,7 @@ func (i *Image) Clear() error {
//
// This function is concurrent-safe.
func (i *Image) Fill(clr color.Color) error {
if err := theImagesForRestoring.flushPixelsIfNeeded(i, glContext()); err != nil {
if err := theImagesForRestoring.resetPixelsIfNeeded(i, glContext()); err != nil {
return err
}
return i.impl.Fill(clr)
@ -185,7 +185,7 @@ func (i *Image) Fill(clr color.Color) error {
//
// This function is concurrent-safe.
func (i *Image) DrawImage(image *Image, options *DrawImageOptions) error {
if err := theImagesForRestoring.flushPixelsIfNeeded(i, glContext()); err != nil {
if err := theImagesForRestoring.resetPixelsIfNeeded(i, glContext()); err != nil {
return err
}
return i.impl.DrawImage(image, options)
@ -223,7 +223,7 @@ func (i *Image) At(x, y int) color.Color {
//
// This function is concurrent-safe.
func (i *Image) Dispose() error {
if err := theImagesForRestoring.flushPixelsIfNeeded(i, glContext()); err != nil {
if err := theImagesForRestoring.resetPixelsIfNeeded(i, glContext()); err != nil {
return err
}
if i.impl.isDisposed() {
@ -240,7 +240,7 @@ func (i *Image) Dispose() error {
//
// This function is concurrent-safe.
func (i *Image) ReplacePixels(p []uint8) error {
if err := theImagesForRestoring.flushPixelsIfNeeded(i, glContext()); err != nil {
if err := theImagesForRestoring.resetPixelsIfNeeded(i, glContext()); err != nil {
return err
}
return i.impl.ReplacePixels(p)

View File

@ -196,19 +196,19 @@ func (i *imageImpl) At(x, y int, context *opengl.Context) color.Color {
return clr
}
func (i *imageImpl) flushPixels(context *opengl.Context) error {
func (i *imageImpl) resetPixels(context *opengl.Context) error {
i.m.Lock()
defer i.m.Unlock()
if i.disposed {
return nil
}
if err := i.pixels.Flush(context); err != nil {
if err := i.pixels.Reset(context); err != nil {
return err
}
return nil
}
func (i *imageImpl) flushPixelsIfNeeded(target *imageImpl, context *opengl.Context) error {
func (i *imageImpl) resetPixelsIfNeeded(target *imageImpl, context *opengl.Context) error {
i.m.Lock()
defer i.m.Unlock()
if i == target {
@ -225,7 +225,7 @@ func (i *imageImpl) flushPixelsIfNeeded(target *imageImpl, context *opengl.Conte
// In this case, pixels is inconsistent with the image.
return nil
}
if err := i.pixels.FlushIfNeeded(target.image, context); err != nil {
if err := i.pixels.ResetIfNeeded(target.image, context); err != nil {
return err
}
return nil

View File

@ -104,7 +104,7 @@ func (p *Pixels) hasHistoryWith(target *graphics.Image) bool {
return false
}
func (p *Pixels) Flush(context *opengl.Context) error {
func (p *Pixels) Reset(context *opengl.Context) error {
var err error
p.basePixels, err = p.image.Pixels(context)
if err != nil {
@ -115,7 +115,7 @@ func (p *Pixels) Flush(context *opengl.Context) error {
return nil
}
func (p *Pixels) FlushIfNeeded(target *graphics.Image, context *opengl.Context) error {
func (p *Pixels) ResetIfNeeded(target *graphics.Image, context *opengl.Context) error {
if p.drawImageHistory == nil {
return nil
}