graphics: Remove imageM (global lock)

This commit is contained in:
Hajime Hoshi 2016-07-03 23:31:03 +09:00
parent d70bf66a59
commit 2c1bcaf87a
2 changed files with 2 additions and 13 deletions

View File

@ -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
}

View File

@ -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
}