clutter/pango: Remove FontMap type
It was created just to keep an instance of the corresponding renderer / context Instead, move those fields into ClutterContext. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4004>
This commit is contained in:
parent
fe3192169a
commit
40dc151e82
6 changed files with 39 additions and 159 deletions
|
@ -35,6 +35,7 @@ struct _ClutterContext
|
||||||
* ordered from least recently added to most recently added */
|
* ordered from least recently added to most recently added */
|
||||||
GList *event_filters;
|
GList *event_filters;
|
||||||
|
|
||||||
|
PangoRenderer *font_renderer;
|
||||||
PangoFontMap *font_map;
|
PangoFontMap *font_map;
|
||||||
|
|
||||||
GSList *current_event;
|
GSList *current_event;
|
||||||
|
@ -50,3 +51,5 @@ struct _ClutterContext
|
||||||
ClutterStageManager * clutter_context_get_stage_manager (ClutterContext *context);
|
ClutterStageManager * clutter_context_get_stage_manager (ClutterContext *context);
|
||||||
|
|
||||||
gboolean clutter_context_get_show_fps (ClutterContext *context);
|
gboolean clutter_context_get_show_fps (ClutterContext *context);
|
||||||
|
|
||||||
|
PangoRenderer * clutter_context_get_font_renderer (ClutterContext *context);
|
||||||
|
|
|
@ -309,6 +309,7 @@ PangoFontMap *
|
||||||
clutter_context_get_pango_fontmap (ClutterContext *context)
|
clutter_context_get_pango_fontmap (ClutterContext *context)
|
||||||
{
|
{
|
||||||
PangoFontMap *font_map;
|
PangoFontMap *font_map;
|
||||||
|
PangoRenderer *font_renderer;
|
||||||
gdouble resolution;
|
gdouble resolution;
|
||||||
ClutterBackend *backend;
|
ClutterBackend *backend;
|
||||||
CoglContext *cogl_context;
|
CoglContext *cogl_context;
|
||||||
|
@ -318,13 +319,15 @@ clutter_context_get_pango_fontmap (ClutterContext *context)
|
||||||
|
|
||||||
backend = clutter_context_get_backend (context);
|
backend = clutter_context_get_backend (context);
|
||||||
cogl_context = clutter_backend_get_cogl_context (backend);
|
cogl_context = clutter_backend_get_cogl_context (backend);
|
||||||
font_map = cogl_pango_font_map_new (cogl_context);
|
font_map = pango_cairo_font_map_new ();
|
||||||
|
font_renderer = _cogl_pango_renderer_new (cogl_context);
|
||||||
|
|
||||||
resolution = clutter_backend_get_resolution (context->backend);
|
resolution = clutter_backend_get_resolution (context->backend);
|
||||||
pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (font_map),
|
pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (font_map),
|
||||||
resolution);
|
resolution);
|
||||||
|
|
||||||
context->font_map = font_map;
|
context->font_map = font_map;
|
||||||
|
context->font_renderer = font_renderer;
|
||||||
|
|
||||||
return context->font_map;
|
return context->font_map;
|
||||||
}
|
}
|
||||||
|
@ -388,3 +391,11 @@ clutter_context_get_settings (ClutterContext *context)
|
||||||
|
|
||||||
return context->settings;
|
return context->settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PangoRenderer *
|
||||||
|
clutter_context_get_font_renderer (ClutterContext *context)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_CONTEXT (context), NULL);
|
||||||
|
|
||||||
|
return context->font_renderer;
|
||||||
|
}
|
||||||
|
|
|
@ -163,16 +163,6 @@ ClutterTextDirection clutter_get_text_direction (void);
|
||||||
typedef void (* ClutterPipelineSetup) (CoglPipeline *pipeline,
|
typedef void (* ClutterPipelineSetup) (CoglPipeline *pipeline,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
/**
|
|
||||||
* clutter_font_map_new:
|
|
||||||
*
|
|
||||||
* Creates a new font map.
|
|
||||||
*
|
|
||||||
* Return value: (transfer full): the newly created #PangoFontMap
|
|
||||||
*/
|
|
||||||
CLUTTER_EXPORT PangoFontMap *
|
|
||||||
clutter_font_map_new (CoglContext *context);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clutter_ensure_glyph_cache_for_layout:
|
* clutter_ensure_glyph_cache_for_layout:
|
||||||
* @layout: A #PangoLayout
|
* @layout: A #PangoLayout
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
/*
|
|
||||||
* Cogl
|
|
||||||
*
|
|
||||||
* A Low Level GPU Graphics and Utilities API
|
|
||||||
*
|
|
||||||
* Copyright (C) 2008 OpenedHand
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person
|
|
||||||
* obtaining a copy of this software and associated documentation
|
|
||||||
* files (the "Software"), to deal in the Software without
|
|
||||||
* restriction, including without limitation the rights to use, copy,
|
|
||||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
||||||
* of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
||||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <pango/pango-fontmap.h>
|
|
||||||
#include <pango/pangocairo.h>
|
|
||||||
#include <pango/pango-renderer.h>
|
|
||||||
|
|
||||||
#include "clutter/pango/cogl-pango-private.h"
|
|
||||||
#include "cogl/cogl.h"
|
|
||||||
|
|
||||||
static GQuark cogl_pango_font_map_get_priv_key (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
typedef struct _CoglPangoFontMapPriv
|
|
||||||
{
|
|
||||||
CoglContext *ctx;
|
|
||||||
PangoRenderer *renderer;
|
|
||||||
} CoglPangoFontMapPriv;
|
|
||||||
|
|
||||||
static void
|
|
||||||
free_priv (gpointer data)
|
|
||||||
{
|
|
||||||
CoglPangoFontMapPriv *priv = data;
|
|
||||||
|
|
||||||
g_object_unref (priv->ctx);
|
|
||||||
g_object_unref (priv->renderer);
|
|
||||||
|
|
||||||
g_free (priv);
|
|
||||||
}
|
|
||||||
|
|
||||||
PangoFontMap *
|
|
||||||
cogl_pango_font_map_new (CoglContext *context)
|
|
||||||
{
|
|
||||||
PangoFontMap *fm = pango_cairo_font_map_new ();
|
|
||||||
g_autofree CoglPangoFontMapPriv *priv = g_new0 (CoglPangoFontMapPriv, 1);
|
|
||||||
|
|
||||||
priv->ctx = g_object_ref (context);
|
|
||||||
|
|
||||||
/* XXX: The public pango api doesn't let us sub-class
|
|
||||||
* PangoCairoFontMap so we attach our own private data using qdata
|
|
||||||
* for now. */
|
|
||||||
g_object_set_qdata_full (G_OBJECT (fm),
|
|
||||||
cogl_pango_font_map_get_priv_key (),
|
|
||||||
g_steal_pointer (&priv),
|
|
||||||
free_priv);
|
|
||||||
|
|
||||||
return fm;
|
|
||||||
}
|
|
||||||
|
|
||||||
PangoRenderer *
|
|
||||||
cogl_pango_font_map_get_renderer (PangoFontMap *fm)
|
|
||||||
{
|
|
||||||
CoglPangoFontMapPriv *priv = g_object_get_qdata (G_OBJECT (fm),
|
|
||||||
cogl_pango_font_map_get_priv_key ());
|
|
||||||
if (G_UNLIKELY (!priv->renderer))
|
|
||||||
priv->renderer = _cogl_pango_renderer_new (priv->ctx);
|
|
||||||
return priv->renderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GQuark
|
|
||||||
cogl_pango_font_map_get_priv_key (void)
|
|
||||||
{
|
|
||||||
static GQuark priv_key = 0;
|
|
||||||
|
|
||||||
if (G_UNLIKELY (priv_key == 0))
|
|
||||||
priv_key = g_quark_from_static_string ("CoglPangoFontMap");
|
|
||||||
|
|
||||||
return priv_key;
|
|
||||||
}
|
|
|
@ -44,20 +44,6 @@ G_BEGIN_DECLS
|
||||||
PangoRenderer *
|
PangoRenderer *
|
||||||
_cogl_pango_renderer_new (CoglContext *context);
|
_cogl_pango_renderer_new (CoglContext *context);
|
||||||
|
|
||||||
PangoFontMap *
|
|
||||||
cogl_pango_font_map_new (CoglContext *context);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cogl_pango_font_map_get_renderer:
|
|
||||||
* @font_map: a #PangoFontMap
|
|
||||||
*
|
|
||||||
* Retrieves the [class@CoglPango.Renderer] for the passed @font_map.
|
|
||||||
*
|
|
||||||
* Return value: (transfer none): a #PangoRenderer
|
|
||||||
*/
|
|
||||||
PangoRenderer *
|
|
||||||
cogl_pango_font_map_get_renderer (PangoFontMap *font_map);
|
|
||||||
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PangoRenderer, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PangoRenderer, g_object_unref)
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
#include <cairo-ft.h>
|
#include <cairo-ft.h>
|
||||||
|
|
||||||
#include "clutter/clutter-debug.h"
|
#include "clutter/clutter-debug.h"
|
||||||
|
#include "clutter/clutter-context-private.h"
|
||||||
|
#include "clutter/clutter-private.h"
|
||||||
#include "clutter/pango/cogl-pango-private.h"
|
#include "clutter/pango/cogl-pango-private.h"
|
||||||
#include "clutter/pango/cogl-pango-glyph-cache.h"
|
#include "clutter/pango/cogl-pango-glyph-cache.h"
|
||||||
#include "clutter/pango/cogl-pango-display-list.h"
|
#include "clutter/pango/cogl-pango-display-list.h"
|
||||||
|
@ -245,22 +247,6 @@ cogl_pango_renderer_finalize (GObject *object)
|
||||||
G_OBJECT_CLASS (cogl_pango_renderer_parent_class)->finalize (object);
|
G_OBJECT_CLASS (cogl_pango_renderer_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CoglPangoRenderer *
|
|
||||||
cogl_pango_get_renderer_from_context (PangoContext *context)
|
|
||||||
{
|
|
||||||
PangoFontMap *font_map;
|
|
||||||
PangoRenderer *renderer;
|
|
||||||
|
|
||||||
font_map = pango_context_get_font_map (context);
|
|
||||||
g_return_val_if_fail (PANGO_IS_FONT_MAP (font_map), NULL);
|
|
||||||
|
|
||||||
renderer = cogl_pango_font_map_get_renderer (font_map);
|
|
||||||
|
|
||||||
g_return_val_if_fail (COGL_PANGO_IS_RENDERER (renderer), NULL);
|
|
||||||
|
|
||||||
return COGL_PANGO_RENDERER (renderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GQuark
|
static GQuark
|
||||||
cogl_pango_layout_get_qdata_key (void)
|
cogl_pango_layout_get_qdata_key (void)
|
||||||
{
|
{
|
||||||
|
@ -310,13 +296,13 @@ clutter_show_layout (CoglFramebuffer *fb,
|
||||||
ClutterPipelineSetup pipeline_setup,
|
ClutterPipelineSetup pipeline_setup,
|
||||||
gpointer pipeline_setup_userdata)
|
gpointer pipeline_setup_userdata)
|
||||||
{
|
{
|
||||||
PangoContext *context;
|
CoglPangoRenderer *renderer;
|
||||||
CoglPangoRenderer *priv;
|
|
||||||
CoglPangoLayoutQdata *qdata;
|
CoglPangoLayoutQdata *qdata;
|
||||||
|
ClutterContext *context;
|
||||||
|
|
||||||
context = pango_layout_get_context (layout);
|
context = _clutter_context_get_default ();
|
||||||
priv = cogl_pango_get_renderer_from_context (context);
|
renderer = COGL_PANGO_RENDERER (clutter_context_get_font_renderer (context));
|
||||||
if (G_UNLIKELY (!priv))
|
if (G_UNLIKELY (!renderer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qdata = g_object_get_qdata (G_OBJECT (layout),
|
qdata = g_object_get_qdata (G_OBJECT (layout),
|
||||||
|
@ -325,7 +311,7 @@ clutter_show_layout (CoglFramebuffer *fb,
|
||||||
if (qdata == NULL)
|
if (qdata == NULL)
|
||||||
{
|
{
|
||||||
qdata = g_new0 (CoglPangoLayoutQdata, 1);
|
qdata = g_new0 (CoglPangoLayoutQdata, 1);
|
||||||
qdata->renderer = priv;
|
qdata->renderer = renderer;
|
||||||
g_object_set_qdata_full (G_OBJECT (layout),
|
g_object_set_qdata_full (G_OBJECT (layout),
|
||||||
cogl_pango_layout_get_qdata_key (),
|
cogl_pango_layout_get_qdata_key (),
|
||||||
qdata,
|
qdata,
|
||||||
|
@ -339,14 +325,14 @@ clutter_show_layout (CoglFramebuffer *fb,
|
||||||
if (qdata->display_list &&
|
if (qdata->display_list &&
|
||||||
((qdata->first_line &&
|
((qdata->first_line &&
|
||||||
qdata->first_line->layout != layout) ||
|
qdata->first_line->layout != layout) ||
|
||||||
qdata->mipmapping_used != priv->use_mipmapping))
|
qdata->mipmapping_used != renderer->use_mipmapping))
|
||||||
cogl_pango_layout_qdata_forget_display_list (qdata);
|
cogl_pango_layout_qdata_forget_display_list (qdata);
|
||||||
|
|
||||||
if (qdata->display_list == NULL)
|
if (qdata->display_list == NULL)
|
||||||
{
|
{
|
||||||
CoglPangoRendererCaches *caches = priv->use_mipmapping ?
|
CoglPangoRendererCaches *caches = renderer->use_mipmapping ?
|
||||||
&priv->mipmap_caches :
|
&renderer->mipmap_caches :
|
||||||
&priv->no_mipmap_caches;
|
&renderer->no_mipmap_caches;
|
||||||
|
|
||||||
clutter_ensure_glyph_cache_for_layout (layout);
|
clutter_ensure_glyph_cache_for_layout (layout);
|
||||||
|
|
||||||
|
@ -360,11 +346,11 @@ clutter_show_layout (CoglFramebuffer *fb,
|
||||||
(GHookFunc) cogl_pango_layout_qdata_forget_display_list,
|
(GHookFunc) cogl_pango_layout_qdata_forget_display_list,
|
||||||
qdata);
|
qdata);
|
||||||
|
|
||||||
priv->display_list = qdata->display_list;
|
renderer->display_list = qdata->display_list;
|
||||||
pango_renderer_draw_layout (PANGO_RENDERER (priv), layout, 0, 0);
|
pango_renderer_draw_layout (PANGO_RENDERER (renderer), layout, 0, 0);
|
||||||
priv->display_list = NULL;
|
renderer->display_list = NULL;
|
||||||
|
|
||||||
qdata->mipmapping_used = priv->use_mipmapping;
|
qdata->mipmapping_used = renderer->use_mipmapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_framebuffer_push_matrix (fb);
|
cogl_framebuffer_push_matrix (fb);
|
||||||
|
@ -506,13 +492,12 @@ cogl_pango_renderer_set_dirty_glyph (PangoFont *font,
|
||||||
static void
|
static void
|
||||||
_cogl_pango_ensure_glyph_cache_for_layout_line_internal (PangoLayoutLine *line)
|
_cogl_pango_ensure_glyph_cache_for_layout_line_internal (PangoLayoutLine *line)
|
||||||
{
|
{
|
||||||
PangoContext *context;
|
ClutterContext *context;
|
||||||
PangoRenderer *renderer;
|
PangoRenderer *renderer;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
|
||||||
context = pango_layout_get_context (line->layout);
|
context = _clutter_context_get_default ();
|
||||||
renderer =
|
renderer = clutter_context_get_font_renderer (context);
|
||||||
PANGO_RENDERER (cogl_pango_get_renderer_from_context (context));
|
|
||||||
|
|
||||||
for (l = line->runs; l; l = l->next)
|
for (l = line->runs; l; l = l->next)
|
||||||
{
|
{
|
||||||
|
@ -549,12 +534,12 @@ _cogl_pango_set_dirty_glyphs (CoglPangoRenderer *priv)
|
||||||
void
|
void
|
||||||
clutter_ensure_glyph_cache_for_layout (PangoLayout *layout)
|
clutter_ensure_glyph_cache_for_layout (PangoLayout *layout)
|
||||||
{
|
{
|
||||||
PangoContext *context;
|
ClutterContext *context;
|
||||||
CoglPangoRenderer *priv;
|
PangoRenderer *renderer;
|
||||||
PangoLayoutIter *iter;
|
PangoLayoutIter *iter;
|
||||||
|
|
||||||
context = pango_layout_get_context (layout);
|
context = _clutter_context_get_default ();
|
||||||
priv = cogl_pango_get_renderer_from_context (context);
|
renderer = clutter_context_get_font_renderer (context);
|
||||||
|
|
||||||
g_return_if_fail (PANGO_IS_LAYOUT (layout));
|
g_return_if_fail (PANGO_IS_LAYOUT (layout));
|
||||||
|
|
||||||
|
@ -575,7 +560,7 @@ clutter_ensure_glyph_cache_for_layout (PangoLayout *layout)
|
||||||
|
|
||||||
/* Now that we know all of the positions are settled we'll fill in
|
/* Now that we know all of the positions are settled we'll fill in
|
||||||
any dirty glyphs */
|
any dirty glyphs */
|
||||||
_cogl_pango_set_dirty_glyphs (priv);
|
_cogl_pango_set_dirty_glyphs (COGL_PANGO_RENDERER (renderer));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue