golang-image/vector/raster_fixed.go

328 lines
10 KiB
Go
Raw Normal View History

vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package vector
// This file contains a fixed point math implementation of the vector
// graphics rasterizer.
const (
// ϕ is the number of binary digits after the fixed point.
//
// For example, if ϕ == 10 (and int1ϕ is based on the int32 type) then we
// are using 22.10 fixed point math.
//
// When changing this number, also change the assembly code (search for ϕ
// in the .s files).
vector: change ϕ from 10 to 9. This slight loss in quality allows us to use int32 math exclusively throughout raster_fixed.go, instead of occasionally dropping into int64 math. The change in ϕ doesn't affect the benchmarks noticably, but staying in int32 does. The net effect: name old time/op new time/op delta GlyphAlpha16Over-8 3.36µs ± 0% 2.99µs ± 0% -10.89% (p=0.000 n=10+9) GlyphAlpha16Src-8 3.26µs ± 0% 2.89µs ± 1% -11.34% (p=0.000 n=9+10) GlyphAlpha32Over-8 5.20µs ± 0% 4.53µs ± 0% -12.76% (p=0.000 n=8+10) GlyphAlpha32Src-8 4.81µs ± 1% 4.14µs ± 0% -13.91% (p=0.000 n=9+9) GlyphAlpha64Over-8 10.2µs ± 0% 9.0µs ± 1% -11.99% (p=0.000 n=9+10) GlyphAlpha64Src-8 8.62µs ± 0% 7.42µs ± 1% -13.89% (p=0.000 n=9+10) GlyphAlpha128Over-8 24.1µs ± 0% 21.8µs ± 0% -9.32% (p=0.000 n=9+9) GlyphAlpha128Src-8 17.9µs ± 0% 15.6µs ± 0% -12.68% (p=0.000 n=9+10) GlyphAlpha256Over-8 70.1µs ± 0% 66.3µs ± 1% -5.44% (p=0.000 n=10+10) GlyphAlpha256Src-8 45.2µs ± 1% 41.2µs ± 1% -8.92% (p=0.000 n=10+10) GlyphRGBA16Over-8 5.12µs ± 0% 4.75µs ± 0% -7.15% (p=0.000 n=10+9) GlyphRGBA16Src-8 4.57µs ± 1% 4.20µs ± 0% -8.18% (p=0.000 n=9+8) GlyphRGBA32Over-8 12.1µs ± 0% 11.4µs ± 0% -5.50% (p=0.000 n=10+9) GlyphRGBA32Src-8 10.0µs ± 0% 9.3µs ± 1% -6.80% (p=0.000 n=10+9) GlyphRGBA64Over-8 37.2µs ± 0% 36.0µs ± 0% -3.17% (p=0.000 n=9+8) GlyphRGBA64Src-8 29.0µs ± 1% 27.9µs ± 1% -4.05% (p=0.000 n=9+10) GlyphRGBA128Over-8 134µs ± 1% 131µs ± 0% -1.85% (p=0.000 n=9+9) GlyphRGBA128Src-8 100µs ± 1% 98µs ± 0% -2.27% (p=0.000 n=10+9) GlyphRGBA256Over-8 506µs ± 0% 503µs ± 0% -0.56% (p=0.000 n=10+8) GlyphRGBA256Src-8 373µs ± 0% 370µs ± 0% -1.01% (p=0.000 n=10+9) Change-Id: Ie02afac6fd6fa95f090bf3fe0a5c744799ea9dc5 Reviewed-on: https://go-review.googlesource.com/31532 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-20 01:34:23 +02:00
ϕ = 9
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
fxOne int1ϕ = 1 << ϕ
fxOneAndAHalf int1ϕ = 1<<ϕ + 1<<(ϕ-1)
fxOneMinusIota int1ϕ = 1<<ϕ - 1 // Used for rounding up.
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
)
// int1ϕ is a signed fixed-point number with 1*ϕ binary digits after the fixed
// point.
type int1ϕ int32
// int2ϕ is a signed fixed-point number with 2*ϕ binary digits after the fixed
// point.
//
// The Rasterizer's bufU32 field, nominally of type []uint32 (since that slice
// is also used by other code), can be thought of as a []int2ϕ during the
// fixedLineTo method. Lines of code that are actually like:
// buf[i] += uint32(etc) // buf has type []uint32.
// can be thought of as
// buf[i] += int2ϕ(etc) // buf has type []int2ϕ.
type int2ϕ int32
func fixedMax(x, y int1ϕ) int1ϕ {
if x > y {
return x
}
return y
}
func fixedMin(x, y int1ϕ) int1ϕ {
if x < y {
return x
}
return y
}
func fixedFloor(x int1ϕ) int32 { return int32(x >> ϕ) }
func fixedCeil(x int1ϕ) int32 { return int32((x + fxOneMinusIota) >> ϕ) }
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
func (z *Rasterizer) fixedLineTo(bx, by float32) {
ax, ay := z.penX, z.penY
z.penX, z.penY = bx, by
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
dir := int1ϕ(1)
if ay > by {
dir, ax, ay, bx, by = -1, bx, by, ax, ay
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
}
// Horizontal line segments yield no change in coverage. Almost horizontal
// segments would yield some change, in ideal math, but the computation
// further below, involving 1 / (by - ay), is unstable in fixed point math,
// so we treat the segment as if it was perfectly horizontal.
if by-ay <= 0.000001 {
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
return
}
dxdy := (bx - ax) / (by - ay)
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
ayϕ := int1ϕ(ay * float32(fxOne))
byϕ := int1ϕ(by * float32(fxOne))
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
x := int1ϕ(ax * float32(fxOne))
y := fixedFloor(ayϕ)
yMax := fixedCeil(byϕ)
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
if yMax > int32(z.size.Y) {
yMax = int32(z.size.Y)
}
width := int32(z.size.X)
for ; y < yMax; y++ {
dy := fixedMin(int1ϕ(y+1)<<ϕ, byϕ) - fixedMax(int1ϕ(y)<<ϕ, ayϕ)
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
xNext := x + int1ϕ(float32(dy)*dxdy)
if y < 0 {
x = xNext
continue
}
buf := z.bufU32[y*width:]
vector: fix overflow when rasterizing a 30 degree line. There are some obvious TODOs, but they will be follow-up commits. This is about correctness, not performance, but for the record: name old time/op new time/op delta GlyphAlpha16Over-8 3.16µs ± 0% 3.38µs ± 0% +6.96% (p=0.000 n=9+10) GlyphAlpha16Src-8 3.06µs ± 0% 3.28µs ± 0% +7.21% (p=0.000 n=10+10) GlyphAlpha32Over-8 4.92µs ± 1% 5.23µs ± 1% +6.24% (p=0.000 n=10+10) GlyphAlpha32Src-8 4.53µs ± 1% 4.83µs ± 0% +6.69% (p=0.000 n=10+10) GlyphAlpha64Over-8 9.60µs ± 1% 10.21µs ± 0% +6.36% (p=0.000 n=10+10) GlyphAlpha64Src-8 8.04µs ± 0% 8.68µs ± 1% +7.99% (p=0.000 n=9+10) GlyphAlpha128Over-8 23.1µs ± 0% 24.2µs ± 1% +5.08% (p=0.000 n=9+10) GlyphAlpha128Src-8 16.8µs ± 0% 18.0µs ± 1% +6.76% (p=0.000 n=10+10) GlyphAlpha256Over-8 68.6µs ± 1% 70.3µs ± 0% +2.50% (p=0.000 n=10+10) GlyphAlpha256Src-8 43.6µs ± 0% 45.4µs ± 0% +4.08% (p=0.000 n=10+8) GlyphRGBA16Over-8 4.92µs ± 0% 5.14µs ± 0% +4.48% (p=0.000 n=9+9) GlyphRGBA16Src-8 4.39µs ± 0% 4.59µs ± 0% +4.60% (p=0.000 n=8+9) GlyphRGBA32Over-8 11.8µs ± 0% 12.2µs ± 1% +2.89% (p=0.000 n=9+10) GlyphRGBA32Src-8 9.79µs ± 1% 10.03µs ± 0% +2.49% (p=0.000 n=10+7) GlyphRGBA64Over-8 36.7µs ± 1% 37.5µs ± 1% +2.23% (p=0.000 n=10+10) GlyphRGBA64Src-8 28.5µs ± 0% 29.1µs ± 0% +2.09% (p=0.000 n=10+10) GlyphRGBA128Over-8 133µs ± 0% 135µs ± 0% +1.51% (p=0.000 n=10+9) GlyphRGBA128Src-8 99.1µs ± 0% 100.5µs ± 1% +1.47% (p=0.000 n=9+10) GlyphRGBA256Over-8 505µs ± 0% 511µs ± 0% +1.18% (p=0.000 n=9+10) GlyphRGBA256Src-8 372µs ± 0% 374µs ± 0% +0.69% (p=0.000 n=9+10) Change-Id: Ice1d77de5bc2649f8cd88366bcae3c00e78d65c2 Reviewed-on: https://go-review.googlesource.com/31113 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-14 08:12:05 +02:00
d := dy * dir // d ranges up to ±1<<(1*ϕ).
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
x0, x1 := x, xNext
if x > xNext {
x0, x1 = x1, x0
}
x0i := fixedFloor(x0)
x0Floor := int1ϕ(x0i) << ϕ
x1i := fixedCeil(x1)
x1Ceil := int1ϕ(x1i) << ϕ
if x1i <= x0i+1 {
xmf := (x+xNext)>>1 - x0Floor
if i := clamp(x0i+0, width); i < uint(len(buf)) {
buf[i] += uint32(d * (fxOne - xmf))
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
}
if i := clamp(x0i+1, width); i < uint(len(buf)) {
buf[i] += uint32(d * xmf)
}
} else {
oneOverS := x1 - x0
twoOverS := 2 * oneOverS
x0f := x0 - x0Floor
oneMinusX0f := fxOne - x0f
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
oneMinusX0fSquared := oneMinusX0f * oneMinusX0f
x1f := x1 - x1Ceil + fxOne
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
x1fSquared := x1f * x1f
// These next two variables are unused, as rounding errors are
// minimized when we delay the division by oneOverS for as long as
// possible. These lines of code (and the "In ideal math" comments
// below) are commented out instead of deleted in order to aid the
// comparison with the floating point version of the rasterizer.
//
// a0 := ((oneMinusX0f * oneMinusX0f) >> 1) / oneOverS
// am := ((x1f * x1f) >> 1) / oneOverS
if i := clamp(x0i, width); i < uint(len(buf)) {
// In ideal math: buf[i] += uint32(d * a0)
D := oneMinusX0fSquared // D ranges up to ±1<<(2*ϕ).
D *= d // D ranges up to ±1<<(3*ϕ).
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
D /= twoOverS
buf[i] += uint32(D)
}
if x1i == x0i+2 {
if i := clamp(x0i+1, width); i < uint(len(buf)) {
// In ideal math: buf[i] += uint32(d * (fxOne - a0 - am))
vector: fix overflow when rasterizing a 30 degree line. There are some obvious TODOs, but they will be follow-up commits. This is about correctness, not performance, but for the record: name old time/op new time/op delta GlyphAlpha16Over-8 3.16µs ± 0% 3.38µs ± 0% +6.96% (p=0.000 n=9+10) GlyphAlpha16Src-8 3.06µs ± 0% 3.28µs ± 0% +7.21% (p=0.000 n=10+10) GlyphAlpha32Over-8 4.92µs ± 1% 5.23µs ± 1% +6.24% (p=0.000 n=10+10) GlyphAlpha32Src-8 4.53µs ± 1% 4.83µs ± 0% +6.69% (p=0.000 n=10+10) GlyphAlpha64Over-8 9.60µs ± 1% 10.21µs ± 0% +6.36% (p=0.000 n=10+10) GlyphAlpha64Src-8 8.04µs ± 0% 8.68µs ± 1% +7.99% (p=0.000 n=9+10) GlyphAlpha128Over-8 23.1µs ± 0% 24.2µs ± 1% +5.08% (p=0.000 n=9+10) GlyphAlpha128Src-8 16.8µs ± 0% 18.0µs ± 1% +6.76% (p=0.000 n=10+10) GlyphAlpha256Over-8 68.6µs ± 1% 70.3µs ± 0% +2.50% (p=0.000 n=10+10) GlyphAlpha256Src-8 43.6µs ± 0% 45.4µs ± 0% +4.08% (p=0.000 n=10+8) GlyphRGBA16Over-8 4.92µs ± 0% 5.14µs ± 0% +4.48% (p=0.000 n=9+9) GlyphRGBA16Src-8 4.39µs ± 0% 4.59µs ± 0% +4.60% (p=0.000 n=8+9) GlyphRGBA32Over-8 11.8µs ± 0% 12.2µs ± 1% +2.89% (p=0.000 n=9+10) GlyphRGBA32Src-8 9.79µs ± 1% 10.03µs ± 0% +2.49% (p=0.000 n=10+7) GlyphRGBA64Over-8 36.7µs ± 1% 37.5µs ± 1% +2.23% (p=0.000 n=10+10) GlyphRGBA64Src-8 28.5µs ± 0% 29.1µs ± 0% +2.09% (p=0.000 n=10+10) GlyphRGBA128Over-8 133µs ± 0% 135µs ± 0% +1.51% (p=0.000 n=10+9) GlyphRGBA128Src-8 99.1µs ± 0% 100.5µs ± 1% +1.47% (p=0.000 n=9+10) GlyphRGBA256Over-8 505µs ± 0% 511µs ± 0% +1.18% (p=0.000 n=9+10) GlyphRGBA256Src-8 372µs ± 0% 374µs ± 0% +0.69% (p=0.000 n=9+10) Change-Id: Ice1d77de5bc2649f8cd88366bcae3c00e78d65c2 Reviewed-on: https://go-review.googlesource.com/31113 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-14 08:12:05 +02:00
//
// (x1i == x0i+2) and (twoOverS == 2 * (x1 - x0)) implies
vector: change ϕ from 10 to 9. This slight loss in quality allows us to use int32 math exclusively throughout raster_fixed.go, instead of occasionally dropping into int64 math. The change in ϕ doesn't affect the benchmarks noticably, but staying in int32 does. The net effect: name old time/op new time/op delta GlyphAlpha16Over-8 3.36µs ± 0% 2.99µs ± 0% -10.89% (p=0.000 n=10+9) GlyphAlpha16Src-8 3.26µs ± 0% 2.89µs ± 1% -11.34% (p=0.000 n=9+10) GlyphAlpha32Over-8 5.20µs ± 0% 4.53µs ± 0% -12.76% (p=0.000 n=8+10) GlyphAlpha32Src-8 4.81µs ± 1% 4.14µs ± 0% -13.91% (p=0.000 n=9+9) GlyphAlpha64Over-8 10.2µs ± 0% 9.0µs ± 1% -11.99% (p=0.000 n=9+10) GlyphAlpha64Src-8 8.62µs ± 0% 7.42µs ± 1% -13.89% (p=0.000 n=9+10) GlyphAlpha128Over-8 24.1µs ± 0% 21.8µs ± 0% -9.32% (p=0.000 n=9+9) GlyphAlpha128Src-8 17.9µs ± 0% 15.6µs ± 0% -12.68% (p=0.000 n=9+10) GlyphAlpha256Over-8 70.1µs ± 0% 66.3µs ± 1% -5.44% (p=0.000 n=10+10) GlyphAlpha256Src-8 45.2µs ± 1% 41.2µs ± 1% -8.92% (p=0.000 n=10+10) GlyphRGBA16Over-8 5.12µs ± 0% 4.75µs ± 0% -7.15% (p=0.000 n=10+9) GlyphRGBA16Src-8 4.57µs ± 1% 4.20µs ± 0% -8.18% (p=0.000 n=9+8) GlyphRGBA32Over-8 12.1µs ± 0% 11.4µs ± 0% -5.50% (p=0.000 n=10+9) GlyphRGBA32Src-8 10.0µs ± 0% 9.3µs ± 1% -6.80% (p=0.000 n=10+9) GlyphRGBA64Over-8 37.2µs ± 0% 36.0µs ± 0% -3.17% (p=0.000 n=9+8) GlyphRGBA64Src-8 29.0µs ± 1% 27.9µs ± 1% -4.05% (p=0.000 n=9+10) GlyphRGBA128Over-8 134µs ± 1% 131µs ± 0% -1.85% (p=0.000 n=9+9) GlyphRGBA128Src-8 100µs ± 1% 98µs ± 0% -2.27% (p=0.000 n=10+9) GlyphRGBA256Over-8 506µs ± 0% 503µs ± 0% -0.56% (p=0.000 n=10+8) GlyphRGBA256Src-8 373µs ± 0% 370µs ± 0% -1.01% (p=0.000 n=10+9) Change-Id: Ie02afac6fd6fa95f090bf3fe0a5c744799ea9dc5 Reviewed-on: https://go-review.googlesource.com/31532 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-20 01:34:23 +02:00
// that twoOverS ranges up to +1<<(1*ϕ+2).
D := twoOverS<<ϕ - oneMinusX0fSquared - x1fSquared // D ranges up to ±1<<(2*ϕ+2).
D *= d // D ranges up to ±1<<(3*ϕ+2).
D /= twoOverS
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
buf[i] += uint32(D)
}
} else {
// This is commented out for the same reason as a0 and am.
//
// a1 := ((fxOneAndAHalf - x0f) << ϕ) / oneOverS
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
if i := clamp(x0i+1, width); i < uint(len(buf)) {
vector: fix overflow when rasterizing a 30 degree line. There are some obvious TODOs, but they will be follow-up commits. This is about correctness, not performance, but for the record: name old time/op new time/op delta GlyphAlpha16Over-8 3.16µs ± 0% 3.38µs ± 0% +6.96% (p=0.000 n=9+10) GlyphAlpha16Src-8 3.06µs ± 0% 3.28µs ± 0% +7.21% (p=0.000 n=10+10) GlyphAlpha32Over-8 4.92µs ± 1% 5.23µs ± 1% +6.24% (p=0.000 n=10+10) GlyphAlpha32Src-8 4.53µs ± 1% 4.83µs ± 0% +6.69% (p=0.000 n=10+10) GlyphAlpha64Over-8 9.60µs ± 1% 10.21µs ± 0% +6.36% (p=0.000 n=10+10) GlyphAlpha64Src-8 8.04µs ± 0% 8.68µs ± 1% +7.99% (p=0.000 n=9+10) GlyphAlpha128Over-8 23.1µs ± 0% 24.2µs ± 1% +5.08% (p=0.000 n=9+10) GlyphAlpha128Src-8 16.8µs ± 0% 18.0µs ± 1% +6.76% (p=0.000 n=10+10) GlyphAlpha256Over-8 68.6µs ± 1% 70.3µs ± 0% +2.50% (p=0.000 n=10+10) GlyphAlpha256Src-8 43.6µs ± 0% 45.4µs ± 0% +4.08% (p=0.000 n=10+8) GlyphRGBA16Over-8 4.92µs ± 0% 5.14µs ± 0% +4.48% (p=0.000 n=9+9) GlyphRGBA16Src-8 4.39µs ± 0% 4.59µs ± 0% +4.60% (p=0.000 n=8+9) GlyphRGBA32Over-8 11.8µs ± 0% 12.2µs ± 1% +2.89% (p=0.000 n=9+10) GlyphRGBA32Src-8 9.79µs ± 1% 10.03µs ± 0% +2.49% (p=0.000 n=10+7) GlyphRGBA64Over-8 36.7µs ± 1% 37.5µs ± 1% +2.23% (p=0.000 n=10+10) GlyphRGBA64Src-8 28.5µs ± 0% 29.1µs ± 0% +2.09% (p=0.000 n=10+10) GlyphRGBA128Over-8 133µs ± 0% 135µs ± 0% +1.51% (p=0.000 n=10+9) GlyphRGBA128Src-8 99.1µs ± 0% 100.5µs ± 1% +1.47% (p=0.000 n=9+10) GlyphRGBA256Over-8 505µs ± 0% 511µs ± 0% +1.18% (p=0.000 n=9+10) GlyphRGBA256Src-8 372µs ± 0% 374µs ± 0% +0.69% (p=0.000 n=9+10) Change-Id: Ice1d77de5bc2649f8cd88366bcae3c00e78d65c2 Reviewed-on: https://go-review.googlesource.com/31113 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-14 08:12:05 +02:00
// In ideal math:
// buf[i] += uint32(d * (a1 - a0))
// or equivalently (but better in non-ideal, integer math,
// with respect to rounding errors),
// buf[i] += uint32(A * d / twoOverS)
// where
// A = (a1 - a0) * twoOverS
// = a1*twoOverS - a0*twoOverS
// Noting that twoOverS/oneOverS equals 2, substituting for
// a0 and then a1, given above, yields:
// A = a1*twoOverS - oneMinusX0fSquared
// = (fxOneAndAHalf-x0f)<<(ϕ+1) - oneMinusX0fSquared
// = fxOneAndAHalf<<(ϕ+1) - x0f<<(ϕ+1) - oneMinusX0fSquared
//
// This is a positive number minus two non-negative
// numbers. For an upper bound on A, the positive number is
// P = fxOneAndAHalf<<(ϕ+1)
// < (2*fxOne)<<(ϕ+1)
// = fxOne<<(ϕ+2)
// = 1<<(2*ϕ+2)
//
// For a lower bound on A, the two non-negative numbers are
// N = x0f<<(ϕ+1) + oneMinusX0fSquared
// ≤ x0f<<(ϕ+1) + fxOne*fxOne
// = x0f<<(ϕ+1) + 1<<(2*ϕ)
// < x0f<<(ϕ+1) + 1<<(2*ϕ+1)
// ≤ fxOne<<(ϕ+1) + 1<<(2*ϕ+1)
// = 1<<(2*ϕ+1) + 1<<(2*ϕ+1)
// = 1<<(2*ϕ+2)
//
// Thus, A ranges up to ±1<<(2*ϕ+2). It is possible to
// derive a tighter bound, but this bound is sufficient to
// reason about overflow.
vector: change ϕ from 10 to 9. This slight loss in quality allows us to use int32 math exclusively throughout raster_fixed.go, instead of occasionally dropping into int64 math. The change in ϕ doesn't affect the benchmarks noticably, but staying in int32 does. The net effect: name old time/op new time/op delta GlyphAlpha16Over-8 3.36µs ± 0% 2.99µs ± 0% -10.89% (p=0.000 n=10+9) GlyphAlpha16Src-8 3.26µs ± 0% 2.89µs ± 1% -11.34% (p=0.000 n=9+10) GlyphAlpha32Over-8 5.20µs ± 0% 4.53µs ± 0% -12.76% (p=0.000 n=8+10) GlyphAlpha32Src-8 4.81µs ± 1% 4.14µs ± 0% -13.91% (p=0.000 n=9+9) GlyphAlpha64Over-8 10.2µs ± 0% 9.0µs ± 1% -11.99% (p=0.000 n=9+10) GlyphAlpha64Src-8 8.62µs ± 0% 7.42µs ± 1% -13.89% (p=0.000 n=9+10) GlyphAlpha128Over-8 24.1µs ± 0% 21.8µs ± 0% -9.32% (p=0.000 n=9+9) GlyphAlpha128Src-8 17.9µs ± 0% 15.6µs ± 0% -12.68% (p=0.000 n=9+10) GlyphAlpha256Over-8 70.1µs ± 0% 66.3µs ± 1% -5.44% (p=0.000 n=10+10) GlyphAlpha256Src-8 45.2µs ± 1% 41.2µs ± 1% -8.92% (p=0.000 n=10+10) GlyphRGBA16Over-8 5.12µs ± 0% 4.75µs ± 0% -7.15% (p=0.000 n=10+9) GlyphRGBA16Src-8 4.57µs ± 1% 4.20µs ± 0% -8.18% (p=0.000 n=9+8) GlyphRGBA32Over-8 12.1µs ± 0% 11.4µs ± 0% -5.50% (p=0.000 n=10+9) GlyphRGBA32Src-8 10.0µs ± 0% 9.3µs ± 1% -6.80% (p=0.000 n=10+9) GlyphRGBA64Over-8 37.2µs ± 0% 36.0µs ± 0% -3.17% (p=0.000 n=9+8) GlyphRGBA64Src-8 29.0µs ± 1% 27.9µs ± 1% -4.05% (p=0.000 n=9+10) GlyphRGBA128Over-8 134µs ± 1% 131µs ± 0% -1.85% (p=0.000 n=9+9) GlyphRGBA128Src-8 100µs ± 1% 98µs ± 0% -2.27% (p=0.000 n=10+9) GlyphRGBA256Over-8 506µs ± 0% 503µs ± 0% -0.56% (p=0.000 n=10+8) GlyphRGBA256Src-8 373µs ± 0% 370µs ± 0% -1.01% (p=0.000 n=10+9) Change-Id: Ie02afac6fd6fa95f090bf3fe0a5c744799ea9dc5 Reviewed-on: https://go-review.googlesource.com/31532 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-20 01:34:23 +02:00
D := (fxOneAndAHalf-x0f)<<(ϕ+1) - oneMinusX0fSquared // D ranges up to ±1<<(2*ϕ+2).
D *= d // D ranges up to ±1<<(3*ϕ+2).
D /= twoOverS
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
buf[i] += uint32(D)
}
dTimesS := uint32((d << (2 * ϕ)) / oneOverS)
for xi := x0i + 2; xi < x1i-1; xi++ {
if i := clamp(xi, width); i < uint(len(buf)) {
buf[i] += dTimesS
}
}
// This is commented out for the same reason as a0 and am.
//
// a2 := a1 + (int1ϕ(x1i-x0i-3)<<(2*ϕ))/oneOverS
if i := clamp(x1i-1, width); i < uint(len(buf)) {
vector: fix overflow when rasterizing a 30 degree line. There are some obvious TODOs, but they will be follow-up commits. This is about correctness, not performance, but for the record: name old time/op new time/op delta GlyphAlpha16Over-8 3.16µs ± 0% 3.38µs ± 0% +6.96% (p=0.000 n=9+10) GlyphAlpha16Src-8 3.06µs ± 0% 3.28µs ± 0% +7.21% (p=0.000 n=10+10) GlyphAlpha32Over-8 4.92µs ± 1% 5.23µs ± 1% +6.24% (p=0.000 n=10+10) GlyphAlpha32Src-8 4.53µs ± 1% 4.83µs ± 0% +6.69% (p=0.000 n=10+10) GlyphAlpha64Over-8 9.60µs ± 1% 10.21µs ± 0% +6.36% (p=0.000 n=10+10) GlyphAlpha64Src-8 8.04µs ± 0% 8.68µs ± 1% +7.99% (p=0.000 n=9+10) GlyphAlpha128Over-8 23.1µs ± 0% 24.2µs ± 1% +5.08% (p=0.000 n=9+10) GlyphAlpha128Src-8 16.8µs ± 0% 18.0µs ± 1% +6.76% (p=0.000 n=10+10) GlyphAlpha256Over-8 68.6µs ± 1% 70.3µs ± 0% +2.50% (p=0.000 n=10+10) GlyphAlpha256Src-8 43.6µs ± 0% 45.4µs ± 0% +4.08% (p=0.000 n=10+8) GlyphRGBA16Over-8 4.92µs ± 0% 5.14µs ± 0% +4.48% (p=0.000 n=9+9) GlyphRGBA16Src-8 4.39µs ± 0% 4.59µs ± 0% +4.60% (p=0.000 n=8+9) GlyphRGBA32Over-8 11.8µs ± 0% 12.2µs ± 1% +2.89% (p=0.000 n=9+10) GlyphRGBA32Src-8 9.79µs ± 1% 10.03µs ± 0% +2.49% (p=0.000 n=10+7) GlyphRGBA64Over-8 36.7µs ± 1% 37.5µs ± 1% +2.23% (p=0.000 n=10+10) GlyphRGBA64Src-8 28.5µs ± 0% 29.1µs ± 0% +2.09% (p=0.000 n=10+10) GlyphRGBA128Over-8 133µs ± 0% 135µs ± 0% +1.51% (p=0.000 n=10+9) GlyphRGBA128Src-8 99.1µs ± 0% 100.5µs ± 1% +1.47% (p=0.000 n=9+10) GlyphRGBA256Over-8 505µs ± 0% 511µs ± 0% +1.18% (p=0.000 n=9+10) GlyphRGBA256Src-8 372µs ± 0% 374µs ± 0% +0.69% (p=0.000 n=9+10) Change-Id: Ice1d77de5bc2649f8cd88366bcae3c00e78d65c2 Reviewed-on: https://go-review.googlesource.com/31113 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-14 08:12:05 +02:00
// In ideal math:
// buf[i] += uint32(d * (fxOne - a2 - am))
// or equivalently (but better in non-ideal, integer math,
// with respect to rounding errors),
// buf[i] += uint32(A * d / twoOverS)
// where
// A = (fxOne - a2 - am) * twoOverS
// = twoOverS<<ϕ - a2*twoOverS - am*twoOverS
// Noting that twoOverS/oneOverS equals 2, substituting for
// am and then a2, given above, yields:
// A = twoOverS<<ϕ - a2*twoOverS - x1f*x1f
// = twoOverS<<ϕ - a1*twoOverS - (int1ϕ(x1i-x0i-3)<<(2*ϕ))*2 - x1f*x1f
// = twoOverS<<ϕ - a1*twoOverS - int1ϕ(x1i-x0i-3)<<(2*ϕ+1) - x1f*x1f
// Substituting for a1, given above, yields:
vector: simplify fixedLineTo computation. name old time/op new time/op delta GlyphAlpha16Over-8 3.38µs ± 0% 3.36µs ± 0% -0.54% (p=0.000 n=10+10) GlyphAlpha16Src-8 3.28µs ± 0% 3.26µs ± 0% -0.69% (p=0.000 n=10+9) GlyphAlpha32Over-8 5.23µs ± 1% 5.20µs ± 0% -0.58% (p=0.000 n=10+8) GlyphAlpha32Src-8 4.83µs ± 0% 4.81µs ± 1% -0.46% (p=0.001 n=10+9) GlyphAlpha64Over-8 10.2µs ± 0% 10.2µs ± 0% -0.21% (p=0.003 n=10+9) GlyphAlpha64Src-8 8.68µs ± 1% 8.62µs ± 0% -0.70% (p=0.000 n=10+9) GlyphAlpha128Over-8 24.2µs ± 1% 24.1µs ± 0% -0.58% (p=0.001 n=10+9) GlyphAlpha128Src-8 18.0µs ± 1% 17.9µs ± 0% -0.61% (p=0.001 n=10+9) GlyphAlpha256Over-8 70.3µs ± 0% 70.1µs ± 0% -0.37% (p=0.019 n=10+10) GlyphAlpha256Src-8 45.4µs ± 0% 45.2µs ± 1% -0.38% (p=0.041 n=8+10) GlyphRGBA16Over-8 5.14µs ± 0% 5.12µs ± 0% -0.43% (p=0.000 n=9+10) GlyphRGBA16Src-8 4.59µs ± 0% 4.57µs ± 1% -0.43% (p=0.005 n=9+9) GlyphRGBA32Over-8 12.2µs ± 1% 12.1µs ± 0% -0.70% (p=0.000 n=10+10) GlyphRGBA32Src-8 10.0µs ± 0% 10.0µs ± 0% ~ (p=0.092 n=7+10) GlyphRGBA64Over-8 37.5µs ± 1% 37.2µs ± 0% -0.75% (p=0.000 n=10+9) GlyphRGBA64Src-8 29.1µs ± 0% 29.0µs ± 1% ~ (p=0.243 n=10+9) GlyphRGBA128Over-8 135µs ± 0% 134µs ± 1% -0.72% (p=0.000 n=9+9) GlyphRGBA128Src-8 101µs ± 1% 100µs ± 1% ~ (p=0.197 n=10+10) GlyphRGBA256Over-8 511µs ± 0% 506µs ± 0% -0.97% (p=0.000 n=10+10) GlyphRGBA256Src-8 374µs ± 0% 373µs ± 0% -0.29% (p=0.002 n=10+10) Change-Id: Ic05a900935cb59e55711374db1e62b055d75c8e3 Reviewed-on: https://go-review.googlesource.com/31116 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-15 04:23:35 +02:00
// A = twoOverS<<ϕ - ((fxOneAndAHalf-x0f)<<ϕ)*2 - int1ϕ(x1i-x0i-3)<<(2*ϕ+1) - x1f*x1f
// = twoOverS<<ϕ - (fxOneAndAHalf-x0f)<<(ϕ+1) - int1ϕ(x1i-x0i-3)<<(2*ϕ+1) - x1f*x1f
// = B<<ϕ - x1f*x1f
vector: fix overflow when rasterizing a 30 degree line. There are some obvious TODOs, but they will be follow-up commits. This is about correctness, not performance, but for the record: name old time/op new time/op delta GlyphAlpha16Over-8 3.16µs ± 0% 3.38µs ± 0% +6.96% (p=0.000 n=9+10) GlyphAlpha16Src-8 3.06µs ± 0% 3.28µs ± 0% +7.21% (p=0.000 n=10+10) GlyphAlpha32Over-8 4.92µs ± 1% 5.23µs ± 1% +6.24% (p=0.000 n=10+10) GlyphAlpha32Src-8 4.53µs ± 1% 4.83µs ± 0% +6.69% (p=0.000 n=10+10) GlyphAlpha64Over-8 9.60µs ± 1% 10.21µs ± 0% +6.36% (p=0.000 n=10+10) GlyphAlpha64Src-8 8.04µs ± 0% 8.68µs ± 1% +7.99% (p=0.000 n=9+10) GlyphAlpha128Over-8 23.1µs ± 0% 24.2µs ± 1% +5.08% (p=0.000 n=9+10) GlyphAlpha128Src-8 16.8µs ± 0% 18.0µs ± 1% +6.76% (p=0.000 n=10+10) GlyphAlpha256Over-8 68.6µs ± 1% 70.3µs ± 0% +2.50% (p=0.000 n=10+10) GlyphAlpha256Src-8 43.6µs ± 0% 45.4µs ± 0% +4.08% (p=0.000 n=10+8) GlyphRGBA16Over-8 4.92µs ± 0% 5.14µs ± 0% +4.48% (p=0.000 n=9+9) GlyphRGBA16Src-8 4.39µs ± 0% 4.59µs ± 0% +4.60% (p=0.000 n=8+9) GlyphRGBA32Over-8 11.8µs ± 0% 12.2µs ± 1% +2.89% (p=0.000 n=9+10) GlyphRGBA32Src-8 9.79µs ± 1% 10.03µs ± 0% +2.49% (p=0.000 n=10+7) GlyphRGBA64Over-8 36.7µs ± 1% 37.5µs ± 1% +2.23% (p=0.000 n=10+10) GlyphRGBA64Src-8 28.5µs ± 0% 29.1µs ± 0% +2.09% (p=0.000 n=10+10) GlyphRGBA128Over-8 133µs ± 0% 135µs ± 0% +1.51% (p=0.000 n=10+9) GlyphRGBA128Src-8 99.1µs ± 0% 100.5µs ± 1% +1.47% (p=0.000 n=9+10) GlyphRGBA256Over-8 505µs ± 0% 511µs ± 0% +1.18% (p=0.000 n=9+10) GlyphRGBA256Src-8 372µs ± 0% 374µs ± 0% +0.69% (p=0.000 n=9+10) Change-Id: Ice1d77de5bc2649f8cd88366bcae3c00e78d65c2 Reviewed-on: https://go-review.googlesource.com/31113 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-14 08:12:05 +02:00
// where
vector: simplify fixedLineTo computation. name old time/op new time/op delta GlyphAlpha16Over-8 3.38µs ± 0% 3.36µs ± 0% -0.54% (p=0.000 n=10+10) GlyphAlpha16Src-8 3.28µs ± 0% 3.26µs ± 0% -0.69% (p=0.000 n=10+9) GlyphAlpha32Over-8 5.23µs ± 1% 5.20µs ± 0% -0.58% (p=0.000 n=10+8) GlyphAlpha32Src-8 4.83µs ± 0% 4.81µs ± 1% -0.46% (p=0.001 n=10+9) GlyphAlpha64Over-8 10.2µs ± 0% 10.2µs ± 0% -0.21% (p=0.003 n=10+9) GlyphAlpha64Src-8 8.68µs ± 1% 8.62µs ± 0% -0.70% (p=0.000 n=10+9) GlyphAlpha128Over-8 24.2µs ± 1% 24.1µs ± 0% -0.58% (p=0.001 n=10+9) GlyphAlpha128Src-8 18.0µs ± 1% 17.9µs ± 0% -0.61% (p=0.001 n=10+9) GlyphAlpha256Over-8 70.3µs ± 0% 70.1µs ± 0% -0.37% (p=0.019 n=10+10) GlyphAlpha256Src-8 45.4µs ± 0% 45.2µs ± 1% -0.38% (p=0.041 n=8+10) GlyphRGBA16Over-8 5.14µs ± 0% 5.12µs ± 0% -0.43% (p=0.000 n=9+10) GlyphRGBA16Src-8 4.59µs ± 0% 4.57µs ± 1% -0.43% (p=0.005 n=9+9) GlyphRGBA32Over-8 12.2µs ± 1% 12.1µs ± 0% -0.70% (p=0.000 n=10+10) GlyphRGBA32Src-8 10.0µs ± 0% 10.0µs ± 0% ~ (p=0.092 n=7+10) GlyphRGBA64Over-8 37.5µs ± 1% 37.2µs ± 0% -0.75% (p=0.000 n=10+9) GlyphRGBA64Src-8 29.1µs ± 0% 29.0µs ± 1% ~ (p=0.243 n=10+9) GlyphRGBA128Over-8 135µs ± 0% 134µs ± 1% -0.72% (p=0.000 n=9+9) GlyphRGBA128Src-8 101µs ± 1% 100µs ± 1% ~ (p=0.197 n=10+10) GlyphRGBA256Over-8 511µs ± 0% 506µs ± 0% -0.97% (p=0.000 n=10+10) GlyphRGBA256Src-8 374µs ± 0% 373µs ± 0% -0.29% (p=0.002 n=10+10) Change-Id: Ic05a900935cb59e55711374db1e62b055d75c8e3 Reviewed-on: https://go-review.googlesource.com/31116 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-15 04:23:35 +02:00
// B = twoOverS - (fxOneAndAHalf-x0f)<<1 - int1ϕ(x1i-x0i-3)<<(ϕ+1)
// = (x1-x0)<<1 - (fxOneAndAHalf-x0f)<<1 - int1ϕ(x1i-x0i-3)<<(ϕ+1)
//
// Re-arranging the defintions given above:
// x0Floor := int1ϕ(x0i) << ϕ
// x0f := x0 - x0Floor
// x1Ceil := int1ϕ(x1i) << ϕ
// x1f := x1 - x1Ceil + fxOne
// combined with fxOne = 1<<ϕ yields:
// x0 = x0f + int1ϕ(x0i)<<ϕ
// x1 = x1f + int1ϕ(x1i-1)<<ϕ
// so that expanding (x1-x0) yields:
// B = (x1f-x0f + int1ϕ(x1i-x0i-1)<<ϕ)<<1 - (fxOneAndAHalf-x0f)<<1 - int1ϕ(x1i-x0i-3)<<(ϕ+1)
// = (x1f-x0f)<<1 + int1ϕ(x1i-x0i-1)<<(ϕ+1) - (fxOneAndAHalf-x0f)<<1 - int1ϕ(x1i-x0i-3)<<(ϕ+1)
// A large part of the second and fourth terms cancel:
// B = (x1f-x0f)<<1 - (fxOneAndAHalf-x0f)<<1 - int1ϕ(-2)<<(ϕ+1)
// = (x1f-x0f)<<1 - (fxOneAndAHalf-x0f)<<1 + 1<<(ϕ+2)
// = (x1f - fxOneAndAHalf)<<1 + 1<<(ϕ+2)
// The first term, (x1f - fxOneAndAHalf)<<1, is a negative
// number, bounded below by -fxOneAndAHalf<<1, which is
// greater than -fxOne<<2, or -1<<(ϕ+2). Thus, B ranges up
// to ±1<<(ϕ+2). One final simplification:
// B = x1f<<1 + (1<<(ϕ+2) - fxOneAndAHalf<<1)
const C = 1<<(ϕ+2) - fxOneAndAHalf<<1
vector: change ϕ from 10 to 9. This slight loss in quality allows us to use int32 math exclusively throughout raster_fixed.go, instead of occasionally dropping into int64 math. The change in ϕ doesn't affect the benchmarks noticably, but staying in int32 does. The net effect: name old time/op new time/op delta GlyphAlpha16Over-8 3.36µs ± 0% 2.99µs ± 0% -10.89% (p=0.000 n=10+9) GlyphAlpha16Src-8 3.26µs ± 0% 2.89µs ± 1% -11.34% (p=0.000 n=9+10) GlyphAlpha32Over-8 5.20µs ± 0% 4.53µs ± 0% -12.76% (p=0.000 n=8+10) GlyphAlpha32Src-8 4.81µs ± 1% 4.14µs ± 0% -13.91% (p=0.000 n=9+9) GlyphAlpha64Over-8 10.2µs ± 0% 9.0µs ± 1% -11.99% (p=0.000 n=9+10) GlyphAlpha64Src-8 8.62µs ± 0% 7.42µs ± 1% -13.89% (p=0.000 n=9+10) GlyphAlpha128Over-8 24.1µs ± 0% 21.8µs ± 0% -9.32% (p=0.000 n=9+9) GlyphAlpha128Src-8 17.9µs ± 0% 15.6µs ± 0% -12.68% (p=0.000 n=9+10) GlyphAlpha256Over-8 70.1µs ± 0% 66.3µs ± 1% -5.44% (p=0.000 n=10+10) GlyphAlpha256Src-8 45.2µs ± 1% 41.2µs ± 1% -8.92% (p=0.000 n=10+10) GlyphRGBA16Over-8 5.12µs ± 0% 4.75µs ± 0% -7.15% (p=0.000 n=10+9) GlyphRGBA16Src-8 4.57µs ± 1% 4.20µs ± 0% -8.18% (p=0.000 n=9+8) GlyphRGBA32Over-8 12.1µs ± 0% 11.4µs ± 0% -5.50% (p=0.000 n=10+9) GlyphRGBA32Src-8 10.0µs ± 0% 9.3µs ± 1% -6.80% (p=0.000 n=10+9) GlyphRGBA64Over-8 37.2µs ± 0% 36.0µs ± 0% -3.17% (p=0.000 n=9+8) GlyphRGBA64Src-8 29.0µs ± 1% 27.9µs ± 1% -4.05% (p=0.000 n=9+10) GlyphRGBA128Over-8 134µs ± 1% 131µs ± 0% -1.85% (p=0.000 n=9+9) GlyphRGBA128Src-8 100µs ± 1% 98µs ± 0% -2.27% (p=0.000 n=10+9) GlyphRGBA256Over-8 506µs ± 0% 503µs ± 0% -0.56% (p=0.000 n=10+8) GlyphRGBA256Src-8 373µs ± 0% 370µs ± 0% -1.01% (p=0.000 n=10+9) Change-Id: Ie02afac6fd6fa95f090bf3fe0a5c744799ea9dc5 Reviewed-on: https://go-review.googlesource.com/31532 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-20 01:34:23 +02:00
D := x1f<<1 + C // D ranges up to ±1<<(1*ϕ+2).
D <<= ϕ // D ranges up to ±1<<(2*ϕ+2).
D -= x1fSquared // D ranges up to ±1<<(2*ϕ+3).
D *= d // D ranges up to ±1<<(3*ϕ+3).
D /= twoOverS
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
buf[i] += uint32(D)
}
}
if i := clamp(x1i, width); i < uint(len(buf)) {
// In ideal math: buf[i] += uint32(d * am)
vector: fix overflow when rasterizing a 30 degree line. There are some obvious TODOs, but they will be follow-up commits. This is about correctness, not performance, but for the record: name old time/op new time/op delta GlyphAlpha16Over-8 3.16µs ± 0% 3.38µs ± 0% +6.96% (p=0.000 n=9+10) GlyphAlpha16Src-8 3.06µs ± 0% 3.28µs ± 0% +7.21% (p=0.000 n=10+10) GlyphAlpha32Over-8 4.92µs ± 1% 5.23µs ± 1% +6.24% (p=0.000 n=10+10) GlyphAlpha32Src-8 4.53µs ± 1% 4.83µs ± 0% +6.69% (p=0.000 n=10+10) GlyphAlpha64Over-8 9.60µs ± 1% 10.21µs ± 0% +6.36% (p=0.000 n=10+10) GlyphAlpha64Src-8 8.04µs ± 0% 8.68µs ± 1% +7.99% (p=0.000 n=9+10) GlyphAlpha128Over-8 23.1µs ± 0% 24.2µs ± 1% +5.08% (p=0.000 n=9+10) GlyphAlpha128Src-8 16.8µs ± 0% 18.0µs ± 1% +6.76% (p=0.000 n=10+10) GlyphAlpha256Over-8 68.6µs ± 1% 70.3µs ± 0% +2.50% (p=0.000 n=10+10) GlyphAlpha256Src-8 43.6µs ± 0% 45.4µs ± 0% +4.08% (p=0.000 n=10+8) GlyphRGBA16Over-8 4.92µs ± 0% 5.14µs ± 0% +4.48% (p=0.000 n=9+9) GlyphRGBA16Src-8 4.39µs ± 0% 4.59µs ± 0% +4.60% (p=0.000 n=8+9) GlyphRGBA32Over-8 11.8µs ± 0% 12.2µs ± 1% +2.89% (p=0.000 n=9+10) GlyphRGBA32Src-8 9.79µs ± 1% 10.03µs ± 0% +2.49% (p=0.000 n=10+7) GlyphRGBA64Over-8 36.7µs ± 1% 37.5µs ± 1% +2.23% (p=0.000 n=10+10) GlyphRGBA64Src-8 28.5µs ± 0% 29.1µs ± 0% +2.09% (p=0.000 n=10+10) GlyphRGBA128Over-8 133µs ± 0% 135µs ± 0% +1.51% (p=0.000 n=10+9) GlyphRGBA128Src-8 99.1µs ± 0% 100.5µs ± 1% +1.47% (p=0.000 n=9+10) GlyphRGBA256Over-8 505µs ± 0% 511µs ± 0% +1.18% (p=0.000 n=9+10) GlyphRGBA256Src-8 372µs ± 0% 374µs ± 0% +0.69% (p=0.000 n=9+10) Change-Id: Ice1d77de5bc2649f8cd88366bcae3c00e78d65c2 Reviewed-on: https://go-review.googlesource.com/31113 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-14 08:12:05 +02:00
D := x1fSquared // D ranges up to ±1<<(2*ϕ).
D *= d // D ranges up to ±1<<(3*ϕ).
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
D /= twoOverS
buf[i] += uint32(D)
}
}
x = xNext
}
}
func fixedAccumulateOpOver(dst []uint8, src []uint32) {
// Sanity check that len(dst) >= len(src).
if len(dst) < len(src) {
return
}
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
acc := int2ϕ(0)
for i, v := range src {
acc += int2ϕ(v)
a := acc
if a < 0 {
a = -a
}
a >>= 2*ϕ - 16
if a > 0xffff {
a = 0xffff
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
}
// This algorithm comes from the standard library's image/draw package.
dstA := uint32(dst[i]) * 0x101
maskA := uint32(a)
outA := dstA*(0xffff-maskA)/0xffff + maskA
dst[i] = uint8(outA >> 8)
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
}
}
func fixedAccumulateOpSrc(dst []uint8, src []uint32) {
// Sanity check that len(dst) >= len(src).
if len(dst) < len(src) {
return
}
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
acc := int2ϕ(0)
for i, v := range src {
acc += int2ϕ(v)
a := acc
if a < 0 {
a = -a
}
a >>= 2*ϕ - 8
if a > 0xff {
a = 0xff
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
}
dst[i] = uint8(a)
vector: add a fixed point math implementation. name old time/op new time/op delta GlyphAlpha16Over-8 4.48µs ± 1% 3.56µs ± 0% -20.70% (p=0.000 n=9+10) GlyphAlpha16Src-8 4.17µs ± 0% 3.38µs ± 1% -19.09% (p=0.000 n=10+10) GlyphAlpha32Over-8 9.03µs ± 0% 6.74µs ± 0% -25.33% (p=0.000 n=9+10) GlyphAlpha32Src-8 7.46µs ± 1% 5.98µs ± 0% -19.80% (p=0.000 n=10+9) GlyphAlpha64Over-8 21.3µs ± 0% 16.4µs ± 0% -22.84% (p=0.000 n=10+10) GlyphAlpha64Src-8 16.2µs ± 1% 13.1µs ± 0% -19.33% (p=0.000 n=10+10) GlyphAlpha128Over-8 59.8µs ± 0% 47.2µs ± 0% -21.11% (p=0.000 n=9+9) GlyphAlpha128Src-8 41.3µs ± 1% 33.0µs ± 0% -20.26% (p=0.000 n=9+10) GlyphAlpha256Over-8 197µs ± 0% 158µs ± 0% -19.44% (p=0.000 n=9+10) GlyphAlpha256Src-8 124µs ± 0% 98µs ± 0% -21.17% (p=0.000 n=9+9) GlyphAlphaLoose16Over-8 4.73µs ± 0% 3.97µs ± 1% -16.06% (p=0.000 n=10+10) GlyphAlphaLoose16Src-8 4.41µs ± 0% 3.64µs ± 1% -17.50% (p=0.000 n=10+10) GlyphAlphaLoose32Over-8 9.62µs ± 0% 8.47µs ± 0% -11.95% (p=0.000 n=10+10) GlyphAlphaLoose32Src-8 8.25µs ± 0% 7.19µs ± 0% -12.88% (p=0.000 n=9+9) GlyphAlphaLoose64Over-8 25.6µs ± 0% 22.2µs ± 0% -13.01% (p=0.000 n=9+9) GlyphAlphaLoose64Src-8 20.2µs ± 0% 17.2µs ± 1% -14.98% (p=0.000 n=10+10) GlyphAlphaLoose128Over-8 83.4µs ± 1% 68.2µs ± 0% -18.27% (p=0.000 n=10+10) GlyphAlphaLoose128Src-8 59.8µs ± 0% 47.4µs ± 0% -20.77% (p=0.000 n=10+9) GlyphAlphaLoose256Over-8 273µs ± 1% 239µs ± 0% -12.52% (p=0.000 n=10+9) GlyphAlphaLoose256Src-8 187µs ± 0% 155µs ± 1% -16.91% (p=0.000 n=9+10) GlyphRGBA16Over-8 5.99µs ± 0% 5.24µs ± 1% -12.60% (p=0.000 n=9+10) GlyphRGBA16Src-8 5.48µs ± 0% 4.68µs ± 0% -14.68% (p=0.000 n=9+10) GlyphRGBA32Over-8 14.6µs ± 0% 13.5µs ± 0% -7.60% (p=0.000 n=9+9) GlyphRGBA32Src-8 12.6µs ± 0% 11.4µs ± 0% -9.62% (p=0.000 n=9+9) GlyphRGBA64Over-8 44.8µs ± 0% 42.2µs ± 0% -5.69% (p=0.000 n=9+9) GlyphRGBA64Src-8 36.6µs ± 1% 33.5µs ± 1% -8.55% (p=0.000 n=9+9) GlyphRGBA128Over-8 162µs ± 0% 148µs ± 1% -8.85% (p=0.000 n=10+9) GlyphRGBA128Src-8 129µs ± 1% 114µs ± 0% -11.61% (p=0.000 n=9+10) GlyphRGBA256Over-8 588µs ± 0% 573µs ± 0% -2.53% (p=0.000 n=9+10) GlyphRGBA256Src-8 455µs ± 0% 426µs ± 1% -6.51% (p=0.000 n=9+10) GlyphNRGBA16Over-8 27.0µs ± 4% 26.3µs ± 2% -2.65% (p=0.001 n=9+10) GlyphNRGBA16Src-8 19.4µs ± 3% 18.6µs ± 1% -4.35% (p=0.000 n=9+10) GlyphNRGBA32Over-8 97.4µs ± 3% 96.8µs ± 2% ~ (p=0.447 n=9+10) GlyphNRGBA32Src-8 66.6µs ± 3% 64.5µs ± 1% -3.21% (p=0.000 n=10+9) GlyphNRGBA64Over-8 372µs ± 3% 368µs ± 1% ~ (p=0.105 n=10+10) GlyphNRGBA64Src-8 235µs ± 1% 234µs ± 1% ~ (p=0.130 n=8+8) GlyphNRGBA128Over-8 1.45ms ± 2% 1.48ms ± 3% +2.06% (p=0.014 n=9+9) GlyphNRGBA128Src-8 926µs ± 3% 937µs ± 1% ~ (p=0.113 n=10+9) GlyphNRGBA256Over-8 5.76ms ± 2% 5.90ms ± 3% +2.29% (p=0.001 n=9+10) GlyphNRGBA256Src-8 3.59ms ± 1% 3.86ms ± 1% +7.46% (p=0.000 n=9+10) Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf Reviewed-on: https://go-review.googlesource.com/29972 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-28 11:29:02 +02:00
}
}
func fixedAccumulateMask(buf []uint32) {
acc := int2ϕ(0)
for i, v := range buf {
acc += int2ϕ(v)
a := acc
if a < 0 {
a = -a
}
a >>= 2*ϕ - 16
if a > 0xffff {
a = 0xffff
}
buf[i] = uint32(a)
}
}