MetaBackgroundActor: stop waiting synchronously on the first frame

We can draw the gradient while we wait for the wallpaper to load.
This also removes the dependency on g_task_wait_sync(), which may
never appear in glib.
This commit is contained in:
Giovanni Campagna 2013-02-13 22:19:54 +01:00
parent db7fa793b0
commit 4f56cfb1e6

View File

@ -113,6 +113,8 @@ static void meta_background_actor_screen_size_changed (MetaScreen *scre
static void meta_background_actor_constructed (GObject *object);
static void clear_state (MetaBackgroundState *state);
static void init_state_from_settings (MetaBackgroundState *state,
GSettings *settings);
static void set_texture (MetaBackground *background,
CoglHandle texture,
MetaBackgroundSlideshow *slideshow);
@ -176,6 +178,8 @@ meta_background_get (MetaScreen *screen,
g_signal_connect (settings, "changed",
G_CALLBACK (on_settings_changed), background);
init_state_from_settings (&background->state, settings);
on_settings_changed (settings, "picture-uri", background);
}
@ -226,6 +230,18 @@ get_color_from_settings (GSettings *settings,
g_free (str);
}
static void
init_state_from_settings (MetaBackgroundState *state,
GSettings *settings)
{
get_color_from_settings (settings, "primary-color",
&state->colors[0]);
get_color_from_settings (settings, "secondary-color",
&state->colors[1]);
state->style = g_settings_get_enum (settings, "picture-options");
state->shading = g_settings_get_enum (settings, "color-shading-type");
}
static void
set_texture (MetaBackground *background,
CoglHandle texture,
@ -244,14 +260,10 @@ set_texture (MetaBackground *background,
background->old_state = background->state;
background->state.texture = cogl_handle_ref (texture);
get_color_from_settings (background->settings, "primary-color",
&background->state.colors[0]);
get_color_from_settings (background->settings, "secondary-color",
&background->state.colors[1]);
background->state.style = g_settings_get_enum (background->settings, "picture-options");
background->state.shading = g_settings_get_enum (background->settings, "color-shading-type");
background->state.texture_width = cogl_texture_get_width (background->state.texture);
background->state.texture_height = cogl_texture_get_height (background->state.texture);
init_state_from_settings (&background->state,
background->settings);
background->state.slideshow = g_object_ref (slideshow);
timeout = meta_background_slideshow_get_next_timeout (slideshow);
@ -305,16 +317,6 @@ set_texture (MetaBackground *background,
}
}
static inline void
meta_background_ensure_rendered (MetaBackground *background)
{
if (G_LIKELY (background->rendering_task == NULL ||
background->state.texture != COGL_INVALID_HANDLE))
return;
g_task_wait_sync (background->rendering_task);
}
static void
meta_background_actor_dispose (GObject *object)
{
@ -481,6 +483,9 @@ paint_background_box (MetaBackgroundState *state,
if (state->style == G_DESKTOP_BACKGROUND_STYLE_NONE)
return;
if (state->texture == COGL_INVALID_HANDLE)
return;
vertices[0].s = 1.0;
vertices[0].t = 0.0;
vertices[1].s = 0.0;
@ -726,8 +731,6 @@ meta_background_actor_paint (ClutterActor *actor)
float first_color_factor, first_alpha_factor,
second_color_factor, second_alpha_factor;
meta_background_ensure_rendered (priv->background);
if (priv->is_crossfading)
crossfade_progress = priv->crossfade_progress;
else