summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am1
-rw-r--r--src/cairo-scaled-font-test.h49
-rw-r--r--src/cairo-scaled-font.c17
3 files changed, 66 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 2f1c8e04..57d1e803 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -189,6 +189,7 @@ libcairo_la_SOURCES = \
cairo-rectangle.c \
cairo-region.c \
cairo-scaled-font.c \
+ cairo-scaled-font-test.h \
cairo-slope.c \
cairo-spline.c \
cairo-stroke-style.c \
diff --git a/src/cairo-scaled-font-test.h b/src/cairo-scaled-font-test.h
new file mode 100644
index 00000000..20723afa
--- /dev/null
+++ b/src/cairo-scaled-font-test.h
@@ -0,0 +1,49 @@
+/* cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2006 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * The Initial Developer of the Original Code is University of Southern
+ * California.
+ *
+ * Contributor(s):
+ * Carl D. Worth <cworth@cworth.org>
+ */
+
+#ifndef CAIRO_SCALED_FONT_TEST_H
+#define CAIRO_SCALED_FONT_TEST_H
+
+#include <cairo.h>
+
+CAIRO_BEGIN_DECLS
+
+void
+cairo_scaled_font_test_set_max_glyphs_cached_per_font (int max);
+
+CAIRO_END_DECLS
+
+#endif /* CAIRO_SCALED_FONT_TEST_H */
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index c614d811..66e9fbc5 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -37,6 +37,7 @@
*/
#include "cairoint.h"
+#include "cairo-scaled-font-test.h"
static cairo_bool_t
_cairo_scaled_glyph_keys_equal (const void *abstract_key_a, const void *abstract_key_b)
@@ -313,6 +314,20 @@ _cairo_scaled_font_keys_equal (const void *abstract_key_a, const void *abstract_
cairo_font_options_equal (&key_a->options, &key_b->options));
}
+/* XXX: This 256 number is arbitary---we've never done any measurement
+ * of this. In fact, having a per-font glyph caches each managed
+ * separately is probably not waht we want anyway. Would probably be
+ * much better to have a single cache for glyphs with random
+ * replacement across all glyphs of all fonts. */
+static int max_glyphs_cached_per_font = 256;
+
+/* For internal testing purposes only. Not part of the supported API. */
+void
+cairo_scaled_font_test_set_max_glyphs_cached_per_font (int max)
+{
+ max_glyphs_cached_per_font = max;
+}
+
/*
* Basic cairo_scaled_font_t object management
*/
@@ -338,7 +353,7 @@ _cairo_scaled_font_init (cairo_scaled_font_t *scaled_font,
scaled_font->glyphs = _cairo_cache_create (_cairo_scaled_glyph_keys_equal,
_cairo_scaled_glyph_destroy,
- 256);
+ max_glyphs_cached_per_font);
scaled_font->surface_backend = NULL;
scaled_font->surface_private = NULL;