From b5bb576a5867fac81cf24e15948e66e254a26a84 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 21 Mar 2022 17:05:50 +0900 Subject: [PATCH] internal/ui: refactoring: unexport ConvertUniforms --- image.go | 7 ++----- internal/ui/image.go | 6 ++++-- internal/ui/shader.go | 2 +- shader.go | 4 ---- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/image.go b/image.go index cbd49a7d2..94df82b3d 100644 --- a/image.go +++ b/image.go @@ -512,9 +512,7 @@ func (i *Image) DrawTrianglesShader(vertices []Vertex, indices []uint16, shader offsets[i][1] = -sy + float32(b.Min.Y) } - us := shader.convertUniforms(options.Uniforms) - - i.image.DrawTriangles(imgs, vs, is, affine.ColorMIdentity{}, mode, graphicsdriver.FilterNearest, graphicsdriver.AddressUnsafe, dstRegion, sr, offsets, shader.shader, us, options.FillRule == EvenOdd, false) + i.image.DrawTriangles(imgs, vs, is, affine.ColorMIdentity{}, mode, graphicsdriver.FilterNearest, graphicsdriver.AddressUnsafe, dstRegion, sr, offsets, shader.shader, options.Uniforms, options.FillRule == EvenOdd, false) } // DrawRectShaderOptions represents options for DrawRectShader. @@ -625,8 +623,7 @@ func (i *Image) DrawRectShader(width, height int, shader *Shader, options *DrawR offsets[i][1] = -sy + float32(b.Min.Y) } - us := shader.convertUniforms(options.Uniforms) - i.image.DrawTriangles(imgs, vs, is, affine.ColorMIdentity{}, mode, graphicsdriver.FilterNearest, graphicsdriver.AddressUnsafe, dstRegion, sr, offsets, shader.shader, us, false, canSkipMipmap(options.GeoM, graphicsdriver.FilterNearest)) + i.image.DrawTriangles(imgs, vs, is, affine.ColorMIdentity{}, mode, graphicsdriver.FilterNearest, graphicsdriver.AddressUnsafe, dstRegion, sr, offsets, shader.shader, options.Uniforms, false, canSkipMipmap(options.GeoM, graphicsdriver.FilterNearest)) } // SubImage returns an image representing the portion of the image p visible through r. diff --git a/internal/ui/image.go b/internal/ui/image.go index 17c494a4c..3ef2e9cf7 100644 --- a/internal/ui/image.go +++ b/internal/ui/image.go @@ -51,7 +51,7 @@ func (i *Image) MarkDisposed() { i.mipmap = nil } -func (i *Image) DrawTriangles(srcs [graphics.ShaderImageNum]*Image, vertices []float32, indices []uint16, colorm affine.ColorM, mode graphicsdriver.CompositeMode, filter graphicsdriver.Filter, address graphicsdriver.Address, dstRegion, srcRegion graphicsdriver.Region, subimageOffsets [graphics.ShaderImageNum - 1][2]float32, shader *Shader, uniforms [][]float32, evenOdd bool, canSkipMipmap bool) { +func (i *Image) DrawTriangles(srcs [graphics.ShaderImageNum]*Image, vertices []float32, indices []uint16, colorm affine.ColorM, mode graphicsdriver.CompositeMode, filter graphicsdriver.Filter, address graphicsdriver.Address, dstRegion, srcRegion graphicsdriver.Region, subimageOffsets [graphics.ShaderImageNum - 1][2]float32, shader *Shader, uniforms map[string]interface{}, evenOdd bool, canSkipMipmap bool) { var srcMipmaps [graphics.ShaderImageNum]*mipmap.Mipmap for i, src := range srcs { if src == nil { @@ -61,11 +61,13 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageNum]*Image, vertices []f } var s *mipmap.Shader + var us [][]float32 if shader != nil { s = shader.shader + us = shader.convertUniforms(uniforms) } - i.mipmap.DrawTriangles(srcMipmaps, vertices, indices, colorm, mode, filter, address, dstRegion, srcRegion, subimageOffsets, s, uniforms, evenOdd, canSkipMipmap) + i.mipmap.DrawTriangles(srcMipmaps, vertices, indices, colorm, mode, filter, address, dstRegion, srcRegion, subimageOffsets, s, us, evenOdd, canSkipMipmap) } func (i *Image) ReplacePixels(pix []byte, x, y, width, height int) { diff --git a/internal/ui/shader.go b/internal/ui/shader.go index 25a7a23d3..def268577 100644 --- a/internal/ui/shader.go +++ b/internal/ui/shader.go @@ -169,7 +169,7 @@ func __vertex(position vec2, texCoord vec2, color vec4) (vec4, vec2, vec4) { }, nil } -func (s *Shader) ConvertUniforms(uniforms map[string]interface{}) [][]float32 { +func (s *Shader) convertUniforms(uniforms map[string]interface{}) [][]float32 { type index struct { resultIndex int shaderUniformIndex int diff --git a/shader.go b/shader.go index 1a96c90c7..1b4baab2c 100644 --- a/shader.go +++ b/shader.go @@ -46,7 +46,3 @@ func (s *Shader) Dispose() { s.shader.MarkDisposed() s.shader = nil } - -func (s *Shader) convertUniforms(uniforms map[string]interface{}) [][]float32 { - return s.shader.ConvertUniforms(uniforms) -}