mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
pixels: Add comments
This commit is contained in:
parent
939284820c
commit
1ec503e1b5
@ -30,10 +30,15 @@ type drawImageHistoryItem struct {
|
|||||||
mode opengl.CompositeMode
|
mode opengl.CompositeMode
|
||||||
}
|
}
|
||||||
|
|
||||||
// basePixels and baseColor are exclusive.
|
// Pixels represents pixels of an image for restoring when GL context is lost.
|
||||||
|
//
|
||||||
|
// Until GL context is available,
|
||||||
|
// Pixels member states might not match with actual pixels in GPU so
|
||||||
|
// there is few function to retrieve the current state.
|
||||||
type Pixels struct {
|
type Pixels struct {
|
||||||
image *graphics.Image
|
image *graphics.Image
|
||||||
|
|
||||||
|
// basePixels and baseColor are exclusive.
|
||||||
basePixels []uint8
|
basePixels []uint8
|
||||||
baseColor color.Color
|
baseColor color.Color
|
||||||
drawImageHistory []*drawImageHistoryItem
|
drawImageHistory []*drawImageHistoryItem
|
||||||
@ -77,6 +82,10 @@ func (p *Pixels) AppendDrawImageHistory(image *graphics.Image, vertices []int16,
|
|||||||
p.drawImageHistory = append(p.drawImageHistory, item)
|
p.drawImageHistory = append(p.drawImageHistory, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
||||||
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 {
|
if p.basePixels == nil || p.drawImageHistory != nil {
|
||||||
var err error
|
var err error
|
||||||
@ -132,7 +141,7 @@ func (p *Pixels) HasHistory() bool {
|
|||||||
return p.drawImageHistory != nil
|
return p.drawImageHistory != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore restores the pixels using its history.
|
// 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.
|
// 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) {
|
func (p *Pixels) Restore(context *opengl.Context, width, height int, filter opengl.Filter) (*graphics.Image, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user