From 2da51925108eb0a909c73e4f9026c1b0f9d8494a Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 28 Oct 2018 20:10:05 +0900 Subject: [PATCH] Rename graphics -> graphicscommand --- graphics.go | 10 ++-- image.go | 18 ++++---- .../{graphics => graphicscommand}/command.go | 2 +- .../debug_ebitendebug.go | 2 +- .../debug_notebitendebug.go | 2 +- internal/{graphics => graphicscommand}/doc.go | 4 +- .../framebuffer.go | 2 +- .../{graphics => graphicscommand}/image.go | 2 +- .../{graphics => graphicscommand}/program.go | 2 +- .../{graphics => graphicscommand}/shader.go | 2 +- .../{graphics => graphicscommand}/texture.go | 2 +- internal/graphicsutil/vertices.go | 4 +- internal/restorable/image.go | 28 +++++------ internal/restorable/images.go | 14 +++--- internal/restorable/images_test.go | 46 +++++++++---------- internal/shareable/shareable.go | 8 ++-- internal/shareable/shareable_test.go | 14 +++--- 17 files changed, 81 insertions(+), 81 deletions(-) rename internal/{graphics => graphicscommand}/command.go (99%) rename internal/{graphics => graphicscommand}/debug_ebitendebug.go (96%) rename internal/{graphics => graphicscommand}/debug_notebitendebug.go (96%) rename internal/{graphics => graphicscommand}/doc.go (85%) rename internal/{graphics => graphicscommand}/framebuffer.go (99%) rename internal/{graphics => graphicscommand}/image.go (99%) rename internal/{graphics => graphicscommand}/program.go (99%) rename internal/{graphics => graphicscommand}/shader.go (99%) rename internal/{graphics => graphicscommand}/texture.go (97%) diff --git a/graphics.go b/graphics.go index 814cfa2f4..6aac0ad84 100644 --- a/graphics.go +++ b/graphics.go @@ -15,7 +15,7 @@ package ebiten import ( - "github.com/hajimehoshi/ebiten/internal/graphics" + "github.com/hajimehoshi/ebiten/internal/graphicscommand" "github.com/hajimehoshi/ebiten/internal/opengl" ) @@ -24,16 +24,16 @@ type Filter int const ( // FilterDefault represents the default filter. - FilterDefault Filter = Filter(graphics.FilterDefault) + FilterDefault Filter = Filter(graphicscommand.FilterDefault) // FilterNearest represents nearest (crisp-edged) filter - FilterNearest Filter = Filter(graphics.FilterNearest) + FilterNearest Filter = Filter(graphicscommand.FilterNearest) // FilterLinear represents linear filter - FilterLinear Filter = Filter(graphics.FilterLinear) + FilterLinear Filter = Filter(graphicscommand.FilterLinear) // filterScreen represents a special filter for screen. Inner usage only. - filterScreen Filter = Filter(graphics.FilterScreen) + filterScreen Filter = Filter(graphicscommand.FilterScreen) ) // CompositeMode represents Porter-Duff composition mode. diff --git a/image.go b/image.go index b70e20fec..d9c91f27f 100644 --- a/image.go +++ b/image.go @@ -20,7 +20,7 @@ import ( "math" "runtime" - "github.com/hajimehoshi/ebiten/internal/graphics" + "github.com/hajimehoshi/ebiten/internal/graphicscommand" "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, graphics.FilterLinear) + s.DrawImage(src, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.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 := graphics.FilterNearest + filter := graphicscommand.FilterNearest if options.Filter != FilterDefault { - filter = graphics.Filter(options.Filter) + filter = graphicscommand.Filter(options.Filter) } else if img.filter != FilterDefault { - filter = graphics.Filter(img.filter) + filter = graphicscommand.Filter(img.filter) } a, b, c, d, tx, ty := geom.elements() level := 0 - if filter == graphics.FilterLinear { + if filter == graphicscommand.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 := graphics.FilterNearest + filter := graphicscommand.FilterNearest if options.Filter != FilterDefault { - filter = graphics.Filter(options.Filter) + filter = graphicscommand.Filter(options.Filter) } else if img.filter != FilterDefault { - filter = graphics.Filter(img.filter) + filter = graphicscommand.Filter(img.filter) } vs := []float32{} diff --git a/internal/graphics/command.go b/internal/graphicscommand/command.go similarity index 99% rename from internal/graphics/command.go rename to internal/graphicscommand/command.go index 1b3e28316..0827c1fe2 100644 --- a/internal/graphics/command.go +++ b/internal/graphicscommand/command.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package graphics +package graphicscommand import ( "fmt" diff --git a/internal/graphics/debug_ebitendebug.go b/internal/graphicscommand/debug_ebitendebug.go similarity index 96% rename from internal/graphics/debug_ebitendebug.go rename to internal/graphicscommand/debug_ebitendebug.go index 0f350ffc1..b05c91584 100644 --- a/internal/graphics/debug_ebitendebug.go +++ b/internal/graphicscommand/debug_ebitendebug.go @@ -14,7 +14,7 @@ // +build ebitendebug -package graphics +package graphicscommand func recordLog() bool { return true diff --git a/internal/graphics/debug_notebitendebug.go b/internal/graphicscommand/debug_notebitendebug.go similarity index 96% rename from internal/graphics/debug_notebitendebug.go rename to internal/graphicscommand/debug_notebitendebug.go index 790cfc2dd..78a5b3acb 100644 --- a/internal/graphics/debug_notebitendebug.go +++ b/internal/graphicscommand/debug_notebitendebug.go @@ -14,7 +14,7 @@ // +build !ebitendebug -package graphics +package graphicscommand func recordLog() bool { return false diff --git a/internal/graphics/doc.go b/internal/graphicscommand/doc.go similarity index 85% rename from internal/graphics/doc.go rename to internal/graphicscommand/doc.go index 073714549..cd2fc67f0 100644 --- a/internal/graphics/doc.go +++ b/internal/graphicscommand/doc.go @@ -12,5 +12,5 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package graphics represents a low layer for graphics using OpenGL. -package graphics +// Package graphicscommand represents a low layer for graphics using OpenGL. +package graphicscommand diff --git a/internal/graphics/framebuffer.go b/internal/graphicscommand/framebuffer.go similarity index 99% rename from internal/graphics/framebuffer.go rename to internal/graphicscommand/framebuffer.go index dd0d4cd9a..3cdf237a8 100644 --- a/internal/graphics/framebuffer.go +++ b/internal/graphicscommand/framebuffer.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package graphics +package graphicscommand import ( "github.com/hajimehoshi/ebiten/internal/opengl" diff --git a/internal/graphics/image.go b/internal/graphicscommand/image.go similarity index 99% rename from internal/graphics/image.go rename to internal/graphicscommand/image.go index 5f5bdefe9..9573749fc 100644 --- a/internal/graphics/image.go +++ b/internal/graphicscommand/image.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package graphics +package graphicscommand import ( "github.com/hajimehoshi/ebiten/internal/affine" diff --git a/internal/graphics/program.go b/internal/graphicscommand/program.go similarity index 99% rename from internal/graphics/program.go rename to internal/graphicscommand/program.go index 61f999e68..e94119972 100644 --- a/internal/graphics/program.go +++ b/internal/graphicscommand/program.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package graphics +package graphicscommand import ( "fmt" diff --git a/internal/graphics/shader.go b/internal/graphicscommand/shader.go similarity index 99% rename from internal/graphics/shader.go rename to internal/graphicscommand/shader.go index d7f1b63dd..9d8e100a5 100644 --- a/internal/graphics/shader.go +++ b/internal/graphicscommand/shader.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package graphics +package graphicscommand import ( "strings" diff --git a/internal/graphics/texture.go b/internal/graphicscommand/texture.go similarity index 97% rename from internal/graphics/texture.go rename to internal/graphicscommand/texture.go index 1c07cd20d..d6c11d276 100644 --- a/internal/graphics/texture.go +++ b/internal/graphicscommand/texture.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package graphics +package graphicscommand import ( "github.com/hajimehoshi/ebiten/internal/opengl" diff --git a/internal/graphicsutil/vertices.go b/internal/graphicsutil/vertices.go index cae64b097..b496d294d 100644 --- a/internal/graphicsutil/vertices.go +++ b/internal/graphicsutil/vertices.go @@ -15,7 +15,7 @@ package graphicsutil import ( - "github.com/hajimehoshi/ebiten/internal/graphics" + "github.com/hajimehoshi/ebiten/internal/graphicscommand" "github.com/hajimehoshi/ebiten/internal/opengl" ) @@ -30,7 +30,7 @@ type verticesBackend struct { func (v *verticesBackend) sliceForOneQuad() []float32 { const num = 256 - size := 4 * graphics.VertexSizeInBytes() / opengl.Float.SizeInBytes() + size := 4 * graphicscommand.VertexSizeInBytes() / opengl.Float.SizeInBytes() if v.backend == nil { v.backend = make([]float32, size*num) } diff --git a/internal/restorable/image.go b/internal/restorable/image.go index d0b24870f..73622ab15 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -20,7 +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" "github.com/hajimehoshi/ebiten/internal/opengl" @@ -33,12 +33,12 @@ type drawImageHistoryItem struct { indices []uint16 colorm *affine.ColorM mode opengl.CompositeMode - filter graphics.Filter + filter graphicscommand.Filter } // Image represents an image that can be restored when GL context is lost. type Image struct { - image *graphics.Image + image *graphicscommand.Image basePixels []byte @@ -66,7 +66,7 @@ var dummyImage = newImageWithoutInit(16, 16, false) // Note that Dispose is not called automatically. func newImageWithoutInit(width, height int, volatile bool) *Image { i := &Image{ - image: graphics.NewImage(width, height), + image: graphicscommand.NewImage(width, height), volatile: volatile, } theImages.add(i) @@ -91,7 +91,7 @@ func NewImage(width, height int, volatile bool) *Image { // Note that Dispose is not called automatically. func NewScreenFramebufferImage(width, height int) *Image { i := &Image{ - image: graphics.NewScreenFramebufferImage(width, height), + image: graphicscommand.NewScreenFramebufferImage(width, height), volatile: false, screen: true, } @@ -166,7 +166,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, graphics.FilterNearest) + i.image.DrawImage(dummyImage.image, vs, is, colorm, opengl.CompositeModeCopy, graphicscommand.FilterNearest) } if x == 0 && y == 0 && width == w && height == h { @@ -203,7 +203,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 graphics.Filter) { +func (i *Image) DrawImage(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphicscommand.Filter) { if len(vertices) == 0 { return } @@ -218,7 +218,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 graphics.Filter) { +func (i *Image) appendDrawImageHistory(image *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphicscommand.Filter) { if i.stale || i.volatile || i.screen { return } @@ -250,7 +250,7 @@ func (i *Image) At(x, y int) color.RGBA { } if i.basePixels == nil || i.drawImageHistory != nil || i.stale { - graphics.FlushCommands() + graphicscommand.FlushCommands() i.readPixelsFromGPU() i.drawImageHistory = nil i.stale = false @@ -328,20 +328,20 @@ func (i *Image) hasDependency() bool { return len(i.drawImageHistory) > 0 } -// Restore restores *graphics.Image from the pixels using its state. +// Restore restores *graphicscommand.Image from the pixels using its state. func (i *Image) restore() error { w, h := i.image.Size() if i.screen { // The screen image should also be recreated because framebuffer might // be changed. - i.image = graphics.NewScreenFramebufferImage(w, h) + i.image = graphicscommand.NewScreenFramebufferImage(w, h) i.basePixels = nil i.drawImageHistory = nil i.stale = false return nil } if i.volatile { - i.image = graphics.NewImage(w, h) + i.image = graphicscommand.NewImage(w, h) i.basePixels = nil i.drawImageHistory = nil i.stale = false @@ -351,7 +351,7 @@ func (i *Image) restore() error { // TODO: panic here? return errors.New("restorable: pixels must not be stale when restoring") } - gimg := graphics.NewImage(w, h) + gimg := graphicscommand.NewImage(w, h) if i.basePixels != nil { gimg.ReplacePixels(i.basePixels, 0, 0, w, h) } else { @@ -392,7 +392,7 @@ func (i *Image) Dispose() { // If an image is invalidated, GL context is lost and all the images should be restored asap. func (i *Image) IsInvalidated() (bool, error) { // FlushCommands is required because c.offscreen.impl might not have an actual texture. - graphics.FlushCommands() + graphicscommand.FlushCommands() if !IsRestoringEnabled() { return false, nil } diff --git a/internal/restorable/images.go b/internal/restorable/images.go index d03d7d2b9..90a10718e 100644 --- a/internal/restorable/images.go +++ b/internal/restorable/images.go @@ -17,7 +17,7 @@ package restorable import ( "image" - "github.com/hajimehoshi/ebiten/internal/graphics" + "github.com/hajimehoshi/ebiten/internal/graphicscommand" ) // restoringEnabled indicates if restoring happens or not. @@ -54,7 +54,7 @@ var theImages = &images{ // // ResolveStaleImages is intended to be called at the end of a frame. func ResolveStaleImages() { - graphics.FlushCommands() + graphicscommand.FlushCommands() if !restoringEnabled { return } @@ -63,9 +63,9 @@ func ResolveStaleImages() { // Restore restores the images. // -// Restoring means to make all *graphics.Image objects have their textures and framebuffers. +// Restoring means to make all *graphicscommand.Image objects have their textures and framebuffers. func Restore() error { - if err := graphics.ResetGLState(); err != nil { + if err := graphicscommand.ResetGLState(); err != nil { return err } return theImages.restore() @@ -144,7 +144,7 @@ func (i *images) makeStaleIfDependingOnImpl(target *Image) { // restore restores the images. // -// Restoring means to make all *graphics.Image objects have their textures and framebuffers. +// Restoring means to make all *graphicscommand.Image objects have their textures and framebuffers. func (i *images) restore() error { if !IsRestoringEnabled() { panic("not reached") @@ -208,9 +208,9 @@ func (i *images) restore() error { // InitializeGLState initializes the GL state. func InitializeGLState() error { - return graphics.ResetGLState() + return graphicscommand.ResetGLState() } func Error() error { - return graphics.Error() + return graphicscommand.Error() } diff --git a/internal/restorable/images_test.go b/internal/restorable/images_test.go index 40fbb49e9..706474c93 100644 --- a/internal/restorable/images_test.go +++ b/internal/restorable/images_test.go @@ -22,7 +22,7 @@ import ( "testing" "github.com/hajimehoshi/ebiten" - "github.com/hajimehoshi/ebiten/internal/graphics" + "github.com/hajimehoshi/ebiten/internal/graphicscommand" "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, graphics.FilterNearest) + imgs[i+1].DrawImage(imgs[i], vs, is, nil, opengl.CompositeModeCopy, graphicscommand.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, graphics.FilterNearest) - imgs[9].DrawImage(imgs[8], vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest) + imgs[8].DrawImage(imgs[7], vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest) + imgs[9].DrawImage(imgs[8], vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest) for i := 0; i < 7; i++ { - imgs[i+1].DrawImage(imgs[i], vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest) + imgs[i+1].DrawImage(imgs[i], vs, is, nil, opengl.CompositeModeCopy, graphicscommand.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, graphics.FilterNearest) - img3.DrawImage(img2, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img2.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest) + img3.DrawImage(img2, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest) fill(img0, clr1.R, clr1.G, clr1.B, clr1.A) - img1.DrawImage(img0, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img1.DrawImage(img0, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.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, graphics.FilterNearest) + img3.DrawImage(img0, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.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, graphics.FilterNearest) + img3.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.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, graphics.FilterNearest) + img4.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.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, graphics.FilterNearest) + img4.DrawImage(img2, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.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, graphics.FilterNearest) + img5.DrawImage(img3, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.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, graphics.FilterNearest) + img6.DrawImage(img3, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.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, graphics.FilterNearest) + img6.DrawImage(img4, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.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, graphics.FilterNearest) + img7.DrawImage(img2, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.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, graphics.FilterNearest) + img7.DrawImage(img3, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.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, graphics.FilterNearest) - img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img1.DrawImage(img0, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.FilterNearest) + img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeSourceOver, graphicscommand.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, graphics.FilterNearest) + img1.DrawImage(img0, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.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, graphics.FilterNearest) - img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphics.FilterNearest) + img1.DrawImage(img2, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest) + img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.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, graphics.FilterNearest) + img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest) img0.ReplacePixels([]uint8{0x00, 0xff, 0x00, 0xff}, 1, 1, 1, 1) // Now img0 is stale. ResolveStaleImages() diff --git a/internal/shareable/shareable.go b/internal/shareable/shareable.go index d54d7bd75..2773c0bd4 100644 --- a/internal/shareable/shareable.go +++ b/internal/shareable/shareable.go @@ -22,7 +22,7 @@ import ( "sync" "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/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, graphics.FilterNearest) + newImg.DrawImage(oldImg, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.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, graphics.FilterNearest) + newImg.DrawImage(i.backend.restorable, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.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 graphics.Filter) { +func (i *Image) DrawImage(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphicscommand.Filter) { backendsM.Lock() defer backendsM.Unlock() diff --git a/internal/shareable/shareable_test.go b/internal/shareable/shareable_test.go index b7e19b308..e6918f3b4 100644 --- a/internal/shareable/shareable_test.go +++ b/internal/shareable/shareable_test.go @@ -22,7 +22,7 @@ import ( "testing" "github.com/hajimehoshi/ebiten" - "github.com/hajimehoshi/ebiten/internal/graphics" + "github.com/hajimehoshi/ebiten/internal/graphicscommand" "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, graphics.FilterNearest) + img4.DrawImage(img3, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.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, graphics.FilterNearest) + img4.DrawImage(img3, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.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, graphics.FilterNearest) + img1.DrawImage(img2, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.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, graphics.FilterNearest) + img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.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, graphics.FilterNearest) + img0.DrawImage(img1, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.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, graphics.FilterNearest) + img0.DrawImage(img3, vs, is, nil, opengl.CompositeModeCopy, graphicscommand.FilterNearest) want := false if got := img3.IsSharedForTesting(); got != want { t.Errorf("got: %v, want: %v", got, want)