Sometimes it is useful to be able to package the result of a run of
the testsuite. This new target creates an archive containing the html
page and at least all the files it links to.
The archive might contain some unneeded images.
The tolerance argument of _cairo_gradient_pattern_box_to_parameter ()
is in pattern space, so to have it constant in device space, it should
depend on the pattern matrix.
In ps and pdf the fallback resolution alone is not meaningful. The
resolution/fallback_resolution ratio should be used instead.
_cairo_gl_operand_init() has parameters to specify an offset for the
source and another for the destination.
_cairo_gl_gradient_operand_init() incorrectly assumed that the two
offsets were identical.
Fixes mask, radial-gradient-mask-source.
Cairo assumes that radial gradients are drawn as defined in ISO3200
since b661bc8712.
To implement them in GLSL, three different shaders are required:
- tangent circles (a=0 in the parameter equation)
- none-extended gradient (solutions outside [0,1] must be ignored)
- extended gradient
Moreover, texcoords are used instead of gl_FragCoord, to fix the
flipping as per 31e116f084.
Fixes huge-radial, radial-gradient, radial-gradient-extend,
radial-gradient-mask, radial-gradient-source.
cairo_tee_surface_create copies the device transform from 'master' to
the new surface. This is wrong since all the cairo_surface_wrapper
functions apply master's device transform themselves.
Reviewed-by: Benjamin Otte <otte@redhat.com>
If a gl surface is resized (with cairo_gl_surface_set_size()) while being the
current target, the resize does not take effect until the target changes to a
different surface and back to the original one. This patch allows a gl_context
to track when the current target surface has been changed and ensures that a
resize always take effect the next time a resized surface is used as the target.
Using the names "min" and "max" is likely to cause collisions. Instead
of them, use the MIN and MAX macros provided by cairoint.h
Reviewed-by: Uli Schlachter <psychon@znc.in>
When we create a temporary cairo_xcb_picture_t, we want to be able to
reuse it, but we don't want the Picture to be alive forever to eat up
resources when it is not being used anymore.
When a surface pattern is about to be used for compositing, if it has
a cairo_xcb_picture_t snapshot, the latter is just reused. Otherwise a
new cairo_xcb_picture_t with the same content is created and attached
as a snapshot to the surface.
To keep the resource usage bounded we keep a per-screen cache of
cairo_xcb_picture_t. When the cache is full, a random entry is evicted
and we detach this snapshot from the surface that it is a snapshot
for. It will be immediately destroyed if nothing else holds a
reference to it. Otherwise it will be charged against the holder of
the reference, so it won't count anymore in the resources occupied by
the cache elements. This makes sure that the cached surface isn't
kept alive indefinitely because of caching.
Based on a patch by Uli Schlachter.
Some code might own a reference to the snapshot when it is
detached. For this reason, we shouldn't finish the snapshot except
when its reference count drops to zero.
This avoids destroying source patterns which get evicted from the
cache while acquiring the mask.
Fixes xcb-stress-cache.
Big "thank you" to Andrea Canciani for helping in figuring this one out.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This was found via cairo-perf-micro which sometimes triggered this bug in its
mask-similar_image-* test.
Signed-off-by: Uli Schlachter <psychon@znc.in>
The optimization of any opaque color IN an alpha-only surface is a
noop (it multiplies the alpha of each pixel of the destination by 1).
The same does not apply to colored destinations, because IN replaces
the original color with the color of the source.
Fixes white-in-noop.
cairo_image_get_data() and other direct access functions are often
misused by applications because they don't call cairo_surface_flush()
and/or cairo_surface_mark_dirty() around the code which accesses the
surface data directly.
Although this information is already available in the description of
the cairo_surface_t type, adding a reminder about it in the direct
access functions should make it easier to use them correctly.
The PNG API is just a toy API whose main purpose is to make it easy to
write minimal examples of cairo features or testcases for bugs. For
these purposes there is no need to tune the output PNG file or to
provide additional information in optional PNG chuncks, but real
applications need to do that quite often. The documentation now points
out what is the correct procedure to write image data to a file.
To ensure that we can correctly issue the glyph operation, glyph size
must fit in an XCB request and its position must be within the
representable range (16-bit offset).
Glyph caches (with direct glyph index matching) cannot be completely
initialized with zeroes, otherwise the code will incorrectly believe
that the lookup for the 0-index glyph has already been performed.
A xcb surface has to be finished before the associated drawable can be freed or
there will be X11 errors when the surface is later finished or used again.
Signed-off-by: Uli Schlachter <psychon@znc.in>
We have to make sure we received all errors that the X server sent out before we
can be sure there are none. To do so, we just have to send some request and wait
for its reply, because that guarantees that the replies/errors to all previous
requests were received.
_cairo_boilerplate_xcb_synchronize doesn't need this, because the GetImage
request already makes sure we received everything.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit makes the boilerplate code check for errors from the X server before
disconnecting and during synchronize. This should make sure no errors are ever
lost and silently ignored.
Signed-off-by: Uli Schlachter <psychon@znc.in>
It is quite likely that following errors are caused by the previous ones. To
avoid flooding users we now silently discard all the errors and events after the
first one.
Signed-off-by: Uli Schlachter <psychon@znc.in>
In X11, errors look like events with response_type == 0. Using a define looks
better than just a "trust me!".
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit delays the return of a SHM area to the free pool. When
_cairo_xcb_shm_info_destroy is called, it now adds the cairo_xcb_shm_info_t to a
list of pending memory areas and sends a GetInputFocus request to the server.
This cairo_xcb_shm_info_t is only really freed when the GetInputFocus request
completes. To avoid unnecessarily waiting for the X server, we check via
xcb_poll_for_reply for the reply which returns immediately if the reply isn't
received yet.
This commits fixes a race where the shared memory area is reused before the X
server finished reading data from it. This does NOT fix races where cairo draws
something new to the same cairo_xcb_shm_info_t while the X server still reads
from it. However, there doesn't seem to exist any code currently where the shm
info isn't immediately destroyed after it was used.
This commit fixes the following tests for xcb-render-0.0 if SHM is enabled:
joins mask mask-transformed-image push-group push-group-color radial-gradient
radil-gradient-mask radial-gradient-mask-source radial-gradient-one-stop
radial-gradient-source smask smask-mask smask-paint
This also fixes mesh-pattern-transformed for all the xcb boilerplate "backends".
Signed-off-by: Uli Schlachter <psychon@znc.in>
The following commit adds a call to _cairo_xcb_shm_info_destroy to some function
in-between, but it also renames it and does some other changes to this. Thus,
move this function first to make the diff easier to read. :)
Signed-off-by: Uli Schlachter <psychon@znc.in>
Using double precision for gradient extreme objects ensures that they
are preserved as specified when constructing the gradient pattern.
Fixes huge-linear, huge-radial.
Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
Cairo makes it possible to create gradients whose extreme objects are
defined with double precision coordinates, but it internally
represents them with 24.8 fixed point precision.
This shows that coordinates that don't fit the valid range are
mishandled and don't even trigger an error status.
The same code was duplicated (incorrectly and with some minor
differences) in pattern, image, xlib and xcb.
_cairo_gradient_pattern_max_val() abstracts that code in a function
that can be used whenever a gradients extremes need to be rescaled to
fit within a given range.
Fixes huge-linear, huge-radial.
Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
Cairo represents gradients coordinate with 24.8 fixed point precision,
but pixman uses 16.16 fixed point coordinates.
This shows that cairo is currently unable to handle gradients with
coordinates which are valid for cairo but not for pixman.
Xlib, XCB and image use the same code to convert a cairo_matrix_t to a
backend-specific transform.
The code did not handle correctly some matrices, thus a new function
that performs the conversion in a more generic way was added and used
in the backends instead of fixing the repeated code.
Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
The old radial gradient tests were actually drawing the same gradients
with different operators (OVER/SOURCE) and operations (paint/mask).
It is possible to refactor them to share the gradient construction
code. This makes it easy to change the gradient shape in all of them
to test more interesting combinations.
Instead of testing 16 generic positions we are now testing just 7
cases, which correspond to every possible combination of the relative
size and position of the two circles defining the gradient. In
particular we are now testing a constant radius gradient and gradients
with tangent circles.
Since 18b48a6ebc the color of each
gradient stop is stored in a cairo_color_stop_t, but
_cairo_gradient_color_stops_hash() was not updated accordingly.
mesh-pattern tests a mesh pattern with non-opaque two overlapping
patches.
mesh-pattern-accuracy tests the accuracy of the color computed in each
point of a patch. It can point out defects in rasterizers which rely
on mesh subdivision only use the mesh shape instead of both shape and
color to decide when the tensor-product patches can be approximated
with Gouraud-shaded triangles.
mesh-pattern-conical is an example of how a conical gradient can be
approximated with a mesh pattern.
mesh-pattern-control-points tests a mesh pattern with control points
in non-default position to verify that their position affects the
color as expected.
mesh-pattern-fold tests a mesh pattern with a patch which folds along
both sides.
mesh-pattern-overlap tests a mesh pattern with a patch which folds
along just one side.
mesh-pattern-transformed tests a mesh pattern with non-identity
transform matrix.
PS and PDF have native support for mesh patterns, but they have encode
mesh points and colors in an appropriate binary stream.
cairo_pdf_shading_* functions implement the encoding, which is the
same for PDF and PS.
Mesh gradients are constructed using multiple commands, bracketed by
explicit begin/end pairs. Using a mesh gradient inside a begin/end
pair is not allowed.
Add the mesh pattern type and an error status to be used to report an
incorrect construction of the pattern.
Update the backends to make them ready to handle the new pattern type,
even if it cannot be created yet.