mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
shareable: Refactoring: Remove PutQuadVertices
This commit is contained in:
parent
5d4f150094
commit
f48a72a43e
8
image.go
8
image.go
@ -74,10 +74,10 @@ func (m *mipmap) level(r image.Rectangle, level int) *shareable.Image {
|
||||
vs := vertexSlice(4)
|
||||
if l := len(imgs); l == 0 {
|
||||
src = m.orig
|
||||
src.PutQuadVertices(vs, r.Min.X, r.Min.Y, r.Max.X, r.Max.Y, 0.5, 0, 0, 0.5, 0, 0, 1, 1, 1, 1)
|
||||
graphics.PutQuadVertices(vs, src, r.Min.X, r.Min.Y, r.Max.X, r.Max.Y, 0.5, 0, 0, 0.5, 0, 0, 1, 1, 1, 1)
|
||||
} else {
|
||||
src = m.level(r, l)
|
||||
src.PutQuadVertices(vs, 0, 0, w, h, 0.5, 0, 0, 0.5, 0, 0, 1, 1, 1, 1)
|
||||
graphics.PutQuadVertices(vs, src, 0, 0, w, h, 0.5, 0, 0, 0.5, 0, 0, 1, 1, 1, 1)
|
||||
}
|
||||
is := graphics.QuadIndices()
|
||||
s.DrawTriangles(src, vs, is, nil, graphics.CompositeModeCopy, graphics.FilterLinear, graphics.AddressClampToZero)
|
||||
@ -356,7 +356,7 @@ func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error {
|
||||
if level == 0 {
|
||||
src := img.mipmap.original()
|
||||
vs := vertexSlice(4)
|
||||
src.PutQuadVertices(vs, bounds.Min.X, bounds.Min.Y, bounds.Max.X, bounds.Max.Y, a, b, c, d, tx, ty, cr, cg, cb, ca)
|
||||
graphics.PutQuadVertices(vs, src, bounds.Min.X, bounds.Min.Y, bounds.Max.X, bounds.Max.Y, a, b, c, d, tx, ty, cr, cg, cb, ca)
|
||||
is := graphics.QuadIndices()
|
||||
i.mipmap.original().DrawTriangles(src, vs, is, colorm, mode, filter, graphics.AddressClampToZero)
|
||||
} else if src := img.mipmap.level(bounds, level); src != nil {
|
||||
@ -367,7 +367,7 @@ func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error {
|
||||
c *= float32(s)
|
||||
d *= float32(s)
|
||||
vs := vertexSlice(4)
|
||||
src.PutQuadVertices(vs, 0, 0, w, h, a, b, c, d, tx, ty, cr, cg, cb, ca)
|
||||
graphics.PutQuadVertices(vs, src, 0, 0, w, h, a, b, c, d, tx, ty, cr, cg, cb, ca)
|
||||
is := graphics.QuadIndices()
|
||||
i.mipmap.original().DrawTriangles(src, vs, is, colorm, mode, filter, graphics.AddressClampToZero)
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ func (i *Image) ensureNotShared() {
|
||||
_, _, w, h := i.region()
|
||||
newImg := restorable.NewImage(w, h)
|
||||
vs := make([]float32, 4*graphics.VertexFloatNum)
|
||||
i.PutQuadVertices(vs, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
||||
graphics.PutQuadVertices(vs, i, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
||||
is := graphics.QuadIndices()
|
||||
newImg.DrawTriangles(i.backend.restorable, vs, is, nil, graphics.CompositeModeCopy, graphics.FilterNearest, graphics.AddressClampToZero)
|
||||
|
||||
@ -230,14 +230,6 @@ func (i *Image) Size() (width, height int) {
|
||||
return i.width, i.height
|
||||
}
|
||||
|
||||
// PutQuadVertices puts the given dst with vertices for rendering a quad.
|
||||
func (i *Image) PutQuadVertices(dst []float32, sx0, sy0, sx1, sy1 int, a, b, c, d, tx, ty float32, cr, cg, cb, ca float32) {
|
||||
if i.backend == nil {
|
||||
i.allocate(true)
|
||||
}
|
||||
graphics.PutQuadVertices(dst, i, sx0, sy0, sx1, sy1, a, b, c, d, tx, ty, cr, cg, cb, ca)
|
||||
}
|
||||
|
||||
// PutVertices puts the given dst with vertices that can be passed to DrawTriangles.
|
||||
func (i *Image) PutVertex(dst []float32, dx, dy, sx, sy float32, bx0, by0, bx1, by1 float32, cr, cg, cb, ca float32) {
|
||||
if i.backend == nil {
|
||||
|
@ -85,7 +85,7 @@ func TestEnsureNotShared(t *testing.T) {
|
||||
)
|
||||
// img4.ensureNotShared() should be called.
|
||||
vs := make([]float32, 4*graphics.VertexFloatNum)
|
||||
img3.PutQuadVertices(vs, 0, 0, size/2, size/2, 1, 0, 0, 1, size/4, size/4, 1, 1, 1, 1)
|
||||
graphics.PutQuadVertices(vs, img3, 0, 0, size/2, size/2, 1, 0, 0, 1, size/4, size/4, 1, 1, 1, 1)
|
||||
is := graphics.QuadIndices()
|
||||
img4.DrawTriangles(img3, vs, is, nil, graphics.CompositeModeCopy, graphics.FilterNearest, graphics.AddressClampToZero)
|
||||
want := false
|
||||
@ -150,7 +150,7 @@ func TestReshared(t *testing.T) {
|
||||
|
||||
// Use img1 as a render target.
|
||||
vs := make([]float32, 4*graphics.VertexFloatNum)
|
||||
img2.PutQuadVertices(vs, 0, 0, size, size, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
||||
graphics.PutQuadVertices(vs, img2, 0, 0, size, size, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
||||
is := graphics.QuadIndices()
|
||||
img1.DrawTriangles(img2, vs, is, nil, graphics.CompositeModeCopy, graphics.FilterNearest, graphics.AddressClampToZero)
|
||||
if got, want := img1.IsSharedForTesting(), false; got != want {
|
||||
@ -277,7 +277,7 @@ func TestReplacePixelsAfterDrawTriangles(t *testing.T) {
|
||||
src.ReplacePixels(pix)
|
||||
|
||||
vs := make([]float32, 4*graphics.VertexFloatNum)
|
||||
src.PutQuadVertices(vs, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
||||
graphics.PutQuadVertices(vs, src, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
||||
is := graphics.QuadIndices()
|
||||
dst.DrawTriangles(src, vs, is, nil, graphics.CompositeModeCopy, graphics.FilterNearest, graphics.AddressClampToZero)
|
||||
dst.ReplacePixels(pix)
|
||||
|
Loading…
Reference in New Issue
Block a user