mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 17:32:02 +01:00
internal/buffered: refactoring
This commit is contained in:
parent
3cbc1870bf
commit
cef272f638
@ -210,11 +210,7 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
|
|||||||
// syncPixelsIfNeeded syncs the pixels between CPU and GPU.
|
// syncPixelsIfNeeded syncs the pixels between CPU and GPU.
|
||||||
// After syncPixelsIfNeeded, dotsBuffer is cleared, but pixels migth remain.
|
// After syncPixelsIfNeeded, dotsBuffer is cleared, but pixels migth remain.
|
||||||
func (i *Image) syncPixelsIfNeeded() {
|
func (i *Image) syncPixelsIfNeeded() {
|
||||||
if len(i.dotsBuffer) == 0 && !i.pixelsUnsynced {
|
if i.pixelsUnsynced {
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if i.pixels != nil {
|
|
||||||
// If this image already has pixels, use WritePixels instead of DrawTriangles for efficiency.
|
// If this image already has pixels, use WritePixels instead of DrawTriangles for efficiency.
|
||||||
for pos, clr := range i.dotsBuffer {
|
for pos, clr := range i.dotsBuffer {
|
||||||
idx := 4 * (pos.Y*i.width + pos.X)
|
idx := 4 * (pos.Y*i.width + pos.X)
|
||||||
@ -229,12 +225,8 @@ func (i *Image) syncPixelsIfNeeded() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if i.pixelsUnsynced {
|
|
||||||
panic("buffered: pixelsUnsynced must be false as pixels is nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(i.dotsBuffer) == 0 {
|
if len(i.dotsBuffer) == 0 {
|
||||||
panic("buffered: len(i.dotsBuffers) must be > 0 at this point")
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := len(i.dotsBuffer)
|
l := len(i.dotsBuffer)
|
||||||
|
Loading…
Reference in New Issue
Block a user