mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
graphics: Rename pixelsToSet -> pendingPixels
This commit is contained in:
parent
de64f3519d
commit
61156dd90e
1
go.sum
1
go.sum
@ -15,6 +15,7 @@ github.com/hajimehoshi/bitmapfont v1.1.1 h1:H1wQ6QXA8kSp+plARsIMCTVb5iOZHq/OP3uy
|
|||||||
github.com/hajimehoshi/bitmapfont v1.1.1/go.mod h1:Hamfxgney7tDSmVOSDh2AWzoDH70OaC+P24zc02Gum4=
|
github.com/hajimehoshi/bitmapfont v1.1.1/go.mod h1:Hamfxgney7tDSmVOSDh2AWzoDH70OaC+P24zc02Gum4=
|
||||||
github.com/hajimehoshi/go-mp3 v0.1.2 h1:mYwauvxfzffmge65glPtAyg0NWPftb8UmU+DPuxV2/s=
|
github.com/hajimehoshi/go-mp3 v0.1.2 h1:mYwauvxfzffmge65glPtAyg0NWPftb8UmU+DPuxV2/s=
|
||||||
github.com/hajimehoshi/go-mp3 v0.1.2/go.mod h1:4i+c5pDNKDrxl1iu9iG90/+fhP37lio6gNhjCx9WBJw=
|
github.com/hajimehoshi/go-mp3 v0.1.2/go.mod h1:4i+c5pDNKDrxl1iu9iG90/+fhP37lio6gNhjCx9WBJw=
|
||||||
|
github.com/hajimehoshi/go-mp3 v0.2.0 h1:isy34iDg+96PsNuFbTdRRXzKr6a1gc2nhsPuFSfXacY=
|
||||||
github.com/hajimehoshi/go-mp3 v0.2.0/go.mod h1:4i+c5pDNKDrxl1iu9iG90/+fhP37lio6gNhjCx9WBJw=
|
github.com/hajimehoshi/go-mp3 v0.2.0/go.mod h1:4i+c5pDNKDrxl1iu9iG90/+fhP37lio6gNhjCx9WBJw=
|
||||||
github.com/hajimehoshi/oto v0.1.1/go.mod h1:hUiLWeBQnbDu4pZsAhOnGqMI1ZGibS6e2qhQdfpwz04=
|
github.com/hajimehoshi/oto v0.1.1/go.mod h1:hUiLWeBQnbDu4pZsAhOnGqMI1ZGibS6e2qhQdfpwz04=
|
||||||
github.com/hajimehoshi/oto v0.3.3 h1:Wi7VVtxe9sF2rbDBIJtVXnpFWhRfK57hw0JY7tR2qXM=
|
github.com/hajimehoshi/oto v0.3.3 h1:Wi7VVtxe9sF2rbDBIJtVXnpFWhRfK57hw0JY7tR2qXM=
|
||||||
|
42
image.go
42
image.go
@ -131,7 +131,7 @@ type Image struct {
|
|||||||
bounds image.Rectangle
|
bounds image.Rectangle
|
||||||
original *Image
|
original *Image
|
||||||
|
|
||||||
pixelsToSet []byte
|
pendingPixels []byte
|
||||||
|
|
||||||
filter Filter
|
filter Filter
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ func (i *Image) Fill(clr color.Color) error {
|
|||||||
panic("ebiten: render to a subimage is not implemented (Fill)")
|
panic("ebiten: render to a subimage is not implemented (Fill)")
|
||||||
}
|
}
|
||||||
|
|
||||||
i.resolvePixelsToSet(false)
|
i.resolvePendingPixels(false)
|
||||||
|
|
||||||
r16, g16, b16, a16 := clr.RGBA()
|
r16, g16, b16, a16 := clr.RGBA()
|
||||||
r, g, b, a := uint8(r16>>8), uint8(g16>>8), uint8(b16>>8), uint8(a16>>8)
|
r, g, b, a := uint8(r16>>8), uint8(g16>>8), uint8(b16>>8), uint8(a16>>8)
|
||||||
@ -254,8 +254,8 @@ func (i *Image) drawImage(img *Image, options *DrawImageOptions) {
|
|||||||
panic("ebiten: render to a subimage is not implemented (drawImage)")
|
panic("ebiten: render to a subimage is not implemented (drawImage)")
|
||||||
}
|
}
|
||||||
|
|
||||||
img.resolvePixelsToSet(true)
|
img.resolvePendingPixels(true)
|
||||||
i.resolvePixelsToSet(true)
|
i.resolvePendingPixels(true)
|
||||||
|
|
||||||
// Calculate vertices before locking because the user can do anything in
|
// Calculate vertices before locking because the user can do anything in
|
||||||
// options.ImageParts interface without deadlock (e.g. Call Image functions).
|
// options.ImageParts interface without deadlock (e.g. Call Image functions).
|
||||||
@ -454,8 +454,8 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o
|
|||||||
panic("ebiten: render to a subimage is not implemented (DrawTriangles)")
|
panic("ebiten: render to a subimage is not implemented (DrawTriangles)")
|
||||||
}
|
}
|
||||||
|
|
||||||
img.resolvePixelsToSet(true)
|
img.resolvePendingPixels(true)
|
||||||
i.resolvePixelsToSet(true)
|
i.resolvePendingPixels(true)
|
||||||
|
|
||||||
if len(indices)%3 != 0 {
|
if len(indices)%3 != 0 {
|
||||||
panic("ebiten: len(indices) % 3 must be 0")
|
panic("ebiten: len(indices) % 3 must be 0")
|
||||||
@ -562,7 +562,7 @@ func (i *Image) At(x, y int) color.Color {
|
|||||||
if i.isSubImage() && !image.Pt(x, y).In(i.bounds) {
|
if i.isSubImage() && !image.Pt(x, y).In(i.bounds) {
|
||||||
return color.RGBA{}
|
return color.RGBA{}
|
||||||
}
|
}
|
||||||
i.resolvePixelsToSet(true)
|
i.resolvePendingPixels(true)
|
||||||
r, g, b, a := i.mipmap.original().At(x, y)
|
r, g, b, a := i.mipmap.original().At(x, y)
|
||||||
return color.RGBA{r, g, b, a}
|
return color.RGBA{r, g, b, a}
|
||||||
}
|
}
|
||||||
@ -591,7 +591,7 @@ func (img *Image) Set(x, y int, clr color.Color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w, h := img.Size()
|
w, h := img.Size()
|
||||||
if img.pixelsToSet == nil {
|
if img.pendingPixels == nil {
|
||||||
pix := make([]byte, 4*w*h)
|
pix := make([]byte, 4*w*h)
|
||||||
idx := 0
|
idx := 0
|
||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
@ -604,32 +604,32 @@ func (img *Image) Set(x, y int, clr color.Color) {
|
|||||||
idx++
|
idx++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
img.pixelsToSet = pix
|
img.pendingPixels = pix
|
||||||
}
|
}
|
||||||
r, g, b, a := clr.RGBA()
|
r, g, b, a := clr.RGBA()
|
||||||
img.pixelsToSet[4*(x+y*w)] = byte(r >> 8)
|
img.pendingPixels[4*(x+y*w)] = byte(r >> 8)
|
||||||
img.pixelsToSet[4*(x+y*w)+1] = byte(g >> 8)
|
img.pendingPixels[4*(x+y*w)+1] = byte(g >> 8)
|
||||||
img.pixelsToSet[4*(x+y*w)+2] = byte(b >> 8)
|
img.pendingPixels[4*(x+y*w)+2] = byte(b >> 8)
|
||||||
img.pixelsToSet[4*(x+y*w)+3] = byte(a >> 8)
|
img.pendingPixels[4*(x+y*w)+3] = byte(a >> 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) resolvePixelsToSet(draw bool) {
|
func (i *Image) resolvePendingPixels(draw bool) {
|
||||||
if i.isSubImage() {
|
if i.isSubImage() {
|
||||||
i.original.resolvePixelsToSet(draw)
|
i.original.resolvePendingPixels(draw)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if i.pixelsToSet == nil {
|
if i.pendingPixels == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !draw {
|
if !draw {
|
||||||
i.pixelsToSet = nil
|
i.pendingPixels = nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
i.ReplacePixels(i.pixelsToSet)
|
i.ReplacePixels(i.pendingPixels)
|
||||||
i.pixelsToSet = nil
|
i.pendingPixels = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispose disposes the image data. After disposing, most of image functions do nothing and returns meaningless values.
|
// Dispose disposes the image data. After disposing, most of image functions do nothing and returns meaningless values.
|
||||||
@ -648,7 +648,7 @@ func (i *Image) Dispose() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
i.mipmap.dispose()
|
i.mipmap.dispose()
|
||||||
i.resolvePixelsToSet(false)
|
i.resolvePendingPixels(false)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -672,7 +672,7 @@ func (i *Image) ReplacePixels(p []byte) error {
|
|||||||
if i.isSubImage() {
|
if i.isSubImage() {
|
||||||
panic("ebiten: render to a subimage is not implemented (ReplacePixels)")
|
panic("ebiten: render to a subimage is not implemented (ReplacePixels)")
|
||||||
}
|
}
|
||||||
i.resolvePixelsToSet(false)
|
i.resolvePendingPixels(false)
|
||||||
s := i.Bounds().Size()
|
s := i.Bounds().Size()
|
||||||
if l := 4 * s.X * s.Y; len(p) != l {
|
if l := 4 * s.X * s.Y; len(p) != l {
|
||||||
panic(fmt.Sprintf("ebiten: len(p) was %d but must be %d", len(p), l))
|
panic(fmt.Sprintf("ebiten: len(p) was %d but must be %d", len(p), l))
|
||||||
|
@ -112,7 +112,7 @@ func (c *uiContext) Update(afterFrameUpdate func()) error {
|
|||||||
// Before clearing the screen, the offscreen's pixels must be resolved.
|
// Before clearing the screen, the offscreen's pixels must be resolved.
|
||||||
// After clearing the screen, resolving doesn't work. This is very hacky
|
// After clearing the screen, resolving doesn't work. This is very hacky
|
||||||
// but we could not find other way so far (#792).
|
// but we could not find other way so far (#792).
|
||||||
c.offscreen.resolvePixelsToSet(true)
|
c.offscreen.resolvePendingPixels(true)
|
||||||
|
|
||||||
// This clear is needed for fullscreen mode or some mobile platforms (#622).
|
// This clear is needed for fullscreen mode or some mobile platforms (#622).
|
||||||
c.screen.Clear()
|
c.screen.Clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user