mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
shareable: Use defer for tests
This commit is contained in:
parent
24e20306f2
commit
8ff79c970a
@ -112,8 +112,8 @@ func (s *Image) region() (x, y, width, height int) {
|
|||||||
|
|
||||||
func (s *Image) Size() (width, height int) {
|
func (s *Image) Size() (width, height int) {
|
||||||
backendsM.Lock()
|
backendsM.Lock()
|
||||||
|
defer backendsM.Unlock()
|
||||||
_, _, w, h := s.region()
|
_, _, w, h := s.region()
|
||||||
backendsM.Unlock()
|
|
||||||
return w, h
|
return w, h
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,15 +149,14 @@ func (s *Image) ReplacePixels(p []byte) {
|
|||||||
|
|
||||||
func (s *Image) At(x, y int) (color.Color, error) {
|
func (s *Image) At(x, y int) (color.Color, error) {
|
||||||
backendsM.Lock()
|
backendsM.Lock()
|
||||||
|
defer backendsM.Unlock()
|
||||||
|
|
||||||
ox, oy, w, h := s.region()
|
ox, oy, w, h := s.region()
|
||||||
if x < 0 || y < 0 || x >= w || y >= h {
|
if x < 0 || y < 0 || x >= w || y >= h {
|
||||||
backendsM.Unlock()
|
|
||||||
return color.RGBA{}, nil
|
return color.RGBA{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
clr, err := s.backend.restorable.At(x+ox, y+oy)
|
clr, err := s.backend.restorable.At(x+ox, y+oy)
|
||||||
backendsM.Unlock()
|
|
||||||
return clr, err
|
return clr, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,8 +206,8 @@ func (s *Image) dispose() {
|
|||||||
|
|
||||||
func (s *Image) IsInvalidated() (bool, error) {
|
func (s *Image) IsInvalidated() (bool, error) {
|
||||||
backendsM.Lock()
|
backendsM.Lock()
|
||||||
|
defer backendsM.Unlock()
|
||||||
v, err := s.backend.restorable.IsInvalidated()
|
v, err := s.backend.restorable.IsInvalidated()
|
||||||
backendsM.Unlock()
|
|
||||||
return v, err
|
return v, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user