From 3724815f217d349587545ceb01d94e6a6c936d01 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 27 Jul 2016 02:50:53 +0900 Subject: [PATCH] pixels: Rename functions --- imageimpl.go | 6 +++--- internal/pixels/pixels.go | 16 +++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/imageimpl.go b/imageimpl.go index 888ec1c6f..4a366ef61 100644 --- a/imageimpl.go +++ b/imageimpl.go @@ -194,7 +194,7 @@ func (i *imageImpl) ensurePixels(context *opengl.Context) error { if i.disposed { return nil } - if err := i.pixels.ResetIfStale(context); err != nil { + if err := i.pixels.ReadPixelsFromVRAMIfStale(context); err != nil { return err } return nil @@ -222,7 +222,7 @@ func (i *imageImpl) resetPixelsIfDependingOn(target *imageImpl, context *opengl. i.pixels.MakeStale() return nil } - if err := i.pixels.Reset(context); err != nil { + if err := i.pixels.ReadPixelsFromVRAM(context); err != nil { return err } return nil @@ -259,7 +259,7 @@ func (i *imageImpl) restore(context *opengl.Context) error { return nil } var err error - i.image, err = i.pixels.Restore(context, i.width, i.height, glFilter(i.filter)) + i.image, err = i.pixels.CreateImage(context, i.width, i.height, glFilter(i.filter)) if err != nil { return err } diff --git a/internal/pixels/pixels.go b/internal/pixels/pixels.go index b393c27f9..c3b3f1a57 100644 --- a/internal/pixels/pixels.go +++ b/internal/pixels/pixels.go @@ -96,10 +96,10 @@ func (p *Pixels) AppendDrawImageHistory(image *graphics.Image, vertices []int16, // At returns a color value at idx. // // Note that this must not be called until context is available. -// This means Pixels members must match with acutal state in GPU. +// This means Pixels members must match with acutal state in VRAM. func (p *Pixels) At(idx int, context *opengl.Context) (color.Color, error) { if p.basePixels == nil || p.drawImageHistory != nil || p.stale { - if err := p.Reset(context); err != nil { + if err := p.ReadPixelsFromVRAM(context); err != nil { return nil, err } } @@ -119,7 +119,7 @@ func (p *Pixels) DependsOn(target *graphics.Image) bool { return false } -func (p *Pixels) Reset(context *opengl.Context) error { +func (p *Pixels) ReadPixelsFromVRAM(context *opengl.Context) error { var err error p.basePixels, err = p.image.Pixels(context) if err != nil { @@ -131,11 +131,11 @@ func (p *Pixels) Reset(context *opengl.Context) error { return nil } -func (p *Pixels) ResetIfStale(context *opengl.Context) error { +func (p *Pixels) ReadPixelsFromVRAMIfStale(context *opengl.Context) error { if !p.stale { return nil } - return p.Reset(context) + return p.ReadPixelsFromVRAM(context) } func (p *Pixels) HasDependency() bool { @@ -145,10 +145,8 @@ func (p *Pixels) HasDependency() bool { return p.drawImageHistory != nil } -// Restore restores the pixels using its history. -// -// Restore is the only function that the pixel data is not present on GPU when this is called. -func (p *Pixels) Restore(context *opengl.Context, width, height int, filter opengl.Filter) (*graphics.Image, error) { +// CreateImage restores *graphics.Image from the pixels using its state. +func (p *Pixels) CreateImage(context *opengl.Context, width, height int, filter opengl.Filter) (*graphics.Image, error) { if p.stale { return nil, errors.New("pixels: pixels must not be stale when restoring") }