Commit graph

5758 commits

Author SHA1 Message Date
Benjamin Otte
056250775f surface: Allow NOTHING_TO_DO as a valid error for now
Lots of code relies on it, so we'd better not break that immediately. ;)
2011-02-18 18:52:11 +01:00
Benjamin Otte
4a3ab4b60a region: Don't be nice to people setting internal error code
Just DIE DIE DIE in the _cairo_status_set_status() assertion.
2011-02-18 18:30:17 +01:00
Benjamin Otte
3823c486f7 device: Don't be nice to people setting internal error codes
Just DIE DIE DIE in the _cairo_status_set_status() assertion.
2011-02-18 18:28:54 +01:00
Benjamin Otte
badf32290f surface: Don't be nice to people setting internal error codes
Just DIE DIE DIE in the _cairo_status_set_status() assertion.
2011-02-18 18:23:35 +01:00
Benjamin Otte
3b3cfbfffe Assert that an error is valid when set 2011-02-18 18:21:54 +01:00
Benjamin Otte
9c58336384 xcb: Don't operate on a status variable that is never set 2011-02-18 17:56:46 +01:00
Alexandros Frantzis
2181a53f61 egl: Ensure that the dummy pbuffer surface is compatible with the supplied context
In order to be able to make an egl context current when using a
pbuffer surface, that surface must have been created with a config
that is compatible with the context config. For Mesa, this means that
the configs must be the same.
2011-02-18 09:45:00 -05:00
Benjamin Franzke
3245d6e120 egl: Fix eglMakeCurrent for egl surfaces 2011-02-18 09:45:00 -05:00
Andrea Canciani
d866bb0405 xlib: Fix compilation when gradient functions are not available
It is not correct to rely on the version defined in render.h. The
Xrender.h header is independent and might not define some functions
available in RENDER 0.10.

Their availability must be detected at configure time and the stubs
must be defined only if the functions are not available.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=31906
2011-02-14 11:07:02 +01:00
Eric Anholt
81d2434b75 gl: Don't reset the FBO draw/readbuffers every time we bind the FBO.
Draw/readbuffers are a property of the framebuffer, not of the
context.  So we can leave them in place across bindings.  I left the
window drawbuffer setting in place until we decide how to handle
interoperating of cairo-gl with normal GL usage.

[  0]  before      firefox-talos-gfx   67.552   67.561   0.22%    3/3
[  0]  after       firefox-talos-gfx   66.689   66.913   0.41%    3/3
2011-02-13 11:53:15 -08:00
Uli Schlachter
788bdec628 Fix errors from src/check-plt.sh
All of these symbols are used in cairo-script-surface.c for emitting mesh
patterns.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-02-12 21:12:46 +01:00
Uli Schlachter
12e41acf9c xcb: Remove the surface pattern cache
Whenever a surface is used as a source, cairo-xcb creates a Picture for it and
adds it as a snapshot to the source. Additionally, there is a per-screen cache
that makes sure old Pictures are destroyed when more than 16 MiB of image data
is used.

There are two problems here:
- Normally, the Picture would be destroyed once it is no longer a snapshot for
  the original source surface. However, the cache kept it alive for longer which
  means it was using memory but couldn't actually be used any more. (The
  Pictures are found via _cairo_surface_has_snapshot)
- When a xcb surface is used as a source, we create a new Picture for it, but
  when that surface is cairo_surface_finish'd, we don't FreePicture this
  Picture. When the drawable was a window, this may later on cause a BadPicture
  error when cairo tries to explicitly free a picture that was already
  implicitly freed when its window was destroyed.

The second point caused lots of tests in the test suite to fail on an assert due
to the above-mentioned BadPicture error, but just removing the cache makes both
these problems go away.

The only downside is that the cache enforced a limit of 16 MiB of pixel data
that was used for source surfaces on the server. After this commit the Picture
will be kept alive until the snapshot is detached. If this becomes a problem
memory-wise, a new solution will have to be invented...

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-02-12 10:34:02 +01:00
Uli Schlachter
050a877a9e xcb: Fix a crash when finishing a device
The xcb backend uses caches for linear, radial and surface patterns so that it
doesn't have to create a new cairo_xcb_picture_t on every use. Whenever any
picture is finished, the surface pattern cache is checked on whether it still
contains that picture.

This means that we cannot destroy the surface_pattern_cache until after the
linear and radial_pattern_cache are destroyed or else we'll be querying the
surface pattern cache after it was finished.

This wasn't noticed before because _cairo_xcb_picture_finish couldn't acquire
the cairo_xcb_connection_t and thus failed earlier. The previous commit changed
this and now lots of tests in the test suite trigger the crash.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-02-10 21:38:41 +01:00
Uli Schlachter
ae669fb8ab Finish devices after their finish callback returns
The problem is that the finish callback might still have to work with the
device, so it can't be made unusable yet. This is in contrast to what
cairo_surface_finish() does, but when finishing a surface it's quite unlikely
that its cairo_surface_t still has to be passed around to functions outside of
the backend.

This "fixes" some problems with the xcb-surface-source test where
_cairo_surface_snapshot()-style snapshots break when the underlying
cairo_device_t is finished. (In the following backtrace, cairo_device_acquire
fails because the device's ->finished member is already TRUE)

 #0  cairo_device_acquire (device=0x690f70) at cairo-device.c:414
 #1  0x00007ffff7b884fb in _cairo_xcb_connection_acquire (surface=0x69c610, use_shm=<value optimized out>, image_out=0x7fffffffcc58) at cairo-xcb-private.h:246
 #2  _get_image (surface=0x69c610, use_shm=<value optimized out>, image_out=0x7fffffffcc58) at cairo-xcb-surface.c:425
 #3  0x00007ffff7b893cf in _cairo_xcb_surface_acquire_source_image (abstract_surface=0x69c610, image_out=0x7fffffffcce8, image_extra=0x7fffffffcce0)
     at cairo-xcb-surface.c:561
 #4  0x00007ffff7b601d4 in _cairo_surface_acquire_source_image (surface=0x690f70, image_out=0x7fffffffcce8, image_extra=0x0) at cairo-surface.c:1458
 #5  0x00007ffff7b65dcf in _cairo_surface_snapshot_copy_on_write (surface=<value optimized out>) at cairo-surface-snapshot.c:125
 #6  0x00007ffff7b609b1 in _cairo_surface_detach_snapshot (snapshot=0x690f70) at cairo-surface.c:330
 #7  0x00007ffff7b606dc in _cairo_surface_detach_snapshots (surface=0x69c610) at cairo-surface.c:315
 #8  cairo_surface_flush (surface=0x69c610) at cairo-surface.c:1126
 #9  0x00007ffff7b6074d in cairo_surface_finish (surface=0x690f70) at cairo-surface.c:718
 #10 0x00007ffff7b881ff in _cairo_xcb_screen_finish (screen=0x691920) at cairo-xcb-screen.c:61
 #11 0x00007ffff7b8629c in _device_finish (device=0x690f70) at cairo-xcb-connection.c:546
 #12 0x0000000000446f7c in cleanup (data=0x69c370) at xcb-surface-source.c:47
 #13 0x00007ffff7b1e56a in _cairo_user_data_array_fini (array=0x693628) at cairo-array.c:390
 #14 0x00007ffff7b60868 in cairo_surface_destroy (surface=0x693600) at cairo-surface.c:651
 #15 0x0000000000447599 in draw (cr=0x7ffff7ddc288, width=<value optimized out>, height=<value optimized out>) at surface-source.c:149
 #16 0x000000000040c1c3 in cairo_test_for_target (ctx=0x7fffffffe640, target=0x669668, dev_offset=<value optimized out>, similar=<value optimized out>)
     at cairo-test.c:984
 #17 0x000000000040d997 in _cairo_test_context_run_for_target (ctx=<value optimized out>, target=<value optimized out>, similar=<value optimized out>,
     dev_offset=<value optimized out>) at cairo-test.c:1617
 #18 0x000000000040ee09 in _cairo_test_runner_draw (argc=<value optimized out>, argv=<value optimized out>) at cairo-test-runner.c:269
 #19 main (argc=<value optimized out>, argv=<value optimized out>) at cairo-test-runner.c:924

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-02-10 17:15:09 +01:00
Alexandros Frantzis
e4fdd9a1cd gl: Replace built-in vertex attributes with custom attributes
Built-in vertex attributes like gl_Vertex and gl_Color, have been obsoleted
and removed in recent GL versions and they are not supported at all in GLES2.0.
Custom attributes are supported in all GL versions >= 2.0, in GL 1.x with
ARB shader extensions and in GLES2.0.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-10 14:54:35 +00:00
Alexandros Frantzis
e68062d9ca gl: Add gl dispatch entries for functions related to vertex attributes
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-10 14:54:35 +00:00
Alexandros Frantzis
80a92b6d79 gl: Use a custom shader uniform for the ModelViewProjection matrix
The built-in gl_ModelViewProjectionMatrix uniform (and others) has been
deprecated and removed in recent GLSL versions and is not supported
at all in GLSL ES. A custom uniform for the same purpose works across
all versions.

[ickle: base _gl_identity_ortho on the 2D variant of glOrtho i.e. with
        fixed near/far values of [-1, 1]]
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-10 14:53:59 +00:00
Alexandros Frantzis
d88ada384f gl: Replace ftransform() with manual coordinate calculation in shaders
The ftransform() shader function was deprecated and removed in recent
GLSL versions and is not included at all in GLSL ES.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-10 14:37:48 +00:00
Alexandros Frantzis
b13198348c gl: Add function to bind a 4x4 float matrix shader uniform
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-10 14:37:43 +00:00
Alexandros Frantzis
966e4a1738 gl: Add entry for UniformMatrix4fv in the gl dispatch table
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-10 14:37:39 +00:00
Adrian Johnson
0984c9ea27 Type1-subset: Fallback if font contains more than one /Encoding
https://bugzilla.gnome.org/show_bug.cgi?id=641704
2011-02-08 21:40:08 +10:30
Andrea Canciani
5f039f0f89 mesh: Rename cairo_pattern_mesh_* functions to cairo_mesh_pattern_*
This is consistent with the naming of most cairo types/functions
(example: cairo_foo_surface_*).

The substitution in the code has been performed using:

  sed -i 's/cairo_pattern_mesh_/cairo_mesh_pattern_/' <files>
2011-02-07 20:28:09 +01:00
Chris Wilson
d558f40c44 image: Limit span rendering to bounded extents
We make the presumption that the incoming geometry is appropriately
clipped to the bounded extents and can simply memset without being out
of bounds.

However, this was not always the case as we were removing the clip boxes
in order to optimise the common case where the operation is naturally
limited to the surface.

(This is a candidate for 1.10)

Bugzilla: https://bugs.launchpad.net/ubuntu/+source/cairo/+bug/710072
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-06 14:19:23 +00:00
Behdad Esfahbod
fc8c54dafe Don't err on non-invertible font matrix
The scaled-font layer handles that later if it actually is a problem:

    scaled_font->scale_inverse = scaled_font->scale;
    status = cairo_matrix_invert (&scaled_font->scale_inverse);
    if (unlikely (status)) {
        /* If the font scale matrix is rank 0, just using an all-zero inverse matrix
         * makes everything work correctly.  This make font size 0 work without
         * producing an error.
         *
         * FIXME:  If the scale is rank 1, we still go into error mode.  But then
         * again, that's what we do everywhere in cairo.
         *
         * Also, the check for == 0. below may be too harsh...
         */
        if (_cairo_matrix_is_scale_0 (&scaled_font->scale)) {
            cairo_matrix_init (&scaled_font->scale_inverse,
                               0, 0, 0, 0,
                               -scaled_font->scale.x0,
                               -scaled_font->scale.y0);
        } else
            return status;
    }
2011-02-04 15:43:40 -05:00
Alexandros Frantzis
7f15319621 gl: Remove fixed-function related code paths
Fixed-function related code paths are no longer used, as we require shader
support for the gl backend.

Reviewed-by: Eric Anholt <eric@anholt.net>
2011-01-31 16:07:53 -08:00
Alexandros Frantzis
f6ca11694b gl: Remove unnecessary checks for NULL shader implementation
Due to the fact that we fail if the system doesn't support shaders, we
now always have a valid shader implementation.

Reviewed-by: Eric Anholt <eric@anholt.net>
2011-01-31 16:07:53 -08:00
Alexandros Frantzis
037c9ba7e2 gl: Fail if GL implementation doesn't support shaders
The non-shaders implementation was never tuned for fixed-function GL
implementation, the maintainers are not interested in supporting it,
and the hardware is rather rare at this point.  This lets us focus on
the implementation for modern hardware, which needs plenty of work
still.

Reviewed-by: Eric Anholt <eric@anholt.net>
2011-01-31 16:07:53 -08:00
Uli Schlachter
0e08e7adfc XCB: Fix build with xcb-shm disabled
The function _cairo_xcb_shm_image_create is defined and needed even when XCB-SHM
is disabled. In this case it just falls back to an image surface.

Thanks to Benjamin Otte for noticing this.

cairo-xcb-surface-render.c: In function ‘_render_to_picture’:
cairo-xcb-surface-render.c:749: error: implicit declaration of function ‘_cairo_xcb_shm_image_create’
cairo-xcb-surface-render.c:749: warning: nested extern declaration of ‘_cairo_xcb_shm_image_create’

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-31 22:42:24 +01:00
Uli Schlachter
2e81f79e95 xcb: Use a normal image surface if SHM fails
If we can't use SHM, we still have PutImage. So instead of returning the error
to the caller, it makes sense to retry with a normal image surface.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-31 18:22:06 +01:00
Uli Schlachter
72788a0660 xcb: Move the allocation of a shm surface into its own function
This simplifies the fallback to an image surface when something causes an error.

Additionally, this causes errors from _cairo_xcb_connection_allocate_shm_info to
be handled via falling back to a normal image surface while previously those
were returned to the caller.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-31 18:20:23 +01:00
Uli Schlachter
48cb9186a2 xcb: Remove a duplicate static function
Both cairo-xcb-surface-core.c and cairo-xcb-surface-render.c contained an
identical definition of _cairo_xcb_shm_image_create. This commits removes the
one from cairo-xcb-surface-render.c and adds the other one to
cairo-xcb-private.h.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-31 18:19:15 +01:00
Uli Schlachter
274289d8c6 xcb: Limit the amount of SHM used
Without this, one could make cairo attach to lots of shared memory. I managed to
make cairo use 1.5 GiB of shared memory according to top. This was done by
disabling XRENDER and thus causing lots of fallbacks.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-31 18:18:02 +01:00
Uli Schlachter
a8e8d2aba8 scaled font: Fix the docs for cairo_scaled_font_get_font_face
With the toy font API, it is possible that cairo_scaled_font_get_font_face()
doesn't return the font face which was passed to cairo_scaled_font_create()
despite the docs saying otherwise.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-27 17:44:59 +01:00
Uli Schlachter
23f87951ba User fonts: Make it clear what should NOT be freed
This is a misunderstanding that I actually saw in some real-world code that used
to work fine with cairo 1.8. Once you spend some time trying to debug such a
problem, you wish the docs would have said so. ;-)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-27 17:44:59 +01:00
Uli Schlachter
00b1eac4b0 xcb: Document all public functions
These docs are based upon cairo-xlib and the existing documentations for
cairo_xcb_surface_create_with_xrender_format.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-26 21:10:59 +01:00
Uli Schlachter
9e7ce0c352 xcb: Automatically enable the backend if the libs are available
It looks like the cairo-xcb backend is in a good shape and hopefully will be a
supported backend for cairo 1.12.0. Let's see if this causes lots of new bugs to
be uncovered. :-)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-26 17:54:13 +01:00
Andrea Canciani
f60e8f0bb2 xcb: Fix compositing of pixel-aligned rectangles
bef8b28300 introduced a regression in
the compositing of pixel-aligned rectangles, because it only
translates the destination, instead of destination, source and mask,
by the extents offset.

The same commit introduces some memleaks when the acquisition of an
xcb picture fails.

74374fce9d causes incorrect rendering
whenever extents are not tight.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=33448
2011-01-25 12:16:51 +01:00
Andrea Canciani
062e78b620 Fix regressions from 1.10 merge
d6dc6e8e39 introduced two regressions:

 - the compiler warns about _gradient_stops_are_opaque being unused in
   cairo-pdf-surface.c

 - get-path-extents now checks for the wrong extents, thus it fails
2011-01-24 10:35:23 +01:00
Uli Schlachter
c7b16098bd xcb: Fix a BadPicture when clearing a surface
This bug was introduced in 6f431886 "xcb: Prefer RenderFillRectangles to perform
the deferred clear". The problem is that we are trying to clear a surface before
we created a Picture for it. This resulted in a FillRectangles call with
dst=XCB_NONE.

I noticed this problem via cairo-perf-micro's dragon-solid-circle-clip.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-23 22:10:20 +01:00
Chris Wilson
74374fce9d xcb: Only use clip rectangles for more than 1 pixel-aligned box
If there is only a single box, then it is naturally equivalent to the
single call to Composite. So need to incur the addition protocol
overhead of setting up the CompositeClip.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-01-23 18:33:00 +00:00
Chris Wilson
d6dc6e8e39 Merge branch '1.10' into tmp
Synchronize stable bug-fixes with development snapshot

Conflicts:
	cairo-version.h
	src/cairo-path-bounds.c
	src/cairo-pdf-surface.c
	test/get-path-extents.c
2011-01-23 16:05:01 +00:00
Chris Wilson
6c65168dcf Makefile: add missing cairo-box-private.h 2011-01-23 15:46:32 +00:00
Chris Wilson
6f4318869c xcb: Prefer RenderFillRectangles to perform the deferred clear
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-01-23 13:29:51 +00:00
Chris Wilson
bef8b28300 xcb: Apply a clip region for compositing many-pixel-aligned-boxes
Based on a patch by  Uli Schlachter.

Uli found that the "fast-path" for compositing pixel-aligned boxes did
not live up to its name; using multiple Composite is many times slower,
because of the extra protocol and driver overheads, than specifying a
clip region and a single Composite.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-01-23 12:28:06 +00:00
Andrea Canciani
ff9e962165 gstate: Remove unused code
_cairo_gstate_redirect_target asserts that this surface is NULL
immediately before destroying it. If the code is compiled with
assertions disabled and the assert would be false, it is now safer
because instead of an invalid access it will only memleak.

_cairo_gstate_get_parent_target () is not used anymore in
cairo_pop_group () and the related code can be removed.

_cairo_gstate_is_redirected () has never been used.

The comment about the clipping is misleading, because the clip is
translated as expected since fb7f7c2f27.
2011-01-22 11:59:38 +01:00
Andrea Canciani
5d95ae924e gstate: Set an error status when restoring a push_group
cairo_push_group (cr) followed by cairo_restore (cr) should put cr in
an error status of CAIRO_STATUS_INVALID_RESTORE.

Fixes group-state.
2011-01-22 11:59:38 +01:00
Andrea Canciani
b51520628d clip: Improve _cairo_clip_contains_*
_cairo_clip_contains_rectangle() considered a NULL clip empty instead
of containing everything.

_cairo_clip_contains_rectangle() checks for NULL clips, so we don't
have to check for them in _cairo_clip_contains_extents().
2011-01-22 11:56:37 +01:00
Mats Palmgren
47d14586f5 win32: Improve error logging
On win32 stderr is fully buffered, so fflush() should be called after
each error to ensure it is printed to the console.

There is no need to use fwprintf if the format string can be
represented as char*.

See https://bugs.freedesktop.org/show_bug.cgi?id=33319
2011-01-21 09:56:46 +01:00
Andrea Canciani
b8e7bfdff0 quartz: Respect pattern filter settings
CAIRO_FILTER_FAST and CAIRO_FILTER_NEAREST both map to nearest
neighbor filtering, whereas all other filter modes are names for
bilinear filtering.

Additionally, translations matrices are transformed into integer
translations when possible (i.e. when they are used on an nearest
neighbor filtered surface pattern), which makes Quartz behave as
cairo-image for these simple transformations.

Fixes a1-image-sample, a1-mask-sample, filter-nearest-offset.

Improves the output of filter-nearest-transformed and
rotate-image-surface-paint. They are not blurry anymore, but they are
different from the reference images because of different in/out rules
between Quartz and cairo-image.
2011-01-19 13:27:33 +01:00
Andrea Canciani
45da39dda7 quartz: Avoid using private APIs
CGContextSetCTM() is not part of the public API and can easily be
replaced by CGContextConcatCTM()-ing an appropriate matrix.
2011-01-19 12:00:58 +01:00