y min, max when drawing optimization

This commit is contained in:
Ryan Oldenburg 2021-02-11 12:41:56 -06:00
parent a40683920d
commit 7e06625c27

View file

@ -620,12 +620,29 @@ proc drawUber(
smooth: bool
) =
let blender = blendMode.blender()
for y in 0 ..< a.height:
# Determine where we should start and stop drawing in the y dimension
var yMin, yMax: int
if blendMode == bmIntersectMask:
yMin = 0
yMax = a.height
else:
yMin = a.height
yMax = 0
for segment in perimeter:
yMin = min(yMin, segment.at.y.floor.int)
yMax = max(yMax, segment.at.y.ceil.int)
yMin = yMin.clamp(0, a.height)
yMax = yMax.clamp(0, a.height)
for y in yMin ..< yMax:
# Determine where we should start and stop drawing in the x dimension
var
xMin = a.width
xMax = 0
for yOffset in [0.float32, 1]:
var scanLine = Line(
let scanLine = Line(
a: vec2(-1000, y.float32 + yOffset),
b: vec2(1000, y.float32 + yOffset)
)