From e6c0c73b9eb9da041f792dc7824243f9f88bff3c Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 13 Apr 2019 00:22:11 +0900 Subject: [PATCH] graphicscommand: Add assertion (the screen cannot be a render source) --- internal/graphicscommand/command.go | 2 ++ internal/graphicscommand/image.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index 02bd1b560..3ad211c63 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -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) } diff --git a/internal/graphicscommand/image.go b/internal/graphicscommand/image.go index 3a3630498..ce17c44ed 100644 --- a/internal/graphicscommand/image.go +++ b/internal/graphicscommand/image.go @@ -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")