mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Remove imageM (global lock)
This commit is contained in:
parent
d70bf66a59
commit
2c1bcaf87a
@ -74,8 +74,6 @@ func (c *graphicsContext) SetSize(screenWidth, screenHeight int, screenScale flo
|
||||
}
|
||||
|
||||
func (c *graphicsContext) needsRestoring(context *opengl.Context) (bool, error) {
|
||||
imageM.Lock()
|
||||
defer imageM.Unlock()
|
||||
// FlushCommands is required because c.offscreen.impl might not have an actual texture.
|
||||
if err := graphics.FlushCommands(context); err != nil {
|
||||
return false, err
|
||||
@ -122,9 +120,6 @@ func (c *graphicsContext) drawToDefaultRenderTarget(context *opengl.Context) err
|
||||
if err := drawWithFittingScale(c.screen, c.offscreen2); err != nil {
|
||||
return err
|
||||
}
|
||||
// TODO: imageM is necessary to call graphics functions. Move this to graphics package.
|
||||
imageM.Lock()
|
||||
defer imageM.Unlock()
|
||||
if err := graphics.FlushCommands(context); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -164,8 +159,6 @@ func (c *graphicsContext) UpdateAndDraw(context *opengl.Context, updateCount int
|
||||
}
|
||||
|
||||
func (c *graphicsContext) restore(context *opengl.Context) error {
|
||||
imageM.Lock()
|
||||
defer imageM.Unlock()
|
||||
if err := graphics.Initialize(context); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -28,10 +28,6 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/internal/ui"
|
||||
)
|
||||
|
||||
var (
|
||||
imageM sync.Mutex
|
||||
)
|
||||
|
||||
type imageImpl struct {
|
||||
image *graphics.Image
|
||||
screen bool
|
||||
@ -99,8 +95,8 @@ func (i *imageImpl) At(x, y int) color.Color {
|
||||
if !loop.IsRunning() {
|
||||
panic("ebiten: At can't be called when the GL context is not initialized (this panic happens as of version 1.4.0-alpha)")
|
||||
}
|
||||
imageM.Lock()
|
||||
defer imageM.Unlock()
|
||||
i.m.Lock()
|
||||
defer i.m.Unlock()
|
||||
if i.isDisposed() {
|
||||
return color.Transparent
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user