summaryrefslogtreecommitdiff
path: root/src/cairo-color.c
Commit message (Collapse)AuthorAgeFilesLines
* _cairo_color_double_to_short(): Use standard rounding algorithmSøren Sandmann Pedersen2013-10-221-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The _cairo_color_double_to_short() function converts a double precision floating point value in the range of [0.0, 1.0] to a uint16_t integer by dividing the [0.0, 1.0] range into 65536 equal-sized intervals and then associating each interval with an integer. Under the assumption that an integer i corresponds to the real value i / 65535.0 this algorithm introduces more error than necessary as can be seen from the following picture showing the analogous transformation for two-bit integers: +-----------+-----------+-----------+-----------+ 0b00 | 0b01 | 0b10 | 0b11 +-----------+-----------+-----------+-----------+ which shows that some floating point values are not converted to the integer that would minimize the error in value that that integer corresponds to. Instead, this patch uses standard rounding, which makes the diagram look like this: +-------+---------------+---------------+-------+ 0b00 | 0b01 | 0b10 | 0b11 +-------+---------------+---------------+-------+ It's clear that if the values corresponding to the given integers are fixed, then it's not possible to decrease the resulting error by moving any of the interval boundaries. See this thread for more information: http://lists.freedesktop.org/archives/cairo/2013-October/024691.html Reference images updated: pthread-similar.ref.png record-paint-alpha.ref.png record90-paint-alpha.argb32.ref record90-paint-alpha.rgb24.ref.png xcb-huge-image-shm.ref.png xcb-huge-subimage.ref.png All of these have only one-step differences to the old images.
* color: Remove unused functionsAndrea Canciani2011-07-081-13/+0
| | | | | _cairo_color_init() and _cairo_color_init_rgb() are basically unused (except in some experimantal code, which is trivial to fix).
* Correct color stops comparison functionAndrea Canciani2010-08-081-21/+4
| | | | | | Two clear stops with different "underlying" colors must be considered different, since when interpolated with non-clear colors they will produce different results.
* pattern: remove content field from solid patternsAndrea Canciani2010-06-101-0/+16
| | | | | The content field in solid patterns had ill-defined semantic (or no semantic at all), thus it can be removed.
* Make _cairo_color_equal() work for unmultiplied colors, tooBenjamin Otte2010-05-131-2/+8
| | | | Color stop colors are unmultiplied, and we use it there.
* Make cairo_color_stop_t a unique type.Chris Wilson2010-05-131-2/+2
| | | | | | | | | Hopefully reduce the occurrence of the confusion between the premultiplied shorts in cairo_color_t and the non-premultiplied shorts in cairo_color_stop_t. The existence of the two separate types is debatable and open for review.
* color: Special case comparing color stops.Chris Wilson2010-05-131-0/+30
| | | | | | color stops are not premultiplied so we need to handle them carefully when comparing. The next step will be to make cairo_color_stop_t a unique type to prevent this mistake again.
* Update FSF addressAndrea Canciani2010-04-271-1/+1
| | | | | | | | | | | I updated the Free Software Foundation address using the following script. for i in $(git grep Temple | cut -d: -f1 ) do sed -e 's/59 Temple Place[, -]* Suite 330, Boston, MA *02111-1307[, ]* USA/51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA/' -i "$i" done Fixes http://bugs.freedesktop.org/show_bug.cgi?id=21356
* color: Add enum value for the largest stock color.Chris Wilson2010-01-221-6/+7
| | | | | Useful if we wish to keep a cache of patterns for the very common stock colors...
* [directfb] When blitting check if we need the un-premultiplied color.Chris Wilson2008-10-201-0/+3
| | | | | When blitting whether we need to use the premultiplied color is dependent upon the destination surface capabilities.
* [cairo-color] Only compare the shorts for equality.Chris Wilson2007-05-051-1/+4
| | | | | By only checking the premultiplied shorts inside the cairo_color_t we only have to compare at most 8 bytes instead of the full 24 bytes.
* Cache solid patternsChris Wilson2007-03-201-0/+7
| | | | | | | | | | | | We use a small cache of size 16 for patterns created from solid colors, e.g. cairo_set_source_rgb(). This helps with toolkits that draw many widgets using the same colour scheme. The cache uses a static index variable, which itself acts like a cache of size 1, remembering the most recently used colour. So repeated lookups for the same colour hit immediately. If that fails, the cache is searched linearly, and if that fails too, a new pattern is created and a random member of the cache is evicted.
* [cairo-color] Add cairo-private _cairo_color_double_to_short()Behdad Esfahbod2007-03-131-5/+6
|
* Revert the solid-pattern cacheBehdad Esfahbod2007-02-281-7/+0
| | | | | | | | | | | | | | | | This reverts the following commits: 2715f2098127d04d2f9e304580a26cd0842c0e64 67e3b3c53bdd69e4d3503eed2db66953f1ac038c See this thread for an analysis of the problems it caused: http://lists.freedesktop.org/archives/cairo/2007-February/009825.html In short, a single cache for all backends doesn't work, as one thread using any backend can cause an unused xlib pattern to be evicted from the cache, and trigger an xlib call while the display is being used from another thread. Xlib is not prepared for this.
* [cairo-pattern] Cache surface for solid patternsJorn Baayen2007-02-141-0/+7
| | | | | | | | | | | | | | | | | | | We use a small cache of size 16 for surfaces created for solid patterns. This mainly helps with the X backends where we don't have to create a pattern for every operation, so we save a lot on X traffic. Xft uses a similar cache, so cairo's text rendering traffic with the xlib backend now completely matches that of Xft. The cache uses an static index variable, which itself acts like a cache of size 1, remembering the most recently used solid pattern. So repeated lookups for the same pattern hit immediately. If that fails, the cache is searched linearly, and if that fails too, a new surface is created and a random member of the cache is evicted. Only surfaces that are "compatible" are used. The definition of compatible is backend specific. For the xlib backend, it means that the two surfaces are allocated on the same display. Implementations for compatibility are provided for all backends that it makes sense.
* Bug #7497: Change _cairo_color_compute_shorts to not rely on any particular ↵Carl Worth2006-10-161-8/+16
| | | | floating-point epsilon value.
* Fix conversion to short, to get a uniform range even for 0xffff. In other ↵Behdad Esfahbod2005-08-131-19/+9
| | | | words, a color component of of (1.0 - epsilon) would convert to 0xffff, not 0xfffe.
* and delete:Carl Worth2005-04-141-27/+93
| | | | | | | | | | | | | | | | | | | | | | | | cairo_set_pattern -> cairo_set_source cairo_get_pattern -> cairo_get_source cairo_set_rgb_color -> cairo_set_source_rgb -> cairo_set_source_rgba cairo_set_alpha -> cairo_get_alpha -> Note that we'll likely want to add cairo_set_source_surface. Add _cairo_stock_color helper function. Improve some interfaces: _cairo_color_init _cairo_color_init_rgb _cairo_color_set_rgb -> _cairo_color_init_rgba _cairo_color_set_alpha _cairo_color_multiply_alpha _cairo_color_get_rgb -> _cairo_color_get_rbga _cairo_color_get_rgba_premultiplied Add cairo_stock_t and some helper macros: CAIRO_COLOR_WHITE CAIRO_COLOR_BLACK CAIRO_COLOR_TRANSPARENT Fix cairo_pattern_t by eliminating pattern->alpha. Fix cairo_solid_pattern_t to use cairo_color_t rather than three doubles. Track removal of pattern->alpha, simplifying the code considerably Track _cairo_color interface changes. Remove gstate->alpha. Propagate down set_source renamings. cairo_pattern_add_color_stop -> cairo_pattern_add_color_stop_rgba and add: cairo_pattern_add_color_stop_rgb Remove pattern->alpha, simplifying the code considerably. Track pattern and color interface changes. Add const where appropriate on cairo_color_t*. Add private type inspection predicate. (cairo_xlib_surface_set_size): Add check for surface type mismatch, (no useful error reporting yet, though). Note coverage as en expected failure. Improve line wrap on expected failure messages. Port all tests to new cairo_set_source interfaces.
* Switch from broken cworth@isi.edu address to canonical cworth@cworth.org ↵Carl Worth2005-02-221-1/+1
| | | | address.
* Qualify color argument as const. Closes bug #2336.Carl Worth2005-01-241-1/+2
|
* Allow NULL values for return pointers so that the user can easily get ↵Carl Worth2005-01-191-3/+6
| | | | partial results from cairo_matrix_get_affine, cairo_current_point, and cairo_current_color_rgb as needed.
* renamed CAIRO_COLOR_DEFAULT to CAIRO_COLOR_WHITEØyvind Kolås2005-01-111-4/+4
|
* changed default paint color to opaque blackØyvind Kolås2005-01-111-2/+2
|
* Convert all files to utf-8. Add copyright information to cairo_png_surface.c.Carl Worth2004-10-211-1/+1
|
* Add the MPL as a new license option, in addition to the LGPL.Carl Worth2004-09-041-10/+27
|
* Fix to explicitly refer to GNU Lesser Public License 2.1 rather than the ↵Carl Worth2004-08-021-7/+5
| | | | Library Public License version 2 or 'any later version'
* Change from MIT license to LGPL.Carl Worth2004-08-021-20/+14
|
* Fixed copyright attribution to refer to "University of Southern CaliforniaCarl Worth2003-10-231-1/+1
|
* Mark const.Richard Henderson2003-07-311-1/+1
| | | | | | Likewise. Likewise. Likewise for cb.
* Made all changes necessary to abandon the Xc library, (sucking the ↵Carl Worth2003-07-301-17/+21
| | | | functionality up into cairo_surface_t instead). Eliminated most of the remaining X datatypes (XFixed, XPointFixed, XLineFixed, XTrapezoid). Fixed some numerical problems relating to pen initialization and intersection calculation.
* Renamed everything from Xr* to cairo_*Carl Worth2003-07-181-0/+80