Revert "graphics: Remove type assertion"

This reverts commit ff331d031a.

Compile error
This commit is contained in:
Hajime Hoshi 2018-03-21 16:48:51 +09:00
parent ff331d031a
commit 23c2fc0134

View File

@ -32,8 +32,6 @@ import (
type command interface {
Exec(indexOffsetInBytes int) error
NumVertices() int
AddNumVertices(n int)
CanMerge(dst, src *Image, mode opengl.CompositeMode, filter Filter) bool
}
// 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.appendVertices(vertices)
if 0 < len(q.commands) {
last := q.commands[len(q.commands)-1]
if last.CanMerge(dst, src, clr, mode, filter) {
last.AddNumVertices(len(vertices))
q.m.Unlock()
return
if c, ok := q.commands[len(q.commands)-1].(*drawImageCommand); ok {
if c.canMerge(dst, src, clr, mode, filter) {
c.nvertices += len(vertices)
q.m.Unlock()
return
}
}
}
c := &drawImageCommand{
@ -228,10 +227,6 @@ func (c *drawImageCommand) NumVertices() int {
return c.nvertices
}
func (c *drawImageCommand) AddNumVertices(n int) {
c.nvertices += n
}
// split splits the drawImageCommand c into two drawImageCommands.
//
// 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}
}
// 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.
func (c *drawImageCommand) canMerge(dst, src *Image, clr *affine.ColorM, mode opengl.CompositeMode, filter Filter) bool {
if c.dst != dst {
@ -302,13 +297,6 @@ func (c *replacePixelsCommand) NumVertices() int {
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.
type disposeCommand struct {
target *Image
@ -330,13 +318,6 @@ func (c *disposeCommand) NumVertices() int {
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.
type newImageCommand struct {
result *Image
@ -379,13 +360,6 @@ func (c *newImageCommand) NumVertices() int {
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.
type newScreenFramebufferImageCommand struct {
result *Image
@ -406,10 +380,3 @@ func (c *newScreenFramebufferImageCommand) Exec(indexOffsetInBytes int) error {
func (c *newScreenFramebufferImageCommand) NumVertices() int {
return 0
}
func (c *newScreenFramebufferImageCommand) AddNumVertices(n int) {
}
func (c *newScreenFramebufferImageCommand) CanMerge(dst, src *Image, mode opengl.CompositeMode, filter Filter) bool {
return false
}