From a6d3a1e0cbf05f42979914cf03ce28ec67e194e7 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 14 Feb 2019 11:09:16 +0900 Subject: [PATCH] graphicsdriver/metal: Refactoring: Use NextPowerOf2Int --- internal/graphicsdriver/metal/driver.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/graphicsdriver/metal/driver.go b/internal/graphicsdriver/metal/driver.go index b1a5541cf..a3a1df79f 100644 --- a/internal/graphicsdriver/metal/driver.go +++ b/internal/graphicsdriver/metal/driver.go @@ -580,12 +580,9 @@ func (d *Driver) Draw(indexLen int, indexOffset int, mode graphics.CompositeMode viewportSize := [...]float32{float32(w), float32(h)} rce.SetVertexBytes(unsafe.Pointer(&viewportSize[0]), unsafe.Sizeof(viewportSize), 1) - sourceSize := [...]float32{float32(1), float32(1)} - for sourceSize[0] < float32(d.src.width) { - sourceSize[0] *= 2 - } - for sourceSize[1] < float32(d.src.height) { - sourceSize[1] *= 2 + sourceSize := [...]float32{ + float32(graphics.NextPowerOf2Int(d.src.width)), + float32(graphics.NextPowerOf2Int(d.src.height)), } rce.SetFragmentBytes(unsafe.Pointer(&sourceSize[0]), unsafe.Sizeof(sourceSize), 2)