From: Sebastian Dröge Date: Sat, 16 Apr 2011 14:21:39 +0000 (+0200) Subject: {clock,time}overlay: Only set the global pango context options once in class_init X-Git-Tag: 1.19.3~511^2~6555^2~962 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=72b142bfdfdb70b324c5d0805ec8318a9a687128;p=platform%2Fupstream%2Fgstreamer.git {clock,time}overlay: Only set the global pango context options once in class_init Instead of doing it over and over again when instantiating a new instance. --- diff --git a/ext/pango/gstclockoverlay.c b/ext/pango/gstclockoverlay.c index 026894d..fe5b0bb 100644 --- a/ext/pango/gstclockoverlay.c +++ b/ext/pango/gstclockoverlay.c @@ -146,6 +146,8 @@ gst_clock_overlay_class_init (GstClockOverlayClass * klass) { GObjectClass *gobject_class; GstTextOverlayClass *gsttextoverlay_class; + PangoContext *context; + PangoFontDescription *font_description; gobject_class = (GObjectClass *) klass; gsttextoverlay_class = (GstTextOverlayClass *) klass; @@ -160,6 +162,21 @@ gst_clock_overlay_class_init (GstClockOverlayClass * klass) g_param_spec_string ("time-format", "Date/Time Format", "Format to use for time and date value, as in strftime.", DEFAULT_PROP_TIMEFORMAT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + context = GST_TEXT_OVERLAY_CLASS (klass)->pango_context; + + pango_context_set_language (context, pango_language_from_string ("en_US")); + pango_context_set_base_dir (context, PANGO_DIRECTION_LTR); + + font_description = pango_font_description_new (); + pango_font_description_set_family_static (font_description, "Monospace"); + pango_font_description_set_style (font_description, PANGO_STYLE_NORMAL); + pango_font_description_set_variant (font_description, PANGO_VARIANT_NORMAL); + pango_font_description_set_weight (font_description, PANGO_WEIGHT_NORMAL); + pango_font_description_set_stretch (font_description, PANGO_STRETCH_NORMAL); + pango_font_description_set_size (font_description, 18 * PANGO_SCALE); + pango_context_set_font_description (context, font_description); + pango_font_description_free (font_description); } @@ -179,27 +196,10 @@ gst_clock_overlay_finalize (GObject * object) static void gst_clock_overlay_init (GstClockOverlay * overlay, GstClockOverlayClass * klass) { - PangoFontDescription *font_description; GstTextOverlay *textoverlay; - PangoContext *context; textoverlay = GST_TEXT_OVERLAY (overlay); - context = GST_TEXT_OVERLAY_CLASS (klass)->pango_context; - - pango_context_set_language (context, pango_language_from_string ("en_US")); - pango_context_set_base_dir (context, PANGO_DIRECTION_LTR); - - font_description = pango_font_description_new (); - pango_font_description_set_family_static (font_description, "Monospace"); - pango_font_description_set_style (font_description, PANGO_STYLE_NORMAL); - pango_font_description_set_variant (font_description, PANGO_VARIANT_NORMAL); - pango_font_description_set_weight (font_description, PANGO_WEIGHT_NORMAL); - pango_font_description_set_stretch (font_description, PANGO_STRETCH_NORMAL); - pango_font_description_set_size (font_description, 18 * PANGO_SCALE); - pango_context_set_font_description (context, font_description); - pango_font_description_free (font_description); - textoverlay->valign = GST_TEXT_OVERLAY_VALIGN_TOP; textoverlay->halign = GST_TEXT_OVERLAY_HALIGN_LEFT; diff --git a/ext/pango/gsttimeoverlay.c b/ext/pango/gsttimeoverlay.c index a342a51..c959c42 100644 --- a/ext/pango/gsttimeoverlay.c +++ b/ext/pango/gsttimeoverlay.c @@ -116,20 +116,12 @@ static void gst_time_overlay_class_init (GstTimeOverlayClass * klass) { GstTextOverlayClass *gsttextoverlay_class; + PangoContext *context; + PangoFontDescription *font_description; gsttextoverlay_class = (GstTextOverlayClass *) klass; gsttextoverlay_class->get_text = gst_time_overlay_get_text; -} - -static void -gst_time_overlay_init (GstTimeOverlay * overlay, GstTimeOverlayClass * klass) -{ - PangoFontDescription *font_description; - GstTextOverlay *textoverlay; - PangoContext *context; - - textoverlay = GST_TEXT_OVERLAY (overlay); context = GST_TEXT_OVERLAY_CLASS (klass)->pango_context; @@ -145,6 +137,14 @@ gst_time_overlay_init (GstTimeOverlay * overlay, GstTimeOverlayClass * klass) pango_font_description_set_size (font_description, 18 * PANGO_SCALE); pango_context_set_font_description (context, font_description); pango_font_description_free (font_description); +} + +static void +gst_time_overlay_init (GstTimeOverlay * overlay, GstTimeOverlayClass * klass) +{ + GstTextOverlay *textoverlay; + + textoverlay = GST_TEXT_OVERLAY (overlay); textoverlay->valign = GST_TEXT_OVERLAY_VALIGN_TOP; textoverlay->halign = GST_TEXT_OVERLAY_HALIGN_LEFT;