internal/ui: refactoring: unexport ConvertUniforms

This commit is contained in:
Hajime Hoshi 2022-03-21 17:05:50 +09:00
parent f4ad12987d
commit b5bb576a58
4 changed files with 7 additions and 12 deletions

View File

@ -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.

View File

@ -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) {

View File

@ -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

View File

@ -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)
}