Commit graph

44 commits

Author SHA1 Message Date
Carl Worth
8084fb9b09 Add new _cairo_pattern_create_in_error.
Propagate error values from cr->status to pattern->status.
2005-06-13 16:53:52 +00:00
Carl Worth
14ae3ce3ad No longer need to check for NULL after creating a pattern.
Propagate status errors from pattern->status to cr->status.
Originally 2005-05-08 Owen Taylor <otaylor@redhat.com>:
src/cairo-pattern.c src/cairoint.h: If allocation of pattern objects fails, return special static nil pattern objects.
If adding a color stop fails to allocate memory, set pattern->status. (And fix a memory leak.) Make public functions return when pattern->status is set, (and no longer return a cairo_status_t).
src/cairo-pattern.c src/cairo.h doc/public/cairo-sections.txt: Add cairo_pattern_status()
Check the status of gstate->source and of mask patterns passed in.
2005-06-13 16:36:40 +00:00
Carl Worth
31dcb954fe Remove STATUS_OK macro which was not being used universally. 2005-06-10 12:18:20 +00:00
Carl Worth
36beed9bf1 Add CODING_STYLE document to standardize on some style issues.
Standardize brace handling around all else clauses according to new CODING_STYLE guidelines.
2005-06-03 14:51:57 +00:00
Carl Worth
c56938e568 Rename CAIRO_OK to STATUS_OK. No intended changes in functionality. 2005-06-01 13:24:10 +00:00
Keith Packard
45a966f695 Replace nesting-only surface clipping with gstate contained serial-number tracked clipping sets that are loaded into the surface on demand just before each rendering operation. This permits multiple cairo_t contexts to reference a surface without regard to ordering of operations among the contexts.
Also in this patch is a change to the xlib surface that creates two separate Pictures, one for source and one for destination operands which separates the source clipping from destination clipping. Cairo now specifies that sources are never clipped by any clipping applied to them as destinations.
Move cairo_clip_t (renamed from cairo_clip_rec_t) from cairoint.h to cairo-gstate-private.h. Eliminate stack of clip state from surfaces. Add new surface clipping API.
Manage clip objects entirely within the gstate, loading the whole thing into the surface just before drawing.
Source surfaces need not have clipping modified as the surface interface now specifies that source surfaces are always unclipped.
Eliminate nested clipping contexts, leaving clip management entirely to the gstate. Create new clip API for the gstate which uses per-surface serial numbers to match gstate clipping against current surface clipping values.
Surfaces no longer track clipping regions at all, so the old _cairo_surface_get_clip_extents has been replaced with _cairo_surface_get_extents. For PDF/PS surfaces, this function is expected to return a rectangle covering the entire fixed point coordinate space to leave rendering unclipped by the surface.
Region clipping capability is now signalled by a non-NULL function pointer in set_clip_region.
Each surface now contains two Pictures, one for source and one for destination operands so that source operands are never clipped by destination clipping.
CAIRO_STATUS_BAD_NESTING removed
self-copy now passes (Xlib only, until libpixman changes land)
reviewed by: krh, otaylor, cworth
2005-05-26 11:35:44 +00:00
Keith Packard
200bcda188 Initialize op->stops[0].scale = 0.
This scale value is used only when computing gradient values before the defined range, in which case stop 0 is used for both ends of the interpolation, making the value of 'scale' not actually matter, except that valgrind notices we're using an undefined value.
2005-05-16 22:31:36 +00:00
Carl Worth
14c690472c Push cairo_matrix_t const-correctness down through the entire implmentation, (expanding on preliminary work by Robert O'Callahan <rocallahan@novell.com>) 2005-05-09 09:12:52 +00:00
Carl Worth
9939e01b69 Remove deprecated cairo_get_rgb_color that was accidentally missed in the recent purge of deprecated functions. 2005-05-06 21:25:56 +00:00
Carl Worth
d7fe527e0f Eliminate the following deprecated functions from cairo's interface:
cairo_copy cairo_get_path cairo_get_path_flat cairo_matrix_create cairo_matrix_destroy cairo_matrix_copy cairo_matrix_get_affine cairo_surface_set_repeat cairo_surface_set_matrix cairo_surface_get_matrix cairo_surface_set_filter cairo_surface_get_filter
Also, eliminate all support for compiling against, or running with old, deprecated names for functions.
Deal with all of the removals.
2005-05-06 13:32:53 +00:00
Owen Taylor
cea1de7579 src/cairo.[ch] doc/public/cairo-sections.txt: Add cairo_paint_with_alpha().
Fix segfault when mask == NULL.
test/mask.c test/mask-ref.png: Add testing of cairo_paint_with_alpha().
test/coverage.c test/coverage-ref.png: Remove ... it's not testing anything that mask doesn't test better.
2005-05-06 12:00:22 +00:00
Owen Taylor
7dbd1f4401 src/cairo-surface.c src/cairoint.h: Add _cairo_surface_begin/end to save and restore the clip state of a surface. Copy and store clip regions set on a surface so that we can save and restore them.
Add a CAIRO_STATUS_BAD_NESTING error for interleaved use of two cairo_t's on the same surface. Also, add a skeleton doc comment for cairo_status_t.
src/cairo.c src/cairo-gstate.c src/cairoint.h: Use _cairo_surface_begin/end to replace _cairo_gstate_restore_external_state.
Use _cairo_surface_begin/end to save the state of a surface when we start drawing at it and restore it at the end. Check that the save level of the surface is what we expect on drawing operations and fail with CAIRO_STATUS_BAD_NESTING otherwise.
src/cairo-pattern.c src/cairoint.h (_cairo_pattern_acquire_surface_for_surface) (_cairo_pattern_release_surface): Surround use of pattern->surface with _cairo_surface->begin/end so we don't clip surfaces used as sources.
test/clip-nesting.c test/Makefile.am: Test of destinatin clipping with the nested creation of cairo_t's for the same context.
test/source-clip.c test/Makefile.am: Test that clipping on a source as a destination doesn't affect use of it as a source.
XFAIL test for copying from a surface as a source to itself as a destination with a clip.
2005-05-02 13:39:30 +00:00
Carl Worth
828094aef8 and delete:
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.
2005-04-14 14:42:26 +00:00
Carl Worth
369d1bf28f Default to CAIRO_FILTER_GOOD rather than CAIRO_FILTER_BEST.
Optimize to use CAIRO_FILTER_NEAREST when the pattern matrix is an integer translation.
2005-04-12 09:14:14 +00:00
Carl Worth
439a94cc7b Use CAIRO_FILTER_BEST by default rather than CAIRO_FILTER_NEAREST. 2005-04-12 07:57:46 +00:00
Carl Worth
d135938efd Rework the cairo_matrix_t interface in several ways. Expose a struct for cairo_matrix_t.
Add new function to return current matrix: cairo_get_matrix
Deprecate the following functions (in documentation): cairo_matrix_create cairo_matrix_destroy cairo_matrix_get_affine
Rename: cairo_matrix_set_affine -> cairo_matrix_init cairo_matrix_set_identity -> cairo_matrix_init_identity
Add other new matrix initialization functions: cairo_matrix_init_translate cairo_matrix_init_scale cairo_matrix_init_rotate
Change return type of almost all cairo_matrix functions from cairo_status_t to void.
Track changes to cairo_matrix_t interface.
Add a test case showing the same path drawn under various transforms, (including skews set directly by initializing a cairo_matrix_t).
2005-04-07 10:01:49 +00:00
Carl Worth
a6d9b6a671 Change type of data parameter from char* to unsigned char*.
Propagate the unsigned char* change down the stack.
Add cast since XImage uses char* rather than unsigned char*.
Fix memory leak of image data.
Switch to use cairo_surface_write_png rather than a custom write_png_argb32.
Add test to exercise the cairo_image_surface_create_for_png function.
2005-04-04 09:47:12 +00:00
Owen Taylor
e7607bb379 Comment and clean up the gradient computation. (_cairo_linear_pattern_classify): Determine if a linear gradient is horizontal or vertical. (_cairo_pattern_acquire_surface_for_gradient): Optimize horizontal/vertical gradients with a repeating surface.
Test case for linear gradients at angles and with a rotated pattern matrix.
2005-03-06 12:05:23 +00:00
Owen Taylor
66af5f9f36 src/cairoint.h src/cairo_pattern.c src/cairo_glitz_surface.c: Add _cairo_pattern_is_opaque, use it rather than pattern->alpha == 1.0. 2005-03-04 09:41:34 +00:00
David Reveman
01b87c7d99 Add overall alpha acceleration using mask surface 2005-03-03 18:46:49 +00:00
David Reveman
50b5344d7d Pass mask to composite operation as pattern 2005-03-03 18:39:06 +00:00
David Reveman
019d381b40 Change to cairo_surface_t like structure of of cairo_pattern_t 2005-03-03 17:40:04 +00:00
Carl Worth
1a043bbf26 Don't put an off-by-one n_stops into cairo_shader_op_t. (_cairo_shader_op_find_color_stops): Put search for two color stops containing a given offset into its own function. Handle the case of before first and after last stop by returning the nearest stop twice. (_cairo_pattern_calc_color_at_pixel): Handle case of no color stops by returning a transparent pixel. 2005-02-25 12:52:47 +00:00
Carl Worth
aca0708fc8 Fix memory leak when realloc fails due to out-of-memory. 2005-02-24 14:06:03 +00:00
Carl Worth
30a02c8e17 Revert accidental commit. 2005-02-21 08:22:47 +00:00
Carl Worth
c8a98b109a Fix y offset to use dst_y instead of dst_x, (caught by David Reveman). 2005-02-21 08:17:42 +00:00
Owen Taylor
26148a1d15 src/cairoint.h src/cairo_image_surface.c src/cairo_pdf_surface.c src/cairo_png_surface.c src/cairo_surface.c src/cairo_xlib_surface.c: Replace the get_image()/set_image() backend operations with a more specific {acquire,release}_{source,dest}_image() and clone_similar().
src/cairoint.h src/cairo_pattern.c: Replace _cairo_pattern_get_surface() with a _cairo_pattern_begin_draw()/_cairo_pattern_end_draw() pair.
Save the format for which an image is created so we can access it later. (Needed for the _cairo_xlib_surface_clone_similar())
src/cairoint.h src/cairo_image_surface.c: Add _cairo_surface_is_image().
Add CAIRO_OK(status) to check for CAIRO_STATUS_SUCCESS.
In the absence of of RENDER, make cairo_xlib_surface_create_similar() return an image surface.
Don't try to use RENDER to composite glyphs in the absence of the RENDER extension.
2005-01-31 08:50:22 +00:00
Owen Taylor
dca785faaf Fixes from David Reveman:
Don't save to surface part of the union when the pattern isn't a surface pattern. (_cairo_pattern_get_surface): Create the new surface at the width and height of the source.
Add cairo-ft-private.h
2005-01-30 11:28:14 +00:00
Kristian Høgsberg
a24f2f909e Update prototype to eliminate warning.
Remember to reference surfaces when copying patterns.
Don't call _gstate_create_pattern for internally created patterns. (_cairo_gstate_show_surface): Don't change the surface matrix here, it's done later when we set it up as a pattern.
Correct clip_twice-ref.png filename.
Add these.
Fix broken intersection code.
2005-01-28 12:27:23 +00:00
Kristian Høgsberg
4c329eecb9 Make sure we always return a surface similar to dst in the gradient case. 2005-01-27 21:14:04 +00:00
Kristian Høgsberg
79c8b29c3b Fold _cairo_pattern_get_image into _cairo_pattern_get_surface and make sure we always return a surface of the same type as dest.
Use _cairo_pattern_get_surface instead of _cairo_pattern_get_image.
Remove use of _cairo_xlib_surface_clone_similar since _cairo_pattern_get_surface always gives us an xlib surface for the pattern. Clean up error handling code in _cairo_xlib_surface_show_glyphs.
Add missing cairo_surface_destroy and tidy up offset calculations as suggested by Owen.
Simplify code for computing the extents of clipping area, by introducing a couple of cairo_rectangle_t functions.
2005-01-27 19:57:31 +00:00
Kristian Høgsberg
17ec6f1482 The overall idea of this rewrite is that we want to pass the source pattern all the way down into the backends. The motivation for this is that not all backends want a surface for the source operand, and by passing the pattern down, backends can choose to convert it to a surface if they need that.
The patch removes the create_surface function pointer from the surface vtable and moves much of that code into a couple of helper functions. The composite, compsite_trapezoids, and show_glyphs backend functions are updated to take a cairo_pattern_t instead of a surface as the source.
Change these functions to not create a surface for the pattern and just pass the pattern down to the backend functions.
New function to translate a set of trapezoids.
Break out the code to adjust and restore surface transformation and repeat settings into _cairo_pattern_prepare_surface and _cairo_pattern_restore_surface.
Split cairo_pattern_create_for_surface into an init function and a create function.
Utility functions to create a surface from a pattern.
Update these backends to work with the new pattern API. Glitz work by David Reveman.
Update these to pass through the new set of args.
Update this reference image as we now render it correctly.
2005-01-27 10:46:20 +00:00
Carl Worth
bf8374dba2 Convert all files to utf-8. Add copyright information to cairo_png_surface.c. 2004-10-21 18:40:50 +00:00
Carl Worth
b0a6de8f0b Fix copyright attributions mistakenly attributed to University of Southern California rather than to David Reveman. 2004-08-02 12:14:57 +00:00
David Reveman
06ef87276e Pre-multiply gradients after color interpolation 2004-06-11 06:20:17 +00:00
Keith Packard
41f549a870 Add WARN_CFLAGS, autodetection for 64/128 bit ints and cairo_wideint.[ch]
Check status return from _cairo_gstate_glyph_extents
Quiet compiler warnings about uninitialized variables
Switch to alternate exact line intersection code.
Add 64/128-bit wide integer arithmetic.
Switch to stdint.h types (and new wide types).
2004-05-28 12:37:15 +00:00
David Reveman
cdf8739c09 Removed pattern_offset 2004-05-11 11:20:06 +00:00
David Reveman
423ea55410 Corrected some confusing comments about the math used for radial gradients 2004-05-04 04:01:18 +00:00
David Reveman
f516564f98 Updated linear and radial patterns 2004-04-29 20:26:56 +00:00
David Reveman
f870f16e98 Converted shading routines to use fixed point values. 2004-04-25 04:02:37 +00:00
David Reveman
e172b7cec7 Fixed pattern source offset 2004-04-22 02:22:36 +00:00
David Reveman
c15c7b9364 Fixed missing limits.h includes 2004-04-20 12:35:44 +00:00
David Reveman
73df0e81cb Added OpenGL surface backend 2004-04-09 14:19:47 +00:00
David Reveman
b26a742bcf Added new pattern API 2004-04-06 09:45:17 +00:00