2018-04-04 19:35:30 +02:00
|
|
|
// Copyright 2018 The Ebiten Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2021-03-11 15:13:24 +01:00
|
|
|
package atlas_test
|
2018-04-04 19:35:30 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"image/color"
|
2018-07-21 22:52:11 +02:00
|
|
|
"runtime"
|
2018-04-04 19:35:30 +02:00
|
|
|
"testing"
|
|
|
|
|
2021-07-27 03:37:14 +02:00
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/affine"
|
2021-10-02 12:58:48 +02:00
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/atlas"
|
2020-10-03 19:35:13 +02:00
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
|
|
|
t "github.com/hajimehoshi/ebiten/v2/internal/testing"
|
2018-04-04 19:35:30 +02:00
|
|
|
)
|
|
|
|
|
2020-06-27 10:09:23 +02:00
|
|
|
const (
|
|
|
|
minImageSizeForTesting = 1024
|
|
|
|
maxImageSizeForTesting = 4096
|
|
|
|
)
|
|
|
|
|
2018-04-04 19:35:30 +02:00
|
|
|
func TestMain(m *testing.M) {
|
2021-10-02 12:58:48 +02:00
|
|
|
atlas.SetImageSizeForTesting(minImageSizeForTesting, maxImageSizeForTesting)
|
|
|
|
defer atlas.ResetImageSizeForTesting()
|
2020-04-01 11:03:08 +02:00
|
|
|
t.MainWithRunLoop(m)
|
2018-04-04 19:35:30 +02:00
|
|
|
}
|
|
|
|
|
2019-09-20 19:35:18 +02:00
|
|
|
func quadVertices(sw, sh, x, y int, scalex float32) []float32 {
|
|
|
|
dx0 := float32(x)
|
|
|
|
dy0 := float32(y)
|
|
|
|
dx1 := float32(x) + float32(sw)*scalex
|
|
|
|
dy1 := float32(y) + float32(sh)
|
|
|
|
sx0 := float32(0)
|
|
|
|
sy0 := float32(0)
|
|
|
|
sx1 := float32(sw)
|
|
|
|
sy1 := float32(sh)
|
|
|
|
return []float32{
|
2020-07-02 16:06:58 +02:00
|
|
|
dx0, dy0, sx0, sy0, 1, 1, 1, 1,
|
|
|
|
dx1, dy0, sx1, sy0, 1, 1, 1, 1,
|
|
|
|
dx0, dy1, sx0, sy1, 1, 1, 1, 1,
|
|
|
|
dx1, dy1, sx1, sy1, 1, 1, 1, 1,
|
2019-09-20 19:35:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-05 18:12:08 +02:00
|
|
|
const bigSize = 2049
|
|
|
|
|
2021-03-11 15:13:24 +01:00
|
|
|
func TestEnsureIsolated(t *testing.T) {
|
2018-04-04 19:35:30 +02:00
|
|
|
// Create img1 and img2 with this size so that the next images are allocated
|
|
|
|
// with non-upper-left location.
|
2021-10-02 12:58:48 +02:00
|
|
|
img1 := atlas.NewImage(bigSize, 100)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer img1.MarkDisposed()
|
2018-04-29 12:15:04 +02:00
|
|
|
// Ensure img1's region is allocated.
|
|
|
|
img1.ReplacePixels(make([]byte, 4*bigSize*100))
|
2018-04-04 19:35:30 +02:00
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
img2 := atlas.NewImage(100, bigSize)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer img2.MarkDisposed()
|
2018-04-29 12:15:04 +02:00
|
|
|
img2.ReplacePixels(make([]byte, 4*100*bigSize))
|
2018-04-04 19:35:30 +02:00
|
|
|
|
|
|
|
const size = 32
|
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
img3 := atlas.NewImage(size/2, size/2)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer img3.MarkDisposed()
|
2018-04-29 12:15:04 +02:00
|
|
|
img3.ReplacePixels(make([]byte, (size/2)*(size/2)*4))
|
2018-04-04 19:35:30 +02:00
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
img4 := atlas.NewImage(size, size)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer img4.MarkDisposed()
|
2018-04-04 19:35:30 +02:00
|
|
|
|
|
|
|
pix := make([]byte, size*size*4)
|
|
|
|
for j := 0; j < size; j++ {
|
|
|
|
for i := 0; i < size; i++ {
|
|
|
|
pix[4*(i+j*size)] = byte(i + j)
|
|
|
|
pix[4*(i+j*size)+1] = byte(i + j)
|
|
|
|
pix[4*(i+j*size)+2] = byte(i + j)
|
|
|
|
pix[4*(i+j*size)+3] = byte(i + j)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
img4.ReplacePixels(pix)
|
|
|
|
|
|
|
|
const (
|
|
|
|
dx0 = size / 4
|
|
|
|
dy0 = size / 4
|
|
|
|
dx1 = size * 3 / 4
|
|
|
|
dy1 = size * 3 / 4
|
|
|
|
)
|
2021-03-11 15:13:24 +01:00
|
|
|
// img4.EnsureIsolated() should be called.
|
2019-09-20 19:35:18 +02:00
|
|
|
vs := quadVertices(size/2, size/2, size/4, size/4, 1)
|
2018-10-28 15:03:06 +01:00
|
|
|
is := graphics.QuadIndices()
|
2020-11-07 11:14:06 +01:00
|
|
|
dr := driver.Region{
|
|
|
|
X: 0,
|
|
|
|
Y: 0,
|
|
|
|
Width: size,
|
|
|
|
Height: size,
|
|
|
|
}
|
2021-10-02 12:58:48 +02:00
|
|
|
img4.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{img3}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2018-07-11 18:40:24 +02:00
|
|
|
want := false
|
2021-03-11 15:13:24 +01:00
|
|
|
if got := img4.IsOnAtlasForTesting(); got != want {
|
2018-07-11 18:40:24 +02:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
2018-04-04 19:35:30 +02:00
|
|
|
|
2020-04-18 13:01:40 +02:00
|
|
|
pix, err := img4.Pixels(0, 0, size, size)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-04-04 19:35:30 +02:00
|
|
|
for j := 0; j < size; j++ {
|
|
|
|
for i := 0; i < size; i++ {
|
2020-04-18 13:01:40 +02:00
|
|
|
r := pix[4*(size*j+i)]
|
|
|
|
g := pix[4*(size*j+i)+1]
|
|
|
|
b := pix[4*(size*j+i)+2]
|
|
|
|
a := pix[4*(size*j+i)+3]
|
2019-01-13 20:25:39 +01:00
|
|
|
got := color.RGBA{r, g, b, a}
|
2018-04-04 19:35:30 +02:00
|
|
|
var want color.RGBA
|
|
|
|
if i < dx0 || dx1 <= i || j < dy0 || dy1 <= j {
|
|
|
|
c := byte(i + j)
|
|
|
|
want = color.RGBA{c, c, c, c}
|
|
|
|
}
|
|
|
|
if got != want {
|
2020-04-18 13:01:40 +02:00
|
|
|
t.Errorf("at(%d, %d): got: %v, want: %v", i, j, got, want)
|
2018-04-04 19:35:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-03 07:10:43 +02:00
|
|
|
|
|
|
|
// Check further drawing doesn't cause panic.
|
|
|
|
// This bug was fixed by 03dcd948.
|
2021-10-02 12:58:48 +02:00
|
|
|
img4.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{img3}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2018-04-04 19:35:30 +02:00
|
|
|
}
|
2018-07-11 18:40:24 +02:00
|
|
|
|
2021-03-11 15:13:24 +01:00
|
|
|
func TestReputOnAtlas(t *testing.T) {
|
2018-07-11 18:40:24 +02:00
|
|
|
const size = 16
|
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
img0 := atlas.NewImage(size, size)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer img0.MarkDisposed()
|
2018-07-11 18:40:24 +02:00
|
|
|
img0.ReplacePixels(make([]byte, 4*size*size))
|
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
img1 := atlas.NewImage(size, size)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer img1.MarkDisposed()
|
2018-07-11 18:40:24 +02:00
|
|
|
img1.ReplacePixels(make([]byte, 4*size*size))
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := img1.IsOnAtlasForTesting(), true; got != want {
|
2018-07-11 18:40:24 +02:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
img2 := atlas.NewImage(size, size)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer img2.MarkDisposed()
|
2018-07-11 18:40:24 +02:00
|
|
|
pix := make([]byte, 4*size*size)
|
|
|
|
for j := 0; j < size; j++ {
|
|
|
|
for i := 0; i < size; i++ {
|
|
|
|
pix[4*(i+j*size)] = byte(i + j)
|
|
|
|
pix[4*(i+j*size)+1] = byte(i + j)
|
|
|
|
pix[4*(i+j*size)+2] = byte(i + j)
|
|
|
|
pix[4*(i+j*size)+3] = byte(i + j)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
img2.ReplacePixels(pix)
|
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
img3 := atlas.NewImage(size, size)
|
2020-08-18 17:54:21 +02:00
|
|
|
img3.SetVolatile(true)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer img3.MarkDisposed()
|
2018-07-24 18:08:04 +02:00
|
|
|
img1.ReplacePixels(make([]byte, 4*size*size))
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := img3.IsOnAtlasForTesting(), false; got != want {
|
2018-07-24 18:08:04 +02:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
|
2018-07-11 18:40:24 +02:00
|
|
|
// Use img1 as a render target.
|
2019-09-20 19:35:18 +02:00
|
|
|
vs := quadVertices(size, size, 0, 0, 1)
|
2018-10-28 15:03:06 +01:00
|
|
|
is := graphics.QuadIndices()
|
2020-11-07 11:14:06 +01:00
|
|
|
dr := driver.Region{
|
|
|
|
X: 0,
|
|
|
|
Y: 0,
|
|
|
|
Width: size,
|
|
|
|
Height: size,
|
|
|
|
}
|
2021-10-02 12:58:48 +02:00
|
|
|
img1.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{img2}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := img1.IsOnAtlasForTesting(), false; got != want {
|
2018-07-11 18:40:24 +02:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use img1 as a render source.
|
2021-03-09 18:29:56 +01:00
|
|
|
// Use the doubled count since img1 was on a texture atlas and became an isolated image once.
|
|
|
|
// Then, img1 requires longer time to recover to be on a textur atlas again.
|
2021-10-02 12:58:48 +02:00
|
|
|
for i := 0; i < atlas.BaseCountToPutOnAtlas*2; i++ {
|
|
|
|
if err := atlas.PutImagesOnAtlasForTesting(); err != nil {
|
2020-01-18 17:18:56 +01:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-10-02 12:58:48 +02:00
|
|
|
img0.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{img1}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := img1.IsOnAtlasForTesting(), false; got != want {
|
2018-07-11 18:40:24 +02:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
}
|
2021-10-02 12:58:48 +02:00
|
|
|
if err := atlas.PutImagesOnAtlasForTesting(); err != nil {
|
2020-01-18 17:18:56 +01:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-07-11 18:40:24 +02:00
|
|
|
|
2020-04-18 13:01:40 +02:00
|
|
|
pix, err := img1.Pixels(0, 0, size, size)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-07-11 18:40:24 +02:00
|
|
|
for j := 0; j < size; j++ {
|
|
|
|
for i := 0; i < size; i++ {
|
|
|
|
want := color.RGBA{byte(i + j), byte(i + j), byte(i + j), byte(i + j)}
|
2020-04-18 13:01:40 +02:00
|
|
|
r := pix[4*(size*j+i)]
|
|
|
|
g := pix[4*(size*j+i)+1]
|
|
|
|
b := pix[4*(size*j+i)+2]
|
|
|
|
a := pix[4*(size*j+i)+3]
|
2019-01-13 20:25:39 +01:00
|
|
|
got := color.RGBA{r, g, b, a}
|
2018-07-11 18:40:24 +02:00
|
|
|
if got != want {
|
2020-06-14 09:03:26 +02:00
|
|
|
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
2018-07-11 18:40:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-11 15:13:24 +01:00
|
|
|
// img1 is on an atlas again.
|
2021-10-02 12:58:48 +02:00
|
|
|
img0.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{img1}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := img1.IsOnAtlasForTesting(), true; got != want {
|
2018-07-11 18:40:24 +02:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
|
2020-04-18 13:01:40 +02:00
|
|
|
pix, err = img1.Pixels(0, 0, size, size)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-07-11 18:40:24 +02:00
|
|
|
for j := 0; j < size; j++ {
|
|
|
|
for i := 0; i < size; i++ {
|
|
|
|
want := color.RGBA{byte(i + j), byte(i + j), byte(i + j), byte(i + j)}
|
2020-04-18 13:01:40 +02:00
|
|
|
r := pix[4*(size*j+i)]
|
|
|
|
g := pix[4*(size*j+i)+1]
|
|
|
|
b := pix[4*(size*j+i)+2]
|
|
|
|
a := pix[4*(size*j+i)+3]
|
2019-01-13 20:25:39 +01:00
|
|
|
got := color.RGBA{r, g, b, a}
|
2018-07-11 18:40:24 +02:00
|
|
|
if got != want {
|
2020-06-14 09:03:26 +02:00
|
|
|
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
2018-07-11 18:40:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-21 22:52:11 +02:00
|
|
|
|
2020-11-05 18:10:03 +01:00
|
|
|
// Use img1 as a render target again.
|
2021-10-02 12:58:48 +02:00
|
|
|
img1.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{img2}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := img1.IsOnAtlasForTesting(), false; got != want {
|
2020-11-05 18:10:03 +01:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use img1 as a render source, but call ReplacePixels.
|
2021-03-09 18:29:56 +01:00
|
|
|
// Now use 4x count as img1 became an isolated image again.
|
2021-10-02 12:58:48 +02:00
|
|
|
for i := 0; i < atlas.BaseCountToPutOnAtlas*4; i++ {
|
|
|
|
if err := atlas.PutImagesOnAtlasForTesting(); err != nil {
|
2020-11-05 18:10:03 +01:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
img1.ReplacePixels(make([]byte, 4*size*size))
|
2021-10-02 12:58:48 +02:00
|
|
|
img0.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{img1}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := img1.IsOnAtlasForTesting(), false; got != want {
|
2020-11-05 18:10:03 +01:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
}
|
2021-10-02 12:58:48 +02:00
|
|
|
if err := atlas.PutImagesOnAtlasForTesting(); err != nil {
|
2020-11-05 18:10:03 +01:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-03-11 15:13:24 +01:00
|
|
|
// img1 is not on an atlas due to ReplacePixels.
|
2021-10-02 12:58:48 +02:00
|
|
|
img0.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{img1}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := img1.IsOnAtlasForTesting(), false; got != want {
|
2020-11-05 18:10:03 +01:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
|
2021-03-11 15:13:24 +01:00
|
|
|
// Use img3 as a render source. As img3 is volatile, img3 is never on an atlas.
|
2021-10-02 12:58:48 +02:00
|
|
|
for i := 0; i < atlas.BaseCountToPutOnAtlas*2; i++ {
|
|
|
|
if err := atlas.PutImagesOnAtlasForTesting(); err != nil {
|
2020-01-18 17:18:56 +01:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-10-02 12:58:48 +02:00
|
|
|
img0.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{img3}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := img3.IsOnAtlasForTesting(), false; got != want {
|
2018-07-24 18:08:04 +02:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-21 22:52:11 +02:00
|
|
|
runtime.GC()
|
2018-07-11 18:40:24 +02:00
|
|
|
}
|
2018-12-15 11:51:17 +01:00
|
|
|
|
|
|
|
func TestExtend(t *testing.T) {
|
2018-12-15 21:09:43 +01:00
|
|
|
const w0, h0 = 100, 100
|
2021-10-02 12:58:48 +02:00
|
|
|
img0 := atlas.NewImage(w0, h0)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer img0.MarkDisposed()
|
2020-11-14 05:15:42 +01:00
|
|
|
|
2018-12-15 21:09:43 +01:00
|
|
|
p0 := make([]byte, 4*w0*h0)
|
|
|
|
for i := 0; i < w0*h0; i++ {
|
2018-12-15 11:51:17 +01:00
|
|
|
p0[4*i] = byte(i)
|
|
|
|
p0[4*i+1] = byte(i)
|
|
|
|
p0[4*i+2] = byte(i)
|
|
|
|
p0[4*i+3] = byte(i)
|
|
|
|
}
|
|
|
|
img0.ReplacePixels(p0)
|
|
|
|
|
2020-11-13 17:02:06 +01:00
|
|
|
const w1, h1 = minImageSizeForTesting + 1, 100
|
2021-10-02 12:58:48 +02:00
|
|
|
img1 := atlas.NewImage(w1, h1)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer img1.MarkDisposed()
|
2020-11-13 17:02:06 +01:00
|
|
|
|
2018-12-15 21:09:43 +01:00
|
|
|
p1 := make([]byte, 4*w1*h1)
|
|
|
|
for i := 0; i < w1*h1; i++ {
|
|
|
|
p1[4*i] = byte(i)
|
|
|
|
p1[4*i+1] = byte(i)
|
|
|
|
p1[4*i+2] = byte(i)
|
|
|
|
p1[4*i+3] = byte(i)
|
|
|
|
}
|
2018-12-15 11:51:17 +01:00
|
|
|
// Ensure to allocate
|
|
|
|
img1.ReplacePixels(p1)
|
|
|
|
|
2020-04-18 13:01:40 +02:00
|
|
|
pix0, err := img0.Pixels(0, 0, w0, h0)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-12-15 21:09:43 +01:00
|
|
|
for j := 0; j < h0; j++ {
|
|
|
|
for i := 0; i < w0; i++ {
|
2020-04-18 13:01:40 +02:00
|
|
|
r := pix0[4*(w0*j+i)]
|
|
|
|
g := pix0[4*(w0*j+i)+1]
|
|
|
|
b := pix0[4*(w0*j+i)+2]
|
|
|
|
a := pix0[4*(w0*j+i)+3]
|
2019-01-13 20:25:39 +01:00
|
|
|
got := color.RGBA{r, g, b, a}
|
2018-12-15 21:09:43 +01:00
|
|
|
c := byte(i + w0*j)
|
2018-12-15 11:51:17 +01:00
|
|
|
want := color.RGBA{c, c, c, c}
|
|
|
|
if got != want {
|
2020-04-18 13:01:40 +02:00
|
|
|
t.Errorf("at(%d, %d): got: %v, want: %v", i, j, got, want)
|
2018-12-15 21:09:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-18 13:01:40 +02:00
|
|
|
pix1, err := img1.Pixels(0, 0, w1, h1)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-12-15 21:09:43 +01:00
|
|
|
for j := 0; j < h1; j++ {
|
|
|
|
for i := 0; i < w1; i++ {
|
2020-04-18 13:01:40 +02:00
|
|
|
r := pix1[4*(w1*j+i)]
|
|
|
|
g := pix1[4*(w1*j+i)+1]
|
|
|
|
b := pix1[4*(w1*j+i)+2]
|
|
|
|
a := pix1[4*(w1*j+i)+3]
|
2019-01-13 20:25:39 +01:00
|
|
|
got := color.RGBA{r, g, b, a}
|
2018-12-15 21:09:43 +01:00
|
|
|
c := byte(i + w1*j)
|
|
|
|
want := color.RGBA{c, c, c, c}
|
|
|
|
if got != want {
|
2020-04-18 13:01:40 +02:00
|
|
|
t.Errorf("at(%d, %d): got: %v, want: %v", i, j, got, want)
|
2018-12-15 11:51:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-16 07:13:35 +01:00
|
|
|
|
2019-04-22 16:12:03 +02:00
|
|
|
func TestReplacePixelsAfterDrawTriangles(t *testing.T) {
|
2018-12-16 07:13:35 +01:00
|
|
|
const w, h = 256, 256
|
2021-10-02 12:58:48 +02:00
|
|
|
src := atlas.NewImage(w, h)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer src.MarkDisposed()
|
2021-10-02 12:58:48 +02:00
|
|
|
dst := atlas.NewImage(w, h)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer dst.MarkDisposed()
|
2018-12-16 07:13:35 +01:00
|
|
|
|
|
|
|
pix := make([]byte, 4*w*h)
|
|
|
|
for i := 0; i < w*h; i++ {
|
|
|
|
pix[4*i] = byte(i)
|
|
|
|
pix[4*i+1] = byte(i)
|
|
|
|
pix[4*i+2] = byte(i)
|
|
|
|
pix[4*i+3] = byte(i)
|
|
|
|
}
|
|
|
|
src.ReplacePixels(pix)
|
|
|
|
|
2019-09-20 19:35:18 +02:00
|
|
|
vs := quadVertices(w, h, 0, 0, 1)
|
2018-12-16 07:13:35 +01:00
|
|
|
is := graphics.QuadIndices()
|
2020-11-07 11:14:06 +01:00
|
|
|
dr := driver.Region{
|
|
|
|
X: 0,
|
|
|
|
Y: 0,
|
|
|
|
Width: w,
|
|
|
|
Height: h,
|
|
|
|
}
|
2021-10-02 12:58:48 +02:00
|
|
|
dst.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{src}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2018-12-16 07:13:35 +01:00
|
|
|
dst.ReplacePixels(pix)
|
|
|
|
|
2020-04-18 13:01:40 +02:00
|
|
|
pix, err := dst.Pixels(0, 0, w, h)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-12-16 07:13:35 +01:00
|
|
|
for j := 0; j < h; j++ {
|
|
|
|
for i := 0; i < w; i++ {
|
2020-04-18 13:01:40 +02:00
|
|
|
r := pix[4*(w*j+i)]
|
|
|
|
g := pix[4*(w*j+i)+1]
|
|
|
|
b := pix[4*(w*j+i)+2]
|
|
|
|
a := pix[4*(w*j+i)+3]
|
2019-01-13 20:25:39 +01:00
|
|
|
got := color.RGBA{r, g, b, a}
|
2018-12-16 07:13:35 +01:00
|
|
|
c := byte(i + w*j)
|
|
|
|
want := color.RGBA{c, c, c, c}
|
|
|
|
if got != want {
|
2020-04-18 13:01:40 +02:00
|
|
|
t.Errorf("at(%d, %d): got %v, want: %v", i, j, got, want)
|
2018-12-16 07:13:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-02 18:39:36 +01:00
|
|
|
|
2019-06-25 15:47:34 +02:00
|
|
|
// Issue #887
|
|
|
|
func TestSmallImages(t *testing.T) {
|
|
|
|
const w, h = 4, 8
|
2021-10-02 12:58:48 +02:00
|
|
|
src := atlas.NewImage(w, h)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer src.MarkDisposed()
|
2021-10-02 12:58:48 +02:00
|
|
|
dst := atlas.NewImage(w, h)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer dst.MarkDisposed()
|
2019-06-25 15:47:34 +02:00
|
|
|
|
|
|
|
pix := make([]byte, 4*w*h)
|
|
|
|
for i := 0; i < w*h; i++ {
|
|
|
|
pix[4*i] = 0xff
|
|
|
|
pix[4*i+1] = 0xff
|
|
|
|
pix[4*i+2] = 0xff
|
|
|
|
pix[4*i+3] = 0xff
|
|
|
|
}
|
|
|
|
src.ReplacePixels(pix)
|
|
|
|
|
2019-09-20 19:35:18 +02:00
|
|
|
vs := quadVertices(w, h, 0, 0, 1)
|
2019-06-25 15:47:34 +02:00
|
|
|
is := graphics.QuadIndices()
|
2020-11-07 11:14:06 +01:00
|
|
|
dr := driver.Region{
|
|
|
|
X: 0,
|
|
|
|
Y: 0,
|
|
|
|
Width: w,
|
|
|
|
Height: h,
|
|
|
|
}
|
2021-10-02 12:58:48 +02:00
|
|
|
dst.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{src}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeSourceOver, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2019-06-25 15:47:34 +02:00
|
|
|
|
2020-04-18 13:01:40 +02:00
|
|
|
pix, err := dst.Pixels(0, 0, w, h)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2019-06-25 15:47:34 +02:00
|
|
|
for j := 0; j < h; j++ {
|
|
|
|
for i := 0; i < w; i++ {
|
2020-04-18 13:01:40 +02:00
|
|
|
r := pix[4*(w*j+i)]
|
|
|
|
a := pix[4*(w*j+i)+3]
|
2019-06-25 15:47:34 +02:00
|
|
|
if got, want := r, byte(0xff); got != want {
|
2020-04-18 13:01:40 +02:00
|
|
|
t.Errorf("at(%d, %d) red: got: %d, want: %d", i, j, got, want)
|
2019-06-25 15:47:34 +02:00
|
|
|
}
|
|
|
|
if got, want := a, byte(0xff); got != want {
|
2020-04-18 13:01:40 +02:00
|
|
|
t.Errorf("at(%d, %d) alpha: got: %d, want: %d", i, j, got, want)
|
2019-06-25 15:47:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-26 04:45:06 +02:00
|
|
|
// Issue #887
|
|
|
|
func TestLongImages(t *testing.T) {
|
|
|
|
const w, h = 1, 6
|
2021-10-02 12:58:48 +02:00
|
|
|
src := atlas.NewImage(w, h)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer src.MarkDisposed()
|
2020-04-18 13:01:40 +02:00
|
|
|
|
|
|
|
const dstW, dstH = 256, 256
|
2021-10-02 12:58:48 +02:00
|
|
|
dst := atlas.NewImage(dstW, dstH)
|
2019-09-21 12:54:39 +02:00
|
|
|
defer dst.MarkDisposed()
|
2019-06-26 04:45:06 +02:00
|
|
|
|
|
|
|
pix := make([]byte, 4*w*h)
|
|
|
|
for i := 0; i < w*h; i++ {
|
|
|
|
pix[4*i] = 0xff
|
|
|
|
pix[4*i+1] = 0xff
|
|
|
|
pix[4*i+2] = 0xff
|
|
|
|
pix[4*i+3] = 0xff
|
|
|
|
}
|
|
|
|
src.ReplacePixels(pix)
|
|
|
|
|
|
|
|
const scale = 120
|
2019-09-20 19:35:18 +02:00
|
|
|
vs := quadVertices(w, h, 0, 0, scale)
|
2019-06-26 04:45:06 +02:00
|
|
|
is := graphics.QuadIndices()
|
2020-11-07 11:14:06 +01:00
|
|
|
dr := driver.Region{
|
|
|
|
X: 0,
|
|
|
|
Y: 0,
|
|
|
|
Width: dstW,
|
|
|
|
Height: dstH,
|
|
|
|
}
|
2021-10-02 12:58:48 +02:00
|
|
|
dst.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{src}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeSourceOver, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2019-06-26 04:45:06 +02:00
|
|
|
|
2020-04-18 13:01:40 +02:00
|
|
|
pix, err := dst.Pixels(0, 0, dstW, dstH)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2019-06-26 04:45:06 +02:00
|
|
|
for j := 0; j < h; j++ {
|
|
|
|
for i := 0; i < w*scale; i++ {
|
2020-04-18 13:01:40 +02:00
|
|
|
r := pix[4*(dstW*j+i)]
|
|
|
|
a := pix[4*(dstW*j+i)+3]
|
2019-06-26 04:45:06 +02:00
|
|
|
if got, want := r, byte(0xff); got != want {
|
2020-04-18 13:01:40 +02:00
|
|
|
t.Errorf("at(%d, %d) red: got: %d, want: %d", i, j, got, want)
|
2019-06-26 04:45:06 +02:00
|
|
|
}
|
|
|
|
if got, want := a, byte(0xff); got != want {
|
2020-04-18 13:01:40 +02:00
|
|
|
t.Errorf("at(%d, %d) alpha: got: %d, want: %d", i, j, got, want)
|
2019-06-26 04:45:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-17 16:03:14 +02:00
|
|
|
func TestDisposeImmediately(t *testing.T) {
|
|
|
|
// This tests restorable.Image.ClearPixels is called but ReplacePixels is not called.
|
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
img0 := atlas.NewImage(16, 16)
|
2021-03-11 15:13:24 +01:00
|
|
|
img0.EnsureIsolatedForTesting()
|
2020-11-13 17:02:06 +01:00
|
|
|
defer img0.MarkDisposed()
|
2019-07-17 16:03:14 +02:00
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
img1 := atlas.NewImage(16, 16)
|
2021-03-11 15:13:24 +01:00
|
|
|
img1.EnsureIsolatedForTesting()
|
2020-11-13 17:02:06 +01:00
|
|
|
defer img1.MarkDisposed()
|
2019-07-17 16:03:14 +02:00
|
|
|
|
|
|
|
// img0 and img1 should share the same backend in 99.9999% possibility.
|
|
|
|
}
|
|
|
|
|
2019-12-19 17:13:23 +01:00
|
|
|
// Issue #1028
|
|
|
|
func TestExtendWithBigImage(t *testing.T) {
|
2021-10-02 12:58:48 +02:00
|
|
|
img0 := atlas.NewImage(1, 1)
|
2019-12-19 17:13:23 +01:00
|
|
|
defer img0.MarkDisposed()
|
|
|
|
|
|
|
|
img0.ReplacePixels(make([]byte, 4*1*1))
|
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
img1 := atlas.NewImage(minImageSizeForTesting+1, minImageSizeForTesting+1)
|
2019-12-19 17:13:23 +01:00
|
|
|
defer img1.MarkDisposed()
|
|
|
|
|
2020-11-13 17:02:06 +01:00
|
|
|
img1.ReplacePixels(make([]byte, 4*(minImageSizeForTesting+1)*(minImageSizeForTesting+1)))
|
2019-12-19 17:13:23 +01:00
|
|
|
}
|
|
|
|
|
2020-06-27 10:09:23 +02:00
|
|
|
// Issue #1217
|
|
|
|
func TestMaxImageSize(t *testing.T) {
|
|
|
|
// This tests that a too-big image is allocated correctly.
|
2021-10-02 12:58:48 +02:00
|
|
|
s := maxImageSizeForTesting - 2*atlas.PaddingSize
|
|
|
|
img := atlas.NewImage(s, s)
|
2020-06-27 10:09:23 +02:00
|
|
|
defer img.MarkDisposed()
|
|
|
|
img.ReplacePixels(make([]byte, 4*s*s))
|
|
|
|
}
|
|
|
|
|
2021-08-14 17:02:50 +02:00
|
|
|
// Issue #1217 (disabled)
|
|
|
|
func Disable_TestMinImageSize(t *testing.T) {
|
|
|
|
// The backend cannot be reset. If this is necessary, sync the state with the images (#1756).
|
|
|
|
// ResetBackendsForTesting()
|
2020-06-27 10:09:23 +02:00
|
|
|
|
|
|
|
// This tests that extending a backend works correctly.
|
|
|
|
// Though the image size is minimum size of the backend, extending the backend happens due to the paddings.
|
|
|
|
s := minImageSizeForTesting
|
2021-10-02 12:58:48 +02:00
|
|
|
img := atlas.NewImage(s, s)
|
2020-06-27 10:09:23 +02:00
|
|
|
defer img.MarkDisposed()
|
|
|
|
img.ReplacePixels(make([]byte, 4*s*s))
|
|
|
|
}
|
|
|
|
|
2020-11-12 15:37:49 +01:00
|
|
|
// Issue #1421
|
2021-03-11 15:13:24 +01:00
|
|
|
func TestDisposedAndReputOnAtlas(t *testing.T) {
|
2020-11-12 15:37:49 +01:00
|
|
|
const size = 16
|
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
src := atlas.NewImage(size, size)
|
2020-11-12 15:37:49 +01:00
|
|
|
defer src.MarkDisposed()
|
2021-10-02 12:58:48 +02:00
|
|
|
src2 := atlas.NewImage(size, size)
|
2020-11-12 15:37:49 +01:00
|
|
|
defer src2.MarkDisposed()
|
2021-10-02 12:58:48 +02:00
|
|
|
dst := atlas.NewImage(size, size)
|
2020-11-12 15:37:49 +01:00
|
|
|
defer dst.MarkDisposed()
|
|
|
|
|
2021-03-11 15:13:24 +01:00
|
|
|
// Use src as a render target so that src is not on an atlas.
|
2020-11-12 15:37:49 +01:00
|
|
|
vs := quadVertices(size, size, 0, 0, 1)
|
|
|
|
is := graphics.QuadIndices()
|
|
|
|
dr := driver.Region{
|
|
|
|
X: 0,
|
|
|
|
Y: 0,
|
|
|
|
Width: size,
|
|
|
|
Height: size,
|
|
|
|
}
|
2021-10-02 12:58:48 +02:00
|
|
|
src.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{src2}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := src.IsOnAtlasForTesting(), false; got != want {
|
2020-11-12 15:37:49 +01:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use src as a render source.
|
2021-10-02 12:58:48 +02:00
|
|
|
for i := 0; i < atlas.BaseCountToPutOnAtlas/2; i++ {
|
|
|
|
if err := atlas.PutImagesOnAtlasForTesting(); err != nil {
|
2020-11-12 15:37:49 +01:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-10-02 12:58:48 +02:00
|
|
|
dst.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{src}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := src.IsOnAtlasForTesting(), false; got != want {
|
2020-11-12 15:37:49 +01:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-11 15:13:24 +01:00
|
|
|
// Before PutImaegsOnAtlasForTesting, dispose the image.
|
2020-11-12 15:37:49 +01:00
|
|
|
src.MarkDisposed()
|
|
|
|
|
|
|
|
// Force to dispose the image.
|
2021-10-02 12:58:48 +02:00
|
|
|
atlas.ResolveDeferredForTesting()
|
2020-11-12 15:37:49 +01:00
|
|
|
|
2021-03-11 15:13:24 +01:00
|
|
|
// Confirm that PutImagesOnAtlasForTesting doesn't panic.
|
2021-10-02 12:58:48 +02:00
|
|
|
if err := atlas.PutImagesOnAtlasForTesting(); err != nil {
|
2020-11-12 15:37:49 +01:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-17 10:22:45 +01:00
|
|
|
// Issue #1456
|
2021-03-11 15:13:24 +01:00
|
|
|
func TestImageIsNotReputOnAtlasWithoutUsingAsSource(t *testing.T) {
|
2021-01-17 10:22:45 +01:00
|
|
|
const size = 16
|
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
src := atlas.NewImage(size, size)
|
2021-01-17 10:22:45 +01:00
|
|
|
defer src.MarkDisposed()
|
2021-10-02 12:58:48 +02:00
|
|
|
src2 := atlas.NewImage(size, size)
|
2021-01-17 10:22:45 +01:00
|
|
|
defer src2.MarkDisposed()
|
2021-10-02 12:58:48 +02:00
|
|
|
dst := atlas.NewImage(size, size)
|
2021-01-17 10:22:45 +01:00
|
|
|
defer dst.MarkDisposed()
|
|
|
|
|
2021-03-11 15:13:24 +01:00
|
|
|
// Use src as a render target so that src is not on an atlas.
|
2021-01-17 10:22:45 +01:00
|
|
|
vs := quadVertices(size, size, 0, 0, 1)
|
|
|
|
is := graphics.QuadIndices()
|
|
|
|
dr := driver.Region{
|
|
|
|
X: 0,
|
|
|
|
Y: 0,
|
|
|
|
Width: size,
|
|
|
|
Height: size,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use src2 as a rendering target, and make src2 an independent image.
|
2021-10-02 12:58:48 +02:00
|
|
|
src2.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{src}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := src2.IsOnAtlasForTesting(), false; got != want {
|
2021-01-17 10:22:45 +01:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the count without using src2 as a rendering source.
|
2021-03-11 15:13:24 +01:00
|
|
|
// This should not affect whether src2 is on an atlas or not.
|
2021-10-02 12:58:48 +02:00
|
|
|
for i := 0; i < atlas.BaseCountToPutOnAtlas; i++ {
|
|
|
|
if err := atlas.PutImagesOnAtlasForTesting(); err != nil {
|
2021-01-17 10:22:45 +01:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := src2.IsOnAtlasForTesting(), false; got != want {
|
2021-01-17 10:22:45 +01:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the count with using src2 as a rendering source.
|
2021-10-02 12:58:48 +02:00
|
|
|
for i := 0; i < atlas.BaseCountToPutOnAtlas; i++ {
|
|
|
|
if err := atlas.PutImagesOnAtlasForTesting(); err != nil {
|
2021-01-17 10:22:45 +01:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-10-02 12:58:48 +02:00
|
|
|
dst.DrawTriangles([graphics.ShaderImageNum]*atlas.Image{src2}, vs, is, affine.ColorMIdentity{}, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressUnsafe, dr, driver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false)
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := src2.IsOnAtlasForTesting(), false; got != want {
|
2021-01-17 10:22:45 +01:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-02 12:58:48 +02:00
|
|
|
if err := atlas.PutImagesOnAtlasForTesting(); err != nil {
|
2021-01-17 10:22:45 +01:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-03-11 15:13:24 +01:00
|
|
|
if got, want := src2.IsOnAtlasForTesting(), true; got != want {
|
2021-01-17 10:22:45 +01:00
|
|
|
t.Errorf("got: %v, want: %v", got, want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-11 15:13:24 +01:00
|
|
|
// TODO: Add tests to extend image on an atlas out of the main loop
|