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 x, y;
gdouble scale_w, scale_h;
int scale_factor;
file = st_theme_node_get_background_image (node);
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,
scale_factor,
node->cached_scale_factor,
resource_scale);
if (surface == NULL)
@ -1374,7 +1372,6 @@ st_theme_node_load_border_image (StThemeNode *node,
{
StBorderImage *border_image;
GFile *file;
int scale_factor;
border_image = st_theme_node_get_border_image (node);
if (border_image == NULL)
@ -1382,10 +1379,9 @@ st_theme_node_load_border_image (StThemeNode *node,
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 (),
file, scale_factor,
file,
node->cached_scale_factor,
resource_scale);
if (node->border_slices_texture == NULL)
goto out;
@ -1413,17 +1409,15 @@ st_theme_node_load_background_image (StThemeNode *node,
{
GFile *background_image;
StShadow *background_image_shadow_spec;
int scale_factor;
background_image = st_theme_node_get_background_image (node);
if (background_image == NULL)
goto out;
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
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 (),
background_image, scale_factor,
background_image,
node->cached_scale_factor,
resource_scale);
if (node->background_texture == NULL)
goto out;

View File

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