partition heights can now vary

This commit is contained in:
Ryan Oldenburg 2022-06-22 02:02:08 -05:00
parent 82c7c8b864
commit a4fbb5365e

View file

@ -44,6 +44,7 @@ type
Partition = object Partition = object
entries: seq[PartitionEntry] entries: seq[PartitionEntry]
requiresAntiAliasing: bool requiresAntiAliasing: bool
bottom: int
Partitioning = object Partitioning = object
partitions: seq[Partition] partitions: seq[Partition]
@ -1147,9 +1148,20 @@ proc partitionSegments(
for i in atPartition .. toPartition: for i in atPartition .. toPartition:
result.partitions[i].entries.add(entry) result.partitions[i].entries.add(entry)
# Set the bottom values for the partitions (y value where this partition ends)
var partitionBottom = top + result.partitionHeight.int
for partition in result.partitions.mitems: for partition in result.partitions.mitems:
partition.bottom = partitionBottom
partition.requiresAntiAliasing = partition.requiresAntiAliasing =
requiresAntiAliasing(partition.entries) requiresAntiAliasing(partition.entries)
partitionBottom += result.partitionHeight.int
# Ensure the final partition goes to the actual bottom
# This is needed since the final partition includes
# height - (height div numPartitions) * numPartitions
result.partitions[^1].bottom = top + height
proc maxEntryCount(partitioning: var Partitioning): int = proc maxEntryCount(partitioning: var Partitioning): int =
for i in 0 ..< partitioning.partitions.len: for i in 0 ..< partitioning.partitions.len:
@ -1245,16 +1257,11 @@ proc computeCoverage(
width: int, width: int,
y, startX: int, y, startX: int,
partitioning: var Partitioning, partitioning: var Partitioning,
partitionIndex: var int,
windingRule: WindingRule windingRule: WindingRule
) {.inline.} = ) {.inline.} =
let partitionIndex = if y >= partitioning.partitions[partitionIndex].bottom:
if partitioning.partitions.len == 1: inc partitionIndex
0.uint32
else:
min(
(y.uint32 - partitioning.startY) div partitioning.partitionHeight,
partitioning.partitions.high.uint32
)
aa = partitioning.partitions[partitionIndex].requiresAntiAliasing aa = partitioning.partitions[partitionIndex].requiresAntiAliasing
@ -1794,6 +1801,7 @@ proc fillShapes(
var var
partitioning = partitionSegments(segments, startY, pathHeight - startY) partitioning = partitionSegments(segments, startY, pathHeight - startY)
partitionIndex: int
coverages = newSeq[uint8](pathWidth) coverages = newSeq[uint8](pathWidth)
hits = newSeq[(Fixed32, int16)](partitioning.maxEntryCount) hits = newSeq[(Fixed32, int16)](partitioning.maxEntryCount)
numHits: int numHits: int
@ -1809,6 +1817,7 @@ proc fillShapes(
y, y,
startX, startX,
partitioning, partitioning,
partitionIndex,
windingRule windingRule
) )
if aa: if aa:
@ -1863,6 +1872,7 @@ proc fillShapes(
var var
partitioning = partitionSegments(segments, startY, pathHeight) partitioning = partitionSegments(segments, startY, pathHeight)
partitionIndex: int
coverages = newSeq[uint8](pathWidth) coverages = newSeq[uint8](pathWidth)
hits = newSeq[(Fixed32, int16)](partitioning.maxEntryCount) hits = newSeq[(Fixed32, int16)](partitioning.maxEntryCount)
numHits: int numHits: int
@ -1878,6 +1888,7 @@ proc fillShapes(
y, y,
startX, startX,
partitioning, partitioning,
partitionIndex,
windingRule windingRule
) )
if aa: if aa: