graphics: Remove unused arguments

This commit is contained in:
Hajime Hoshi 2016-06-11 05:48:09 +09:00
parent f897c3958e
commit 912d498cdf
4 changed files with 14 additions and 16 deletions

View File

@ -84,6 +84,7 @@ func (c *graphicsContext) Update() error {
if err := c.defaultRenderTarget.DrawImage(c.screen, options); err != nil {
return err
}
graphics.FlushCommands(ui.GLContext())
// Call glFlush to prevent black flicking (especially on Android (#226)).
ui.GLContext().Flush()
return nil

View File

@ -199,10 +199,10 @@ type imageImpl struct {
texture *graphics.Texture
defaultFramebuffer bool
disposed bool
pixels []uint8
width int
height int
filter Filter
pixels []uint8
}
func (i *imageImpl) Fill(clr color.Color) error {
@ -213,7 +213,7 @@ func (i *imageImpl) Fill(clr color.Color) error {
return errors.New("ebiten: image is already disposed")
}
i.pixels = nil
return i.framebuffer.Fill(ui.GLContext(), clr)
return i.framebuffer.Fill(clr)
}
if theDelayedImageTasks.add(f) {
return nil
@ -261,7 +261,7 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error {
geom := &options.GeoM
colorm := &options.ColorM
mode := opengl.CompositeMode(options.CompositeMode)
if err := i.framebuffer.DrawTexture(ui.GLContext(), image.impl.texture, vertices[:16*n], geom, colorm, mode); err != nil {
if err := i.framebuffer.DrawTexture(image.impl.texture, vertices[:16*n], geom, colorm, mode); err != nil {
return err
}
return nil
@ -373,12 +373,12 @@ func (i *imageImpl) ReplacePixels(p []uint8) error {
f := func() error {
imageM.Lock()
defer imageM.Unlock()
// Don't set i.pixels here because i.pixels is used not every time.
// TODO: Copy p?
i.pixels = nil
if i.isDisposed() {
return errors.New("ebiten: image is already disposed")
}
return i.framebuffer.ReplacePixels(ui.GLContext(), i.texture, p)
return i.framebuffer.ReplacePixels(i.texture, p)
}
if theDelayedImageTasks.add(f) {
return nil
@ -427,7 +427,7 @@ func NewImage(width, height int, filter Filter) (*Image, error) {
image.framebuffer = framebuffer
image.texture = texture
runtime.SetFinalizer(image, (*imageImpl).Dispose)
if err := image.framebuffer.Fill(ui.GLContext(), color.Transparent); err != nil {
if err := image.framebuffer.Fill(color.Transparent); err != nil {
return err
}
return nil

View File

@ -66,6 +66,10 @@ func (q *commandQueue) Flush(context *opengl.Context) error {
return nil
}
func FlushCommands(context *opengl.Context) error {
return theCommandQueue.Flush(context)
}
type fillCommand struct {
dst *Framebuffer
color color.Color

View File

@ -96,7 +96,7 @@ func (f *Framebuffer) projectionMatrix() *[4][4]float64 {
return f.proMatrix
}
func (f *Framebuffer) Fill(context *opengl.Context, clr color.Color) error {
func (f *Framebuffer) Fill(clr color.Color) error {
c := &fillCommand{
dst: f,
color: clr,
@ -105,7 +105,7 @@ func (f *Framebuffer) Fill(context *opengl.Context, clr color.Color) error {
return nil
}
func (f *Framebuffer) DrawTexture(context *opengl.Context, t *Texture, vertices []int16, geo, clr Matrix, mode opengl.CompositeMode) error {
func (f *Framebuffer) DrawTexture(t *Texture, vertices []int16, geo, clr Matrix, mode opengl.CompositeMode) error {
c := &drawImageCommand{
dst: f,
src: t,
@ -115,13 +115,6 @@ func (f *Framebuffer) DrawTexture(context *opengl.Context, t *Texture, vertices
mode: mode,
}
theCommandQueue.Enqueue(c)
// Drawing a texture to the default buffer must be the last command.
// TODO(hajimehoshi): This seems a little hacky. Refactor.
if f.native == opengl.ZeroFramebuffer {
if err := theCommandQueue.Flush(context); err != nil {
return err
}
}
return nil
}
@ -133,7 +126,7 @@ func (f *Framebuffer) Pixels(context *opengl.Context) ([]uint8, error) {
return context.FramebufferPixels(f.native, f.width, f.height)
}
func (f *Framebuffer) ReplacePixels(context *opengl.Context, t *Texture, p []uint8) error {
func (f *Framebuffer) ReplacePixels(t *Texture, p []uint8) error {
c := &replacePixelsCommand{
dst: f,
texture: t,