mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +01:00
parent
38a1ee7f57
commit
0793d35c40
@ -1238,9 +1238,10 @@ func TestImageLinearFilterGlitch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
src.ReplacePixels(pix)
|
src.ReplacePixels(pix)
|
||||||
|
|
||||||
|
for _, f := range []Filter{FilterNearest, FilterLinear} {
|
||||||
op := &DrawImageOptions{}
|
op := &DrawImageOptions{}
|
||||||
op.GeoM.Scale(scale, 1)
|
op.GeoM.Scale(scale, 1)
|
||||||
op.Filter = FilterLinear
|
op.Filter = f
|
||||||
dst.DrawImage(src, op)
|
dst.DrawImage(src, op)
|
||||||
|
|
||||||
for j := 1; j < h-1; j++ {
|
for j := 1; j < h-1; j++ {
|
||||||
@ -1254,7 +1255,8 @@ func TestImageLinearFilterGlitch(t *testing.T) {
|
|||||||
want = color.RGBA{0, 0, 0, 0xff}
|
want = color.RGBA{0, 0, 0, 0xff}
|
||||||
}
|
}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("src.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("src.At(%d, %d): filter: %d, got: %v, want: %v", i, j, f, got, want)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,8 @@ import (
|
|||||||
type CompositeMode int
|
type CompositeMode int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CompositeModeSourceOver CompositeMode = iota // This value must be 0 (= initial value)
|
CompositeModeUnknown CompositeMode = iota - 1
|
||||||
|
CompositeModeSourceOver // This value must be 0 (= initial value)
|
||||||
CompositeModeClear
|
CompositeModeClear
|
||||||
CompositeModeCopy
|
CompositeModeCopy
|
||||||
CompositeModeDestination
|
CompositeModeDestination
|
||||||
@ -34,7 +35,6 @@ const (
|
|||||||
CompositeModeDestinationAtop
|
CompositeModeDestinationAtop
|
||||||
CompositeModeXor
|
CompositeModeXor
|
||||||
CompositeModeLighter
|
CompositeModeLighter
|
||||||
CompositeModeUnknown
|
|
||||||
|
|
||||||
CompositeModeMax = CompositeModeLighter
|
CompositeModeMax = CompositeModeLighter
|
||||||
)
|
)
|
||||||
|
@ -265,7 +265,61 @@ type drawTrianglesCommand struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *drawTrianglesCommand) String() string {
|
func (c *drawTrianglesCommand) String() string {
|
||||||
return fmt.Sprintf("draw-triangles: dst: %p <- src: %p, colorm: %v, mode %d, filter: %d, address: %d", c.dst, c.src, c.color, c.mode, c.filter, c.address)
|
mode := ""
|
||||||
|
switch c.mode {
|
||||||
|
case driver.CompositeModeSourceOver:
|
||||||
|
mode = "source-over"
|
||||||
|
case driver.CompositeModeClear:
|
||||||
|
mode = "clear"
|
||||||
|
case driver.CompositeModeCopy:
|
||||||
|
mode = "copy"
|
||||||
|
case driver.CompositeModeDestination:
|
||||||
|
mode = "destination"
|
||||||
|
case driver.CompositeModeDestinationOver:
|
||||||
|
mode = "destination-over"
|
||||||
|
case driver.CompositeModeSourceIn:
|
||||||
|
mode = "source-in"
|
||||||
|
case driver.CompositeModeDestinationIn:
|
||||||
|
mode = "destination-in"
|
||||||
|
case driver.CompositeModeSourceOut:
|
||||||
|
mode = "source-out"
|
||||||
|
case driver.CompositeModeDestinationOut:
|
||||||
|
mode = "destination-out"
|
||||||
|
case driver.CompositeModeSourceAtop:
|
||||||
|
mode = "source-atop"
|
||||||
|
case driver.CompositeModeDestinationAtop:
|
||||||
|
mode = "destination-atop"
|
||||||
|
case driver.CompositeModeXor:
|
||||||
|
mode = "xor"
|
||||||
|
case driver.CompositeModeLighter:
|
||||||
|
mode = "lighter"
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("graphicscommand: invalid composite mode: %d", c.mode))
|
||||||
|
}
|
||||||
|
|
||||||
|
filter := ""
|
||||||
|
switch c.filter {
|
||||||
|
case driver.FilterNearest:
|
||||||
|
filter = "nearest"
|
||||||
|
case driver.FilterLinear:
|
||||||
|
filter = "linear"
|
||||||
|
case driver.FilterScreen:
|
||||||
|
filter = "screen"
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("graphicscommand: invalid filter: %d", c.filter))
|
||||||
|
}
|
||||||
|
|
||||||
|
address := ""
|
||||||
|
switch c.address {
|
||||||
|
case driver.AddressClampToZero:
|
||||||
|
address = "clamp_to_zero"
|
||||||
|
case driver.AddressRepeat:
|
||||||
|
address = "repeat"
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("graphicscommand: invalid address: %d", c.address))
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("draw-triangles: dst: %d <- src: %d, colorm: %v, mode %s, filter: %s, address: %s", c.dst.id, c.src.id, c.color, mode, filter, address)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec executes the drawTrianglesCommand.
|
// Exec executes the drawTrianglesCommand.
|
||||||
@ -334,7 +388,7 @@ type replacePixelsCommand struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *replacePixelsCommand) String() string {
|
func (c *replacePixelsCommand) String() string {
|
||||||
return fmt.Sprintf("replace-pixels: dst: %p, x: %d, y: %d, width: %d, height: %d", c.dst, c.x, c.y, c.width, c.height)
|
return fmt.Sprintf("replace-pixels: dst: %d, x: %d, y: %d, width: %d, height: %d", c.dst.id, c.x, c.y, c.width, c.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec executes the replacePixelsCommand.
|
// Exec executes the replacePixelsCommand.
|
||||||
@ -377,7 +431,7 @@ func (c *pixelsCommand) Exec(indexOffset int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *pixelsCommand) String() string {
|
func (c *pixelsCommand) String() string {
|
||||||
return fmt.Sprintf("pixels: img: %p", c.img)
|
return fmt.Sprintf("pixels: image: %d", c.img.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *pixelsCommand) NumVertices() int {
|
func (c *pixelsCommand) NumVertices() int {
|
||||||
@ -404,7 +458,7 @@ type disposeCommand struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *disposeCommand) String() string {
|
func (c *disposeCommand) String() string {
|
||||||
return fmt.Sprintf("dispose: target: %p", c.target)
|
return fmt.Sprintf("dispose: target: %d", c.target.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec executes the disposeCommand.
|
// Exec executes the disposeCommand.
|
||||||
@ -439,7 +493,7 @@ type newImageCommand struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *newImageCommand) String() string {
|
func (c *newImageCommand) String() string {
|
||||||
return fmt.Sprintf("new-image: result: %p, width: %d, height: %d", c.result, c.width, c.height)
|
return fmt.Sprintf("new-image: result: %d, width: %d, height: %d", c.result.id, c.width, c.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec executes a newImageCommand.
|
// Exec executes a newImageCommand.
|
||||||
@ -478,7 +532,7 @@ type newScreenFramebufferImageCommand struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *newScreenFramebufferImageCommand) String() string {
|
func (c *newScreenFramebufferImageCommand) String() string {
|
||||||
return fmt.Sprintf("new-screen-framebuffer-image: result: %p, width: %d, height: %d", c.result, c.width, c.height)
|
return fmt.Sprintf("new-screen-framebuffer-image: result: %d, width: %d, height: %d", c.result.id, c.width, c.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec executes a newScreenFramebufferImageCommand.
|
// Exec executes a newScreenFramebufferImageCommand.
|
||||||
|
@ -37,9 +37,19 @@ type Image struct {
|
|||||||
internalWidth int
|
internalWidth int
|
||||||
internalHeight int
|
internalHeight int
|
||||||
screen bool
|
screen bool
|
||||||
|
id int
|
||||||
|
|
||||||
lastCommand lastCommand
|
lastCommand lastCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var nextID = 1
|
||||||
|
|
||||||
|
func genNextID() int {
|
||||||
|
id := nextID
|
||||||
|
nextID++
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
// NewImage returns a new image.
|
// NewImage returns a new image.
|
||||||
//
|
//
|
||||||
// Note that the image is not initialized yet.
|
// Note that the image is not initialized yet.
|
||||||
@ -49,6 +59,7 @@ func NewImage(width, height int) *Image {
|
|||||||
height: height,
|
height: height,
|
||||||
internalWidth: graphics.InternalImageSize(width),
|
internalWidth: graphics.InternalImageSize(width),
|
||||||
internalHeight: graphics.InternalImageSize(height),
|
internalHeight: graphics.InternalImageSize(height),
|
||||||
|
id: genNextID(),
|
||||||
}
|
}
|
||||||
c := &newImageCommand{
|
c := &newImageCommand{
|
||||||
result: i,
|
result: i,
|
||||||
@ -66,6 +77,7 @@ func NewScreenFramebufferImage(width, height int) *Image {
|
|||||||
internalWidth: graphics.InternalImageSize(width),
|
internalWidth: graphics.InternalImageSize(width),
|
||||||
internalHeight: graphics.InternalImageSize(height),
|
internalHeight: graphics.InternalImageSize(height),
|
||||||
screen: true,
|
screen: true,
|
||||||
|
id: genNextID(),
|
||||||
}
|
}
|
||||||
c := &newScreenFramebufferImageCommand{
|
c := &newScreenFramebufferImageCommand{
|
||||||
result: i,
|
result: i,
|
||||||
|
Loading…
Reference in New Issue
Block a user