From c0eb01d69e2a2b53c904914b6db65397d6ef5a09 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 25 Jul 2016 09:10:51 +0900 Subject: [PATCH] pixels: Rename s/flush/reset/ --- graphicscontext.go | 2 +- image.go | 18 +++++++++--------- imageimpl.go | 8 ++++---- internal/pixels/pixels.go | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/graphicscontext.go b/graphicscontext.go index a50c7edc6..f5871f857 100644 --- a/graphicscontext.go +++ b/graphicscontext.go @@ -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) diff --git a/image.go b/image.go index 01fe56c51..aeeda340d 100644 --- a/image.go +++ b/image.go @@ -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) diff --git a/imageimpl.go b/imageimpl.go index bf94bd0ef..9c041ee09 100644 --- a/imageimpl.go +++ b/imageimpl.go @@ -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 diff --git a/internal/pixels/pixels.go b/internal/pixels/pixels.go index 6e5e1c974..2221c19c5 100644 --- a/internal/pixels/pixels.go +++ b/internal/pixels/pixels.go @@ -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 }