graphics: Move theDelayedImageTasks.exec() to newImageWithZeroFramebuffer

This commit is contained in:
Hajime Hoshi 2016-05-18 22:45:15 +09:00
parent 71a508ca7b
commit dbd6ed8139
2 changed files with 12 additions and 8 deletions

View File

@ -25,7 +25,6 @@ type graphicsContext struct {
screen *Image
defaultRenderTarget *Image
screenScale int
initialized bool
}
func (c *graphicsContext) SetSize(screenWidth, screenHeight, screenScale int) error {
@ -46,13 +45,6 @@ func (c *graphicsContext) SetSize(screenWidth, screenHeight, screenScale int) er
c.defaultRenderTarget.Clear()
c.screen = screen
c.screenScale = screenScale
// TODO: This code is a little hacky. Refactor this.
if !c.initialized {
if err := theDelayedImageTasks.exec(); err != nil {
return err
}
c.initialized = true
}
return nil
}

View File

@ -557,6 +557,18 @@ func NewImageFromImage(source image.Image, filter Filter) (*Image, error) {
}
func newImageWithZeroFramebuffer(width, height int) (*Image, error) {
img, err := newImageWithZeroFramebufferImpl(width, height)
if err != nil {
return nil, err
}
// When this is called, OpenGL context should exist.
if err := theDelayedImageTasks.exec(); err != nil {
return nil, err
}
return img, nil
}
func newImageWithZeroFramebufferImpl(width, height int) (*Image, error) {
imageM.Lock()
defer imageM.Unlock()
f, err := graphics.NewZeroFramebuffer(ui.GLContext(), width, height)