2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>

Bug #919 - Replacement pango renderer (Neil Roberts)

	* clutter/clutter-backend.h:
	* clutter/clutter-backend.c:
	(clutter_backend_set_font_options),
	(clutter_backend_get_font_options): Add the ability to set
	the cairo_font_options_t* for the backend at construction
	time, so that backend implementations can have their own
	options.

	* clutter/clutter-color.c: Include pango/pango-attributes.h
	for the pango_color_parse() function.

	* clutter/clutter-label.c:
	(clutter_label_ensure_layout),
	(clutter_label_init), (clutter_label_set_text),
	(clutter_label_set_font_name), (clutter_label_set_ellipsize),
	(clutter_label_set_use_markup): Ensure that the cache is
	always primed when the Label changes; this makes sure that
	the cache is rebuilt outside the paint run, which should
	make the painting perform better especially on embedded
	devices.

	* clutter/clutter-entry.c:
	(clutter_entry_ensure_layout),
	(clutter_entry_init), (clutter_entry_set_text),
	(clutter_entry_set_font_name): Ditto as above.

	* clutter/clutter-private.h:
	* clutter/clutter-main.[ch]: Create the font-map inside the
	main context; add two new functions:

	  clutter_clear_glyph_cache()
	  clutter_set_use_mipmapped_text()

	that control the glyphs cache.

	* clutter/pango/Makefile.am:
	* clutter/pango/pangoclutter-fontmap.c:
	* clutter/pango/pangoclutter-private.h:
	* clutter/pango/pangoclutter-render.c:
	* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
	using a PangoCairo context and saving the glyphs inside a
	more efficient cache.

	* configure.ac: Depend on pangocairo instead of pangoft2.
This commit is contained in:
Emmanuele Bassi
2008-05-28 14:03:28 +00:00
parent a0747e8c2d
commit f20cfeadb4
15 changed files with 765 additions and 863 deletions

View File

@ -41,10 +41,10 @@
#include "config.h"
#endif
#include "clutter-fixed.h"
#include "clutter-backend.h"
#include "clutter-private.h"
#include "clutter-debug.h"
#include "clutter-fixed.h"
#include "clutter-private.h"
G_DEFINE_ABSTRACT_TYPE (ClutterBackend, clutter_backend, G_TYPE_OBJECT);
@ -58,6 +58,8 @@ struct _ClutterBackendPrivate
guint double_click_distance;
ClutterFixed resolution;
cairo_font_options_t *font_options;
};
static void
@ -74,6 +76,8 @@ clutter_backend_dispose (GObject *gobject)
clutter_context->events_queue = NULL;
}
clutter_backend_set_font_options (CLUTTER_BACKEND (gobject), NULL);
G_OBJECT_CLASS (clutter_backend_parent_class)->dispose (gobject);
}
@ -382,6 +386,10 @@ clutter_backend_set_resolution (ClutterBackend *backend,
fixed_dpi = CLUTTER_FLOAT_TO_FIXED (dpi);
if (priv->resolution != fixed_dpi)
priv->resolution = fixed_dpi;
if (CLUTTER_CONTEXT ()->font_map)
pango_clutter_font_map_set_resolution (CLUTTER_CONTEXT ()->font_map,
CLUTTER_FIXED_TO_FLOAT (fixed_dpi));
}
/**
@ -403,3 +411,49 @@ clutter_backend_get_resolution (ClutterBackend *backend)
return CLUTTER_FIXED_TO_FLOAT (backend->priv->resolution);
}
void
clutter_backend_set_font_options (ClutterBackend *backend,
cairo_font_options_t *options)
{
ClutterBackendPrivate *priv;
g_return_if_fail (CLUTTER_IS_BACKEND (backend));
priv = backend->priv;
if (priv->font_options != options)
{
if (priv->font_options)
cairo_font_options_destroy (priv->font_options);
if (options)
priv->font_options = cairo_font_options_copy (options);
else
priv->font_options = NULL;
}
}
cairo_font_options_t *
clutter_backend_get_font_options (ClutterBackend *backend)
{
ClutterBackendPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), NULL);
priv = backend->priv;
if (G_LIKELY (priv->font_options))
return priv->font_options;
priv->font_options = cairo_font_options_create ();
cairo_font_options_set_hint_style (priv->font_options,
CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_subpixel_order (priv->font_options,
CAIRO_SUBPIXEL_ORDER_DEFAULT);
cairo_font_options_set_antialias (priv->font_options,
CAIRO_ANTIALIAS_DEFAULT);
return priv->font_options;
}