Add 'private' cairo_scaled_font_test_set_max_glyphs_cached_per_font for testing

This commit is contained in:
Carl Worth 2006-06-22 22:03:06 -07:00
parent d5197c1e0d
commit 333ac8f4d9
3 changed files with 66 additions and 1 deletions

View file

@ -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 \

View file

@ -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 */

View file

@ -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;