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>
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>
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>
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>
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
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
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>
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>
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>
_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.
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.
_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().
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.