mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 21:16:24 +00:00
{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.
This commit is contained in:
parent
9ee7398fae
commit
72b142bfdf
2 changed files with 27 additions and 27 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue