Rename a function

This commit is contained in:
Hajime Hoshi 2013-10-19 03:15:25 +09:00
parent d360f0effe
commit b594624105
3 changed files with 10 additions and 10 deletions

View File

@ -1,4 +1,4 @@
package opengl
var AdjustPixels = adjustPixels
var Clp2 = clp2
var NextPowerOf2 = nextPowerOf2

View File

@ -10,7 +10,7 @@ import (
"unsafe"
)
func clp2(x uint64) uint64 {
func nextPowerOf2(x uint64) uint64 {
x -= 1
x |= (x >> 1)
x |= (x >> 2)
@ -22,8 +22,8 @@ func clp2(x uint64) uint64 {
}
func adjustPixels(width, height int, pixels []uint8) []uint8 {
textureWidth := int(clp2(uint64(width)))
textureHeight := int(clp2(uint64(height)))
textureWidth := int(nextPowerOf2(uint64(width)))
textureHeight := int(nextPowerOf2(uint64(height)))
if width == textureWidth && height == textureHeight {
return pixels
}
@ -62,8 +62,8 @@ func createTexture(width, height int, pixels []uint8) *Texture {
if pixels != nil {
pixels = adjustPixels(width, height, pixels)
}
textureWidth := int(clp2(uint64(width)))
textureHeight := int(clp2(uint64(height)))
textureWidth := int(nextPowerOf2(uint64(width)))
textureHeight := int(nextPowerOf2(uint64(height)))
texture := &Texture{
id: 0,
width: width,
@ -129,8 +129,8 @@ func newRenderTargetWithFramebuffer(width, height int,
id: 0,
width: width,
height: height,
textureWidth: int(clp2(uint64(width))),
textureHeight: int(clp2(uint64(height))),
textureWidth: int(nextPowerOf2(uint64(width))),
textureHeight: int(nextPowerOf2(uint64(height))),
framebuffer: framebuffer,
}
}

View File

@ -36,7 +36,7 @@ func TestAdjustPixels(t *testing.T) {
}
}
func TestClp2(t *testing.T) {
func TestNextPowerOf2(t *testing.T) {
testCases := []struct {
expected uint64
arg uint64
@ -47,7 +47,7 @@ func TestClp2(t *testing.T) {
}
for _, testCase := range testCases {
got := Clp2(testCase.arg)
got := NextPowerOf2(testCase.arg)
wanted := testCase.expected
if wanted != got {
t.Errorf("Clp(%d) = %d, wanted %d",