mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
Revert "graphics: Remove type assertion"
This reverts commit ff331d031a
.
Compile error
This commit is contained in:
parent
ff331d031a
commit
23c2fc0134
@ -32,8 +32,6 @@ import (
|
|||||||
type command interface {
|
type command interface {
|
||||||
Exec(indexOffsetInBytes int) error
|
Exec(indexOffsetInBytes int) error
|
||||||
NumVertices() int
|
NumVertices() int
|
||||||
AddNumVertices(n int)
|
|
||||||
CanMerge(dst, src *Image, mode opengl.CompositeMode, filter Filter) bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// commandQueue is a command queue for drawing commands.
|
// commandQueue is a command queue for drawing commands.
|
||||||
@ -75,11 +73,12 @@ func (q *commandQueue) EnqueueDrawImageCommand(dst, src *Image, vertices []float
|
|||||||
q.m.Lock()
|
q.m.Lock()
|
||||||
q.appendVertices(vertices)
|
q.appendVertices(vertices)
|
||||||
if 0 < len(q.commands) {
|
if 0 < len(q.commands) {
|
||||||
last := q.commands[len(q.commands)-1]
|
if c, ok := q.commands[len(q.commands)-1].(*drawImageCommand); ok {
|
||||||
if last.CanMerge(dst, src, clr, mode, filter) {
|
if c.canMerge(dst, src, clr, mode, filter) {
|
||||||
last.AddNumVertices(len(vertices))
|
c.nvertices += len(vertices)
|
||||||
q.m.Unlock()
|
q.m.Unlock()
|
||||||
return
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c := &drawImageCommand{
|
c := &drawImageCommand{
|
||||||
@ -228,10 +227,6 @@ func (c *drawImageCommand) NumVertices() int {
|
|||||||
return c.nvertices
|
return c.nvertices
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *drawImageCommand) AddNumVertices(n int) {
|
|
||||||
c.nvertices += n
|
|
||||||
}
|
|
||||||
|
|
||||||
// split splits the drawImageCommand c into two drawImageCommands.
|
// split splits the drawImageCommand c into two drawImageCommands.
|
||||||
//
|
//
|
||||||
// split is called when the number of vertices reaches of the maximum and
|
// split is called when the number of vertices reaches of the maximum and
|
||||||
@ -246,7 +241,7 @@ func (c *drawImageCommand) split(quadsNum int) [2]*drawImageCommand {
|
|||||||
return [2]*drawImageCommand{&c1, &c2}
|
return [2]*drawImageCommand{&c1, &c2}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CanMerge returns a boolean value indicating whether the other drawImageCommand can be merged
|
// canMerge returns a boolean value indicating whether the other drawImageCommand can be merged
|
||||||
// with the drawImageCommand c.
|
// with the drawImageCommand c.
|
||||||
func (c *drawImageCommand) canMerge(dst, src *Image, clr *affine.ColorM, mode opengl.CompositeMode, filter Filter) bool {
|
func (c *drawImageCommand) canMerge(dst, src *Image, clr *affine.ColorM, mode opengl.CompositeMode, filter Filter) bool {
|
||||||
if c.dst != dst {
|
if c.dst != dst {
|
||||||
@ -302,13 +297,6 @@ func (c *replacePixelsCommand) NumVertices() int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *replacePixelsCommand) AddNumVertices(n int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *replacePixelsCommand) CanMerge(dst, src *Image, mode opengl.CompositeMode, filter Filter) bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// disposeCommand represents a command to dispose an image.
|
// disposeCommand represents a command to dispose an image.
|
||||||
type disposeCommand struct {
|
type disposeCommand struct {
|
||||||
target *Image
|
target *Image
|
||||||
@ -330,13 +318,6 @@ func (c *disposeCommand) NumVertices() int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *disposeCommand) AddNumVertices(n int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *disposeCommand) CanMerge(dst, src *Image, mode opengl.CompositeMode, filter Filter) bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// newImageCommand represents a command to create an empty image with given width and height.
|
// newImageCommand represents a command to create an empty image with given width and height.
|
||||||
type newImageCommand struct {
|
type newImageCommand struct {
|
||||||
result *Image
|
result *Image
|
||||||
@ -379,13 +360,6 @@ func (c *newImageCommand) NumVertices() int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *newImageCommand) AddNumVertices(n int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *newImageCommand) CanMerge(dst, src *Image, mode opengl.CompositeMode, filter Filter) bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// newScreenFramebufferImageCommand is a command to create a special image for the screen.
|
// newScreenFramebufferImageCommand is a command to create a special image for the screen.
|
||||||
type newScreenFramebufferImageCommand struct {
|
type newScreenFramebufferImageCommand struct {
|
||||||
result *Image
|
result *Image
|
||||||
@ -406,10 +380,3 @@ func (c *newScreenFramebufferImageCommand) Exec(indexOffsetInBytes int) error {
|
|||||||
func (c *newScreenFramebufferImageCommand) NumVertices() int {
|
func (c *newScreenFramebufferImageCommand) NumVertices() int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *newScreenFramebufferImageCommand) AddNumVertices(n int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *newScreenFramebufferImageCommand) CanMerge(dst, src *Image, mode opengl.CompositeMode, filter Filter) bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user