Add graphics package and move Filter to graphics

This commit is contained in:
Hajime Hoshi 2018-10-28 20:25:52 +09:00
parent 2da5192510
commit 06f2052817
11 changed files with 95 additions and 76 deletions

View File

@ -15,7 +15,7 @@
package ebiten
import (
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/opengl"
)
@ -24,16 +24,16 @@ type Filter int
const (
// FilterDefault represents the default filter.
FilterDefault Filter = Filter(graphicscommand.FilterDefault)
FilterDefault Filter = Filter(graphics.FilterDefault)
// FilterNearest represents nearest (crisp-edged) filter
FilterNearest Filter = Filter(graphicscommand.FilterNearest)
FilterNearest Filter = Filter(graphics.FilterNearest)
// FilterLinear represents linear filter
FilterLinear Filter = Filter(graphicscommand.FilterLinear)
FilterLinear Filter = Filter(graphics.FilterLinear)
// filterScreen represents a special filter for screen. Inner usage only.
filterScreen Filter = Filter(graphicscommand.FilterScreen)
filterScreen Filter = Filter(graphics.FilterScreen)
)
// CompositeMode represents Porter-Duff composition mode.

View File

@ -20,7 +20,7 @@ import (
"math"
"runtime"
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/graphicsutil"
"github.com/hajimehoshi/ebiten/internal/opengl"
"github.com/hajimehoshi/ebiten/internal/shareable"
@ -92,7 +92,7 @@ func (m *mipmap) level(r image.Rectangle, level int) *shareable.Image {
vs = src.QuadVertices(0, 0, w, h, 0.5, 0, 0, 0.5, 0, 0, 1, 1, 1, 1)
}
is := graphicsutil.QuadIndices()
s.DrawImage(src, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterLinear)
s.DrawImage(src, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterLinear)
imgs = append(imgs, s)
w = w2
h = h2
@ -376,17 +376,17 @@ func (i *Image) drawImage(img *Image, options *DrawImageOptions) {
mode := opengl.CompositeMode(options.CompositeMode)
filter := graphicscommand.FilterNearest
filter := graphics.FilterNearest
if options.Filter != FilterDefault {
filter = graphicscommand.Filter(options.Filter)
filter = graphics.Filter(options.Filter)
} else if img.filter != FilterDefault {
filter = graphicscommand.Filter(img.filter)
filter = graphics.Filter(img.filter)
}
a, b, c, d, tx, ty := geom.elements()
level := 0
if filter == graphicscommand.FilterLinear {
if filter == graphics.FilterLinear {
det := geom.det()
if det == 0 {
return
@ -511,11 +511,11 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o
mode := opengl.CompositeMode(options.CompositeMode)
filter := graphicscommand.FilterNearest
filter := graphics.FilterNearest
if options.Filter != FilterDefault {
filter = graphicscommand.Filter(options.Filter)
filter = graphics.Filter(options.Filter)
} else if img.filter != FilterDefault {
filter = graphicscommand.Filter(img.filter)
filter = graphics.Filter(img.filter)
}
vs := []float32{}

View File

@ -0,0 +1,24 @@
// 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.
package graphics
type Filter int
const (
FilterDefault Filter = iota
FilterNearest
FilterLinear
FilterScreen
)

View File

@ -18,6 +18,7 @@ import (
"fmt"
"github.com/hajimehoshi/ebiten/internal/affine"
"github.com/hajimehoshi/ebiten/internal/graphics"
emath "github.com/hajimehoshi/ebiten/internal/math"
"github.com/hajimehoshi/ebiten/internal/opengl"
)
@ -36,7 +37,7 @@ type command interface {
NumIndices() int
AddNumVertices(n int)
AddNumIndices(n int)
CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter Filter) bool
CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) bool
}
// commandQueue is a command queue for drawing commands.
@ -88,7 +89,7 @@ func (q *commandQueue) appendIndices(indices []uint16, offset uint16) {
q.nindices += len(indices)
}
func (q *commandQueue) doEnqueueDrawImageCommand(dst, src *Image, nvertices, nindices int, color *affine.ColorM, mode opengl.CompositeMode, filter Filter, forceNewCommand bool) {
func (q *commandQueue) doEnqueueDrawImageCommand(dst, src *Image, nvertices, nindices int, color *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter, forceNewCommand bool) {
if nindices > indicesNum {
panic("not implemented for too many indices")
}
@ -112,7 +113,7 @@ func (q *commandQueue) doEnqueueDrawImageCommand(dst, src *Image, nvertices, nin
}
// EnqueueDrawImageCommand enqueues a drawing-image command.
func (q *commandQueue) EnqueueDrawImageCommand(dst, src *Image, vertices []float32, indices []uint16, color *affine.ColorM, mode opengl.CompositeMode, filter Filter) {
func (q *commandQueue) EnqueueDrawImageCommand(dst, src *Image, vertices []float32, indices []uint16, color *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) {
if len(indices) > indicesNum {
panic("not reached")
}
@ -221,7 +222,7 @@ type drawImageCommand struct {
nindices int
color *affine.ColorM
mode opengl.CompositeMode
filter Filter
filter graphics.Filter
}
// VertexSizeInBytes returns the size in bytes of one vertex.
@ -275,7 +276,7 @@ func (c *drawImageCommand) AddNumIndices(n int) {
// CanMerge returns a boolean value indicating whether the other drawImageCommand can be merged
// with the drawImageCommand c.
func (c *drawImageCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter Filter) bool {
func (c *drawImageCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) bool {
if c.dst != dst {
return false
}
@ -332,7 +333,7 @@ func (c *replacePixelsCommand) AddNumVertices(n int) {
func (c *replacePixelsCommand) AddNumIndices(n int) {
}
func (c *replacePixelsCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter Filter) bool {
func (c *replacePixelsCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) bool {
return false
}
@ -373,7 +374,7 @@ func (c *pixelsCommand) AddNumVertices(n int) {
func (c *pixelsCommand) AddNumIndices(n int) {
}
func (c *pixelsCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter Filter) bool {
func (c *pixelsCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) bool {
return false
}
@ -412,7 +413,7 @@ func (c *disposeCommand) AddNumVertices(n int) {
func (c *disposeCommand) AddNumIndices(n int) {
}
func (c *disposeCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter Filter) bool {
func (c *disposeCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) bool {
return false
}
@ -472,7 +473,7 @@ func (c *newImageCommand) AddNumVertices(n int) {
func (c *newImageCommand) AddNumIndices(n int) {
}
func (c *newImageCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter Filter) bool {
func (c *newImageCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) bool {
return false
}
@ -511,6 +512,6 @@ func (c *newScreenFramebufferImageCommand) AddNumVertices(n int) {
func (c *newScreenFramebufferImageCommand) AddNumIndices(n int) {
}
func (c *newScreenFramebufferImageCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter Filter) bool {
func (c *newScreenFramebufferImageCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) bool {
return false
}

View File

@ -16,6 +16,7 @@ package graphicscommand
import (
"github.com/hajimehoshi/ebiten/internal/affine"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/math"
"github.com/hajimehoshi/ebiten/internal/opengl"
)
@ -86,7 +87,7 @@ func (i *Image) Size() (int, int) {
return i.width, i.height
}
func (i *Image) DrawImage(src *Image, vertices []float32, indices []uint16, clr *affine.ColorM, mode opengl.CompositeMode, filter Filter) {
func (i *Image) DrawImage(src *Image, vertices []float32, indices []uint16, clr *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) {
theCommandQueue.EnqueueDrawImageCommand(i, src, vertices, indices, clr, mode, filter)
}

View File

@ -18,6 +18,7 @@ import (
"fmt"
"github.com/hajimehoshi/ebiten/internal/affine"
"github.com/hajimehoshi/ebiten/internal/graphics"
emath "github.com/hajimehoshi/ebiten/internal/math"
"github.com/hajimehoshi/ebiten/internal/opengl"
"github.com/hajimehoshi/ebiten/internal/web"
@ -255,16 +256,16 @@ func areSameFloat32Array(a, b []float32) bool {
}
// useProgram uses the program (programTexture).
func (s *openGLState) useProgram(proj []float32, texture opengl.Texture, dst, src *Image, colorM *affine.ColorM, filter Filter) {
func (s *openGLState) useProgram(proj []float32, texture opengl.Texture, dst, src *Image, colorM *affine.ColorM, filter graphics.Filter) {
c := opengl.GetContext()
var program opengl.Program
switch filter {
case FilterNearest:
case graphics.FilterNearest:
program = s.programNearest
case FilterLinear:
case graphics.FilterLinear:
program = s.programLinear
case FilterScreen:
case graphics.FilterScreen:
program = s.programScreen
default:
panic("not reached")

View File

@ -18,15 +18,6 @@ import (
"github.com/hajimehoshi/ebiten/internal/opengl"
)
type Filter int
const (
FilterDefault Filter = iota
FilterNearest
FilterLinear
FilterScreen
)
// texture represents OpenGL's texture.
type texture struct {
native opengl.Texture

View File

@ -20,6 +20,7 @@ import (
"image/color"
"github.com/hajimehoshi/ebiten/internal/affine"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
"github.com/hajimehoshi/ebiten/internal/graphicsutil"
"github.com/hajimehoshi/ebiten/internal/math"
@ -33,7 +34,7 @@ type drawImageHistoryItem struct {
indices []uint16
colorm *affine.ColorM
mode opengl.CompositeMode
filter graphicscommand.Filter
filter graphics.Filter
}
// Image represents an image that can be restored when GL context is lost.
@ -166,7 +167,7 @@ func (i *Image) ReplacePixels(pixels []byte, x, y, width, height int) {
float32(x), float32(y),
1, 1, 1, 1)
is := graphicsutil.QuadIndices()
i.image.DrawImage(dummyImage.image, vs, is, colorm, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
i.image.DrawImage(dummyImage.image, vs, is, colorm, opengl.CompositeModeCopy, graphics.FilterNearest)
}
if x == 0 && y == 0 && width == w && height == h {
@ -203,7 +204,7 @@ func (i *Image) ReplacePixels(pixels []byte, x, y, width, height int) {
}
// DrawImage draws a given image img to the image.
func (i *Image) DrawImage(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphicscommand.Filter) {
func (i *Image) DrawImage(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) {
if len(vertices) == 0 {
return
}
@ -218,7 +219,7 @@ func (i *Image) DrawImage(img *Image, vertices []float32, indices []uint16, colo
}
// appendDrawImageHistory appends a draw-image history item to the image.
func (i *Image) appendDrawImageHistory(image *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphicscommand.Filter) {
func (i *Image) appendDrawImageHistory(image *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) {
if i.stale || i.volatile || i.screen {
return
}

View File

@ -22,7 +22,7 @@ import (
"testing"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/graphicsutil"
"github.com/hajimehoshi/ebiten/internal/opengl"
. "github.com/hajimehoshi/ebiten/internal/restorable"
@ -118,7 +118,7 @@ func TestRestoreChain(t *testing.T) {
w, h := imgs[i].Size()
vs := graphicsutil.QuadVertices(w, h, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
is := graphicsutil.QuadIndices()
imgs[i+1].DrawImage(imgs[i], vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
imgs[i+1].DrawImage(imgs[i], vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
}
ResolveStaleImages()
if err := Restore(); err != nil {
@ -160,10 +160,10 @@ func TestRestoreChain2(t *testing.T) {
vs := graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
is := graphicsutil.QuadIndices()
imgs[8].DrawImage(imgs[7], vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
imgs[9].DrawImage(imgs[8], vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
imgs[8].DrawImage(imgs[7], vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
imgs[9].DrawImage(imgs[8], vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
for i := 0; i < 7; i++ {
imgs[i+1].DrawImage(imgs[i], vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
imgs[i+1].DrawImage(imgs[i], vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
}
ResolveStaleImages()
@ -206,10 +206,10 @@ func TestRestoreOverrideSource(t *testing.T) {
fill(img1, clr0.R, clr0.G, clr0.B, clr0.A)
vs := graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
is := graphicsutil.QuadIndices()
img2.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img3.DrawImage(img2, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img2.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
img3.DrawImage(img2, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
fill(img0, clr1.R, clr1.G, clr1.B, clr1.A)
img1.DrawImage(img0, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img1.DrawImage(img0, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
ResolveStaleImages()
if err := Restore(); err != nil {
t.Fatal(err)
@ -291,23 +291,23 @@ func TestRestoreComplexGraph(t *testing.T) {
}()
vs := graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
is := graphicsutil.QuadIndices()
img3.DrawImage(img0, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img3.DrawImage(img0, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
vs = graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1)
img3.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img3.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
vs = graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1)
img4.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img4.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
vs = graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 2, 0, 1, 1, 1, 1)
img4.DrawImage(img2, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img4.DrawImage(img2, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
vs = graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
img5.DrawImage(img3, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img5.DrawImage(img3, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
vs = graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
img6.DrawImage(img3, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img6.DrawImage(img3, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
vs = graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1)
img6.DrawImage(img4, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img6.DrawImage(img4, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
vs = graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
img7.DrawImage(img2, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img7.DrawImage(img2, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
vs = graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 2, 0, 1, 1, 1, 1)
img7.DrawImage(img3, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img7.DrawImage(img3, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
ResolveStaleImages()
if err := Restore(); err != nil {
t.Fatal(err)
@ -399,8 +399,8 @@ func TestRestoreRecursive(t *testing.T) {
}()
vs := graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1)
is := graphicsutil.QuadIndices()
img1.DrawImage(img0, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest)
img1.DrawImage(img0, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest)
ResolveStaleImages()
if err := Restore(); err != nil {
t.Fatal(err)
@ -487,7 +487,7 @@ func TestDrawImageAndReplacePixels(t *testing.T) {
vs := graphicsutil.QuadVertices(1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
is := graphicsutil.QuadIndices()
img1.DrawImage(img0, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
img1.DrawImage(img0, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
img1.ReplacePixels([]byte{0xff, 0xff, 0xff, 0xff}, 1, 0, 1, 1)
ResolveStaleImages()
@ -519,8 +519,8 @@ func TestDispose(t *testing.T) {
vs := graphicsutil.QuadVertices(1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
is := graphicsutil.QuadIndices()
img1.DrawImage(img2, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
img1.DrawImage(img2, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
img1.Dispose()
ResolveStaleImages()
@ -547,7 +547,7 @@ func TestDoubleResolve(t *testing.T) {
vs := graphicsutil.QuadVertices(1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
is := graphicsutil.QuadIndices()
img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
img0.ReplacePixels([]uint8{0x00, 0xff, 0x00, 0xff}, 1, 1, 1, 1)
// Now img0 is stale.
ResolveStaleImages()

View File

@ -22,7 +22,7 @@ import (
"sync"
"github.com/hajimehoshi/ebiten/internal/affine"
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/graphicsutil"
"github.com/hajimehoshi/ebiten/internal/opengl"
"github.com/hajimehoshi/ebiten/internal/packing"
@ -65,7 +65,7 @@ func (b *backend) TryAlloc(width, height int) (*packing.Node, bool) {
w, h := oldImg.Size()
vs := graphicsutil.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
is := graphicsutil.QuadIndices()
newImg.DrawImage(oldImg, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
newImg.DrawImage(oldImg, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
oldImg.Dispose()
b.restorable = newImg
@ -131,7 +131,7 @@ func (i *Image) ensureNotShared() {
vw, vh := i.backend.restorable.Size()
vs := graphicsutil.QuadVertices(vw, vh, x, y, x+w, y+h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
is := graphicsutil.QuadIndices()
newImg.DrawImage(i.backend.restorable, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
newImg.DrawImage(i.backend.restorable, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
i.dispose(false)
i.backend = &backend{
@ -204,7 +204,7 @@ func (i *Image) Vertex(dx, dy, sx, sy float32, cr, cg, cb, ca float32) []float32
const MaxCountForShare = 10
func (i *Image) DrawImage(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphicscommand.Filter) {
func (i *Image) DrawImage(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) {
backendsM.Lock()
defer backendsM.Unlock()

View File

@ -22,7 +22,7 @@ import (
"testing"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/graphicsutil"
"github.com/hajimehoshi/ebiten/internal/opengl"
. "github.com/hajimehoshi/ebiten/internal/shareable"
@ -88,7 +88,7 @@ func TestEnsureNotShared(t *testing.T) {
// img4.ensureNotShared() should be called.
vs := img3.QuadVertices(0, 0, size/2, size/2, 1, 0, 0, 1, size/4, size/4, 1, 1, 1, 1)
is := graphicsutil.QuadIndices()
img4.DrawImage(img3, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
img4.DrawImage(img3, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
want := false
if got := img4.IsSharedForTesting(); got != want {
t.Errorf("got: %v, want: %v", got, want)
@ -110,7 +110,7 @@ func TestEnsureNotShared(t *testing.T) {
// Check further drawing doesn't cause panic.
// This bug was fixed by 03dcd948.
img4.DrawImage(img3, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
img4.DrawImage(img3, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
}
func Disabled_TestReshared(t *testing.T) {
@ -152,7 +152,7 @@ func Disabled_TestReshared(t *testing.T) {
// Use img1 as a render target.
vs := img2.QuadVertices(0, 0, size, size, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
is := graphicsutil.QuadIndices()
img1.DrawImage(img2, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
img1.DrawImage(img2, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
want = false
if got := img1.IsSharedForTesting(); got != want {
t.Errorf("got: %v, want: %v", got, want)
@ -160,7 +160,7 @@ func Disabled_TestReshared(t *testing.T) {
// Use img1 as a render source.
for i := 0; i < MaxCountForShare-1; i++ {
img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
want := false
if got := img1.IsSharedForTesting(); got != want {
t.Errorf("got: %v, want: %v", got, want)
@ -177,7 +177,7 @@ func Disabled_TestReshared(t *testing.T) {
}
}
img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
want = true
if got := img1.IsSharedForTesting(); got != want {
t.Errorf("got: %v, want: %v", got, want)
@ -195,7 +195,7 @@ func Disabled_TestReshared(t *testing.T) {
// Use img3 as a render source. img3 never uses a shared texture.
for i := 0; i < MaxCountForShare*2; i++ {
img0.DrawImage(img3, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest)
img0.DrawImage(img3, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest)
want := false
if got := img3.IsSharedForTesting(); got != want {
t.Errorf("got: %v, want: %v", got, want)