mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
ebiten: Rename DrawTriaglesWithShaderOptions.Textures to Images
This commit is contained in:
parent
ab95c9014d
commit
7f70797a6d
@ -130,7 +130,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
|||||||
[]float32{float32(cx), float32(cy)}, // Cursor
|
[]float32{float32(cx), float32(cy)}, // Cursor
|
||||||
}
|
}
|
||||||
if g.idx != 0 {
|
if g.idx != 0 {
|
||||||
op.Textures = append(op.Textures, gophersImage)
|
op.Images = append(op.Images, gophersImage)
|
||||||
}
|
}
|
||||||
screen.DrawTrianglesWithShader(vs, is, s, op)
|
screen.DrawTrianglesWithShader(vs, is, s, op)
|
||||||
|
|
||||||
|
12
image.go
12
image.go
@ -342,7 +342,7 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o
|
|||||||
|
|
||||||
type DrawTrianglesWithShaderOptions struct {
|
type DrawTrianglesWithShaderOptions struct {
|
||||||
Uniforms []interface{}
|
Uniforms []interface{}
|
||||||
Textures []*Image // TODO: Rename to Images?
|
Images []*Image
|
||||||
CompositeMode CompositeMode
|
CompositeMode CompositeMode
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,12 +375,12 @@ func (i *Image) DrawTrianglesWithShader(vertices []Vertex, indices []uint16, sha
|
|||||||
// The actual value is set at graphicscommand package.
|
// The actual value is set at graphicscommand package.
|
||||||
us := append([]interface{}{[]float32{0, 0}}, options.Uniforms...)
|
us := append([]interface{}{[]float32{0, 0}}, options.Uniforms...)
|
||||||
|
|
||||||
var ts []*buffered.Image
|
var imgs []*buffered.Image
|
||||||
for _, t := range options.Textures {
|
for _, img := range options.Images {
|
||||||
if t.isDisposed() {
|
if img.isDisposed() {
|
||||||
panic("ebiten: the given image to DrawTriangles must not be disposed")
|
panic("ebiten: the given image to DrawTriangles must not be disposed")
|
||||||
}
|
}
|
||||||
ts = append(ts, t.buffered)
|
imgs = append(imgs, img.buffered)
|
||||||
}
|
}
|
||||||
|
|
||||||
vs := make([]float32, len(vertices)*graphics.VertexFloatNum)
|
vs := make([]float32, len(vertices)*graphics.VertexFloatNum)
|
||||||
@ -397,7 +397,7 @@ func (i *Image) DrawTrianglesWithShader(vertices []Vertex, indices []uint16, sha
|
|||||||
is := make([]uint16, len(indices))
|
is := make([]uint16, len(indices))
|
||||||
copy(is, indices)
|
copy(is, indices)
|
||||||
|
|
||||||
i.buffered.DrawTriangles(nil, vs, is, nil, mode, driver.FilterNearest, driver.AddressUnsafe, driver.Region{}, shader.shader, us, ts)
|
i.buffered.DrawTriangles(nil, vs, is, nil, mode, driver.FilterNearest, driver.AddressUnsafe, driver.Region{}, shader.shader, us, imgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubImage returns an image representing the portion of the image p visible through r.
|
// SubImage returns an image representing the portion of the image p visible through r.
|
||||||
|
@ -268,13 +268,13 @@ func (i *Image) drawImage(src *Image, bounds image.Rectangle, g mipmap.GeoM, col
|
|||||||
// DrawTriangles draws the src image with the given vertices.
|
// DrawTriangles draws the src image with the given vertices.
|
||||||
//
|
//
|
||||||
// Copying vertices and indices is the caller's responsibility.
|
// Copying vertices and indices is the caller's responsibility.
|
||||||
func (i *Image) DrawTriangles(src *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, textures []*Image) {
|
func (i *Image) DrawTriangles(src *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, images []*Image) {
|
||||||
if src != nil {
|
if src != nil {
|
||||||
if i == src {
|
if i == src {
|
||||||
panic("buffered: Image.DrawTriangles: src must be different from the receiver")
|
panic("buffered: Image.DrawTriangles: src must be different from the receiver")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, src := range textures {
|
for _, src := range images {
|
||||||
if i == src {
|
if i == src {
|
||||||
panic("buffered: Image.DrawTriangles: source images must be different from the receiver")
|
panic("buffered: Image.DrawTriangles: source images must be different from the receiver")
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ func (i *Image) DrawTriangles(src *Image, vertices []float32, indices []uint16,
|
|||||||
if maybeCanAddDelayedCommand() {
|
if maybeCanAddDelayedCommand() {
|
||||||
if tryAddDelayedCommand(func() error {
|
if tryAddDelayedCommand(func() error {
|
||||||
// Arguments are not copied. Copying is the caller's responsibility.
|
// Arguments are not copied. Copying is the caller's responsibility.
|
||||||
i.DrawTriangles(src, vertices, indices, colorm, mode, filter, address, sourceRegion, shader, uniforms, textures)
|
i.DrawTriangles(src, vertices, indices, colorm, mode, filter, address, sourceRegion, shader, uniforms, images)
|
||||||
return nil
|
return nil
|
||||||
}) {
|
}) {
|
||||||
return
|
return
|
||||||
@ -293,7 +293,7 @@ func (i *Image) DrawTriangles(src *Image, vertices []float32, indices []uint16,
|
|||||||
if src != nil {
|
if src != nil {
|
||||||
src.resolvePendingPixels(true)
|
src.resolvePendingPixels(true)
|
||||||
}
|
}
|
||||||
for _, src := range textures {
|
for _, src := range images {
|
||||||
src.resolvePendingPixels(true)
|
src.resolvePendingPixels(true)
|
||||||
}
|
}
|
||||||
i.resolvePendingPixels(false)
|
i.resolvePendingPixels(false)
|
||||||
@ -308,12 +308,12 @@ func (i *Image) DrawTriangles(src *Image, vertices []float32, indices []uint16,
|
|||||||
srcImg = src.img
|
srcImg = src.img
|
||||||
}
|
}
|
||||||
|
|
||||||
var ts []*mipmap.Mipmap
|
var imgs []*mipmap.Mipmap
|
||||||
for _, t := range textures {
|
for _, img := range images {
|
||||||
ts = append(ts, t.img)
|
imgs = append(imgs, img.img)
|
||||||
}
|
}
|
||||||
|
|
||||||
i.img.DrawTriangles(srcImg, vertices, indices, colorm, mode, filter, address, sourceRegion, s, uniforms, ts)
|
i.img.DrawTriangles(srcImg, vertices, indices, colorm, mode, filter, address, sourceRegion, s, uniforms, imgs)
|
||||||
i.invalidatePendingPixels()
|
i.invalidatePendingPixels()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ type Graphics interface {
|
|||||||
//
|
//
|
||||||
// * float32
|
// * float32
|
||||||
// * []float32
|
// * []float32
|
||||||
DrawShader(dst ImageID, shader ShaderID, indexLen int, indexOffset int, mode CompositeMode, uniforms []interface{}, textures []ImageID) error
|
DrawShader(dst ImageID, shader ShaderID, indexLen int, indexOffset int, mode CompositeMode, uniforms []interface{}, srcs []ImageID) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphicsNotReady represents that the graphics driver is not ready for recovering from the context lost.
|
// GraphicsNotReady represents that the graphics driver is not ready for recovering from the context lost.
|
||||||
|
@ -143,7 +143,7 @@ func (q *commandQueue) appendIndices(indices []uint16, offset uint16) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EnqueueDrawTrianglesCommand enqueues a drawing-image command.
|
// EnqueueDrawTrianglesCommand enqueues a drawing-image command.
|
||||||
func (q *commandQueue) EnqueueDrawTrianglesCommand(dst, src *Image, vertices []float32, indices []uint16, color *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, textures []*Image) {
|
func (q *commandQueue) EnqueueDrawTrianglesCommand(dst, src *Image, vertices []float32, indices []uint16, color *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, images []*Image) {
|
||||||
if len(indices) > graphics.IndicesNum {
|
if len(indices) > graphics.IndicesNum {
|
||||||
panic(fmt.Sprintf("graphicscommand: len(indices) must be <= graphics.IndicesNum but not at EnqueueDrawTrianglesCommand: len(indices): %d, graphics.IndicesNum: %d", len(indices), graphics.IndicesNum))
|
panic(fmt.Sprintf("graphicscommand: len(indices) must be <= graphics.IndicesNum but not at EnqueueDrawTrianglesCommand: len(indices): %d, graphics.IndicesNum: %d", len(indices), graphics.IndicesNum))
|
||||||
}
|
}
|
||||||
@ -157,8 +157,8 @@ func (q *commandQueue) EnqueueDrawTrianglesCommand(dst, src *Image, vertices []f
|
|||||||
|
|
||||||
if src != nil {
|
if src != nil {
|
||||||
q.appendVertices(vertices, src)
|
q.appendVertices(vertices, src)
|
||||||
} else if len(textures) > 0 {
|
} else if len(images) > 0 {
|
||||||
q.appendVertices(vertices, textures[0])
|
q.appendVertices(vertices, images[0])
|
||||||
} else {
|
} else {
|
||||||
q.appendVertices(vertices, nil)
|
q.appendVertices(vertices, nil)
|
||||||
}
|
}
|
||||||
@ -195,7 +195,7 @@ func (q *commandQueue) EnqueueDrawTrianglesCommand(dst, src *Image, vertices []f
|
|||||||
sourceRegion: sourceRegion,
|
sourceRegion: sourceRegion,
|
||||||
shader: shader,
|
shader: shader,
|
||||||
uniforms: uniforms,
|
uniforms: uniforms,
|
||||||
textures: textures,
|
images: images,
|
||||||
}
|
}
|
||||||
q.commands = append(q.commands, c)
|
q.commands = append(q.commands, c)
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ type drawTrianglesCommand struct {
|
|||||||
sourceRegion driver.Region
|
sourceRegion driver.Region
|
||||||
shader *Shader
|
shader *Shader
|
||||||
uniforms []interface{}
|
uniforms []interface{}
|
||||||
textures []*Image
|
images []*Image
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *drawTrianglesCommand) String() string {
|
func (c *drawTrianglesCommand) String() string {
|
||||||
@ -407,9 +407,9 @@ func (c *drawTrianglesCommand) Exec(indexOffset int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.shader != nil {
|
if c.shader != nil {
|
||||||
var ts []driver.ImageID
|
var imgs []driver.ImageID
|
||||||
for _, t := range c.textures {
|
for _, img := range c.images {
|
||||||
ts = append(ts, t.image.ID())
|
imgs = append(imgs, img.image.ID())
|
||||||
}
|
}
|
||||||
|
|
||||||
// The last uniform variables are added at /shader.go and represents a viewport size.
|
// The last uniform variables are added at /shader.go and represents a viewport size.
|
||||||
@ -418,7 +418,7 @@ func (c *drawTrianglesCommand) Exec(indexOffset int) error {
|
|||||||
viewport[0] = float32(w)
|
viewport[0] = float32(w)
|
||||||
viewport[1] = float32(h)
|
viewport[1] = float32(h)
|
||||||
|
|
||||||
return theGraphicsDriver.DrawShader(c.dst.image.ID(), c.shader.shader.ID(), c.nindices, indexOffset, c.mode, c.uniforms, ts)
|
return theGraphicsDriver.DrawShader(c.dst.image.ID(), c.shader.shader.ID(), c.nindices, indexOffset, c.mode, c.uniforms, imgs)
|
||||||
}
|
}
|
||||||
return theGraphicsDriver.Draw(c.dst.image.ID(), c.src.image.ID(), c.nindices, indexOffset, c.mode, c.color, c.filter, c.address, c.sourceRegion)
|
return theGraphicsDriver.Draw(c.dst.image.ID(), c.src.image.ID(), c.nindices, indexOffset, c.mode, c.color, c.filter, c.address, c.sourceRegion)
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ func processSrc(src *Image) {
|
|||||||
//
|
//
|
||||||
// If the source image is not specified, i.e., src is nil and there is no image in the uniform variables, the
|
// If the source image is not specified, i.e., src is nil and there is no image in the uniform variables, the
|
||||||
// elements for the source image are not used.
|
// elements for the source image are not used.
|
||||||
func (i *Image) DrawTriangles(src *Image, vertices []float32, indices []uint16, clr *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, textures []*Image) {
|
func (i *Image) DrawTriangles(src *Image, vertices []float32, indices []uint16, clr *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, images []*Image) {
|
||||||
if i.lastCommand == lastCommandNone {
|
if i.lastCommand == lastCommandNone {
|
||||||
if !i.screen && mode != driver.CompositeModeClear {
|
if !i.screen && mode != driver.CompositeModeClear {
|
||||||
panic("graphicscommand: the image must be cleared first")
|
panic("graphicscommand: the image must be cleared first")
|
||||||
@ -164,12 +164,12 @@ func (i *Image) DrawTriangles(src *Image, vertices []float32, indices []uint16,
|
|||||||
if src != nil {
|
if src != nil {
|
||||||
processSrc(src)
|
processSrc(src)
|
||||||
}
|
}
|
||||||
for _, t := range textures {
|
for _, src := range images {
|
||||||
processSrc(t)
|
processSrc(src)
|
||||||
}
|
}
|
||||||
i.resolveBufferedReplacePixels()
|
i.resolveBufferedReplacePixels()
|
||||||
|
|
||||||
theCommandQueue.EnqueueDrawTrianglesCommand(i, src, vertices, indices, clr, mode, filter, address, sourceRegion, shader, uniforms, textures)
|
theCommandQueue.EnqueueDrawTrianglesCommand(i, src, vertices, indices, clr, mode, filter, address, sourceRegion, shader, uniforms, images)
|
||||||
|
|
||||||
if i.lastCommand == lastCommandNone && !i.screen {
|
if i.lastCommand == lastCommandNone && !i.screen {
|
||||||
i.lastCommand = lastCommandClear
|
i.lastCommand = lastCommandClear
|
||||||
|
@ -796,7 +796,7 @@ func (g *Graphics) NewShader(program *shaderir.Program) (driver.Shader, error) {
|
|||||||
panic("metal: NewShader is not implemented")
|
panic("metal: NewShader is not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Graphics) DrawShader(dst driver.ImageID, shader driver.ShaderID, indexLen int, indexOffset int, mode driver.CompositeMode, uniforms []interface{}, textures []driver.ImageID) error {
|
func (g *Graphics) DrawShader(dst driver.ImageID, shader driver.ShaderID, indexLen int, indexOffset int, mode driver.CompositeMode, uniforms []interface{}, srcs []driver.ImageID) error {
|
||||||
panic("metal: DrawShader is not implemented")
|
panic("metal: DrawShader is not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ func (g *Graphics) removeShader(shader *Shader) {
|
|||||||
delete(g.shaders, shader.id)
|
delete(g.shaders, shader.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Graphics) DrawShader(dst driver.ImageID, shader driver.ShaderID, indexLen int, indexOffset int, mode driver.CompositeMode, uniforms []interface{}, textures []driver.ImageID) error {
|
func (g *Graphics) DrawShader(dst driver.ImageID, shader driver.ShaderID, indexLen int, indexOffset int, mode driver.CompositeMode, uniforms []interface{}, srcs []driver.ImageID) error {
|
||||||
d := g.images[dst]
|
d := g.images[dst]
|
||||||
s := g.shaders[shader]
|
s := g.shaders[shader]
|
||||||
|
|
||||||
@ -292,8 +292,8 @@ func (g *Graphics) DrawShader(dst driver.ImageID, shader driver.ShaderID, indexL
|
|||||||
us[k].value = v
|
us[k].value = v
|
||||||
}
|
}
|
||||||
|
|
||||||
ts := make([]textureNative, len(textures))
|
ts := make([]textureNative, len(srcs))
|
||||||
for k, v := range textures {
|
for k, v := range srcs {
|
||||||
ts[k] = g.images[v].textureNative
|
ts[k] = g.images[v].textureNative
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ func (m *Mipmap) DrawImage(src *Mipmap, bounds image.Rectangle, geom GeoM, color
|
|||||||
m.disposeMipmaps()
|
m.disposeMipmaps()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mipmap) DrawTriangles(src *Mipmap, vertices []float32, indices []uint16, colorm *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, textures []*Mipmap) {
|
func (m *Mipmap) DrawTriangles(src *Mipmap, vertices []float32, indices []uint16, colorm *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, images []*Mipmap) {
|
||||||
// TODO: Use a mipmap? (#909)
|
// TODO: Use a mipmap? (#909)
|
||||||
|
|
||||||
if colorm != nil && colorm.ScaleOnly() {
|
if colorm != nil && colorm.ScaleOnly() {
|
||||||
@ -206,12 +206,12 @@ func (m *Mipmap) DrawTriangles(src *Mipmap, vertices []float32, indices []uint16
|
|||||||
srcOrig = src.orig
|
srcOrig = src.orig
|
||||||
}
|
}
|
||||||
|
|
||||||
var ts []*shareable.Image
|
var imgs []*shareable.Image
|
||||||
for _, t := range textures {
|
for _, img := range images {
|
||||||
ts = append(ts, t.orig)
|
imgs = append(imgs, img.orig)
|
||||||
}
|
}
|
||||||
|
|
||||||
m.orig.DrawTriangles(srcOrig, vertices, indices, colorm, mode, filter, address, sourceRegion, s, uniforms, ts)
|
m.orig.DrawTriangles(srcOrig, vertices, indices, colorm, mode, filter, address, sourceRegion, s, uniforms, imgs)
|
||||||
m.disposeMipmaps()
|
m.disposeMipmaps()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ type drawTrianglesHistoryItem struct {
|
|||||||
sourceRegion driver.Region
|
sourceRegion driver.Region
|
||||||
shader *Shader
|
shader *Shader
|
||||||
uniforms []interface{}
|
uniforms []interface{}
|
||||||
textures []*Image
|
images []*Image
|
||||||
}
|
}
|
||||||
|
|
||||||
// Image represents an image that can be restored when GL context is lost.
|
// Image represents an image that can be restored when GL context is lost.
|
||||||
@ -352,7 +352,7 @@ func (i *Image) ReplacePixels(pixels []byte, x, y, width, height int) {
|
|||||||
// 5: Color G
|
// 5: Color G
|
||||||
// 6: Color B
|
// 6: Color B
|
||||||
// 7: Color Y
|
// 7: Color Y
|
||||||
func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, textures []*Image) {
|
func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, images []*Image) {
|
||||||
if i.priority {
|
if i.priority {
|
||||||
panic("restorable: DrawTriangles cannot be called on a priority image")
|
panic("restorable: DrawTriangles cannot be called on a priority image")
|
||||||
}
|
}
|
||||||
@ -367,7 +367,7 @@ func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16,
|
|||||||
srcstale = true
|
srcstale = true
|
||||||
}
|
}
|
||||||
if !srcstale {
|
if !srcstale {
|
||||||
for _, t := range textures {
|
for _, t := range images {
|
||||||
if t.stale || t.volatile {
|
if t.stale || t.volatile {
|
||||||
srcstale = true
|
srcstale = true
|
||||||
break
|
break
|
||||||
@ -378,7 +378,7 @@ func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16,
|
|||||||
if srcstale || i.screen || !needsRestoring() || i.volatile {
|
if srcstale || i.screen || !needsRestoring() || i.volatile {
|
||||||
i.makeStale()
|
i.makeStale()
|
||||||
} else {
|
} else {
|
||||||
i.appendDrawTrianglesHistory(img, vertices, indices, colorm, mode, filter, address, sourceRegion, shader, uniforms, textures)
|
i.appendDrawTrianglesHistory(img, vertices, indices, colorm, mode, filter, address, sourceRegion, shader, uniforms, images)
|
||||||
}
|
}
|
||||||
var s *graphicscommand.Shader
|
var s *graphicscommand.Shader
|
||||||
if shader != nil {
|
if shader != nil {
|
||||||
@ -390,14 +390,14 @@ func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16,
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ts []*graphicscommand.Image
|
var ts []*graphicscommand.Image
|
||||||
for _, t := range textures {
|
for _, t := range images {
|
||||||
ts = append(ts, t.image)
|
ts = append(ts, t.image)
|
||||||
}
|
}
|
||||||
i.image.DrawTriangles(gimg, vertices, indices, colorm, mode, filter, address, sourceRegion, s, uniforms, ts)
|
i.image.DrawTriangles(gimg, vertices, indices, colorm, mode, filter, address, sourceRegion, s, uniforms, ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// appendDrawTrianglesHistory appends a draw-image history item to the image.
|
// appendDrawTrianglesHistory appends a draw-image history item to the image.
|
||||||
func (i *Image) appendDrawTrianglesHistory(image *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, textures []*Image) {
|
func (i *Image) appendDrawTrianglesHistory(image *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, images []*Image) {
|
||||||
if i.stale || i.volatile || i.screen {
|
if i.stale || i.volatile || i.screen {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -426,7 +426,7 @@ func (i *Image) appendDrawTrianglesHistory(image *Image, vertices []float32, ind
|
|||||||
sourceRegion: sourceRegion,
|
sourceRegion: sourceRegion,
|
||||||
shader: shader,
|
shader: shader,
|
||||||
uniforms: uniforms,
|
uniforms: uniforms,
|
||||||
textures: textures,
|
images: images,
|
||||||
}
|
}
|
||||||
i.drawTrianglesHistory = append(i.drawTrianglesHistory, item)
|
i.drawTrianglesHistory = append(i.drawTrianglesHistory, item)
|
||||||
}
|
}
|
||||||
@ -518,8 +518,8 @@ func (i *Image) dependsOn(target *Image) bool {
|
|||||||
if c.image == target {
|
if c.image == target {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
for _, t := range c.textures {
|
for _, img := range c.images {
|
||||||
if t == target {
|
if img == target {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -544,8 +544,8 @@ func (i *Image) dependingImages() map[*Image]struct{} {
|
|||||||
if c.image != nil {
|
if c.image != nil {
|
||||||
r[c.image] = struct{}{}
|
r[c.image] = struct{}{}
|
||||||
}
|
}
|
||||||
for _, t := range c.textures {
|
for _, img := range c.images {
|
||||||
r[t] = struct{}{}
|
r[img] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
@ -604,11 +604,11 @@ func (i *Image) restore() error {
|
|||||||
if c.shader != nil {
|
if c.shader != nil {
|
||||||
s = c.shader.shader
|
s = c.shader.shader
|
||||||
}
|
}
|
||||||
var ts []*graphicscommand.Image
|
var imgs []*graphicscommand.Image
|
||||||
for _, t := range c.textures {
|
for _, img := range c.images {
|
||||||
ts = append(ts, t.image)
|
imgs = append(imgs, img.image)
|
||||||
}
|
}
|
||||||
gimg.DrawTriangles(img, c.vertices, c.indices, c.colorm, c.mode, c.filter, c.address, c.sourceRegion, s, c.uniforms, ts)
|
gimg.DrawTriangles(img, c.vertices, c.indices, c.colorm, c.mode, c.filter, c.address, c.sourceRegion, s, c.uniforms, imgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(i.drawTrianglesHistory) > 0 {
|
if len(i.drawTrianglesHistory) > 0 {
|
||||||
|
@ -305,7 +305,7 @@ func makeSharedIfNeeded(src *Image) {
|
|||||||
// 5: Color G
|
// 5: Color G
|
||||||
// 6: Color B
|
// 6: Color B
|
||||||
// 7: Color Y
|
// 7: Color Y
|
||||||
func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, textures []*Image) {
|
func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, images []*Image) {
|
||||||
backendsM.Lock()
|
backendsM.Lock()
|
||||||
// Do not use defer for performance.
|
// Do not use defer for performance.
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16,
|
|||||||
i.processSrc(img)
|
i.processSrc(img)
|
||||||
}
|
}
|
||||||
firstImg := img
|
firstImg := img
|
||||||
for _, src := range textures {
|
for _, src := range images {
|
||||||
if firstImg == nil {
|
if firstImg == nil {
|
||||||
firstImg = src
|
firstImg = src
|
||||||
}
|
}
|
||||||
@ -356,16 +356,16 @@ func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16,
|
|||||||
s = shader.shader
|
s = shader.shader
|
||||||
}
|
}
|
||||||
|
|
||||||
var ts []*restorable.Image
|
var imgs []*restorable.Image
|
||||||
for _, t := range textures {
|
for _, img := range images {
|
||||||
ts = append(ts, t.backend.restorable)
|
imgs = append(imgs, img.backend.restorable)
|
||||||
}
|
}
|
||||||
|
|
||||||
var r *restorable.Image
|
var r *restorable.Image
|
||||||
if img != nil {
|
if img != nil {
|
||||||
r = img.backend.restorable
|
r = img.backend.restorable
|
||||||
}
|
}
|
||||||
i.backend.restorable.DrawTriangles(r, vertices, indices, colorm, mode, filter, address, sourceRegion, s, uniforms, ts)
|
i.backend.restorable.DrawTriangles(r, vertices, indices, colorm, mode, filter, address, sourceRegion, s, uniforms, imgs)
|
||||||
|
|
||||||
i.nonUpdatedCount = 0
|
i.nonUpdatedCount = 0
|
||||||
delete(imagesToMakeShared, i)
|
delete(imagesToMakeShared, i)
|
||||||
@ -373,7 +373,7 @@ func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16,
|
|||||||
if img != nil {
|
if img != nil {
|
||||||
makeSharedIfNeeded(img)
|
makeSharedIfNeeded(img)
|
||||||
}
|
}
|
||||||
for _, src := range textures {
|
for _, src := range images {
|
||||||
makeSharedIfNeeded(src)
|
makeSharedIfNeeded(src)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user