Find a file
Krzysztof Kosiński fb57ea13e0 image: Use convolution filters for sample reconstruction when downscaling
I had a look at how complex would it be to add correct downscaling to
Cairo now that Pixman supports convolution filters. It turns out it
this is rather easy. Here is an initial, minimal attempt. It uses
convolution filters only if the image is being downscaled by more than
half a pixel in at least one dimension.

Some discussion:

1. The sampling and reconstruction kernels are picked in a way that
gives comparable quality when upscaling and downscaling. I paired box
sampling with bilinear reconstruction and impulse (point) sampling
with box reconstruction. This gives the expected result for NEAREST
filter. BEST filter uses Lanczos3 for both kernels.

> Do we need to use a reconstruction filter for NEAREST at all? Or maybe
> differentiate between NEAREST and FAST in that case?

If impulse (point) sampling is used, there must be some reconstruction
filter, otherwise no image is produced. That's because the sampling
grid does not match the data grid, and since there is no
reconstruction filter, values between data points are undefined. The
alternative is to use box sampling + no reconstruction.

2. Subsampling bits are always set to 1, since this doesn't seem to
affect quality at all.

3. I am not sure whether this code works correctly for matrices with a
skew component. It should be OK for any combination of scale, rotation
and translation.

4. This patch causes new failures in the test suite:
- recording-surface*: possibly an effect of improved quality.
- surface-pattern-scale-down*, surface-pattern-big-scale-down: the
reference images should be updated.
- pthread-same-source: I have no idea why this is failing, since this
test shouldn't even trigger the new code.
- large-source-roi: this test attempts to downscale an image which is
30000 pixels wide down to 7 pixels. The filter parameters seem to be
created correctly, but they might trigger an overflow somewhere in the
convolution code; the output rectangle is white instead of red, as if
nothing was drawn.
- device-offset-scale: there are subtle differences which look like
convolution-related smoothing; I'm not sure whether this is OK or not.
2013-09-05 16:08:19 +01:00
boilerplate boilerplate/gl: Disable thread awareness 2013-04-04 12:04:50 -07:00
build Revert accidentally committed stuff 2013-07-29 22:47:26 -04:00
doc typo 2012-04-16 22:11:36 +02:00
perf perf: Move macro-benchmark documentation to cairo-traces 2013-08-11 16:37:02 +02:00
src image: Use convolution filters for sample reconstruction when downscaling 2013-09-05 16:08:19 +01:00
test gl: Return surface in error when creating oversized texture surfaces 2013-08-19 14:54:28 -07:00
util trace: Improve operand emission 2013-06-05 22:34:52 +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: Use correct email for me 2011-02-15 20:41:04 +01:00
autogen.sh build: Do not replace existing files 2012-05-26 16:04:33 +02: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 Bump version for new development tree, 1.13.1 2013-09-05 16:08:19 +01:00
CODING_STYLE [CODING_STYLE] Add vim modeline 2008-09-06 08:11:33 +01:00
configure.ac Provide backwards compatibilty with old pixman 2013-08-23 12:53:27 +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 HACKING: Make mention of the separate cairo-traces repo 2013-08-11 16:33:43 +02:00
INSTALL [INSTALL] Mention pkg-config requirement 2008-10-10 18:03:49 +01:00
KNOWN_ISSUES Add a KNOWN_ISSUES file to track WONTFIX(?) bugs 2010-12-25 10:19:38 +00:00
Makefile.am configure.ac: Update autotools configuration 2012-04-14 15:02:10 +01:00
Makefile.win32 build: Make 'all' the default target in the base Makefile.win32 build 2012-02-18 08:55:59 +01:00
NEWS 1.12.16 release 2013-08-26 17:56:27 +01:00
PORTING_GUIDE Update name from "0.5 porting guide" to "1.0 porting guide." 2005-08-24 08:46:02 +00:00
README README: Note that xcb is no longer experimental 2012-03-27 21:25:07 +02: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 (via both Xlib and XCB), quartz, win32, and image buffers,
as well as PDF, PostScript, and SVG file output. Experimental backends
include OpenGL, 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.20.2	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[*].

	xcb backend
	-----------
	XCB			http://xcb.freedesktop.org

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
-----------------------------
	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.