Disable fill optimization for now.

This commit is contained in:
treeform 2022-01-30 12:15:13 -08:00
parent 3a590eea1e
commit 2da986d0fe
4 changed files with 50 additions and 29 deletions

View file

@ -595,7 +595,7 @@ proc getRgbaSmooth*(
topMix topMix
proc drawCorrect( proc drawCorrect(
a, b: Image | Mask, transform = mat3(), tiled = false, blendMode = bmNormal a, b: Image | Mask, transform = mat3(), blendMode = bmNormal, tiled = false
) {.raises: [PixieError].} = ) {.raises: [PixieError].} =
## Draws one image onto another using matrix with color blending. ## Draws one image onto another using matrix with color blending.
@ -792,15 +792,16 @@ proc drawUber(
sy = srcPos.y.int sy = srcPos.y.int
var sx = srcPos.x.int var sx = srcPos.x.int
when type(a) is Image and type(b) is Image: # TODO Fix
if blendMode in {bmNormal, bmOverwrite} and # when type(a) is Image and type(b) is Image:
isOpaque(b.data, b.dataIndex(xStart, y), xStop - xStart): # if blendMode in {bmNormal, bmOverwrite} and
copyMem( # isOpaque(b.data, b.dataIndex(sx, sy), xStop - sx):
a.data[a.dataIndex(x, y)].addr, # copyMem(
b.data[b.dataIndex(sx, sy)].addr, # a.data[a.dataIndex(x, y)].addr,
(xStop - xStart) * 4 # b.data[b.dataIndex(sx, sy)].addr,
) # (xStop - xStart) * 4
continue # )
# continue
when defined(amd64) and not defined(pixieNoSimd): when defined(amd64) and not defined(pixieNoSimd):
case blendMode: case blendMode:
@ -1142,7 +1143,7 @@ proc draw*(
proc drawTiled*( proc drawTiled*(
dst, src: Image, mat: Mat3, blendMode = bmNormal dst, src: Image, mat: Mat3, blendMode = bmNormal
) {.raises: [PixieError].} = ) {.raises: [PixieError].} =
dst.drawCorrect(src, mat, true, blendMode) dst.drawCorrect(src, mat, blendMode, true)
proc resize*(srcImage: Image, width, height: int): Image {.raises: [PixieError].} = proc resize*(srcImage: Image, width, height: int): Image {.raises: [PixieError].} =
## Resize an image to a given height and width. ## Resize an image to a given height and width.

View file

@ -139,25 +139,26 @@ proc toPremultipliedAlpha*(data: var seq[ColorRGBA | ColorRGBX]) {.raises: [].}
proc isOpaque*(data: var seq[ColorRGBX], start, len: int): bool = proc isOpaque*(data: var seq[ColorRGBX], start, len: int): bool =
result = true result = true
var i: int var i: int = start
when defined(amd64) and not defined(pixieNoSimd): # TODO FIX:
let # when defined(amd64) and not defined(pixieNoSimd):
vec255 = mm_set1_epi32(cast[int32](uint32.high)) # let
colorMask = mm_set1_epi32(cast[int32]([255.uint8, 255, 255, 0])) # vec255 = mm_set1_epi32(cast[int32](uint32.high))
for _ in 0 ..< len div 16: # colorMask = mm_set1_epi32(cast[int32]([255.uint8, 255, 255, 0]))
let # for _ in start div 16 ..< (start + len) div 16:
values0 = mm_loadu_si128(data[i + 0].addr) # let
values1 = mm_loadu_si128(data[i + 4].addr) # values0 = mm_loadu_si128(data[i + 0].addr)
values2 = mm_loadu_si128(data[i + 8].addr) # values1 = mm_loadu_si128(data[i + 4].addr)
values3 = mm_loadu_si128(data[i + 12].addr) # values2 = mm_loadu_si128(data[i + 8].addr)
values01 = mm_and_si128(values0, values1) # values3 = mm_loadu_si128(data[i + 12].addr)
values23 = mm_and_si128(values2, values3) # values01 = mm_and_si128(values0, values1)
values = mm_or_si128(mm_and_si128(values01, values23), colorMask) # values23 = mm_and_si128(values2, values3)
if mm_movemask_epi8(mm_cmpeq_epi8(values, vec255)) != 0xffff: # values = mm_or_si128(mm_and_si128(values01, values23), colorMask)
return false # if mm_movemask_epi8(mm_cmpeq_epi8(values, vec255)) != 0xffff:
i += 16 # return false
# i += 16
for j in i ..< len: for j in i ..< start + len:
if data[j].a != 255: if data[j].a != 255:
return false return false

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

View file

@ -1,5 +1,24 @@
import chroma, pixie, pixie/fileformats/png, strformat import chroma, pixie, pixie/fileformats/png, strformat
block:
let pathStr = """
M 0 0
L 20 0
L 20 20
L 0 20
z
"""
let
image = newImage(20, 20)
strokeImage = newImage(20, 20)
image.fillPath(pathStr, color(1.0, 0.5, 0.25, 1.0))
strokeImage.strokePath(pathStr, color(1, 1, 1, 1), strokeWidth = 4)
image.draw(strokeImage)
image.writeFile("tests/paths/fillOptimization.png")
doAssert image[10, 10] == rgbx(255, 127, 63, 255)
block: block:
let pathStr = """ let pathStr = """
m 1 2 3 4 5 6 m 1 2 3 4 5 6