mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
pixels: Rename functions
This commit is contained in:
parent
459046f52a
commit
3724815f21
@ -194,7 +194,7 @@ func (i *imageImpl) ensurePixels(context *opengl.Context) error {
|
|||||||
if i.disposed {
|
if i.disposed {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err := i.pixels.ResetIfStale(context); err != nil {
|
if err := i.pixels.ReadPixelsFromVRAMIfStale(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -222,7 +222,7 @@ func (i *imageImpl) resetPixelsIfDependingOn(target *imageImpl, context *opengl.
|
|||||||
i.pixels.MakeStale()
|
i.pixels.MakeStale()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err := i.pixels.Reset(context); err != nil {
|
if err := i.pixels.ReadPixelsFromVRAM(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -259,7 +259,7 @@ func (i *imageImpl) restore(context *opengl.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var err error
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -96,10 +96,10 @@ func (p *Pixels) AppendDrawImageHistory(image *graphics.Image, vertices []int16,
|
|||||||
// At returns a color value at idx.
|
// At returns a color value at idx.
|
||||||
//
|
//
|
||||||
// Note that this must not be called until context is available.
|
// 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) {
|
func (p *Pixels) At(idx int, context *opengl.Context) (color.Color, error) {
|
||||||
if p.basePixels == nil || p.drawImageHistory != nil || p.stale {
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ func (p *Pixels) DependsOn(target *graphics.Image) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pixels) Reset(context *opengl.Context) error {
|
func (p *Pixels) ReadPixelsFromVRAM(context *opengl.Context) error {
|
||||||
var err error
|
var err error
|
||||||
p.basePixels, err = p.image.Pixels(context)
|
p.basePixels, err = p.image.Pixels(context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -131,11 +131,11 @@ func (p *Pixels) Reset(context *opengl.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pixels) ResetIfStale(context *opengl.Context) error {
|
func (p *Pixels) ReadPixelsFromVRAMIfStale(context *opengl.Context) error {
|
||||||
if !p.stale {
|
if !p.stale {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return p.Reset(context)
|
return p.ReadPixelsFromVRAM(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pixels) HasDependency() bool {
|
func (p *Pixels) HasDependency() bool {
|
||||||
@ -145,10 +145,8 @@ func (p *Pixels) HasDependency() bool {
|
|||||||
return p.drawImageHistory != nil
|
return p.drawImageHistory != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore restores the pixels using its history.
|
// 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) {
|
||||||
// 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) {
|
|
||||||
if p.stale {
|
if p.stale {
|
||||||
return nil, errors.New("pixels: pixels must not be stale when restoring")
|
return nil, errors.New("pixels: pixels must not be stale when restoring")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user