mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 22:20:24 +00:00
Merge branch 'more-glyph-drawing-fixes' into 'master'
ngl: Use exact device scales for glyphs See merge request GNOME/gtk!3971
This commit is contained in:
commit
ece5fd7db5
@ -4477,10 +4477,10 @@ gsk_text_node_new (PangoFont *font,
|
|||||||
self->num_glyphs = n;
|
self->num_glyphs = n;
|
||||||
|
|
||||||
graphene_rect_init (&node->bounds,
|
graphene_rect_init (&node->bounds,
|
||||||
offset->x + ink_rect.x,
|
offset->x + ink_rect.x - 1,
|
||||||
offset->y + ink_rect.y,
|
offset->y + ink_rect.y - 1,
|
||||||
ink_rect.width,
|
ink_rect.width + 2,
|
||||||
ink_rect.height);
|
ink_rect.height + 2);
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,8 @@ gsk_ngl_glyph_library_create_surface (GskNglGlyphLibrary *self,
|
|||||||
int stride,
|
int stride,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
double device_scale)
|
int uwidth,
|
||||||
|
int uheight)
|
||||||
{
|
{
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
gsize n_bytes;
|
gsize n_bytes;
|
||||||
@ -153,7 +154,7 @@ gsk_ngl_glyph_library_create_surface (GskNglGlyphLibrary *self,
|
|||||||
surface = cairo_image_surface_create_for_data (self->surface_data,
|
surface = cairo_image_surface_create_for_data (self->surface_data,
|
||||||
CAIRO_FORMAT_ARGB32,
|
CAIRO_FORMAT_ARGB32,
|
||||||
width, height, stride);
|
width, height, stride);
|
||||||
cairo_surface_set_device_scale (surface, device_scale, device_scale);
|
cairo_surface_set_device_scale (surface, width / (double)uwidth, height / (double)uheight);
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
@ -192,7 +193,8 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
|
|||||||
int y,
|
int y,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
double device_scale)
|
int uwidth,
|
||||||
|
int uheight)
|
||||||
{
|
{
|
||||||
GskNglTextureLibrary *tl = (GskNglTextureLibrary *)self;
|
GskNglTextureLibrary *tl = (GskNglTextureLibrary *)self;
|
||||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||||
@ -220,7 +222,7 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
|
|||||||
"Uploading glyph %d",
|
"Uploading glyph %d",
|
||||||
key->glyph);
|
key->glyph);
|
||||||
|
|
||||||
surface = gsk_ngl_glyph_library_create_surface (self, stride, width, height, device_scale);
|
surface = gsk_ngl_glyph_library_create_surface (self, stride, width, height, uwidth, uheight);
|
||||||
render_glyph (surface, scaled_font, key, value);
|
render_glyph (surface, scaled_font, key, value);
|
||||||
|
|
||||||
texture_id = GSK_NGL_TEXTURE_ATLAS_ENTRY_TEXTURE (value);
|
texture_id = GSK_NGL_TEXTURE_ATLAS_ENTRY_TEXTURE (value);
|
||||||
@ -289,16 +291,10 @@ gsk_ngl_glyph_library_add (GskNglGlyphLibrary *self,
|
|||||||
pango_font_get_glyph_extents (key->font, key->glyph, &ink_rect, NULL);
|
pango_font_get_glyph_extents (key->font, key->glyph, &ink_rect, NULL);
|
||||||
pango_extents_to_pixels (&ink_rect, NULL);
|
pango_extents_to_pixels (&ink_rect, NULL);
|
||||||
|
|
||||||
if (key->xshift != 0)
|
ink_rect.x -= 1;
|
||||||
{
|
ink_rect.width += 2;
|
||||||
ink_rect.x -= 1;
|
ink_rect.y -= 1;
|
||||||
ink_rect.width += 2;
|
ink_rect.height += 2;
|
||||||
}
|
|
||||||
if (key->yshift != 0)
|
|
||||||
{
|
|
||||||
ink_rect.y -= 1;
|
|
||||||
ink_rect.height += 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
width = (int) ceil (ink_rect.width * key->scale / 1024.0);
|
width = (int) ceil (ink_rect.width * key->scale / 1024.0);
|
||||||
height = (int) ceil (ink_rect.height * key->scale / 1024.0);
|
height = (int) ceil (ink_rect.height * key->scale / 1024.0);
|
||||||
@ -321,7 +317,8 @@ gsk_ngl_glyph_library_add (GskNglGlyphLibrary *self,
|
|||||||
packed_y + 1,
|
packed_y + 1,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
key->scale / 1024.0);
|
ink_rect.width,
|
||||||
|
ink_rect.height);
|
||||||
|
|
||||||
*out_value = value;
|
*out_value = value;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user