texture-cache: require icon scale to load gicon
To support HiDpi. https://bugzilla.gnome.org/show_bug.cgi?id=705410
This commit is contained in:
parent
65ad65fe52
commit
e5e764b402
@ -193,8 +193,14 @@ shell_app_create_icon_texture (ShellApp *app,
|
|||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
GIcon *icon;
|
GIcon *icon;
|
||||||
|
gint scale;
|
||||||
ClutterActor *ret;
|
ClutterActor *ret;
|
||||||
|
ShellGlobal *global;
|
||||||
|
StThemeContext *context;
|
||||||
|
|
||||||
|
global = shell_global_get ();
|
||||||
|
context = st_theme_context_get_for_stage (shell_global_get_stage (global));
|
||||||
|
g_object_get (context, "scale-factor", &scale, NULL);
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
|
|
||||||
if (app->info == NULL)
|
if (app->info == NULL)
|
||||||
@ -202,12 +208,12 @@ shell_app_create_icon_texture (ShellApp *app,
|
|||||||
|
|
||||||
icon = g_app_info_get_icon (G_APP_INFO (app->info));
|
icon = g_app_info_get_icon (G_APP_INFO (app->info));
|
||||||
if (icon != NULL)
|
if (icon != NULL)
|
||||||
ret = st_texture_cache_load_gicon (st_texture_cache_get_default (), NULL, icon, size);
|
ret = st_texture_cache_load_gicon (st_texture_cache_get_default (), NULL, icon, size, scale);
|
||||||
|
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
{
|
{
|
||||||
icon = g_themed_icon_new ("application-x-executable");
|
icon = g_themed_icon_new ("application-x-executable");
|
||||||
ret = st_texture_cache_load_gicon (st_texture_cache_get_default (), NULL, icon, size);
|
ret = st_texture_cache_load_gicon (st_texture_cache_get_default (), NULL, icon, size, scale);
|
||||||
g_object_unref (icon);
|
g_object_unref (icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -848,18 +848,25 @@ shell_startup_sequence_create_icon (ShellStartupSequence *sequence, guint size)
|
|||||||
GIcon *themed;
|
GIcon *themed;
|
||||||
const char *icon_name;
|
const char *icon_name;
|
||||||
ClutterActor *texture;
|
ClutterActor *texture;
|
||||||
|
gint scale;
|
||||||
|
ShellGlobal *global;
|
||||||
|
StThemeContext *context;
|
||||||
|
|
||||||
|
global = shell_global_get ();
|
||||||
|
context = st_theme_context_get_for_stage (shell_global_get_stage (global));
|
||||||
|
g_object_get (context, "scale-factor", &scale, NULL);
|
||||||
|
|
||||||
icon_name = sn_startup_sequence_get_icon_name ((SnStartupSequence*)sequence);
|
icon_name = sn_startup_sequence_get_icon_name ((SnStartupSequence*)sequence);
|
||||||
if (!icon_name)
|
if (!icon_name)
|
||||||
{
|
{
|
||||||
texture = clutter_texture_new ();
|
texture = clutter_texture_new ();
|
||||||
clutter_actor_set_size (texture, size, size);
|
clutter_actor_set_size (texture, size * scale, size * scale);
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
themed = g_themed_icon_new (icon_name);
|
themed = g_themed_icon_new (icon_name);
|
||||||
texture = st_texture_cache_load_gicon (st_texture_cache_get_default (),
|
texture = st_texture_cache_load_gicon (st_texture_cache_get_default (),
|
||||||
NULL, themed, size);
|
NULL, themed, size, scale);
|
||||||
g_object_unref (G_OBJECT (themed));
|
g_object_unref (G_OBJECT (themed));
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "st-enum-types.h"
|
#include "st-enum-types.h"
|
||||||
#include "st-icon.h"
|
#include "st-icon.h"
|
||||||
#include "st-texture-cache.h"
|
#include "st-texture-cache.h"
|
||||||
|
#include "st-theme-context.h"
|
||||||
#include "st-private.h"
|
#include "st-private.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -430,6 +431,9 @@ st_icon_update (StIcon *icon)
|
|||||||
StIconPrivate *priv = icon->priv;
|
StIconPrivate *priv = icon->priv;
|
||||||
StThemeNode *theme_node;
|
StThemeNode *theme_node;
|
||||||
StTextureCache *cache;
|
StTextureCache *cache;
|
||||||
|
gint scale;
|
||||||
|
ClutterActor *stage;
|
||||||
|
StThemeContext *context;
|
||||||
|
|
||||||
if (priv->pending_texture)
|
if (priv->pending_texture)
|
||||||
{
|
{
|
||||||
@ -443,13 +447,18 @@ st_icon_update (StIcon *icon)
|
|||||||
if (theme_node == NULL)
|
if (theme_node == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
stage = clutter_actor_get_stage (CLUTTER_ACTOR (icon));
|
||||||
|
context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage));
|
||||||
|
g_object_get (context, "scale-factor", &scale, NULL);
|
||||||
|
|
||||||
cache = st_texture_cache_get_default ();
|
cache = st_texture_cache_get_default ();
|
||||||
if (priv->gicon)
|
if (priv->gicon)
|
||||||
{
|
{
|
||||||
priv->pending_texture = st_texture_cache_load_gicon (cache,
|
priv->pending_texture = st_texture_cache_load_gicon (cache,
|
||||||
theme_node,
|
theme_node,
|
||||||
priv->gicon,
|
priv->gicon,
|
||||||
priv->icon_size);
|
priv->icon_size,
|
||||||
|
scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->pending_texture)
|
if (priv->pending_texture)
|
||||||
@ -483,7 +492,19 @@ st_icon_update_icon_size (StIcon *icon)
|
|||||||
if (priv->prop_icon_size > 0)
|
if (priv->prop_icon_size > 0)
|
||||||
new_size = priv->prop_icon_size;
|
new_size = priv->prop_icon_size;
|
||||||
else if (priv->theme_icon_size > 0)
|
else if (priv->theme_icon_size > 0)
|
||||||
new_size = priv->theme_icon_size;
|
{
|
||||||
|
gint scale;
|
||||||
|
ClutterActor *stage;
|
||||||
|
StThemeContext *context;
|
||||||
|
|
||||||
|
/* The theme will give us an already-scaled size, so we
|
||||||
|
* undo it here, as priv->icon_size is in unscaled pixels.
|
||||||
|
*/
|
||||||
|
stage = clutter_actor_get_stage (CLUTTER_ACTOR (icon));
|
||||||
|
context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage));
|
||||||
|
g_object_get (context, "scale-factor", &scale, NULL);
|
||||||
|
new_size = (gint) (priv->theme_icon_size / scale);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
new_size = DEFAULT_ICON_SIZE;
|
new_size = DEFAULT_ICON_SIZE;
|
||||||
|
|
||||||
|
@ -909,6 +909,7 @@ static ClutterActor *
|
|||||||
load_gicon_with_colors (StTextureCache *cache,
|
load_gicon_with_colors (StTextureCache *cache,
|
||||||
GIcon *icon,
|
GIcon *icon,
|
||||||
gint size,
|
gint size,
|
||||||
|
gint scale,
|
||||||
StIconColors *colors)
|
StIconColors *colors)
|
||||||
{
|
{
|
||||||
AsyncTextureLoadData *request;
|
AsyncTextureLoadData *request;
|
||||||
@ -922,7 +923,7 @@ load_gicon_with_colors (StTextureCache *cache,
|
|||||||
/* Do theme lookups in the main thread to avoid thread-unsafety */
|
/* Do theme lookups in the main thread to avoid thread-unsafety */
|
||||||
theme = cache->priv->icon_theme;
|
theme = cache->priv->icon_theme;
|
||||||
|
|
||||||
info = gtk_icon_theme_lookup_by_gicon (theme, icon, size, GTK_ICON_LOOKUP_USE_BUILTIN);
|
info = gtk_icon_theme_lookup_by_gicon_for_scale (theme, icon, size, scale, GTK_ICON_LOOKUP_USE_BUILTIN);
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -936,8 +937,8 @@ load_gicon_with_colors (StTextureCache *cache,
|
|||||||
if (colors)
|
if (colors)
|
||||||
{
|
{
|
||||||
/* This raises some doubts about the practice of using string keys */
|
/* This raises some doubts about the practice of using string keys */
|
||||||
key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d,colors=%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x",
|
key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d,scale=%d,colors=%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x",
|
||||||
gicon_string, size,
|
gicon_string, size, scale,
|
||||||
colors->foreground.red, colors->foreground.blue, colors->foreground.green, colors->foreground.alpha,
|
colors->foreground.red, colors->foreground.blue, colors->foreground.green, colors->foreground.alpha,
|
||||||
colors->warning.red, colors->warning.blue, colors->warning.green, colors->warning.alpha,
|
colors->warning.red, colors->warning.blue, colors->warning.green, colors->warning.alpha,
|
||||||
colors->error.red, colors->error.blue, colors->error.green, colors->error.alpha,
|
colors->error.red, colors->error.blue, colors->error.green, colors->error.alpha,
|
||||||
@ -945,13 +946,13 @@ load_gicon_with_colors (StTextureCache *cache,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d",
|
key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d,scale=%d",
|
||||||
gicon_string, size);
|
gicon_string, size, scale);
|
||||||
}
|
}
|
||||||
g_free (gicon_string);
|
g_free (gicon_string);
|
||||||
|
|
||||||
texture = (ClutterActor *) create_default_texture ();
|
texture = (ClutterActor *) create_default_texture ();
|
||||||
clutter_actor_set_size (texture, size, size);
|
clutter_actor_set_size (texture, size * scale, size * scale);
|
||||||
|
|
||||||
if (ensure_request (cache, key, policy, &request, texture))
|
if (ensure_request (cache, key, policy, &request, texture))
|
||||||
{
|
{
|
||||||
@ -969,7 +970,7 @@ load_gicon_with_colors (StTextureCache *cache,
|
|||||||
request->policy = policy;
|
request->policy = policy;
|
||||||
request->colors = colors ? st_icon_colors_ref (colors) : NULL;
|
request->colors = colors ? st_icon_colors_ref (colors) : NULL;
|
||||||
request->icon_info = info;
|
request->icon_info = info;
|
||||||
request->width = request->height = size;
|
request->width = request->height = size * scale;
|
||||||
request->enforced_square = TRUE;
|
request->enforced_square = TRUE;
|
||||||
|
|
||||||
load_texture_async (cache, request);
|
load_texture_async (cache, request);
|
||||||
@ -985,6 +986,7 @@ load_gicon_with_colors (StTextureCache *cache,
|
|||||||
* if the icon must not be recolored
|
* if the icon must not be recolored
|
||||||
* @icon: the #GIcon to load
|
* @icon: the #GIcon to load
|
||||||
* @size: Size of themed
|
* @size: Size of themed
|
||||||
|
* @scale: Scale factor of display
|
||||||
*
|
*
|
||||||
* This method returns a new #ClutterActor for a given #GIcon. If the
|
* This method returns a new #ClutterActor for a given #GIcon. If the
|
||||||
* icon isn't loaded already, the texture will be filled
|
* icon isn't loaded already, the texture will be filled
|
||||||
@ -996,9 +998,10 @@ ClutterActor *
|
|||||||
st_texture_cache_load_gicon (StTextureCache *cache,
|
st_texture_cache_load_gicon (StTextureCache *cache,
|
||||||
StThemeNode *theme_node,
|
StThemeNode *theme_node,
|
||||||
GIcon *icon,
|
GIcon *icon,
|
||||||
gint size)
|
gint size,
|
||||||
|
gint scale)
|
||||||
{
|
{
|
||||||
return load_gicon_with_colors (cache, icon, size, theme_node ? st_theme_node_get_icon_colors (theme_node) : NULL);
|
return load_gicon_with_colors (cache, icon, size, scale, theme_node ? st_theme_node_get_icon_colors (theme_node) : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ClutterActor *
|
static ClutterActor *
|
||||||
|
@ -83,7 +83,8 @@ ClutterActor *st_texture_cache_bind_pixbuf_property (StTextureCache *cache,
|
|||||||
ClutterActor *st_texture_cache_load_gicon (StTextureCache *cache,
|
ClutterActor *st_texture_cache_load_gicon (StTextureCache *cache,
|
||||||
StThemeNode *theme_node,
|
StThemeNode *theme_node,
|
||||||
GIcon *icon,
|
GIcon *icon,
|
||||||
gint size);
|
gint size,
|
||||||
|
gint scale);
|
||||||
|
|
||||||
ClutterActor *st_texture_cache_load_uri_async (StTextureCache *cache,
|
ClutterActor *st_texture_cache_load_uri_async (StTextureCache *cache,
|
||||||
const gchar *uri,
|
const gchar *uri,
|
||||||
|
Loading…
Reference in New Issue
Block a user