handle partition index differently
This commit is contained in:
parent
4afb0e58c4
commit
48c7db719e
1 changed files with 26 additions and 17 deletions
|
@ -44,7 +44,7 @@ type
|
||||||
Partition = object
|
Partition = object
|
||||||
entries: seq[PartitionEntry]
|
entries: seq[PartitionEntry]
|
||||||
requiresAntiAliasing: bool
|
requiresAntiAliasing: bool
|
||||||
bottom: int
|
top, bottom: int
|
||||||
|
|
||||||
Fixed32 = int32 ## 24.8 fixed point
|
Fixed32 = int32 ## 24.8 fixed point
|
||||||
|
|
||||||
|
@ -1131,6 +1131,18 @@ proc partitionSegments(
|
||||||
startY = top.uint32
|
startY = top.uint32
|
||||||
partitionHeight = height.uint32 div numPartitions
|
partitionHeight = height.uint32 div numPartitions
|
||||||
|
|
||||||
|
# Set the bottom values for the partitions (y value where this partition ends)
|
||||||
|
result[0].top = top
|
||||||
|
result[0].bottom = top + partitionHeight.int
|
||||||
|
for i in 1 ..< result.len:
|
||||||
|
result[i].top = result[i - 1].bottom
|
||||||
|
result[i].bottom = result[i - 1].bottom + 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[^1].bottom = top + height
|
||||||
|
|
||||||
var entries = newSeq[PartitionEntry](segments.len)
|
var entries = newSeq[PartitionEntry](segments.len)
|
||||||
for i, (segment, winding) in segments:
|
for i, (segment, winding) in segments:
|
||||||
entries[i] = initPartitionEntry(segment, winding)
|
entries[i] = initPartitionEntry(segment, winding)
|
||||||
|
@ -1166,18 +1178,8 @@ proc partitionSegments(
|
||||||
result[partitionIndex].entries[indexes[partitionIndex]] = entries[i]
|
result[partitionIndex].entries[indexes[partitionIndex]] = entries[i]
|
||||||
inc indexes[partitionIndex]
|
inc indexes[partitionIndex]
|
||||||
|
|
||||||
# Set the bottom values for the partitions (y value where this partition ends)
|
|
||||||
var partitionBottom = top + partitionHeight.int
|
|
||||||
for partition in result.mitems:
|
for partition in result.mitems:
|
||||||
partition.bottom = partitionBottom
|
partition.requiresAntiAliasing = requiresAntiAliasing(partition.entries)
|
||||||
partition.requiresAntiAliasing =
|
|
||||||
requiresAntiAliasing(partition.entries)
|
|
||||||
partitionBottom += 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[^1].bottom = top + height
|
|
||||||
|
|
||||||
proc maxEntryCount(partitions: var seq[Partition]): int =
|
proc maxEntryCount(partitions: var seq[Partition]): int =
|
||||||
for i in 0 ..< partitions.len:
|
for i in 0 ..< partitions.len:
|
||||||
|
@ -1273,12 +1275,9 @@ proc computeCoverage(
|
||||||
width: int,
|
width: int,
|
||||||
y, startX: int,
|
y, startX: int,
|
||||||
partitions: var seq[Partition],
|
partitions: var seq[Partition],
|
||||||
partitionIndex: var int,
|
partitionIndex: int,
|
||||||
windingRule: WindingRule
|
windingRule: WindingRule
|
||||||
) {.inline.} =
|
) {.inline.} =
|
||||||
if y >= partitions[partitionIndex].bottom:
|
|
||||||
inc partitionIndex
|
|
||||||
|
|
||||||
aa = partitions[partitionIndex].requiresAntiAliasing
|
aa = partitions[partitionIndex].requiresAntiAliasing
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -1823,7 +1822,11 @@ proc fillShapes(
|
||||||
numHits: int
|
numHits: int
|
||||||
aa: bool
|
aa: bool
|
||||||
|
|
||||||
for y in startY ..< pathHeight:
|
var y = startY
|
||||||
|
while y < pathHeight:
|
||||||
|
if y >= partitions[partitionIndex].bottom:
|
||||||
|
inc partitionIndex
|
||||||
|
|
||||||
computeCoverage(
|
computeCoverage(
|
||||||
cast[ptr UncheckedArray[uint8]](coverages[0].addr),
|
cast[ptr UncheckedArray[uint8]](coverages[0].addr),
|
||||||
hits,
|
hits,
|
||||||
|
@ -1836,6 +1839,7 @@ proc fillShapes(
|
||||||
partitionIndex,
|
partitionIndex,
|
||||||
windingRule
|
windingRule
|
||||||
)
|
)
|
||||||
|
|
||||||
if aa:
|
if aa:
|
||||||
image.fillCoverage(
|
image.fillCoverage(
|
||||||
rgbx,
|
rgbx,
|
||||||
|
@ -1856,6 +1860,8 @@ proc fillShapes(
|
||||||
blendMode
|
blendMode
|
||||||
)
|
)
|
||||||
|
|
||||||
|
inc y
|
||||||
|
|
||||||
if blendMode == MaskBlend:
|
if blendMode == MaskBlend:
|
||||||
image.clearUnsafe(0, 0, 0, startY)
|
image.clearUnsafe(0, 0, 0, startY)
|
||||||
image.clearUnsafe(0, pathHeight, 0, image.height)
|
image.clearUnsafe(0, pathHeight, 0, image.height)
|
||||||
|
@ -1895,6 +1901,9 @@ proc fillShapes(
|
||||||
aa: bool
|
aa: bool
|
||||||
|
|
||||||
for y in startY ..< pathHeight:
|
for y in startY ..< pathHeight:
|
||||||
|
if y >= partitions[partitionIndex].bottom:
|
||||||
|
inc partitionIndex
|
||||||
|
|
||||||
computeCoverage(
|
computeCoverage(
|
||||||
cast[ptr UncheckedArray[uint8]](coverages[0].addr),
|
cast[ptr UncheckedArray[uint8]](coverages[0].addr),
|
||||||
hits,
|
hits,
|
||||||
|
|
Loading…
Reference in a new issue