ebiten: Remove FilterDefault

Fixes #503
This commit is contained in:
Hajime Hoshi 2020-10-05 01:48:45 +09:00
parent fe97e7b0a5
commit 448a863eb1
5 changed files with 5 additions and 26 deletions

View File

@ -79,9 +79,6 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
// Specifying filter on NewImage[FromImage] is just for backward compatibility.
// Now specifying filter at DrawImageOptions is recommended.
// Specify FilterDefault here, that means to prefer filter specified at DrawImageOptions.
ebitenImage, _ = ebiten.NewImageFromImage(img) ebitenImage, _ = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth, screenHeight) ebiten.SetWindowSize(screenWidth, screenHeight)

View File

@ -111,9 +111,6 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
// Specifying filter on NewImage[FromImage] is just for backward compatibility.
// Now specifying filter at DrawImageOptions is recommended.
// Specify FilterDefault here, that means to prefer filter specified at DrawImageOptions.
gophersImage, _ = ebiten.NewImageFromImage(img) gophersImage, _ = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth, screenHeight) ebiten.SetWindowSize(screenWidth, screenHeight)

View File

@ -22,9 +22,6 @@ import (
type Filter int type Filter int
const ( const (
// FilterDefault represents the default filter.
FilterDefault Filter = 0
// FilterNearest represents nearest (crisp-edged) filter // FilterNearest represents nearest (crisp-edged) filter
FilterNearest Filter = Filter(driver.FilterNearest) FilterNearest Filter = Filter(driver.FilterNearest)

View File

@ -121,15 +121,10 @@ type DrawImageOptions struct {
CompositeMode CompositeMode CompositeMode CompositeMode
// Filter is a type of texture filter. // Filter is a type of texture filter.
// The default (zero) value is FilterDefault. // The default (zero) value is FilterNearest.
// //
// Filter can also be specified at NewImage* functions, but // Filter can also be specified at NewImage* functions, but
// specifying filter at DrawImageOptions is recommended (as of 1.7.0). // specifying filter at DrawImageOptions is recommended (as of 1.7.0).
//
// If both Filter specified at NewImage* and DrawImageOptions are FilterDefault,
// FilterNearest is used.
// If either is FilterDefault and the other is not, the latter is used.
// Otherwise, Filter specified at DrawImageOptions is used.
Filter Filter Filter Filter
} }
@ -193,11 +188,7 @@ func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error {
bounds := img.Bounds() bounds := img.Bounds()
mode := driver.CompositeMode(options.CompositeMode) mode := driver.CompositeMode(options.CompositeMode)
filter := driver.Filter(options.Filter)
filter := driver.FilterNearest
if options.Filter != FilterDefault {
filter = driver.Filter(options.Filter)
}
a, b, c, d, tx, ty := options.GeoM.elements32() a, b, c, d, tx, ty := options.GeoM.elements32()
@ -262,7 +253,7 @@ type DrawTrianglesOptions struct {
CompositeMode CompositeMode CompositeMode CompositeMode
// Filter is a type of texture filter. // Filter is a type of texture filter.
// The default (zero) value is FilterDefault. // The default (zero) value is FilterNearest.
Filter Filter Filter Filter
// Address is a sampler address mode. // Address is a sampler address mode.
@ -324,10 +315,7 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o
} }
} }
filter := driver.FilterNearest filter := driver.Filter(options.Filter)
if options.Filter != FilterDefault {
filter = driver.Filter(options.Filter)
}
vs := make([]float32, len(vertices)*graphics.VertexFloatNum) vs := make([]float32, len(vertices)*graphics.VertexFloatNum)
for i, v := range vertices { for i, v := range vertices {

View File

@ -17,7 +17,7 @@ package driver
type Filter int type Filter int
const ( const (
FilterNearest Filter = iota + 1 // TODO: Remove '+ 1' when ebiten.FilterDefault can be removed. FilterNearest Filter = iota
FilterLinear FilterLinear
FilterScreen FilterScreen
) )