mirror of
https://github.com/brl/mutter.git
synced 2025-02-23 16:34:10 +00:00
[backend] Constify font options
The font options accessors in ClutterBackend only deal with const cairo_font_options_t values, since: - set_font_options() will copy the font options - get_font_options() will return a pointer to the internal font options Not using const in these cases makes the API confusing and might lead to erroneous calls to cairo_font_options_destroy().
This commit is contained in:
parent
8354295986
commit
b39223d8cb
@ -533,9 +533,12 @@ clutter_backend_get_resolution (ClutterBackend *backend)
|
|||||||
* @backend: a #ClutterBackend
|
* @backend: a #ClutterBackend
|
||||||
* @options: Cairo font options for the backend, or %NULL
|
* @options: Cairo font options for the backend, or %NULL
|
||||||
*
|
*
|
||||||
* Sets the new font options for @backend. If @options is %NULL,
|
* Sets the new font options for @backend. The #ClutterBackend will
|
||||||
* the first following call to clutter_backend_get_font_options()
|
* copy the #cairo_font_options_t.
|
||||||
* will return the default font options for @backend.
|
*
|
||||||
|
* If @options is %NULL, the first following call to
|
||||||
|
* clutter_backend_get_font_options() will return the default font
|
||||||
|
* options for @backend.
|
||||||
*
|
*
|
||||||
* This function is intended for actors creating a Pango layout
|
* This function is intended for actors creating a Pango layout
|
||||||
* using the PangoCairo API.
|
* using the PangoCairo API.
|
||||||
@ -544,7 +547,7 @@ clutter_backend_get_resolution (ClutterBackend *backend)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
clutter_backend_set_font_options (ClutterBackend *backend,
|
clutter_backend_set_font_options (ClutterBackend *backend,
|
||||||
cairo_font_options_t *options)
|
const cairo_font_options_t *options)
|
||||||
{
|
{
|
||||||
ClutterBackendPrivate *priv;
|
ClutterBackendPrivate *priv;
|
||||||
|
|
||||||
@ -572,11 +575,13 @@ clutter_backend_set_font_options (ClutterBackend *backend,
|
|||||||
*
|
*
|
||||||
* Retrieves the font options for @backend.
|
* Retrieves the font options for @backend.
|
||||||
*
|
*
|
||||||
* Return value: (transfer none): the font options of the #ClutterBackend
|
* Return value: (transfer none): the font options of the #ClutterBackend.
|
||||||
|
* The returned #cairo_font_options_t is owned by the backend and should
|
||||||
|
* not be modified or freed
|
||||||
*
|
*
|
||||||
* Since: 0.8
|
* Since: 0.8
|
||||||
*/
|
*/
|
||||||
cairo_font_options_t *
|
const cairo_font_options_t *
|
||||||
clutter_backend_get_font_options (ClutterBackend *backend)
|
clutter_backend_get_font_options (ClutterBackend *backend)
|
||||||
{
|
{
|
||||||
ClutterBackendPrivate *priv;
|
ClutterBackendPrivate *priv;
|
||||||
|
@ -99,11 +99,11 @@ void clutter_backend_set_double_click_distance (ClutterBackend
|
|||||||
guint distance);
|
guint distance);
|
||||||
guint clutter_backend_get_double_click_distance (ClutterBackend *backend);
|
guint clutter_backend_get_double_click_distance (ClutterBackend *backend);
|
||||||
void clutter_backend_set_font_options (ClutterBackend *backend,
|
void clutter_backend_set_font_options (ClutterBackend *backend,
|
||||||
cairo_font_options_t *options);
|
const cairo_font_options_t *options);
|
||||||
cairo_font_options_t *clutter_backend_get_font_options (ClutterBackend *backend);
|
const cairo_font_options_t *clutter_backend_get_font_options (ClutterBackend *backend);
|
||||||
void clutter_backend_set_font_name (ClutterBackend *backend,
|
void clutter_backend_set_font_name (ClutterBackend *backend,
|
||||||
const gchar *font_name);
|
const gchar *font_name);
|
||||||
G_CONST_RETURN gchar *clutter_backend_get_font_name (ClutterBackend *backend);
|
G_CONST_RETURN gchar * clutter_backend_get_font_name (ClutterBackend *backend);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -447,7 +447,7 @@ update_pango_context (ClutterBackend *backend,
|
|||||||
PangoContext *context)
|
PangoContext *context)
|
||||||
{
|
{
|
||||||
PangoFontDescription *font_desc;
|
PangoFontDescription *font_desc;
|
||||||
cairo_font_options_t *font_options;
|
const cairo_font_options_t *font_options;
|
||||||
const gchar *font_name;
|
const gchar *font_name;
|
||||||
gdouble resolution;
|
gdouble resolution;
|
||||||
|
|
||||||
@ -2671,7 +2671,11 @@ void
|
|||||||
clutter_set_font_flags (ClutterFontFlags flags)
|
clutter_set_font_flags (ClutterFontFlags flags)
|
||||||
{
|
{
|
||||||
ClutterFontFlags old_flags, changed_flags;
|
ClutterFontFlags old_flags, changed_flags;
|
||||||
cairo_font_options_t *font_options;
|
const cairo_font_options_t *font_options;
|
||||||
|
cairo_font_options_t *new_font_options;
|
||||||
|
ClutterBackend *backend;
|
||||||
|
|
||||||
|
backend = clutter_get_default_backend ();
|
||||||
|
|
||||||
if (CLUTTER_CONTEXT ()->font_map)
|
if (CLUTTER_CONTEXT ()->font_map)
|
||||||
cogl_pango_font_map_set_use_mipmapping (CLUTTER_CONTEXT ()->font_map,
|
cogl_pango_font_map_set_use_mipmapping (CLUTTER_CONTEXT ()->font_map,
|
||||||
@ -2680,26 +2684,25 @@ clutter_set_font_flags (ClutterFontFlags flags)
|
|||||||
|
|
||||||
old_flags = clutter_get_font_flags ();
|
old_flags = clutter_get_font_flags ();
|
||||||
|
|
||||||
font_options = clutter_backend_get_font_options (CLUTTER_CONTEXT ()->backend);
|
font_options = clutter_backend_get_font_options (backend);
|
||||||
font_options = cairo_font_options_copy (font_options);
|
new_font_options = cairo_font_options_copy (font_options);
|
||||||
|
|
||||||
/* Only set the font options that have actually changed so we don't
|
/* Only set the font options that have actually changed so we don't
|
||||||
override a detailed setting from the backend */
|
override a detailed setting from the backend */
|
||||||
changed_flags = old_flags ^ flags;
|
changed_flags = old_flags ^ flags;
|
||||||
|
|
||||||
if ((changed_flags & CLUTTER_FONT_HINTING))
|
if ((changed_flags & CLUTTER_FONT_HINTING))
|
||||||
cairo_font_options_set_hint_style (font_options,
|
cairo_font_options_set_hint_style (new_font_options,
|
||||||
(flags & CLUTTER_FONT_HINTING)
|
(flags & CLUTTER_FONT_HINTING)
|
||||||
? CAIRO_HINT_STYLE_FULL
|
? CAIRO_HINT_STYLE_FULL
|
||||||
: CAIRO_HINT_STYLE_NONE);
|
: CAIRO_HINT_STYLE_NONE);
|
||||||
|
|
||||||
clutter_backend_set_font_options (CLUTTER_CONTEXT ()->backend, font_options);
|
clutter_backend_set_font_options (backend, new_font_options);
|
||||||
|
|
||||||
cairo_font_options_destroy (font_options);
|
cairo_font_options_destroy (new_font_options);
|
||||||
|
|
||||||
if (CLUTTER_CONTEXT ()->pango_context)
|
if (CLUTTER_CONTEXT ()->pango_context)
|
||||||
update_pango_context (CLUTTER_CONTEXT ()->backend,
|
update_pango_context (backend, CLUTTER_CONTEXT ()->pango_context);
|
||||||
CLUTTER_CONTEXT ()->pango_context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2717,7 +2720,7 @@ clutter_get_font_flags (void)
|
|||||||
{
|
{
|
||||||
ClutterMainContext *ctxt = CLUTTER_CONTEXT ();
|
ClutterMainContext *ctxt = CLUTTER_CONTEXT ();
|
||||||
CoglPangoFontMap *font_map = NULL;
|
CoglPangoFontMap *font_map = NULL;
|
||||||
cairo_font_options_t *font_options;
|
const cairo_font_options_t *font_options;
|
||||||
ClutterFontFlags flags = 0;
|
ClutterFontFlags flags = 0;
|
||||||
|
|
||||||
font_map = CLUTTER_CONTEXT ()->font_map;
|
font_map = CLUTTER_CONTEXT ()->font_map;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user