mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
graphics: Refactoring: Remove (*sharedImagePart).image()
This commit is contained in:
parent
afda41a5ed
commit
26f4999ddd
6
image.go
6
image.go
@ -246,7 +246,7 @@ func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error {
|
||||
filter = graphics.Filter(img.filter)
|
||||
}
|
||||
|
||||
i.sharedImagePart.image().DrawImage(img.sharedImagePart.image(), sx0, sy0, sx1, sy1, geom, options.ColorM.impl, mode, filter)
|
||||
i.sharedImagePart.DrawImage(img.sharedImagePart, sx0, sy0, sx1, sy1, geom, options.ColorM.impl, mode, filter)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ func (i *Image) At(x, y int) color.Color {
|
||||
if x < 0 || y < 0 || x >= w || y >= h {
|
||||
return color.RGBA{}
|
||||
}
|
||||
clr, err := i.sharedImagePart.image().At(x+ox, y+oy)
|
||||
clr, err := i.sharedImagePart.At(x+ox, y+oy)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -321,7 +321,7 @@ func (i *Image) ReplacePixels(p []byte) error {
|
||||
if l := 4 * w * h; len(p) != l {
|
||||
panic(fmt.Sprintf("ebiten: len(p) was %d but must be %d", len(p), l))
|
||||
}
|
||||
i.sharedImagePart.image().ReplacePixels(p, x, y, w, h)
|
||||
i.sharedImagePart.ReplacePixels(p, x, y, w, h)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
19
shared.go
19
shared.go
@ -15,6 +15,9 @@
|
||||
package ebiten
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||
"github.com/hajimehoshi/ebiten/internal/packing"
|
||||
@ -53,10 +56,6 @@ func (s *sharedImagePart) ensureNotShared() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *sharedImagePart) image() *restorable.Image {
|
||||
return s.sharedImage.restorable
|
||||
}
|
||||
|
||||
func (s *sharedImagePart) region() (x, y, width, height int) {
|
||||
if s.node == nil {
|
||||
w, h := s.sharedImage.restorable.Size()
|
||||
@ -65,6 +64,18 @@ func (s *sharedImagePart) region() (x, y, width, height int) {
|
||||
return s.node.Region()
|
||||
}
|
||||
|
||||
func (s *sharedImagePart) DrawImage(img *sharedImagePart, sx0, sy0, sx1, sy1 int, geom *affine.GeoM, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) {
|
||||
s.sharedImage.restorable.DrawImage(img.sharedImage.restorable, sx0, sy0, sx1, sy1, geom, colorm, mode, filter)
|
||||
}
|
||||
|
||||
func (s *sharedImagePart) ReplacePixels(pixels []byte, x, y, width, height int) {
|
||||
s.sharedImage.restorable.ReplacePixels(pixels, x, y, width, height)
|
||||
}
|
||||
|
||||
func (s *sharedImagePart) At(x, y int) (color.Color, error) {
|
||||
return s.sharedImage.restorable.At(x, y)
|
||||
}
|
||||
|
||||
func (s *sharedImagePart) isDisposed() bool {
|
||||
return s.sharedImage == nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user