Commit graph

288 commits

Author SHA1 Message Date
John Ralls
b6e0f36ee5 [quartz]Cleanup _cairo_quartz_cairo_repeating_surface_pattern_to_quartz 2022-02-24 17:00:07 -08:00
John Ralls
ae320c4d75 [quartz] Use CoreGraphics instead of Qt to write debug png file. 2022-02-24 17:00:07 -08:00
John Ralls
bacbe9bb2d [quartz] Create similar surfaces using a CGLayer for faster drawing. 2022-02-24 17:00:07 -08:00
John Ralls
76e6a0ddf7 [quartz] Remove cached image_surface on quartz surfaces.
Caching doesn't really do anything and removing it provides a 50%
speedup and gets pdf-operators-text to pass on argb32.
2022-02-24 17:00:07 -08:00
John Ralls
64786613ee [quartz] Snapshot CGBitmapContext-mapped surfaces to cache CGImages.
Motivation: Avoid need to recreate CGImages for unchanged surfaces,
an expensive operation, while ensuring that the CGImages are properly
freed and new ones created when the surface does change.

Thanks to Uli Schlacter for suggestion and coding guidance.
2022-02-24 16:59:56 -08:00
Christopher Chavez
04394d5b15 quartz: Fix spelling in comment 2022-02-23 13:12:35 +00:00
Emmanuele Bassi
bfd1602db9 Remove stray _GNU_SOURCE definitions
We define _GNU_SOURCE globally in both the Autotools build, through the
use of the AC_USE_SYSTEM_EXTENSIONS macro; and in the Meson build, with
add_project_arguments().
2021-05-01 16:58:15 +01:00
John Ralls
dccaa9179b Quartz Better manage acquired/replayed surface. 2020-12-05 11:51:17 -08:00
John Ralls
1ddfccca31 Quartz image drawing: Remove containers for cairo_surface_t.
Since we now copy the data that CGImage needs we don't need to
keep the surface around anymore, nor release it or the image in the
DataProviderReleaseCallback.
2020-12-03 13:56:50 -08:00
John Ralls
b5e84a9783 Quartz: Ensure that image data and surface are available to draw.
Snapshot the cairo_surface_t and copy the image data to provide to
the CGDataProvider so that it is independent of the cairo_surface_t's
lifetime.

Closes https://gitlab.freedesktop.org/cairo/cairo/-/issues/420
2020-12-03 10:59:04 -08:00
John Ralls
32c12c617a Ensure _cairo_quartz_surface_create_internal always nulls imageSurfaceEquiv. 2020-11-30 14:10:18 -08:00
Adrian Johnson
1998239387 Use _cairo_malloc instead of malloc
_cairo_malloc(0) always returns NULL, but has not been used
consistently.  This patch replaces many calls to malloc() with
_cairo_malloc().

Fixes:  fdo# 101547
CVE: CVE-2017-9814 Heap buffer overflow at cairo-truetype-subset.c:1299
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-05-07 16:35:51 -07:00
Adrian Johnson
aa1323f04c Fix some surfaces missed in b1192bea 2015-10-17 22:02:11 +10:30
Andrea Canciani
66bc7b8cb0 quartz: be more strict about the behavior of blend operators
Some blend operators have a (small, but potentially noticeable)
different behaviour in Quartz and pixman. Use the Quartz ones only for
the operators which match pixman except for rounding errors.

Fixes:
 - extended-blend
 - extended-blend-alpha
 - extended-blend-mask
 - extended-blend-alpha-mask
 - extended-blend-solid
 - extended-blend-solid-alpha
2015-07-27 12:46:00 +02:00
Andrea Canciani
6210e34771 quartz: Align filtering quality with image backend
The Quartz framework provides several quality settings, but they were
not used. Now the translation of cairo_filter_t to Quartz filtering
modes tries to match the quality settings from image as much as
possible.

Specifically, CAIRO_FILTER_GOOD and CAIRO_FILTER_BILINEAR are now
converted to kCGInterpolationLow, which seems to be a bilinear filter.

Fixes:
 - pixman-downscale-bilinear-24
 - pixman-downscale-bilinear-95
 - pixman-downscale-good-24
 - pixman-downscale-good-95
 - pthread-same-source
 - recording-surface-extend-none
 - recording-surface-extend-reflect
 - recording-surface-extend-repeat
 - recording-surface-over
 - recording-surface-source
 - surface-pattern-big-scale-down
 - surface-pattern-scale-down
 - surface-pattern-scale-down-extend-none
 - surface-pattern-scale-down-extend-reflect
 - surface-pattern-scale-down-extend-repeat
2015-07-27 12:46:00 +02:00
Andrea Canciani
03756e042a quartz-image: Fix build
The quartz-image backend uses _cairo_surface_is_quartz(), which
therefore needs to be made available to it. Fixed as suggested by
Bryce in the referenced bugreport.

References: https://bugs.freedesktop.org/show_bug.cgi?id=84569
Signed-off-by: Andrea Canciani <ranma42@gmail.com>
2014-10-03 11:38:48 -07:00
Andrea Canciani
531da6fb91 quartz: Fix build
Cairo cannot build with Quartz enabled since
573ddfc3d5, because of a double
definition of _cairo_surface_is_quartz().

References: https://bugs.freedesktop.org/show_bug.cgi?id=84569
Signed-off-by: Andrea Canciani <ranma42@gmail.com>
2014-10-03 11:38:44 -07:00
Ravi Nanjundappa
573ddfc3d5 src: check the surface backend for NULL
This is a follow-up patch on top of 150c1e7044
As discussed in the mailing list, http://lists.cairographics.org/archives/cairo/2014-September/025647.html,
check if the surfaces are of particular backend type or not, before proceeding further.

These changes are based on _cairo_surface_is_xlib() and _cairo_surface_is_image()

Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com>
2014-09-29 15:59:26 -07:00
Michael Hutchinson
fdec6b3759 quartz: Don't release memory we don't own
This was causing crashes due to double frees.

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

Signed-off-by: Benjamin Otte <otte@redhat.com>
2013-03-29 02:40:13 +01:00
Andrea Canciani
d00539ca13 quartz: Use the correct transform when replaying recording surfaces
Recording surfaces should be replayed with the transform matrix used
in the pattern, otherwise the image surface will be transformed,
introducing artifacts.

Fixes record{1414x,2x}-paint-alpha-{,solid-clip,clip},
record2x-{self-intersecting,text-transform} and record90-paint-alpha.
2012-07-24 11:06:30 +02:00
Henry (Yu) Song - SISA
44a07a6613 quartz: Never acquire recording surfaces
We need to replay if the source/mask surface is a recording surface
otherwise, a crash happens if it is unbounded.

Fixes crashes in recordxx-xxx tests
2012-07-24 11:06:30 +02:00
Andrea Canciani
fc33cc3c3a quartz: Provide a valid implementation of map_to_image
and reuse it to implement acquire_source.

Fixes

cairo-quartz-surface.c: In function '_cairo_quartz_surface_map_to_image':
cairo-quartz-surface.c:1568: warning: return from incompatible pointer type
cairo-quartz-surface.c:1576: warning: return from incompatible pointer type
2012-05-26 16:07:47 +02:00
Andrea Canciani
a8a4a8dfd4 quartz: Mark surfaces created clear as is_clear
This might provide a speedup when clearing an already clear surface
and is required by cairo_surface_create_similar().

Fixes zero-mask.
2012-05-26 16:07:33 +02:00
Andrea Canciani
3735881e38 quartz: Silence warning
cairo-quartz-surface.c:177: warning: enumeration value
'CAIRO_FORMAT_RGB30' not handled in switch
2012-05-26 16:07:26 +02:00
Andrea Canciani
d6fb8d2134 surface: Make backend-specific map/unmap functions symmetric
Map allocates a surface. Symmetrically, unmap should destroy it.
2012-05-26 16:06:31 +02:00
Andrea Canciani
df7829e2cc surface: Make map_to_image return cairo_image_surface_t*
This makes it easier to check that the funciton is returning the
correct type of surfaces.
2012-05-26 16:06:26 +02:00
Andrea Canciani
2470065edf doc: Fix some wrong versions
The script from the previous commit reported that some 'Since' fields
indicate incorrect versions.
2012-03-29 11:03:18 +02:00
Andrea Canciani
1d3d64469f doc: Add "since" tag to documentation
The following Python script was used to compute "Since: 1.X" tags,
based on the first version where a symbol became officially supported.

This script requires a concatenation of the the cairo public headers
for the officially supported beckends to be available as
"../../includes/1.X.0.h".

from sys import argv
import re

syms = {}

def stripcomments(text):
    def replacer(match):
        s = match.group(0)
        if s.startswith('/'):
            return ""
        else:
            return s
    pattern = re.compile(
        r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
        re.DOTALL | re.MULTILINE
    )
    return re.sub(pattern, replacer, text)

for minor in range(12,-2,-2):
    version = "1.%d" % minor
    names = re.split('([A-Za-z0-9_]+)', stripcomments(open("../../includes/%s.0.h" % version).read()))
    for s in names: syms[s] = version

for filename in argv[1:]:
    is_public = False
    lines = open(filename, "r").read().split("\n")
    newlines = []
    for i in range(len(lines)):
        if lines[i] == "/**":
            last_sym = lines[i+1][2:].strip().replace(":", "")
            is_public = last_sym.lower().startswith("cairo")
        elif is_public and lines[i] == " **/":
            if last_sym in syms:
                v = syms[last_sym]
                if re.search("Since", newlines[-1]): newlines = newlines[:-1]
                if newlines[-1].strip() != "*": newlines.append(" *")
                newlines.append(" * Since: %s" % v)
            else:
                print "%s (%d): Cannot determine the version in which '%s' was introduced" % (filename, i, last_sym)
        newlines.append(lines[i])

    out = open(filename, "w")
    out.write("\n".join(newlines))
    out.close()
2012-03-29 11:03:18 +02:00
Andrea Canciani
7f635e4ead doc: Make doc ids more consistent my always putting ':' after them
This makes the documentations comments more consistent and fixes many
reports of 'invalid doc id'.
2012-03-29 11:03:18 +02:00
Andrea Canciani
f717341ab9 doc: Make documentation comments symmetric
Documentation comments should always start with "/**" and end with
"**/". This is not required by gtk-doc, but it makes the
documentations formatting more consistent and simplifies the checking
of documentation comments.

The following Python script tries to enforce this.

from sys import argv
from sre import search

for filename in argv[1:]:
    in_doc = False
    lines = open(filename, "r").read().split("\n")
    for i in range(len(lines)):
        ls = lines[i].strip()
        if ls == "/**":
            in_doc = True
        elif in_doc and ls == "*/":
            lines[i] = " **/"
        if ls.endswith("*/"):
            in_doc = False

    out = open(filename, "w")
    out.write("\n".join(lines))
    out.close()

This fixes most 'documentation comment not closed with **/' warnings
by check-doc-syntax.awk.
2012-03-29 11:03:18 +02:00
Chris Wilson
154e6b052b quartz: Add missing source hook
Regression from 2061cd81f2.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=45866
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-10 09:21:32 +00:00
Andrea Canciani
7058e8c181 quartz: Make glyph antialiasing consistent with quartz-font
CAIRO_ANTIALIAS_{FAST,GOOD,BEST} were introduced and used in
cairo-quartz-font.c by commit 70cd3b473d.

Fixes the warnings:

cairo-quartz-surface.c: In function '_cairo_quartz_cg_glyphs':
cairo-quartz-surface.c:1976: warning: enumeration value 'CAIRO_ANTIALIAS_FAST' not handled in switch
cairo-quartz-surface.c:1976: warning: enumeration value 'CAIRO_ANTIALIAS_GOOD' not handled in switch
cairo-quartz-surface.c:1976: warning: enumeration value 'CAIRO_ANTIALIAS_BEST' not handled in switch
2012-01-15 16:23:14 +01:00
Andrea Canciani
29145f4e48 quartz: Fix building with QUARTZ_DEBUG
Multiple code refactorings broke the debugging code.
2012-01-15 16:23:14 +01:00
Andrea Canciani
7827f46d7c quartz: Fix build
Fix a bunch of typos and "wrong number of arguments" errors.
Clean up some "unused variable" errors.
2011-09-18 08:48:05 -07:00
Chris Wilson
af9fbd176b Introduce a new compositor architecture
Having spent the last dev cycle looking at how we could specialize the
compositors for various backends, we once again look for the
commonalities in order to reduce the duplication. In part this is
motivated by the idea that spans is a good interface for both the
existent GL backend and pixman, and so they deserve a dedicated
compositor. xcb/xlib target an identical rendering system and so they
should be using the same compositor, and it should be possible to run
that same compositor locally against pixman to generate reference tests.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

P.S. This brings massive upheaval (read breakage) I've tried delaying in
order to fix as many things as possible but now this one patch does far,
far, far too much. Apologies in advance for breaking your favourite
backend, but trust me in that the end result will be much better. :)
2011-09-12 08:29:48 +01:00
Andrea Canciani
0c620080af quartz: Fix compilation
cairo-image-surface-private.h is needed in order to access
cairo_image_surface_t fields.

Fixes multiple build errors: dereferencing pointer to incomplete type
2011-09-02 12:00:29 +02:00
Andrea Canciani
e04e368748 Remove useless checks for NULL before freeing
This patch has been generated by the following Coccinelle semantic patch:
// Remove useless checks for NULL before freeing
//
// free (NULL) is a no-op, so there is no need to avoid it

@@
expression E;
@@
+ free (E);
+ E = NULL;
- if (unlikely (E != NULL)) {
-   free(E);
(
-   E = NULL;
|
-   E = 0;
)
   ...
- }

@@
expression E;
@@
+ free (E);
- if (unlikely (E != NULL)) {
-   free (E);
- }
2011-07-31 16:46:36 +02:00
Andrea Canciani
81efbc1847 quartz: Silence some clang warnings
Clang static analysis relies on the Core Foundation naming convention
for the object ownership tracking.

Functions that return an object whose ownership is given to the
caller, should contain "Create" or "Copy" in their name.
2011-07-29 12:07:06 +02:00
Andrea Canciani
87016112c5 Fix surface backend structures
a69335a84e introduced some new members
in the backend structure, but quartz, qt and xlib-xcb were not
updated.
2011-07-26 22:03:31 +02:00
Andrea Canciani
ca53fed939 quartz: Silence const cast warnings
b132fae5e8 const-ified some arguments,
but missed others.
2011-07-26 22:03:07 +02:00
Chris Wilson
b132fae5e8 clip: Rudimentary support for clip-polygon extraction
Step 1, fix the failings sighted recently by tracking clip-boxes as an
explicit property of the clipping and of composition.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-19 21:14:34 +01:00
Andrea Canciani
29d19c683b build: Fix compilation
83bfd85a13 and
2458120dee did not update some backends
properly, breaking their compilation.
2011-07-19 08:10:21 +02: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
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
Andrea Canciani
ca9068839b 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.
2011-01-19 12:00:58 +01:00
Andrea Canciani
d7e3637af2 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.
2011-01-19 11:53:53 +01:00
Andrea Canciani
aa2fb0c05f 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.
2011-01-19 11:53:53 +01:00
Andrea Canciani
7d89d69c49 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.
2011-01-19 11:53:52 +01:00
Andrea Canciani
4874dab984 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.
2011-01-19 11:53:52 +01:00