Skip to content

Commit cd95095

Browse files
committed
karm-gfx: Fix clip aet not being sorted.
1 parent ae80c38 commit cd95095

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/karm-gfx/cpu/canvas.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ export struct CpuCanvas : Canvas {
267267
_poly.clear();
268268
createSolid(_poly, _path);
269269
_poly.transform(current().trans);
270+
_poly.sortForAet();
270271

271272
auto clipBound = _poly.bound().ceil().cast<isize>().clipTo(current().clip);
272273

@@ -275,7 +276,7 @@ export struct CpuCanvas : Canvas {
275276
current().clip = clipBound;
276277
_rast.fill(_poly, current().clip, rule, [&](CpuRast::Frag frag) {
277278
u8 const parentPixel = current().clipMask.has() ? current().clipMask.unwrap()->pixels().load(frag.xy - current().clipBound.xy).red : 255;
278-
newClipMask->mutPixels().store(frag.xy - clipBound.xy, Color::fromRgb(parentPixel * frag.a, 0, 0));
279+
newClipMask->mutPixels().store(frag.xy - clipBound.xy, Color::fromRgb(Math::roundi(parentPixel * frag.a), 0, 0));
279280
});
280281

281282
current().clipMask = newClipMask;
@@ -313,7 +314,9 @@ export struct CpuCanvas : Canvas {
313314
bool isSuitableForFastFill =
314315
radii.zero() and
315316
current().fill.is<Color>() and
316-
current().trans.isAxisAligned();
317+
current().trans.isAxisAligned() and
318+
not current().clipMask.has() and
319+
current().opacity > 0.99;
317320

318321
if (isSuitableForFastFill) {
319322
_fillRect(r, current().fill.unwrap<Color>());
@@ -346,13 +349,15 @@ export struct CpuCanvas : Canvas {
346349
_poly.clear();
347350
createStroke(_poly, path, current().stroke);
348351
_poly.transform(current().trans);
352+
_poly.sortForAet();
349353
_fill(current().stroke.fill);
350354
}
351355

352356
void fill(Math::Path const& path, FillRule rule = FillRule::NONZERO) override {
353357
_poly.clear();
354358
createSolid(_poly, path);
355359
_poly.transform(current().trans);
360+
_poly.sortForAet();
356361
_fill(current().fill, rule);
357362
}
358363

src/karm-kira/scaffold.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export auto scaffoldContent() {
193193
.borderWidth = 1,
194194
.borderFill = Ui::GRAY800,
195195
.backgroundFill = Ui::GRAY950,
196+
.overflow = Ui::BoxOverflow::HIDDEN,
196197
});
197198
};
198199
}

src/karm-ui/box.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export struct BoxStyle {
8686
g.fill(bound, borderRadii);
8787
}
8888

89+
g.push();
8990
if (overflow == BoxOverflow::HIDDEN) {
9091
g.beginPath();
9192
g.rect(bound.cast<f64>(), borderRadii);
@@ -94,6 +95,7 @@ export struct BoxStyle {
9495

9596
g.fillStyle(foregroundFill);
9697
inner();
98+
g.pop();
9799

98100
if (borderWidth and borderFill) {
99101
g.strokeStyle(

0 commit comments

Comments
 (0)