Commit graph

107 commits

Author SHA1 Message Date
Mathieu Duponchelle
c4fd00c2c4 script-surface: Fix unitialized variable compiler warning
gcc doesn't warn about this because status is potentially
initialized in a loop.
2020-07-18 19:43:43 +00:00
luz.paz
6d93bddbd6 Misc. typos
Found via `codespell -i 3 -w -I ../cairo-word-whitelist.txt -L tim,ned,uint`
Follow up of 12cb59be7d

Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
2019-01-31 17:37:15 -08:00
Maarten Lankhorst
a34cb719cd Add support for RGBA128F and RGB96F formats.
IGT wants to add support for planes with a bit depth >10, which
requires a higher precision format than we have currently.

I'm using RGBA as format, because of its existence in OpenGL.
With the new formats we can directly convert our bytes to half float,
or multiply a colro vector with a matrix to go to the Y'CbCr colorspace.

This requires pixman 0.36.0, so bump the version requirement.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
2019-01-07 19:10:44 -08:00
Bryce Harrington
9d2e3646fa script-surface: Check for invalid ids (CID #1159557, 1159558)
If the bitmap's min is non-zero, _bitmap_next_id() could break out of
its loop early, before initializing the prev variable.  prev would then
be dereferenced without a null ptr check.  This condition should never
occur in practice, so add an assert() to assure it doesn't.

Same issue is present in trace.c.

Coverity IDs: #1159557, #1159558
Reviewed-By: Uli Schlachter <psychon@znc.in>
Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
2018-06-13 15:21:50 -07: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
38fbe621cf image: prevent invalid ptr access for > 4GB images
Image data is often accessed using:

  image->data + y * image->stride

On 64-bit achitectures if the image data is > 4GB, this computation
will overflow since both y and stride are 32-bit types.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=98165
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-11-07 17:01:49 -08:00
Adrian Johnson
b1192beac7 Don't cull very thin lines on vector surfaces
On vector surfaces, use a minimum line width when calculating extents.

Bug 77298
2015-10-17 18:39:18 +10:30
Bryce Harrington
bf4f5f3a90 cairo-script: Return a cairo_status_t error, not FALSE
This typo results in certain paths being incorrectly recorded with
script surfaces.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=91054
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-26 16:30:06 -07:00
Bryce Harrington
c1c3028a0c cairo-script: Fix sp. "directoriy"
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-25 17:42:27 -07:00
Chris Wilson
80cc532271 script: Thaw the scaled font cache on the error path
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-01-08 15:01:38 +00:00
Chris Wilson
a18506acf0 Update the remaining backends to handle a NULL extents for _cairo_surface_get_source
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-27 22:13:01 +01:00
Chris Wilson
7eb33099d3 snapshot: Perform the cow under a mutex
In order to prevent a race between concurrent destroy and use in another
thread, we need to acquire a reference to the snapshot->target under a
mutex. Whilst we hold that reference, it prevents the internal destroy
mechanism from freeing the memory we are using (if we have a pointer to
the original surface) and the client drops their final reference.

Oh boy, talk about opening a can of worms...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-27 14:10:50 +01:00
Chris Wilson
57cfdfd979 Split cairo-list into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 13:17:29 +01:00
Chris Wilson
8653c2692e Split cairo-recording-surface-private into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 12:46:34 +01: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
79740139e0 doc: Do not use the '@' prefix on some tags
Make the 'Since' and 'Returns' tags consistent by removing the '@'
prefix.

Fixes some "missing 'Since' field" warnings.
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
58639857f9 script: Update mesh pattern for earlier change of csi operators
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-22 17:42:16 +00:00
Chris Wilson
2061cd81f2 Replace the ad-hoc surface unwrappers with a function pointer
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-09 13:01:17 +00:00
Chris Wilson
d6440f2d66 script: Add documentation
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-02 16:12:02 +00:00
Chris Wilson
8844d50308 Convert cairo_mime_surface_t to cairo_raster_source_pattern_t
As discussed, overloading the cairo_surface_t semantics to include
sources (i.e. read-only surfaces) was duplicating the definition of
cairo_pattern_t. So rather than introduce a new surface type with
pattern semantics, start along the thorny road of extensible pattern
types.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-25 10:35:42 +00:00
Chris Wilson
f2a49e9329 script: Tag the similar surface rather than snapshot
As we discard the snapshot immediately upon drawing to it, it serves no
purpose.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-09-15 15:29:15 +01: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
Chris Wilson
70cd3b473d api: Extend cairo_antialias_t to include performace/quality hints
The existing API only described the method to be used for performing
rasterisation and unlike other API provided no opportunity for the user
to give a hint as to how to trade off performance against speed. So in
order to no be overly prescriptive, we extend the NONE/GRAY/SUBPIXEL
methods with FAST/GOOD/BEST hints and leave the backend to decide how
best to achieve those goals.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-30 15:17:38 +01:00
Chris Wilson
0efdc8d27e observer: record all operations and their timings
The immediate use of this is to print out the slowest operation of each
type in a replayable manner. A continuing demonstration of how we may
analyse traces...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-20 11:51:50 +01:00
Chris Wilson
5bc7c059fd script: Hook image caching into the snapshot mechanism
So that we remember to forget the old image when the surface is dirtied.

Fixes filter-bilinear-extents.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 15:00:13 +01:00
Chris Wilson
0c6b892ce3 script: take advantage of the polymorphism of the interpreter
If a function expects a surface but receives a context, it automatically
queries the context's target. We can take advantage of this to short-cut
a few operations.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 12:37:57 +01:00
Chris Wilson
6b3d53646e image: peek through a snapshot to the recording surface behind
Fixes record-* after the recent overhaul.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 12:37:57 +01:00
Chris Wilson
8a90b22897 subsurface+recording: handle recursion
Ouch, a nasty bug surfaces after rearranging code to fix the others.
Another self-copy loop this time through a subsurface of a recording
surface.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 12:37:57 +01:00
Chris Wilson
9f6428c517 recording: remove the duplicate 'content' field
Just use the member in the base class.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 12:37:56 +01:00
Chris Wilson
4a990925e9 script: Support unbounded native recording surfaces
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 12:37:56 +01:00
Chris Wilson
99fa5ff6c2 snapshot: Defer acquisition
Fixes 'xlib-expose-event' but triggers an infinite loop in self-copy.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 12:37:56 +01:00
Chris Wilson
0f4cc1f118 script: Emit sequences of boxes to as 'rectangle' for clarity
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-13 20:54:24 +01:00
Chris Wilson
e849e7c929 image: move surface definition to new header for subclassing
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-13 09:54:28 +01:00
Chris Wilson
a3d2d5b42b script: Remove reference to image-surface-private
That header doesn't exist yet.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-12 20:25:59 +01:00
Chris Wilson
69c1ec9f13 script: Compile fix
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-10 14:06:16 +01: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
ad3ef3a8fb Silence Clang static analyzer reports
Clang static analysis triggers some reports in non-buggy code.

Silence them trying to follow better coding practices.
2011-07-29 11:54:56 +02:00
Chris Wilson
a69335a84e API: map-to-image and create-similar-image
A common requirement is the fast upload of pixel data. In order to
allocate the most appropriate image buffer, we need knowledge of the
destination. The most obvious example is that we could use a
shared-memory region for the image to avoid the transfer cost of
uploading the pixels to the X server. Similarly, gl, win32, quartz...

The other side of the equation is that for manual modification of a
remote surface, it would be more efficient if we can create a similar
image to reduce the transfer costs. This strategy is already followed
for the destination fallbacks and this merely exposes the same
capability for the application fallbacks.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-26 14:55:58 +01: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
Chris Wilson
83bfd85a13 Implement cairo_backend_t
Allow a backend to completely reimplement the Cairo API as it wants. The
goal is to pass operations to the native backends such as Quartz,
Direct2D, Qt, Skia, OpenVG with no overhead. And to permit complete
logging contexts, and whatever else the imagination holds. Perhaps to
experiment with double-paths?

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-15 11:05:19 +01:00
Andrea Canciani
5a79e9f536 script: Return status when flushing device
Since 92d7b1eee9 the flush vfunction
should return a cairo_status_t.

Silences the warning:

cairo-script-surface.c: At top level:
cairo-script-surface.c:3528:5: warning: initialization from
incompatible pointer type [enabled by default]
cairo-script-surface.c:3528:5: warning: (near initialization for
'_cairo_script_device_backend.flush') [enabled by default]
2011-06-20 09:44:49 +02: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
5f039f0f89 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>
2011-02-07 20:28:09 +01:00
Andrea Canciani
200e147322 pattern: Use double precision for gradient extreme objects
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
2011-01-02 18:33:14 +01:00
Andrea Canciani
96426fdf01 script: Add support for mesh patterns
Extend CairoScript with operators based on the mesh pattern API.
2011-01-01 13:05:13 +01:00
Andrea Canciani
a8ae8759f5 path: Always interpret in forward direction
Path are always interpreted in forward direction, so the ability of
interpreting in the opposite direction (which is very unlikely to be
useful at all) can be removed.
2010-12-10 10:58:51 +01:00
Andrea Canciani
bb30dae210 script: Fix compilation
Use accessors instead of directly accessing path optimization flags.

Change the conditions for outputting tolerance (was 'when
path->is_rectilinear is FALSE', now is 'whenever the path includes a
curve').

Always output tolerance for strokes, because pen depends on tolerance
(for round caps/joins and for cusps).
2010-10-30 13:37:33 +02:00