1
0
Fork 0
mutter-performance-source/clutter/pango/pangoclutter-fontmap.c
Emmanuele Bassi f20cfeadb4 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.
2008-05-28 14:03:28 +00:00

124 lines
3.4 KiB
C

/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* This is needed to get the Pango headers to export stuff needed to
subclass */
#ifndef PANGO_ENABLE_BACKEND
#define PANGO_ENABLE_BACKEND 1
#endif
#include <pango/pango-fontmap.h>
#include <pango/pangocairo.h>
#include <pango/pango-renderer.h>
#include "pangoclutter.h"
#include "pangoclutter-private.h"
static GQuark pango_clutter_font_map_get_renderer_key (void) G_GNUC_CONST;
PangoFontMap *
pango_clutter_font_map_new (void)
{
return pango_cairo_font_map_new ();
}
PangoContext *
pango_clutter_font_map_create_context (PangoClutterFontMap *fm)
{
g_return_val_if_fail (PANGO_CLUTTER_IS_FONT_MAP (fm), NULL);
/* We can just directly use the pango context from the Cairo font
map */
return pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fm));
}
PangoRenderer *
_pango_clutter_font_map_get_renderer (PangoClutterFontMap *fm)
{
PangoRenderer *renderer;
/* We want to keep a cached pointer to the renderer from the font
map instance but as we don't have a proper subclass we have to
store it in the object data instead */
renderer = g_object_get_qdata (G_OBJECT (fm),
pango_clutter_font_map_get_renderer_key ());
if (G_UNLIKELY (renderer == NULL))
{
renderer = g_object_new (PANGO_CLUTTER_TYPE_RENDERER, NULL);
g_object_set_qdata_full (G_OBJECT (fm),
pango_clutter_font_map_get_renderer_key (),
renderer,
g_object_unref);
}
return renderer;
}
void
pango_clutter_font_map_set_resolution (PangoClutterFontMap *font_map,
double dpi)
{
g_return_if_fail (PANGO_CLUTTER_IS_FONT_MAP (font_map));
pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (font_map), dpi);
}
void
pango_clutter_font_map_clear_glyph_cache (PangoClutterFontMap *fm)
{
PangoRenderer *renderer;
renderer = _pango_clutter_font_map_get_renderer (fm);
_pango_clutter_renderer_clear_glyph_cache (PANGO_CLUTTER_RENDERER (renderer));
}
void
pango_clutter_font_map_set_use_mipmapping (PangoClutterFontMap *fm,
gboolean value)
{
PangoClutterRenderer *renderer;
renderer = PANGO_CLUTTER_RENDERER (_pango_clutter_font_map_get_renderer (fm));
_pango_clutter_renderer_set_use_mipmapping (renderer, value);
}
static GQuark
pango_clutter_font_map_get_renderer_key (void)
{
static GQuark renderer_key = 0;
if (G_UNLIKELY (renderer_key == 0))
renderer_key = g_quark_from_static_string ("PangoClutterFontMap");
return renderer_key;
}