Compare commits

...

2 Commits

Author SHA1 Message Date
Matthias Clasen
27c978ce64 gsk: Fix ink leakage in node diffing
We do need to enlarge the node bounds for text nodes after all,
to prevent leaking ink, in particular with fractional scaling.

This reverts 24de5ffd4e.
2024-02-17 16:58:20 -05:00
Matthias Clasen
add0afae30 gsk: Fix subpixel positioning
The previous code did not subtract the fractional part from  the
origin after determining it, and it neglected the case where we
are close enough to the next integral position to just use that.
2024-02-17 16:20:54 -05:00
2 changed files with 25 additions and 10 deletions

View File

@@ -3032,12 +3032,19 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
offset.y + (float) glyphs[i].geometry.y_offset / PANGO_SCALE);
if (glyph_align)
{
glyph_origin.x = roundf (glyph_origin.x * scale * 4);
glyph_origin.y = roundf (glyph_origin.y * scale * 4);
flags = ((int) glyph_origin.x & 3) |
(((int) glyph_origin.y & 3) << 2);
glyph_origin.x = 0.25 * inv_scale * glyph_origin.x;
glyph_origin.y = 0.25 * inv_scale * glyph_origin.y;
float x, y;
int frac_x, frac_y;
x = glyph_origin.x * scale;
y = glyph_origin.y * scale;
frac_x = (int) roundf ((x - floor (x)) * 4);
frac_y = (int) roundf ((y - floor (y)) * 4);
flags = (frac_x & 3) | ((frac_y & 3) << 2);
glyph_origin.x = (floor (x) + (frac_x == 4 ? 1.f : 0.f)) * inv_scale;
glyph_origin.y = (floor (y) + (frac_y == 4 ? 1.f : 0.f)) * inv_scale;
}
else
{

View File

@@ -5854,11 +5854,19 @@ gsk_text_node_new (PangoFont *font,
self->glyphs = glyph_infos;
self->num_glyphs = n;
/* Since we do subpixel positioning in device pixels, and the app and
* device pixel grid may not be aligned, we can end up rounding down
* for subpixel positioning even when we are exactly on an app pixel
* boundary.
*
* Play it safe, and enlarge the node bounds by one app pixel
* in each direction, so we don't leak ink when diffing.
*/
gsk_rect_init (&node->bounds,
offset->x + ink_rect.x,
offset->y + ink_rect.y,
ink_rect.width,
ink_rect.height);
offset->x + ink_rect.x - 1,
offset->y + ink_rect.y - 1,
ink_rect.width + 2,
ink_rect.height + 2);
return node;
}