GtkImage: Reuse previously calculated baseline_align in draw()

No need to recalculate this every time we draw.
This commit is contained in:
Alexander Larsson 2013-03-27 09:42:43 +01:00
parent 43f1ac2b8f
commit c630804647

View File

@ -1462,22 +1462,8 @@ gtk_image_draw (GtkWidget *widget,
if (baseline == -1)
y = floor ((gtk_widget_get_allocated_height (widget) - height) * yalign) + border.top;
else
{
PangoContext *pango_context;
PangoFontMetrics *metrics;
float baseline_align;
pango_context = gtk_widget_get_pango_context (widget);
metrics = pango_context_get_metrics (pango_context,
pango_context_get_font_description (pango_context),
pango_context_get_language (pango_context));
baseline_align =
(double)pango_font_metrics_get_ascent (metrics) /
(pango_font_metrics_get_ascent (metrics) + pango_font_metrics_get_descent (metrics));
y = CLAMP (baseline - height * baseline_align,
border.top, gtk_widget_get_allocated_height (widget) - height);
}
y = CLAMP (baseline - height * gtk_image_get_baseline_align (image),
border.top, gtk_widget_get_allocated_height (widget) - height);
if (gtk_image_get_storage_type (image) == GTK_IMAGE_ANIMATION)
{