diff --git a/experiments/benchmark_cairo.nim b/experiments/benchmark_cairo.nim index 5e1acb9..ae352a8 100644 --- a/experiments/benchmark_cairo.nim +++ b/experiments/benchmark_cairo.nim @@ -175,9 +175,9 @@ block: # discard surface.writeToPng("cairo4.png") var a: Image - a = newImage(1000, 1000) + # a = newImage(1000, 1000) timeIt "pixie4": - # a = newImage(1000, 1000) + a = newImage(1000, 1000) let p = newPath() p.moveTo(shapes[0][0]) diff --git a/src/pixie/paths.nim b/src/pixie/paths.nim index 73c523d..8cfd4ec 100644 --- a/src/pixie/paths.nim +++ b/src/pixie/paths.nim @@ -1546,7 +1546,7 @@ proc fillHits( filledTo = fillStart + fillLen - if blendMode == bmNormal: + if blendMode == bmNormal or blendMode == bmOverwrite: fillUnsafe(mask.data, 255, mask.dataIndex(fillStart, y), fillLen) continue @@ -2454,13 +2454,16 @@ else: image.clearUnsafe(0, 0, 0, startY) image.clearUnsafe(0, pathHeight, 0, image.height) +proc fillMask*(path: SomePath, width, height: int): Mask = + result = newMask(width, height) + result.fillPath(path, blendMode = bmOverwrite) + proc fillImage*(path: SomePath, width, height: int, color: SomeColor): Image = result = newImage(width, height) - let mask = newMask(width, height) - mask.fillPath(path) - - let rgbx = color.rgbx() + let + mask = path.fillMask(width, height) + rgbx = color.rgbx() var i: int when defined(amd64) and not defined(pixieNoSimd):