From b4046a795ecff19556a9d99cf733e54a75b3b184 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 8 Aug 2020 16:01:33 +0900 Subject: [PATCH] graphics: Reduce the usage of InternalImageSize --- internal/graphicscommand/image.go | 3 +++ internal/graphicsdriver/opengl/graphics.go | 9 ++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/internal/graphicscommand/image.go b/internal/graphicscommand/image.go index e1a09b5c4..164df5501 100644 --- a/internal/graphicscommand/image.go +++ b/internal/graphicscommand/image.go @@ -117,6 +117,9 @@ func (i *Image) Dispose() { } func (i *Image) InternalSize() (int, int) { + if i.screen { + return i.width, i.height + } if i.internalWidth == 0 { i.internalWidth = graphics.InternalImageSize(i.width) } diff --git a/internal/graphicsdriver/opengl/graphics.go b/internal/graphicsdriver/opengl/graphics.go index d044f4ef6..e791eaf1a 100644 --- a/internal/graphicsdriver/opengl/graphics.go +++ b/internal/graphicsdriver/opengl/graphics.go @@ -154,8 +154,6 @@ func (g *Graphics) SetVertices(vertices []float32, indices []uint16) { } func (g *Graphics) Draw(dst, src driver.ImageID, indexLen int, indexOffset int, mode driver.CompositeMode, colorM *affine.ColorM, filter driver.Filter, address driver.Address, sourceRegion driver.Region) error { - // TODO: Use sourceRegion. - destination := g.images[dst] source := g.images[src] @@ -206,9 +204,7 @@ func (g *Graphics) Draw(dst, src driver.ImageID, indexLen int, indexOffset int, } if filter != driver.FilterNearest { - srcW, srcH := source.width, source.height - sw := graphics.InternalImageSize(srcW) - sh := graphics.InternalImageSize(srcH) + sw, sh := source.framebufferSize() uniforms = append(uniforms, uniformVariable{ name: "source_size", value: []float32{float32(sw), float32(sh)}, @@ -305,8 +301,7 @@ func (g *Graphics) DrawShader(dst driver.ImageID, srcs [graphics.ShaderImageNum] g.context.blendFunc(mode) us := make([]uniformVariable, graphics.PreservedUniformVariablesNum+len(uniforms)) - vw := graphics.InternalImageSize(d.width) - vh := graphics.InternalImageSize(d.height) + vw, vh := d.framebufferSize() us[0].name = "U0" us[0].value = []float32{float32(vw), float32(vh)} us[0].typ = s.ir.Uniforms[0]