From cc2174bd698b08f3c5071d8785b18fb2654372a6 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 11 Nov 2018 23:57:23 +0900 Subject: [PATCH] graphicsdriver: Adjust API --- internal/graphicscommand/command.go | 5 +++-- internal/graphicsdriver/graphicsdriver.go | 2 +- internal/graphicsdriver/opengl/driver.go | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index aeaa975d5..697e59624 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -433,8 +433,9 @@ func (c *newScreenFramebufferImageCommand) String() string { // Exec executes a newScreenFramebufferImageCommand. func (c *newScreenFramebufferImageCommand) Exec(indexOffset int) error { - c.result.image = driver().NewScreenFramebufferImage(c.width, c.height) - return nil + var err error + c.result.image, err = driver().NewScreenFramebufferImage(c.width, c.height) + return err } func (c *newScreenFramebufferImageCommand) NumVertices() int { diff --git a/internal/graphicsdriver/graphicsdriver.go b/internal/graphicsdriver/graphicsdriver.go index d537c0f59..4d406e57b 100644 --- a/internal/graphicsdriver/graphicsdriver.go +++ b/internal/graphicsdriver/graphicsdriver.go @@ -24,7 +24,7 @@ type GraphicsDriver interface { Flush() MaxImageSize() int NewImage(width, height int) (Image, error) - NewScreenFramebufferImage(width, height int) Image + NewScreenFramebufferImage(width, height int) (Image, error) Reset() error Draw(indexLen int, indexOffset int, mode graphics.CompositeMode, colorM *affine.ColorM, filter graphics.Filter) error } diff --git a/internal/graphicsdriver/opengl/driver.go b/internal/graphicsdriver/opengl/driver.go index a58c640fc..dbb6e3a33 100644 --- a/internal/graphicsdriver/opengl/driver.go +++ b/internal/graphicsdriver/opengl/driver.go @@ -67,7 +67,7 @@ func (d *Driver) NewImage(width, height int) (graphicsdriver.Image, error) { 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) i := &Image{ 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 // Edge can't treat a bigger viewport than the drawing area (#71). i.framebuffer = newScreenFramebuffer(&d.context, width, height) - return i + return i, nil } // Reset resets or initializes the current OpenGL state.