graphicscommand: Add assertion (the screen cannot be a render source)

This commit is contained in:
Hajime Hoshi 2019-04-13 00:22:11 +09:00
parent 5afcc65387
commit e6c0c73b9e
2 changed files with 6 additions and 0 deletions

View File

@ -136,6 +136,7 @@ func (q *commandQueue) EnqueueDrawImageCommand(dst, src *Image, vertices []float
q.nextIndex += len(vertices) / graphics.VertexFloatNum
q.tmpNumIndices += len(indices)
// TODO: If dst is the screen, reorder the command to be the last.
q.doEnqueueDrawImageCommand(dst, src, len(vertices), len(indices), color, mode, filter, address, split)
}
@ -143,6 +144,7 @@ func (q *commandQueue) EnqueueDrawImageCommand(dst, src *Image, vertices []float
//
// For a draw-image command, use EnqueueDrawImageCommand.
func (q *commandQueue) Enqueue(command command) {
// TODO: If dst is the screen, reorder the command to be the last.
q.commands = append(q.commands, command)
}

View File

@ -83,6 +83,10 @@ func (i *Image) Size() (int, int) {
}
func (i *Image) DrawImage(src *Image, vertices []float32, indices []uint16, clr *affine.ColorM, mode graphics.CompositeMode, filter graphics.Filter, address graphics.Address) {
if src.screen {
panic("graphicscommand: the screen image cannot be the rendering source")
}
if i.lastCommand == lastCommandNone {
if !i.screen && mode != graphics.CompositeModeClear {
panic("graphicscommand: the image must be cleared first")