Skip to content

Commit

Permalink
internal/ui: refactoring: unexport ConvertUniforms
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Mar 21, 2022
1 parent f4ad129 commit b5bb576
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
7 changes: 2 additions & 5 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions internal/ui/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/shader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions shader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit b5bb576

Please sign in to comment.