graphicsdriver: Adjust API

This commit is contained in:
Hajime Hoshi 2018-11-11 23:57:23 +09:00
parent 907a28c434
commit cc2174bd69
3 changed files with 6 additions and 5 deletions

View File

@ -433,8 +433,9 @@ func (c *newScreenFramebufferImageCommand) String() string {
// Exec executes a newScreenFramebufferImageCommand. // Exec executes a newScreenFramebufferImageCommand.
func (c *newScreenFramebufferImageCommand) Exec(indexOffset int) error { func (c *newScreenFramebufferImageCommand) Exec(indexOffset int) error {
c.result.image = driver().NewScreenFramebufferImage(c.width, c.height) var err error
return nil c.result.image, err = driver().NewScreenFramebufferImage(c.width, c.height)
return err
} }
func (c *newScreenFramebufferImageCommand) NumVertices() int { func (c *newScreenFramebufferImageCommand) NumVertices() int {

View File

@ -24,7 +24,7 @@ type GraphicsDriver interface {
Flush() Flush()
MaxImageSize() int MaxImageSize() int
NewImage(width, height int) (Image, error) NewImage(width, height int) (Image, error)
NewScreenFramebufferImage(width, height int) Image NewScreenFramebufferImage(width, height int) (Image, error)
Reset() error Reset() error
Draw(indexLen int, indexOffset int, mode graphics.CompositeMode, colorM *affine.ColorM, filter graphics.Filter) error Draw(indexLen int, indexOffset int, mode graphics.CompositeMode, colorM *affine.ColorM, filter graphics.Filter) error
} }

View File

@ -67,7 +67,7 @@ func (d *Driver) NewImage(width, height int) (graphicsdriver.Image, error) {
return i, nil return i, nil
} }
func (d *Driver) NewScreenFramebufferImage(width, height int) graphicsdriver.Image { func (d *Driver) NewScreenFramebufferImage(width, height int) (graphicsdriver.Image, error) {
d.checkSize(width, height) d.checkSize(width, height)
i := &Image{ i := &Image{
driver: d, driver: d,
@ -78,7 +78,7 @@ func (d *Driver) NewScreenFramebufferImage(width, height int) graphicsdriver.Ima
// On browsers, c.width and c.height are used as viewport size and // On browsers, c.width and c.height are used as viewport size and
// Edge can't treat a bigger viewport than the drawing area (#71). // Edge can't treat a bigger viewport than the drawing area (#71).
i.framebuffer = newScreenFramebuffer(&d.context, width, height) i.framebuffer = newScreenFramebuffer(&d.context, width, height)
return i return i, nil
} }
// Reset resets or initializes the current OpenGL state. // Reset resets or initializes the current OpenGL state.