st/theme-node: Use the node's scale factor

Each node stores the scale factor in place when it was created.
Creating nodes with the same style, but with different scale
factors, yields different nodes.

Use the node's scale factor instead of retrieving the context's
one.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1176
This commit is contained in:
Georges Basile Stavracas Neto 2020-04-03 18:04:13 -03:00
parent c9cfeb8318
commit 9f870aa1c7
2 changed files with 8 additions and 22 deletions

View File

@ -643,15 +643,13 @@ create_cairo_pattern_of_background_image (StThemeNode *node,
gdouble background_image_width, background_image_height; gdouble background_image_width, background_image_height;
gdouble x, y; gdouble x, y;
gdouble scale_w, scale_h; gdouble scale_w, scale_h;
int scale_factor;
file = st_theme_node_get_background_image (node); file = st_theme_node_get_background_image (node);
texture_cache = st_texture_cache_get_default (); texture_cache = st_texture_cache_get_default ();
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
surface = st_texture_cache_load_file_to_cairo_surface (texture_cache, file, surface = st_texture_cache_load_file_to_cairo_surface (texture_cache, file,
scale_factor, node->cached_scale_factor,
resource_scale); resource_scale);
if (surface == NULL) if (surface == NULL)
@ -1374,7 +1372,6 @@ st_theme_node_load_border_image (StThemeNode *node,
{ {
StBorderImage *border_image; StBorderImage *border_image;
GFile *file; GFile *file;
int scale_factor;
border_image = st_theme_node_get_border_image (node); border_image = st_theme_node_get_border_image (node);
if (border_image == NULL) if (border_image == NULL)
@ -1382,10 +1379,9 @@ st_theme_node_load_border_image (StThemeNode *node,
file = st_border_image_get_file (border_image); file = st_border_image_get_file (border_image);
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
node->border_slices_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (), node->border_slices_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (),
file, scale_factor, file,
node->cached_scale_factor,
resource_scale); resource_scale);
if (node->border_slices_texture == NULL) if (node->border_slices_texture == NULL)
goto out; goto out;
@ -1413,17 +1409,15 @@ st_theme_node_load_background_image (StThemeNode *node,
{ {
GFile *background_image; GFile *background_image;
StShadow *background_image_shadow_spec; StShadow *background_image_shadow_spec;
int scale_factor;
background_image = st_theme_node_get_background_image (node); background_image = st_theme_node_get_background_image (node);
if (background_image == NULL) if (background_image == NULL)
goto out; goto out;
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
background_image_shadow_spec = st_theme_node_get_background_image_shadow (node); background_image_shadow_spec = st_theme_node_get_background_image_shadow (node);
node->background_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (), node->background_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (),
background_image, scale_factor, background_image,
node->cached_scale_factor,
resource_scale); resource_scale);
if (node->background_texture == NULL) if (node->background_texture == NULL)
goto out; goto out;

View File

@ -978,9 +978,7 @@ get_length_from_term (StThemeNode *node,
} type = ABSOLUTE; } type = ABSOLUTE;
double multiplier = 1.0; double multiplier = 1.0;
int scale_factor;
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
if (term->type != TERM_NUMBER) if (term->type != TERM_NUMBER)
{ {
@ -995,7 +993,7 @@ get_length_from_term (StThemeNode *node,
{ {
case NUM_LENGTH_PX: case NUM_LENGTH_PX:
type = ABSOLUTE; type = ABSOLUTE;
multiplier = 1 * scale_factor; multiplier = 1 * node->cached_scale_factor;
break; break;
case NUM_LENGTH_PT: case NUM_LENGTH_PT:
type = POINTS; type = POINTS;
@ -1126,14 +1124,10 @@ get_length_from_term_int (StThemeNode *node,
{ {
double value; double value;
GetFromTermResult result; GetFromTermResult result;
int scale_factor;
result = get_length_from_term (node, term, use_parent_font, &value); result = get_length_from_term (node, term, use_parent_font, &value);
if (result == VALUE_FOUND) if (result == VALUE_FOUND)
{ *length = (int) ((value / node->cached_scale_factor) + 0.5) * node->cached_scale_factor;
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
*length = (int) ((value / scale_factor) + 0.5) * scale_factor;
}
return result; return result;
} }
@ -3015,7 +3009,6 @@ StBorderImage *
st_theme_node_get_border_image (StThemeNode *node) st_theme_node_get_border_image (StThemeNode *node)
{ {
int i; int i;
int scale_factor;
if (node->border_image_computed) if (node->border_image_computed)
return node->border_image; return node->border_image;
@ -3024,7 +3017,6 @@ st_theme_node_get_border_image (StThemeNode *node)
node->border_image_computed = TRUE; node->border_image_computed = TRUE;
ensure_properties (node); ensure_properties (node);
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
for (i = node->n_properties - 1; i >= 0; i--) for (i = node->n_properties - 1; i >= 0; i--)
{ {
@ -3129,7 +3121,7 @@ st_theme_node_get_border_image (StThemeNode *node)
node->border_image = st_border_image_new (file, node->border_image = st_border_image_new (file,
border_top, border_right, border_bottom, border_left, border_top, border_right, border_bottom, border_left,
scale_factor); node->cached_scale_factor);
g_object_unref (file); g_object_unref (file);