[gnome-shell/gbsneto/fix-switching-scale: 16/18] st/theme-node: Use the node's scale factor
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/fix-switching-scale: 16/18] st/theme-node: Use the node's scale factor
- Date: Mon, 6 Apr 2020 14:25:03 +0000 (UTC)
commit 9f870aa1c713ceaa68fb517622a5d82dc1273d1f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Apr 3 18:04:13 2020 -0300
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
src/st/st-theme-node-drawing.c | 16 +++++-----------
src/st/st-theme-node.c | 14 +++-----------
2 files changed, 8 insertions(+), 22 deletions(-)
---
diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c
index c2d4ccf839..5ec0e87afb 100644
--- a/src/st/st-theme-node-drawing.c
+++ b/src/st/st-theme-node-drawing.c
@@ -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;
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index 4e122f4410..85e5dbe418 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]