mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 20:28:02 +02:00
[scaled-font] Get rid of _cairo_scaled_font_test_set_max_glyphs_cached_per_font
in favor of cairo_boilerplate_scaled_font_set_max_glyphs_cached.
This commit is contained in:
parent
44563161de
commit
79098c0370
8 changed files with 53 additions and 64 deletions
|
|
@ -3,6 +3,7 @@ EXTRA_LTLIBRARIES = libcairoboilerplate.la
|
|||
libcairoboilerplate_la_SOURCES =\
|
||||
cairo-boilerplate.c \
|
||||
cairo-boilerplate.h \
|
||||
cairo-boilerplate-scaled-font.h \
|
||||
xmalloc.c \
|
||||
xmalloc.h
|
||||
libcairoboilerplate_la_LIBADD = $(top_builddir)/src/libcairo.la $(CAIRO_LDADD)
|
||||
|
|
|
|||
34
boilerplate/cairo-boilerplate-scaled-font.h
Normal file
34
boilerplate/cairo-boilerplate-scaled-font.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
|
||||
/*
|
||||
* Copyright © 2007 Red Hat, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the name of
|
||||
* Red Hat, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior
|
||||
* permission. Red Hat, Inc. makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: Behdad Esfahbod <behdad@behdad.org>
|
||||
*/
|
||||
|
||||
#ifndef _CAIRO_BOILERPLATE_SCALED_FONT_H_
|
||||
#define _CAIRO_BOILERPLATE_SCALED_FONT_H_
|
||||
|
||||
void
|
||||
cairo_boilerplate_scaled_font_set_max_glyphs_cached (cairo_scaled_font_t *scaled_font,
|
||||
int max_glyphs);
|
||||
|
||||
#endif
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "cairo-boilerplate.h"
|
||||
#include "cairo-boilerplate-scaled-font.h"
|
||||
|
||||
#if CAIRO_HAS_BEOS_SURFACE
|
||||
#include "cairo-boilerplate-beos-private.h"
|
||||
|
|
@ -60,6 +61,9 @@
|
|||
#include "cairo-boilerplate-xlib-private.h"
|
||||
#endif
|
||||
|
||||
#include <cairo-types-private.h>
|
||||
#include <cairo-scaled-font-private.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
|
|
@ -434,3 +438,10 @@ cairo_boilerplate_surface_set_user_data (cairo_surface_t *surface,
|
|||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cairo_boilerplate_scaled_font_set_max_glyphs_cached (cairo_scaled_font_t *scaled_font,
|
||||
int max_glyphs)
|
||||
{
|
||||
scaled_font->glyphs->max_size = max_glyphs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,7 +205,6 @@ libcairo_la_SOURCES = \
|
|||
cairo-rectangle.c \
|
||||
cairo-region.c \
|
||||
cairo-scaled-font.c \
|
||||
cairo-scaled-font-test.h \
|
||||
cairo-scaled-font-private.h \
|
||||
cairo-skiplist.c \
|
||||
cairo-skiplist-private.h \
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
#include "cairo.h"
|
||||
|
||||
#include "cairo-types-private.h"
|
||||
#include "cairo-mutex-private.h"
|
||||
|
||||
struct _cairo_scaled_font {
|
||||
/* For most cairo objects, the rule for multiple threads is that
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
/* 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
|
||||
|
||||
cairo_public void
|
||||
_cairo_scaled_font_test_set_max_glyphs_cached_per_font (int max);
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#endif /* CAIRO_SCALED_FONT_TEST_H */
|
||||
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-scaled-font-private.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)
|
||||
|
|
@ -332,14 +331,7 @@ _cairo_scaled_font_keys_equal (const void *abstract_key_a, const void *abstract_
|
|||
* separately is probably not what 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;
|
||||
}
|
||||
#define MAX_GLYPHS_CACHED_PER_FONT 256
|
||||
|
||||
/*
|
||||
* Basic cairo_scaled_font_t object management
|
||||
|
|
@ -372,7 +364,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,
|
||||
max_glyphs_cached_per_font);
|
||||
MAX_GLYPHS_CACHED_PER_FONT);
|
||||
if (scaled_font->glyphs == NULL)
|
||||
return CAIRO_STATUS_NO_MEMORY;
|
||||
|
||||
|
|
@ -410,7 +402,7 @@ _cairo_scaled_font_reset_cache (cairo_scaled_font_t *scaled_font)
|
|||
_cairo_cache_destroy (scaled_font->glyphs);
|
||||
scaled_font->glyphs = _cairo_cache_create (_cairo_scaled_glyph_keys_equal,
|
||||
_cairo_scaled_glyph_destroy,
|
||||
max_glyphs_cached_per_font);
|
||||
MAX_GLYPHS_CACHED_PER_FONT);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
#include "cairo-scaled-font-test.h"
|
||||
#include "cairo-boilerplate-scaled-font.h"
|
||||
|
||||
#define TEXT_SIZE 12
|
||||
|
||||
|
|
@ -67,8 +67,6 @@ draw (cairo_t *cr, int width, int height)
|
|||
cairo_paint (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
_cairo_scaled_font_test_set_max_glyphs_cached_per_font (1);
|
||||
|
||||
cairo_select_font_face (cr, "Bitstream Vera Sans",
|
||||
CAIRO_FONT_SLANT_NORMAL,
|
||||
CAIRO_FONT_WEIGHT_NORMAL);
|
||||
|
|
@ -76,6 +74,8 @@ draw (cairo_t *cr, int width, int height)
|
|||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0); /* black */
|
||||
|
||||
cairo_boilerplate_scaled_font_set_max_glyphs_cached (cairo_get_scaled_font (cr), 1);
|
||||
|
||||
cairo_move_to (cr, 1, TEXT_SIZE);
|
||||
cairo_show_text (cr, "the five boxing wizards jump quickly");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue