chromiumos/third_party/cairo.git
3 years agoxcb: Remove _cairo_xcb_picture_copy master
Uli Schlachter [Thu, 3 Mar 2011 18:14:36 +0000 (19:14 +0100)]
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>
3 years agoxcb boilerplate: Handle device offsets correctly
Uli Schlachter [Sun, 13 Feb 2011 18:40:57 +0000 (19:40 +0100)]
xcb boilerplate: Handle device offsets correctly

When running cairo-test-suite with "-a", backends are also tested with a
non-zero device offset. However, for "xcb-window&" the boilerplate incorrectly
overwrote the device offset with a zero offset again.

This caused all test results to be offset by 25 pixels which obviously makes all
tests fail.

Just removing the call to cairo_surface_set_device_offset solves the problem.

Signed-off-by: Uli Schlachter <psychon@znc.in>
3 years agoAdd an implementation of fmax for use with MSVC
Jeff Muizelaar [Thu, 3 Mar 2011 21:34:43 +0000 (16:34 -0500)]
Add an implementation of fmax for use with MSVC

3 years agoAdd UINT32_MAX define.
Jeff Muizelaar [Thu, 3 Mar 2011 21:31:03 +0000 (16:31 -0500)]
Add UINT32_MAX define.

This is needed for building with MSCV

3 years agosurface: Don't pass INT_UNSUPPORTED to _cairo_surface_set_error
Chris Wilson [Wed, 2 Mar 2011 18:30:47 +0000 (18:30 +0000)]
surface: Don't pass INT_UNSUPPORTED to _cairo_surface_set_error

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
3 years agoxcb: Remove CAIRO_XCB_RENDER_HAS_COMPOSITE_SPANS
Uli Schlachter [Mon, 28 Feb 2011 14:54:02 +0000 (15:54 +0100)]
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>
3 years agoxcb: Fix for PDF operators with RENDER 0.11
Uli Schlachter [Mon, 28 Feb 2011 14:45:14 +0000 (15:45 +0100)]
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>
3 years agoxcb: Remove some unused code
Uli Schlachter [Mon, 28 Feb 2011 14:42:57 +0000 (15:42 +0100)]
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>
3 years agogl: Bind samplers just once at program compile time.
Eric Anholt [Mon, 21 Feb 2011 21:37:00 +0000 (13:37 -0800)]
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>
3 years agogl: Take advantage of GLX_MESA_multithread_makecurrent to avoid unbinding.
Eric Anholt [Tue, 1 Feb 2011 04:47:15 +0000 (20:47 -0800)]
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

3 years agogl: Add a first bit of general documentation on cairo-gl usage.
Eric Anholt [Mon, 31 Jan 2011 07:41:39 +0000 (23:41 -0800)]
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.

3 years agoBug 34011 - headers-standalone target is incorrect for some non-gcc compilers
Behdad Esfahbod [Sun, 20 Feb 2011 23:16:10 +0000 (18:16 -0500)]
Bug 34011 - headers-standalone target is incorrect for some non-gcc compilers

3 years agoimage: Fix surface acquisition if PIXMAN_HAS_ATOMIC_OPS
Andrea Canciani [Sat, 19 Feb 2011 18:13:59 +0000 (19:13 +0100)]
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 .

3 years agoimage: Avoid reusing pixman images for threadsafety.
M Joonas Pihlaja [Sat, 19 Feb 2011 15:46:45 +0000 (17:46 +0200)]
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

3 years agotest: Fix gcc signedness warning
Benjamin Otte [Sat, 19 Feb 2011 10:33:22 +0000 (11:33 +0100)]
test: Fix gcc signedness warning

3 years agoarc: Remove erroneous return statement
Benjamin Otte [Sat, 19 Feb 2011 09:40:01 +0000 (10:40 +0100)]
arc: Remove erroneous return statement

Introduced in e46dc9e17a6f6737d5624dbcdd3c42c2353a72f1.

3 years agotest: Fix copy/paste error
Benjamin Otte [Sat, 19 Feb 2011 09:32:19 +0000 (10:32 +0100)]
test: Fix copy/paste error

3 years agotest: Fix gcc complaints about old style definitions
Benjamin Otte [Sat, 19 Feb 2011 09:25:22 +0000 (10:25 +0100)]
test: Fix gcc complaints about old style definitions

3 years agotest: Add a test for 0-radius negative arcs
Benjamin Otte [Sat, 19 Feb 2011 09:23:46 +0000 (10:23 +0100)]
test: Add a test for 0-radius negative arcs

This test checks the behavior of
e46dc9e17a6f6737d5624dbcdd3c42c2353a72f1

3 years agoDeclare variables first so gcc shuts up
Benjamin Otte [Sat, 19 Feb 2011 09:22:45 +0000 (10:22 +0100)]
Declare variables first so gcc shuts up

3 years agoRevert accidental checkin in last commit
Benjamin Otte [Fri, 18 Feb 2011 18:57:22 +0000 (19:57 +0100)]
Revert accidental checkin in last commit

Today is not my day...

3 years agoarc: Handle radius == 0 the same no matter the arc direction
Benjamin Otte [Fri, 18 Feb 2011 18:51:44 +0000 (19:51 +0100)]
arc: Handle radius == 0 the same no matter the arc direction

Commit a0ea0b63fdd38a73d6696da5cd4800d9a7289240 fixed cairo_arc() but
did not apply the same patch to cairo_arc_negative(). This patch fixes
that oversight.

3 years agosurface: Actually return a value from _cairo_surface_set_error()
Benjamin Otte [Fri, 18 Feb 2011 18:06:16 +0000 (19:06 +0100)]
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.

3 years agotest: Add missing format to any2ppm to silence gcc
Benjamin Otte [Fri, 18 Feb 2011 17:53:29 +0000 (18:53 +0100)]
test: Add missing format to any2ppm to silence gcc

3 years agosurface: Allow NOTHING_TO_DO as a valid error for now
Benjamin Otte [Fri, 18 Feb 2011 17:52:11 +0000 (18:52 +0100)]
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. ;)

3 years agoregion: Don't be nice to people setting internal error code
Benjamin Otte [Fri, 18 Feb 2011 17:30:17 +0000 (18:30 +0100)]
region: Don't be nice to people setting internal error code

Just DIE DIE DIE in the _cairo_status_set_status() assertion.

3 years agodevice: Don't be nice to people setting internal error codes
Benjamin Otte [Fri, 18 Feb 2011 17:26:14 +0000 (18:26 +0100)]
device: Don't be nice to people setting internal error codes

Just DIE DIE DIE in the _cairo_status_set_status() assertion.

3 years agosurface: Don't be nice to people setting internal error codes
Benjamin Otte [Fri, 18 Feb 2011 17:23:25 +0000 (18:23 +0100)]
surface: Don't be nice to people setting internal error codes

Just DIE DIE DIE in the _cairo_status_set_status() assertion.

3 years agoAssert that an error is valid when set
Benjamin Otte [Fri, 18 Feb 2011 17:21:54 +0000 (18:21 +0100)]
Assert that an error is valid when set

3 years agoxcb: Don't operate on a status variable that is never set
Benjamin Otte [Fri, 18 Feb 2011 16:56:46 +0000 (17:56 +0100)]
xcb: Don't operate on a status variable that is never set

3 years agoboilerplate/egl: Ensure that we are using an RGBA32 egl config
Alexandros Frantzis [Fri, 11 Feb 2011 15:46:51 +0000 (17:46 +0200)]
boilerplate/egl: Ensure that we are using an RGBA32 egl config

3 years agoegl: Ensure that the dummy pbuffer surface is compatible with the supplied context
Alexandros Frantzis [Fri, 11 Feb 2011 14:11:43 +0000 (16:11 +0200)]
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.

3 years agoegl: Fix eglMakeCurrent for egl surfaces
Benjamin Franzke [Thu, 10 Feb 2011 16:07:43 +0000 (18:07 +0200)]
egl: Fix eglMakeCurrent for egl surfaces

3 years agotest: Add line-width-overlap
Benjamin Otte [Thu, 17 Feb 2011 17:17:08 +0000 (18:17 +0100)]
test: Add line-width-overlap

Test case taken from the WebKit test suite, failure originally reported
by Zan Dobersek <zandobersek@gmail.com>. WebKit test is
LayoutTests/canvas/philip/tests/2d.path.rect.selfintersect.html

3 years agotests: Fix gcc complaint
Benjamin Otte [Thu, 17 Feb 2011 17:09:22 +0000 (18:09 +0100)]
tests: Fix gcc complaint

warning: ‘static’ is not at beginning of declaration

3 years agotests: Add line-width-tolerance
Benjamin Otte [Tue, 15 Feb 2011 19:40:23 +0000 (20:40 +0100)]
tests: Add line-width-tolerance

Test case taken from the WebKit test suite, failure originally reported
by Zan Dobersek <zandobersek@gmail.com> at
https://bugs.webkit.org/show_bug.cgi?id=54471

3 years agoAUTHORS: Use correct email for me
Benjamin Otte [Tue, 9 Nov 2010 15:05:39 +0000 (10:05 -0500)]
AUTHORS: Use correct email for me

3 years agoxlib: Fix compilation when gradient functions are not available
Andrea Canciani [Mon, 7 Feb 2011 21:13:53 +0000 (22:13 +0100)]
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

3 years agotest: Fix REFERENCE_IMAGES
Andrea Canciani [Mon, 14 Feb 2011 08:58:13 +0000 (09:58 +0100)]
test: Fix REFERENCE_IMAGES

Makefile.am not updated along with changing the reference images in
6825007ac6d46e8d8a7a3bc065453af5d6e755a8 and
070bc5dd891ba698aeb3eaa899f662d4123f6928.

3 years agogl: Don't reset the FBO draw/readbuffers every time we bind the FBO.
Eric Anholt [Mon, 31 Jan 2011 04:11:11 +0000 (20:11 -0800)]
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

3 years agotest: Fix surface-pattern-scale-down-extend
Andrea Canciani [Sun, 13 Feb 2011 17:36:12 +0000 (18:36 +0100)]
test: Fix surface-pattern-scale-down-extend

This test creates a similar surface using cairo_push_group () and
assumes its size will be w x h. This is not true when testing similar
surfaces with "cairo-test-suite -a", because they are bigger than the
actual ROI, which corresponds to the rectangle (0,0) - (w,h).

Clipping to the ROI guarantees that the surface created by
cairo_push_group () always has the same size.

Fixes surface-pattern-scale-down-extend.

3 years agotest: Fix clip-device-offset
Andrea Canciani [Sun, 13 Feb 2011 16:28:31 +0000 (17:28 +0100)]
test: Fix clip-device-offset

The test was incorrectly translating the "target" of the context
instead of the "group target" (i.e. the current destination).

"cairo-test-suite -a" runs the tests on similar surfaces created using
cairo_push_group (), thus without this change the device-offset did
not affect the real destination surface.

Fixes clip-device-offset.

3 years agoarc-looping-dash: Add a missing cairo_restore ()
Uli Schlachter [Sat, 12 Feb 2011 19:49:02 +0000 (20:49 +0100)]
arc-looping-dash: Add a missing cairo_restore ()

This test called cairo_save () without restoring again. Normally, this doesn't
cause a problem. However, when cairo-test-suite is called with "-a", it also
executes the tests on a similar surface. This then caused
cairo_pop_group_to_source to be called on a cairo_save state which causes a
CAIRO_STATUS_INVALID_RESTORE since commit 5d95ae924ed1520.

Signed-off-by: Uli Schlachter <psychon@znc.in>
3 years agoFix errors from src/check-plt.sh
Uli Schlachter [Sat, 12 Feb 2011 13:51:30 +0000 (14:51 +0100)]
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>
3 years agoxcb: Remove the surface pattern cache
Uli Schlachter [Fri, 11 Feb 2011 21:25:12 +0000 (22:25 +0100)]
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>
3 years agoxcb: Fix a crash when finishing a device
Uli Schlachter [Thu, 10 Feb 2011 16:33:52 +0000 (17:33 +0100)]
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>
3 years agoFinish devices after their finish callback returns
Uli Schlachter [Wed, 9 Feb 2011 18:41:03 +0000 (19:41 +0100)]
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>
3 years agoxcb-surface-source: Add image16 and ps ref images
Uli Schlachter [Wed, 9 Feb 2011 19:08:28 +0000 (20:08 +0100)]
xcb-surface-source: Add image16 and ps ref images

Signed-off-by: Uli Schlachter <psychon@znc.in>
3 years agops: Update xlib-surface-source ref images
Uli Schlachter [Wed, 9 Feb 2011 18:58:05 +0000 (19:58 +0100)]
ps: Update xlib-surface-source ref images

Since 9948b5180a, the *-surface-source tests draw a different image (a
translucent region was added). However, the ref images for xlib-surface-source
with cairo-ps weren't updated and thus the test failed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
3 years agogl: Replace built-in vertex attributes with custom attributes
Alexandros Frantzis [Thu, 3 Feb 2011 21:06:26 +0000 (23:06 +0200)]
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>
3 years agogl: Add gl dispatch entries for functions related to vertex attributes
Alexandros Frantzis [Thu, 3 Feb 2011 20:06:27 +0000 (22:06 +0200)]
gl: Add gl dispatch entries for functions related to vertex attributes

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
3 years agogl: Use a custom shader uniform for the ModelViewProjection matrix
Alexandros Frantzis [Mon, 31 Jan 2011 16:02:02 +0000 (18:02 +0200)]
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>
3 years agogl: Replace ftransform() with manual coordinate calculation in shaders
Alexandros Frantzis [Thu, 27 Jan 2011 14:10:38 +0000 (16:10 +0200)]
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>
3 years agogl: Add function to bind a 4x4 float matrix shader uniform
Alexandros Frantzis [Mon, 31 Jan 2011 14:18:29 +0000 (16:18 +0200)]
gl: Add function to bind a 4x4 float matrix shader uniform

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
3 years agogl: Add entry for UniformMatrix4fv in the gl dispatch table
Alexandros Frantzis [Mon, 31 Jan 2011 13:55:07 +0000 (15:55 +0200)]
gl: Add entry for UniformMatrix4fv in the gl dispatch table

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
3 years agoType1-subset: Fallback if font contains more than one /Encoding
Adrian Johnson [Tue, 8 Feb 2011 11:10:08 +0000 (21:40 +1030)]
Type1-subset: Fallback if font contains more than one /Encoding

https://bugzilla.gnome.org/show_bug.cgi?id=641704

3 years agomesh: Rename cairo_pattern_mesh_* functions to cairo_mesh_pattern_*
Andrea Canciani [Thu, 3 Feb 2011 21:55:53 +0000 (22:55 +0100)]
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>

3 years agotest: Attempt to capture out-of-bounds spans compositing bug
Chris Wilson [Sun, 6 Feb 2011 18:11:25 +0000 (18:11 +0000)]
test: Attempt to capture out-of-bounds spans compositing bug

Attempt to provoke out-of-bounds accesses as demonstrated by
https://bugs.launchpad.net/ubuntu/+source/cairo/+bug/710072

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
3 years agoimage: Limit span rendering to bounded extents
Chris Wilson [Sun, 6 Feb 2011 14:11:30 +0000 (14:11 +0000)]
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>
3 years agoDon't err on non-invertible font matrix
Behdad Esfahbod [Fri, 4 Feb 2011 20:43:40 +0000 (15:43 -0500)]
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;
    }

3 years agogl: Remove fixed-function related code paths
Alexandros Frantzis [Fri, 28 Jan 2011 13:02:54 +0000 (15:02 +0200)]
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>
3 years agogl: Remove unnecessary checks for NULL shader implementation
Alexandros Frantzis [Fri, 28 Jan 2011 13:02:53 +0000 (15:02 +0200)]
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>
3 years agogl: Fail if GL implementation doesn't support shaders
Alexandros Frantzis [Fri, 28 Jan 2011 13:02:52 +0000 (15:02 +0200)]
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>
3 years agoXCB: Fix build with xcb-shm disabled
Uli Schlachter [Mon, 31 Jan 2011 21:39:39 +0000 (22:39 +0100)]
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>
3 years agoxcb: Use a normal image surface if SHM fails
Uli Schlachter [Sun, 30 Jan 2011 15:29:50 +0000 (16:29 +0100)]
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>
3 years agoxcb: Move the allocation of a shm surface into its own function
Uli Schlachter [Sun, 30 Jan 2011 14:43:00 +0000 (15:43 +0100)]
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>
3 years agoxcb: Remove a duplicate static function
Uli Schlachter [Sun, 30 Jan 2011 14:35:36 +0000 (15:35 +0100)]
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>
3 years agoxcb: Limit the amount of SHM used
Uli Schlachter [Sun, 30 Jan 2011 15:19:50 +0000 (16:19 +0100)]
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>
3 years agoscaled font: Fix the docs for cairo_scaled_font_get_font_face
Uli Schlachter [Tue, 25 Jan 2011 15:29:58 +0000 (16:29 +0100)]
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>
3 years agoUser fonts: Make it clear what should NOT be freed
Uli Schlachter [Tue, 25 Jan 2011 15:19:27 +0000 (16:19 +0100)]
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>
3 years agoxcb: Document all public functions
Uli Schlachter [Wed, 26 Jan 2011 20:10:59 +0000 (21:10 +0100)]
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>
3 years agoxcb: Automatically enable the backend if the libs are available
Uli Schlachter [Wed, 26 Jan 2011 16:54:13 +0000 (17:54 +0100)]
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>
3 years agoLD_PRELOAD is supported on Hurd
Pino Toscano [Tue, 25 Jan 2011 13:33:11 +0000 (14:33 +0100)]
LD_PRELOAD is supported on Hurd

LD_PRELOAD is supported on Hurd. Adding Hurd to the list of supported
systems makes cairo-trace available on them as well.

See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=608492

3 years agoxcb: Fix compositing of pixel-aligned rectangles
Andrea Canciani [Tue, 25 Jan 2011 07:41:27 +0000 (08:41 +0100)]
xcb: Fix compositing of pixel-aligned rectangles

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

74374fce9d71d373287cddc3a0bf4aaf4bda568b causes incorrect rendering
whenever extents are not tight.

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

3 years agoFix regressions from 1.10 merge
Andrea Canciani [Mon, 24 Jan 2011 09:35:23 +0000 (10:35 +0100)]
Fix regressions from 1.10 merge

d6dc6e8e396506d5160266dda6575ddfce671c2d 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

3 years agoxcb: Fix a BadPicture when clearing a surface
Uli Schlachter [Sun, 23 Jan 2011 21:10:20 +0000 (22:10 +0100)]
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>
3 years agoxcb: Only use clip rectangles for more than 1 pixel-aligned box
Chris Wilson [Sun, 23 Jan 2011 18:32:12 +0000 (18:32 +0000)]
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>
3 years agoversion: Post-snapshot bump
Chris Wilson [Sun, 23 Jan 2011 16:52:50 +0000 (16:52 +0000)]
version: Post-snapshot bump

3 years agoversion: Bump for 1.11.2 snapshot
Chris Wilson [Sun, 23 Jan 2011 16:32:13 +0000 (16:32 +0000)]
version: Bump for 1.11.2 snapshot

3 years agoNEWS: 1.11.2 snapshot
Chris Wilson [Sun, 23 Jan 2011 16:31:40 +0000 (16:31 +0000)]
NEWS: 1.11.2 snapshot

3 years agoMerge branch '1.10' into tmp
Chris Wilson [Sun, 23 Jan 2011 16:05:01 +0000 (16:05 +0000)]
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

3 years agoMakefile: add missing cairo-box-private.h
Chris Wilson [Sun, 23 Jan 2011 15:46:32 +0000 (15:46 +0000)]
Makefile: add missing cairo-box-private.h

3 years agoxcb: Prefer RenderFillRectangles to perform the deferred clear
Chris Wilson [Sun, 23 Jan 2011 13:29:51 +0000 (13:29 +0000)]
xcb: Prefer RenderFillRectangles to perform the deferred clear

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
3 years agoxcb: Apply a clip region for compositing many-pixel-aligned-boxes
Chris Wilson [Sun, 23 Jan 2011 12:28:06 +0000 (12:28 +0000)]
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>
3 years agogstate: Remove unused code
Andrea Canciani [Wed, 19 Jan 2011 22:22:31 +0000 (23:22 +0100)]
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 fb7f7c2f27f0823d7702f960204d6e638d697624.

3 years agogstate: Set an error status when restoring a push_group
Andrea Canciani [Thu, 20 Jan 2011 00:44:29 +0000 (01:44 +0100)]
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.

3 years agotest: Add group-state
Andrea Canciani [Tue, 18 Jan 2011 13:48:15 +0000 (14:48 +0100)]
test: Add group-state

The interaction between the group and the state API is currently
untested and buggy. This test tries to use them incorrectly and check
that cairo notices the problem and marks the cr object with an error
status.

3 years agoclip: Improve _cairo_clip_contains_*
Andrea Canciani [Sat, 22 Jan 2011 10:56:37 +0000 (11:56 +0100)]
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().

3 years agowin32: Improve error logging
Mats Palmgren [Fri, 21 Jan 2011 08:52:19 +0000 (09:52 +0100)]
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

3 years agoBump pixman requirements to 0.20.2 for radial gradients
Andrea Canciani [Wed, 19 Jan 2011 14:04:49 +0000 (15:04 +0100)]
Bump pixman requirements to 0.20.2 for radial gradients

Pixman has PDF-like radial gradients since 0.20.0, but the
implementation of the tangent circles case was not correct. This has
been fixed in 0.20.2, along with some invalid operations fixes.

3 years agotest: Workaround pixman limits in large-source-roi
Andrea Canciani [Wed, 19 Jan 2011 13:35:46 +0000 (14:35 +0100)]
test: Workaround pixman limits in large-source-roi

Since 1cc750ed92a936d84b47cac696aaffd226e1c02e pixman won't perform
the compositing if it can't prove that this the computations it has to
perform will fit within the size of the variables it uses.

It looks like in this case it cannot prove that no overflow will
happen unless surface_width <= 30582. Instead of this size (discovered
by bisection), a safer looking 30000 was chosen. It should still
trigger the problems the original test was looking for, because
backends which support 30000xheight surfaces will likely support
32767xheight as well.

3 years agoquartz: Respect pattern filter settings
Andrea Canciani [Thu, 6 Jan 2011 16:40:05 +0000 (17:40 +0100)]
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.

3 years agoquartz: Avoid using private APIs
Andrea Canciani [Fri, 7 Jan 2011 17:00:37 +0000 (18:00 +0100)]
quartz: Avoid using private APIs

CGContextSetCTM() is not part of the public API and can easily be
replaced by CGContextConcatCTM()-ing an appropriate matrix.

3 years agoquartz: Use CGLayer to implement unbounded operators
Andrea Canciani [Wed, 5 Jan 2011 15:12:34 +0000 (16:12 +0100)]
quartz: Use CGLayer to implement unbounded operators

Quartz operators are not unbounded, but it is possible to implement
unbounded operators by using a temporary destination.

Fixes clip-stroke-unbounded, clip-fill-nz-unbounded,
clip-fill-eo-unbounded, clip-operator, operator-alpha-alpha,
overlapping-glyphs, surface-pattern-operator, unbounded-operator.

3 years agoquartz: Cleanup extents computation
Andrea Canciani [Sat, 1 Jan 2011 22:16:11 +0000 (23:16 +0100)]
quartz: Cleanup extents computation

All the draw operations use the same code to compute the gradient
parameter range. It can be moved to the function which sets up the
source.

3 years agoquartz: Do not use opaque patterns as masks
Andrea Canciani [Sat, 1 Jan 2011 21:36:45 +0000 (22:36 +0100)]
quartz: Do not use opaque patterns as masks

When an opaque surface is used as a mask, Quartz converts it to
greyscale and uses the result as an alpha value. Cairo expects the
mask operation to ignore the color components and only use the alpha
of the pattern.

The expected behavior can be achieved by drawing the mask on a
temporary surface with an alpha channel.

Fixes clear-source.

3 years agoquartz: Make huge domain handling more stable
Andrea Canciani [Wed, 5 Jan 2011 11:15:06 +0000 (12:15 +0100)]
quartz: Make huge domain handling more stable

Quartz cannot correctly handle arbitrary domains. Falling back is
needed to get correct results on very large (in parameter space)
gradients.

For PAD extended gradients, limiting the domain to (at most) [-0.5,
1.5] is sufficient to guarantee that it will correctly sample the
extreme stops and improves the accuracy (over having a much bigger
domain).

Fixes radial-gradient, radial-gradient-mask, radial-gradient-source,
radial-gradient-mask-source, radial-gradient-one-stop.

Improves the quality of the linear gradients in linear-gradient,
linear-gradient-subset, mask, operator-source, trap-clip.

3 years agoquartz: Use standard stack allocation size
Andrea Canciani [Sat, 1 Jan 2011 21:57:27 +0000 (22:57 +0100)]
quartz: Use standard stack allocation size

Make cairo-quartz respect the convention that stack-allocated data
structures use the size computed by CAIRO_STACK_ARRAY_LENGTH ().

Additionally this increases the size of the dash and glyph arrays,
making dynamic memory allocation less likely.

3 years agotest: Update quartz ref images
Andrea Canciani [Fri, 7 Jan 2011 23:56:38 +0000 (00:56 +0100)]
test: Update quartz ref images

The following commits fix and/or improve the output of some tests.
Updating the ref images before fixing the code allows to check that
the fix is correct and makes it easy to find out which tests are fixed
by each commit.

3 years agotest: Fix operator-alpha-alpha
Andrea Canciani [Wed, 5 Jan 2011 15:00:37 +0000 (16:00 +0100)]
test: Fix operator-alpha-alpha

The test is checking the compositing of color-alpha sources although
it was meant to check the compositing of alpha-only sources on
alpha-only destinations.

This commit fixes the code to respect the test description.