Commit graph

6538 commits

Author SHA1 Message Date
Andrea Canciani
e0444a458a image: Silence missing enum value warning
cairo-image-surface.c:101: warning: enumeration value ‘PIXMAN_x14r6g6b6’ not handled in switch
2011-03-18 17:54:54 +01:00
Andrea Canciani
f2eb3f2178 Improve cairo_rectangle_list_t error handling
Unify the _cairo_rectangle_list_create_in_error() functions, keeping
the best features from both (the one in cairo-clip.c statically
allocates the most common cases, the one in cairo.c throws a NO_MEMORY
error when it cannot malloc() instead of rethrowing the same error).

The same function can be used to return an error-list in
_cairo_gstate_copy_clip_rectangle_list() when _cairo_clip_rectangle()
fails (for example becaouse of an OOM).
2011-03-18 17:54:54 +01:00
Andrea Canciani
8a4299bf7e quartz-font: Remove unused variables
x_scale and y_scale are computed but never used.
2011-03-18 11:46:15 +01:00
Andrea Canciani
fd1fca8010 Make cairo_set_font_size() a wrapper of cairo_set_font_matrix()
cairo_set_font_size() should be equivalent to setting the font matrix
to an appropriate scale matrix.

Implementing it this way saves some code and makes sure that the same
code path is used whenever the font matrix is changed.
2011-03-18 11:43:42 +01:00
Andrea Canciani
f99358acf7 script: Fix stroking of 3 sided boxes
3-sided boxes can be replaced with rectangles when clipping and
filling, but not when stroking. _emit_path() is used for all of these
operations, so it cannot perform the optimization except for 4-sided
boxes.

Fixes stroke-open-box.
2011-03-18 10:50:23 +01:00
Andrea Canciani
c0fe556515 path: Fix _cairo_path_fixed_is_rectangle()
__cairo_path_fixed_is_rectangle() is used by the PS and PDF backends
to check if a path is equivalent to a rectangle when stroking. This is
different from being a rectangle when filling, because of the implicit
close_path appended to every subpath when filling.

Fixes stroke-open-box.

See https://bugs.freedesktop.org/show_bug.cgi?id=34560
2011-03-18 10:30:25 +01:00
Andrea Canciani
6521bab6e8 xcb,xlib: Fallback upon generic radial gradients
The RENDER specification requires radial gradients to have the first
circle completely inside the second one, but the error is not actually
generated.

The implementation produces the expected results if either circle
contains the other one, so only fall back in these cases.
2011-03-18 09:48:56 +01:00
Andrea Canciani
426fe6fadf xcb,xlib: Fix 1-stop gradients
The RENDER specification does not specify the constraints on the
gradient stops, but its implementation returns an error if less than 2
stops are used.

Xlib and XCB can work around this because gradients with just one stop
are by-definition the same as gradients with that stop repeated twice.

Fixes radial-gradient-one-stop.
2011-03-18 09:48:56 +01:00
Andrea Canciani
c42d7f7acf quartz: Fix y glyph advance
The advances must be transformed by the "quartz inverse scale",
i.e. (scale_inverse * scale(1,-1)).

Fixes show-glyph-advance.
2011-03-18 09:41:55 +01:00
Uli Schlachter
ed78510154 xcb-drm: Fix undeclared variable error
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-16 16:01:35 +01:00
Chris Wilson
02b2e3c93f xcb: Compile fix when using xcb-drm
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=31368
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-03-16 15:56:10 +01:00
Uli Schlachter
f6e6891b59 xcb: Never return NULL from create_similar
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-15 19:41:41 +01:00
Adrian Johnson
f2f65684f0 cff: Fix heap corruption
caused by holding a pointer into a cairo_array after a realloc

https://bugs.freedesktop.org/show_bug.cgi?id=35161
2011-03-13 21:16:14 +10:30
Uli Schlachter
f1d313e042 xcb: Remove _cairo_xcb_picture_copy
All cairo_xcb_picture_t now get their own, private Picture instead of possibly
sharing it with a cairo_xcb_surface_t.

This solves a cyclic dependency which caused cairo_xcb_picture_t to be leaked
until their device was finished.

When an xcb surface was used as a source, a cairo_xcb_picture_t was created
which kept a reference to the surface. This picture was then added as a snapshot
to the surface which caused the surface to own a reference to the picture.

As a result, the Picture and possibly its associated Pixmap were not freed on
the X11 server which could thus run out of memory.

This change causes more Pictures to be created which could possibly slow down
cairo-xcb. There seems to be no measurable difference with cairo-perf-trace. For
the micro benchmarks, this has the most impact on paint_similar-rgba_source.512:

       min(ticks)  min(ms) median(ms) stddev. iterations overhead
before     158732    0.159    0.159  0.11%   4: 1651.49
after      162579    0.163    0.163  0.18%   4: 1612.41

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=34912

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-04 16:37:13 +01:00
Jeff Muizelaar
de2c5bfa19 Add an implementation of fmax for use with MSVC 2011-03-03 16:34:43 -05:00
Jeff Muizelaar
aca492eb3f Add UINT32_MAX define.
This is needed for building with MSCV
2011-03-03 16:31:03 -05:00
Chris Wilson
9669b300a0 surface: Don't pass INT_UNSUPPORTED to _cairo_surface_set_error
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-03-02 18:31:28 +00:00
Uli Schlachter
c0dc933efd xcb: Remove CAIRO_XCB_RENDER_HAS_COMPOSITE_SPANS
This flag was only ever tested, but never set. Also, there is no X11 server out
there which actually supports this.

AFAIK it was just an experiment which turned into dead code.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-02-28 15:54:02 +01:00
Uli Schlachter
6cd96f966f xcb: Fix for PDF operators with RENDER 0.11
RENDER 0.11 added PDF operators and the cairo-xcb backend is already prepared
for handling them. However, it doesn't actually handle them.

If you used such an operator with RENDER 0.11, _operator_is_supported() would
return TRUE, but later on an ASSERT_NOT_REACHED in _render_operator() is hit.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-02-28 15:45:14 +01:00
Uli Schlachter
da9d6db115 xcb: Remove some unused code
All of these defines where not used anymore and this '#if 0'd code was so for
ages and most likely would stay commented out for more ages, too.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-02-28 15:42:57 +01:00
Eric Anholt
17169a1e51 gl: Bind samplers just once at program compile time.
We never bound any other value to the sampler uniforms, so why bother
resetting them all the time?

[  0]   before      firefox-talos-gfx   29.972   30.493   0.89%    3/3
[  0]   after       firefox-talos-gfx   29.397   29.599   1.27%    3/3

Signed-off-by: Eric Anholt <eric@anholt.net>
2011-02-26 14:09:54 -08:00
Eric Anholt
2fae22a3f2 gl: Take advantage of GLX_MESA_multithread_makecurrent to avoid unbinding.
Because of GLX's unfortunate requirement that only one context have a
thread current at a time, we had to unbind the context, triggering a
flush, and eating of all the CPU.  With a small tweak to the GLX spec
by GLX_MESA_multithread_makecurrent, and a small tweak to Mesa that
consisted mostly of deleting the "is this thread already bound
elsewhere?" check, we can bind our context to any thread and use it
safely as long as our usage of it is mutexed, which cairo-gl should
already be doing.

[  0] before      firefox-talos-gfx   50.260   50.525   0.25%    3/3
[  0] after       firefox-talos-gfx   32.091   32.422   0.65%    3/3
2011-02-26 14:09:33 -08:00
Eric Anholt
2e67809be0 gl: Add a first bit of general documentation on cairo-gl usage.
Since its inception, cairo-gl has been plagued by the "how am I really
supposed to use it?" problem.  This lays down my expectations for how
cairo-gl will interact with other usage of the GL API.
2011-02-21 14:12:47 -08:00
Behdad Esfahbod
90e1ef2d80 Bug 34011 - headers-standalone target is incorrect for some non-gcc compilers 2011-02-20 18:16:10 -05:00
Andrea Canciani
47f70537b8 image: Fix surface acquisition if PIXMAN_HAS_ATOMIC_OPS
If PIXMAN_HAS_ATOMIC_OPS, ix and iy will be changed if the source
surface is of subsurface type. They need to be reset to 0 before being
passed to _cairo_matrix_to_pixman_matrix_offset() or the acquired
surface will have an incorrect offset .
2011-02-19 19:26:20 +01:00
M Joonas Pihlaja
71e8a4c230 image: Avoid reusing pixman images for threadsafety.
The pixman_image_ref() and pixman_image_unref() functions
aren't threadsafe in current pixman, so we can't share
pixman images across contexts where they may end up
moving between threads.  The main use of these functions
is in keeping a global cache of pixman_image_ts for
solid colours and reusing the same pixman_image_t for
patterns pointing to the same image data where possible.

This patch removes those uses from cairo by wrapping
them in a PIXMAN_HAS_ATOMIC_OPS conditional.  There is
no automatic test this, so we will have to manually
turn this code back on when pixman does gain atomic
ops.

The only two remaining calls to pixman_image_ref() are
done on locally created images so they are safe.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=34177
2011-02-19 18:01:27 +02:00
Benjamin Otte
94612bc032 arc: Remove erroneous return statement
Introduced in e46dc9e17a.
2011-02-19 10:40:01 +01:00
Benjamin Otte
b2bda24e42 Declare variables first so gcc shuts up 2011-02-19 10:22:45 +01:00
Benjamin Otte
e46dc9e17a arc: Handle radius == 0 the same no matter the arc direction
Commit a0ea0b63fd fixed cairo_arc() but
did not apply the same patch to cairo_arc_negative(). This patch fixes
that oversight.
2011-02-18 19:51:44 +01:00
Benjamin Otte
ea0595c5ec surface: Actually return a value from _cairo_surface_set_error()
This is what happens when there's too many warnings on the screen: I
don't see the important ones. Oops.
2011-02-18 19:06:16 +01:00
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