Skip to content

Commit 1dff13b

Browse files
committed
gfx/d3d8: Cull text on the top side of the soft scissor too
The font path's whole-line scissor cull added in 5f23e85 only checked the bottom side: skip when the baseline ly is at or below the scissor's bottom edge. The top-side case was left out on the assumption that entries scrolled above the scissor "don't occur in practice." They do — scrolling Ozone's entry list far enough down pushes the topmost entry's text up past the scissor's top edge, where it bleeds into the header bar (the icons get correctly clipped by gfx_display_d3d8_draw's geometry path, but the text leaked through unchecked). Add the symmetric ly < sy cull. Visible glyphs sit at or above the baseline, so a baseline above sy means the whole line is above sy and entirely outside the scissor. Edge-aligned lines (baseline ~ sy or ~ sy2) still render in full; partial overlap isn't clipped. Pixel-perfect glyph clipping would need per-glyph bounding-box checks against the rect with UV remap similar to what gfx_display_d3d8_draw does for quads, which isn't worth the complexity for a fallback-quality backend. The whole-line cull is enough to stop the visible overflow into both of Ozone's header and footer regions.
1 parent 45699e2 commit 1dff13b

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

gfx/drivers/d3d8.c

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,20 +1406,34 @@ static void d3d8_font_render_line(
14061406
return;
14071407

14081408
/* Soft scissor for text. The font path doesn't go through
1409-
* gfx_display_d3d8_draw, so apply the same skip-only check
1410-
* here. ly is the baseline in top-down screen pixels;
1411-
* visible glyphs sit at and above ly (descenders may dip
1412-
* slightly below). Conservative cull when the baseline is
1413-
* well below the scissor's bottom edge — that's the case
1414-
* which produces visible overflow into Ozone's footer. We
1415-
* deliberately don't cull on the top side: line height isn't
1416-
* known here and the symmetric overflow (entries above the
1417-
* scissor) doesn't occur in practice. */
1409+
* gfx_display_d3d8_draw, so apply a similar skip-only check
1410+
* here. ly is the baseline in top-down screen pixels.
1411+
* Visible glyphs sit at or above ly (the baseline is the
1412+
* bottom of the line for most glyphs; descenders dip slightly
1413+
* below). We don't know the line height here, but two
1414+
* conservative whole-line culls catch the cases that actually
1415+
* overflow in practice:
1416+
*
1417+
* - ly >= sy2: baseline at or below the scissor bottom edge
1418+
* means the whole line (which is above the baseline) is
1419+
* mostly below the scissor. In Ozone that's the entry
1420+
* that has just scrolled past the footer.
1421+
* - ly < sy: baseline above the scissor top edge means
1422+
* the whole line is above sy — every visible glyph sits
1423+
* above its own baseline, so above sy too. In Ozone
1424+
* that's the entry that has just scrolled past the
1425+
* header.
1426+
*
1427+
* Edge-aligned lines (baseline ~ sy or ~ sy2) still render in
1428+
* full — partial overlap isn't culled. Pixel-perfect glyph
1429+
* clipping would need per-glyph bounding-box checks; the
1430+
* whole-line cull is enough to stop the visible overflow into
1431+
* Ozone's header/footer regions. */
14181432
if (d3d->menu_display.scissor_active)
14191433
{
1420-
int sy2 = d3d->menu_display.scissor_y
1421-
+ d3d->menu_display.scissor_h;
1422-
if (ly >= sy2)
1434+
int sy = d3d->menu_display.scissor_y;
1435+
int sy2 = sy + d3d->menu_display.scissor_h;
1436+
if (ly >= sy2 || ly < sy)
14231437
return;
14241438
}
14251439

0 commit comments

Comments
 (0)