graphicsdriver: Rename TexSubImage2D -> ReplacePixels

This commit is contained in:
Hajime Hoshi 2018-11-11 01:35:10 +09:00
parent 61ca48225c
commit 2f692d98c7
4 changed files with 10 additions and 11 deletions

View File

@ -237,11 +237,6 @@ func (c *drawImageCommand) Exec(indexOffsetInBytes int) error {
return err return err
} }
driver().DrawElements(c.nindices, indexOffsetInBytes) driver().DrawElements(c.nindices, indexOffsetInBytes)
// glFlush() might be necessary at least on MacBook Pro (a smilar problem at #419),
// but basically this pass the tests (esp. TestImageTooManyFill).
// As glFlush() causes performance problems, this should be avoided as much as possible.
// Let's wait and see, and file a new issue when this problem is newly found.
return nil return nil
} }
@ -298,10 +293,7 @@ func (c *replacePixelsCommand) String() string {
// Exec executes the replacePixelsCommand. // Exec executes the replacePixelsCommand.
func (c *replacePixelsCommand) Exec(indexOffsetInBytes int) error { func (c *replacePixelsCommand) Exec(indexOffsetInBytes int) error {
// glFlush is necessary on Android. c.dst.image.ReplacePixels(c.pixels, c.x, c.y, c.width, c.height)
// glTexSubImage2D didn't work without this hack at least on Nexus 5x and NuAns NEO [Reloaded] (#211).
driver().Flush()
c.dst.image.TexSubImage2D(c.pixels, c.x, c.y, c.width, c.height)
return nil return nil
} }

View File

@ -36,5 +36,5 @@ type Image interface {
Pixels() ([]byte, error) Pixels() ([]byte, error)
SetAsDestination() SetAsDestination()
SetAsSource() SetAsSource()
TexSubImage2D(p []byte, x, y, width, height int) ReplacePixels(pixels []byte, x, y, width, height int)
} }

View File

@ -77,6 +77,10 @@ func (d *Driver) UseProgram(mode graphics.CompositeMode, colorM *affine.ColorM,
func (d *Driver) DrawElements(len int, offsetInBytes int) { func (d *Driver) DrawElements(len int, offsetInBytes int) {
theContext.drawElements(len, offsetInBytes) theContext.drawElements(len, offsetInBytes)
// glFlush() might be necessary at least on MacBook Pro (a smilar problem at #419),
// but basically this pass the tests (esp. TestImageTooManyFill).
// As glFlush() causes performance problems, this should be avoided as much as possible.
// Let's wait and see, and file a new issue when this problem is newly found.
} }
func (d *Driver) Flush() { func (d *Driver) Flush() {

View File

@ -100,7 +100,10 @@ func (i *Image) ensureFramebuffer() error {
return nil return nil
} }
func (i *Image) TexSubImage2D(p []byte, x, y, width, height int) { func (i *Image) ReplacePixels(p []byte, x, y, width, height int) {
// glFlush is necessary on Android.
// glTexSubImage2D didn't work without this hack at least on Nexus 5x and NuAns NEO [Reloaded] (#211).
theContext.flush()
theContext.texSubImage2D(i.textureNative, p, x, y, width, height) theContext.texSubImage2D(i.textureNative, p, x, y, width, height)
} }