mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +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) {
|
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.
|
// FlushCommands is required because c.offscreen.impl might not have an actual texture.
|
||||||
if err := graphics.FlushCommands(context); err != nil {
|
if err := graphics.FlushCommands(context); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -122,9 +120,6 @@ func (c *graphicsContext) drawToDefaultRenderTarget(context *opengl.Context) err
|
|||||||
if err := drawWithFittingScale(c.screen, c.offscreen2); err != nil {
|
if err := drawWithFittingScale(c.screen, c.offscreen2); err != nil {
|
||||||
return err
|
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 {
|
if err := graphics.FlushCommands(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -164,8 +159,6 @@ func (c *graphicsContext) UpdateAndDraw(context *opengl.Context, updateCount int
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *graphicsContext) restore(context *opengl.Context) error {
|
func (c *graphicsContext) restore(context *opengl.Context) error {
|
||||||
imageM.Lock()
|
|
||||||
defer imageM.Unlock()
|
|
||||||
if err := graphics.Initialize(context); err != nil {
|
if err := graphics.Initialize(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,6 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/internal/ui"
|
"github.com/hajimehoshi/ebiten/internal/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
imageM sync.Mutex
|
|
||||||
)
|
|
||||||
|
|
||||||
type imageImpl struct {
|
type imageImpl struct {
|
||||||
image *graphics.Image
|
image *graphics.Image
|
||||||
screen bool
|
screen bool
|
||||||
@ -99,8 +95,8 @@ func (i *imageImpl) At(x, y int) color.Color {
|
|||||||
if !loop.IsRunning() {
|
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)")
|
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()
|
i.m.Lock()
|
||||||
defer imageM.Unlock()
|
defer i.m.Unlock()
|
||||||
if i.isDisposed() {
|
if i.isDisposed() {
|
||||||
return color.Transparent
|
return color.Transparent
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user