y min, max when drawing optimization
This commit is contained in:
parent
a40683920d
commit
7e06625c27
1 changed files with 19 additions and 2 deletions
|
@ -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)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue