From e97a0b3e3760d68d3ce9c29b8e6457cd113b6c5e Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 3 May 2017 02:51:38 +0900 Subject: [PATCH] Revert "grahics: Remove unneeded 'if' branches" This reverts commit aa8e77e0bf0c0016ef59ec67ce36a7a18d5b0068. --- vertices_js.go | 6 ++++++ vertices_notjs.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/vertices_js.go b/vertices_js.go index 5dd3e6b97..7b37a2f04 100644 --- a/vertices_js.go +++ b/vertices_js.go @@ -46,7 +46,13 @@ func vertices(parts ImageParts, width, height int, geo *affine.GeoM) []float32 { n := 0 for i := 0; i < l; i++ { dx0, dy0, dx1, dy1 := parts.Dst(i) + if dx0 == dx1 || dy0 == dy1 { + continue + } sx0, sy0, sx1, sy1 := parts.Src(i) + if sx0 == sx1 || sy0 == sy1 { + continue + } u0, v0, u1, v1 := float64(sx0)/wf, float64(sy0)/hf, float64(sx1)/wf, float64(sy1)/hf // Adjust texels to fix a problem that outside texels are used (#317). u1 -= 1.0 / wf / texelAdjustment diff --git a/vertices_notjs.go b/vertices_notjs.go index 5134b446e..2524bb9e6 100644 --- a/vertices_notjs.go +++ b/vertices_notjs.go @@ -44,8 +44,14 @@ func vertices(parts ImageParts, width, height int, geo *affine.GeoM) []float32 { n := 0 for i := 0; i < l; i++ { dx0, dy0, dx1, dy1 := parts.Dst(i) + if dx0 == dx1 || dy0 == dy1 { + continue + } x0, y0, x1, y1 := float32(dx0), float32(dy0), float32(dx1), float32(dy1) sx0, sy0, sx1, sy1 := parts.Src(i) + if sx0 == sx1 || sy0 == sy1 { + continue + } u0, v0, u1, v1 := float32(sx0)/wf, float32(sy0)/hf, float32(sx1)/wf, float32(sy1)/hf // Adjust texels to fix a problem that outside texels are used (#317). u1 -= 1.0 / wf / texelAdjustment