Find a file
Dmitri Vorobiev 5cb764850f scaled-font: optimize cairo_scaled_font_text_to_glyphs()
This patch serves two purposes. First, it factors out the heavy part
of the cairo_scaled_font_text_to_glyphs() routine thus allowing GCC
to better optimize the cache cleanup loop. Keeping the look-up table
indices in a separate array speeds up array initialization even further.

Second, this patch introduces a shortcut for the case when the string
to be rendered consists of a single character. In this case, caching is
not necessary at all.

We have a benchmark that uses Cairo to render a large amount of random
strings of consisting of printable ASCII characters. Below are Oprofile
results collected while running this benchmark. It is easy to see that
the heavy part becomes noticeably lighter.

Before:

Profiling through timer interrupt
samples  %        app name                 symbol name
198755   13.5580  libcairo.so.2.10907.0    cairo_scaled_font_text_to_glyphs
88580     6.0424  libcairo.so.2.10907.0    _cairo_scaled_glyph_lookup
81127     5.5340  libcairo.so.2.10907.0    _cairo_hash_table_lookup
68186     4.6513  libcairo.so.2.10907.0    cairo_scaled_font_glyph_extents
47145     3.2160  libcairo.so.2.10907.0    _composite_glyphs_via_mask
46327     3.1602  libcairo.so.2.10907.0    _cairo_scaled_font_glyph_device_extents
44817     3.0572  libcairo.so.2.10907.0    _composite_glyphs
40431     2.7580  libcairo.so.2.10907.0    .plt

After (note that cairo_scaled_font_text_to_glyphs_internal_single() was inlined):

Profiling through timer interrupt
samples  %        app name                 symbol name
107264    7.6406  libcairo.so.2.10907.0    cairo_scaled_font_text_to_glyphs_internal_multiple
87888     6.2604  libcairo.so.2.10907.0    _cairo_scaled_glyph_lookup
79011     5.6281  libcairo.so.2.10907.0    _cairo_hash_table_lookup
71723     5.1090  libcairo.so.2.10907.0    cairo_scaled_font_glyph_extents
48084     3.4251  libcairo.so.2.10907.0    _composite_glyphs_via_mask
46636     3.3220  libcairo.so.2.10907.0    _cairo_scaled_font_glyph_device_extents
44740     3.1869  libcairo.so.2.10907.0    _composite_glyphs
42472     3.0254  libc-2.8.so              _int_malloc
39194     2.7919  libcairo.so.2.10907.0    _cairo_gstate_transform_glyphs_to_backend
38614     2.7506  libcairo.so.2.10907.0    .plt
37063     2.6401  libcairo.so.2.10907.0    _cairo_ft_ucs4_to_index
36856     2.6253  libc-2.8.so              random
36376     2.5911  libcairo.so.2.10907.0    _cairo_scaled_glyphs_equal
34545     2.4607  libcairo.so.2.10907.0    cairo_matrix_transform_point
31690     2.2573  libc-2.8.so              malloc
29395     2.0939  libcairo.so.2.10907.0    _cairo_matrix_is_identity
26142     1.8621  libcairo.so.2.10907.0    _cairo_utf8_to_ucs4
24406     1.7385  libc-2.8.so              free
24059     1.7138  libcairo.so.2.10907.0    cairo_scaled_font_text_to_glyphs

[ickle: slightly amended for stylistic consistency.]
2010-06-10 12:05:41 +01:00
boilerplate boilerplate: Exercise RENDER capable windows. 2010-05-27 17:53:30 +01:00
build build: Fix pthread detection 2010-05-13 15:17:27 +02:00
doc language bindings guide: clarify mapping for cairo_pattern_create_rgb[a] 2010-05-13 10:08:32 +01:00
perf perf: Correct cairo-perf-diff syntax 2010-04-10 18:25:25 +02:00
src scaled-font: optimize cairo_scaled_font_text_to_glyphs() 2010-06-10 12:05:41 +01:00
test test: Add half-coverage to exercise the rasteriser with subpixel geometry. 2010-06-09 10:34:06 +01:00
util script: Update csi-exec to match new interface. 2010-05-27 17:53:30 +01:00
.gitignore gitignore: refresh 2010-01-22 22:30:43 +00:00
acinclude.m4 [build] Remove a level of quoting from CAIRO_PARSE_VERSION. 2009-06-20 06:11:44 -06:00
AUTHORS AUTHORS: Add Andrea Canciani 2009-11-05 10:13:34 +00:00
autogen.sh Rename Makefile.*.config to Makefile.*.features as they should not be modified 2008-09-22 17:34:36 -04:00
BIBLIOGRAPHY BIBLIOGRAPHY: Cite Hars & Petruska's Pseudorandom Recursions paper. 2008-11-18 00:20:38 +02:00
BUGS Add notes on reporting bugs to BUGS file and move bugs listed there to ROADMAP instead. 2006-08-18 15:02:24 -07:00
cairo-version.h Update version to 1.9.7. 2010-02-19 17:39:50 -08:00
CODING_STYLE [CODING_STYLE] Add vim modeline 2008-09-06 08:11:33 +01:00
configure.ac configure: Include PTHREAD_CFLAGS in CAIRO_LDFLAGS 2010-05-16 10:07:07 +01:00
COPYING Add a COPYING file to each aux. source directory 2008-10-31 16:14:14 +00:00
COPYING-LGPL-2.1 Update FSF address 2010-04-27 11:13:38 +02:00
COPYING-MPL-1.1 Add the MPL as a new license option, in addition to the LGPL. 2004-09-04 06:38:34 +00:00
HACKING Fix various README typos 2009-01-02 02:56:38 -05:00
INSTALL [INSTALL] Mention pkg-config requirement 2008-10-10 18:03:49 +01:00
Makefile.am Comment win32 maintainer-clean files again 2009-01-10 13:09:06 -05:00
Makefile.win32 [Makefile.win32] Add comments about where to edit for customization 2008-09-23 04:11:48 -04:00
NEWS NEWS: Add notes for the 1.9.6 snapshot. 2010-02-19 17:24:01 -08:00
PORTING_GUIDE Update name from "0.5 porting guide" to "1.0 porting guide." 2005-08-24 08:46:02 +00:00
README build: Remove glitz surface 2010-01-27 09:56:14 +01:00
README.win32 [README.win32] Update wording from Tor Lillqvist 2008-09-26 12:44:53 -04:00
RELEASING [RELEASING] Correct a few minor typos. 2008-12-14 16:39:55 +00:00

Cairo - Multi-platform 2D graphics library
http://cairographics.org

What is cairo
=============
Cairo is a 2D graphics library with support for multiple output
devices. Currently supported output targets include the X Window
System, quartz, win32, and image buffers, as well as PDF, PostScript,
and SVG file output. Experimental backends include OpenGL, XCB, BeOS,
OS/2, and DirectFB.

Cairo is designed to produce consistent output on all output media
while taking advantage of display hardware acceleration when available
(for example, through the X Render Extension).

The cairo API provides operations similar to the drawing operators of
PostScript and PDF. Operations in cairo include stroking and filling
cubic Bézier splines, transforming and compositing translucent images,
and antialiased text rendering. All drawing operations can be
transformed by any affine transformation (scale, rotation, shear,
etc.).

Cairo has been designed to let you draw anything you want in a modern
2D graphical user interface.  At the same time, the cairo API has been
designed to be as fun and easy to learn as possible. If you're not
having fun while programming with cairo, then we have failed
somewhere---let us know and we'll try to fix it next time around.

Cairo is free software and is available to be redistributed and/or
modified under the terms of either the GNU Lesser General Public
License (LGPL) version 2.1 or the Mozilla Public License (MPL) version
1.1.

Where to get more information about cairo
=========================================
The primary source of information about cairo is:

	http://cairographics.org/

The latest versions of cairo can always be found at:

	http://cairographics.org/download

Documentation on using cairo and frequently-asked questions:

	http://cairographics.org/documentation
	http://cairographics.org/FAQ

Mailing lists for contacting cairo users and developers:

	http://cairographics.org/lists

Roadmap and unscheduled things to do, (please feel free to help out):

	http://cairographics.org/roadmap
	http://cairographics.org/todo

Dependencies
============
The set of libraries needed to compile cairo depends on which backends
are enabled when cairo is configured. So look at the list below to
determine which dependencies are needed for the backends of interest.

For the surface backends, we have both "supported" and "experimental"
backends. Further, the supported backends can be divided into the
"standard" backends which can be easily built on any platform, and the
"platform" backends which depend on some underlying platform-specific
system, (such as the X Window System or some other window system).

As an example, for a standard Linux build, (with image, png, pdf,
PostScript, svg, and xlib surface backends, and the freetype font
backend), the following sample commands will install necessary
dependencies:

    Debian (and similar):

	apt-get install libpng12-dev libz-dev libxrender-dev libfontconfig1-dev

    Fedora (and similar):

	yum install libpng-devel zlib-devel libXrender-devel fontconfig-devel

(Those commands intentionally don't install pixman from a distribution
package since if you're manually compiling cairo, then you likely want
to grab pixman from the same place at the same time and compile it as
well.)

Supported, "standard" surface backends
------------------------------------
	image backend (required)
	------------------------
	pixman >= 0.12.0	http://cairographics.org/releases

	png support (can be left out if desired, but many
	-----------  applications expect it to be present)
	libpng			http://www.libpng.org/pub/png/libpng.html

	pdf backend
	-----------
	zlib			http://www.gzip.org/zlib

	postscript backend
	------------------
	zlib			http://www.gzip.org/zlib

	svg backend
	-----------
	[none]

Supported, "platform" surface backends
-----------------------------------
	xlib backend
	------------
	X11			http://freedesktop.org/Software/xlibs

	xlib-xrender backend
	--------------------
	Xrender >= 0.6		http://freedesktop.org/Software/xlibs

	quartz backend
	--------------
	MacOS X >= 10.4 with Xcode >= 2.4

	win32 backend
	-------------
	Microsoft Windows 2000 or newer[*].

Font backends (required to have at least one)
---------------------------------------------
	freetype font backend
	---------------------
	freetype >= 2.1.9	http://freetype.org
	fontconfig		http://fontconfig.org

	quartz-font backend
	-------------------
	MacOS X >= 10.4 with Xcode >= 2.4

	win32 font backend
	------------------
	Microsoft Windows 2000 or newer[*].

	[*] The Win32 backend should work on Windows 2000 and newer
	    (excluding Windows Me.) Most testing has been done on
	    Windows XP. While some portions of the code have been
	    adapted to work on older versions of Windows, considerable
	    work still needs to be done to get cairo running in those
	    environments.

	    Cairo can be compiled on Windows with either the gcc
	    toolchain (see http://www.mingw.org) or with Microsoft
	    Visual C++.  If the gcc toolchain is used, the standard
	    build instructions using configure apply, (see INSTALL).
	    If Visual C++ is desired, GNU make is required and
	    Makefile.win32 can be used via 'make -f Makefile.win32'.
	    The compiler, include paths, and library paths must be set
	    up correctly in the environment.

	    MSVC versions earlier than 7.1 are known to miscompile
	    parts of cairo and pixman, and so should be avoided. MSVC
	    7.1 or later, including the free Microsoft Visual Studio
	    Express editions, produce correct code.

Experimental surface backends
-----------------------------
	xcb backend
	-----------
	XCB			http://xcb.freedesktop.org

	beos backend
	------------
	No dependencies in itself other than an installed BeOS system, but cairo
	requires a font backend. See the freetype dependency list.

	os2 backend
	-----------
	Cairo should run on any recent version of OS/2 or eComStation, but it
	requires a font backend. See the freetype dependency list. Ready to use
	packages and developer dependencies are available at Netlabs:
				ftp://ftp.netlabs.org/pub/cairo

Compiling
=========
See the INSTALL document for build instructions.

History
=======
Cairo was originally developed by Carl Worth <cworth@cworth.org> and
Keith Packard <keithp@keithp.com>. Many thanks are due to Lyle Ramshaw
without whose patient help our ignorance would be much more apparent.

Since the original development, many more people have contributed to
cairo. See the AUTHORS files for as complete a list as we've been able
to compile so far.