Commit graph

558 commits

Author SHA1 Message Date
Adrian Johnson
56ad58a807 pdf: fix combined image/smask
a736fd8 introduced a regression
2016-07-19 22:42:53 +09:30
Adrian Johnson
16a8c13b6a pdf: Don't fail subsetting if unable to convert utf8 to utf16
If the unicode came from the font, don't fail if utf8_to_utf16 fails.
2016-07-17 21:19:37 +09:30
Adrian Johnson
1a380ef5f3 ps/pdf: remove debug and commented out code 2016-07-15 22:03:04 +09:30
Adrian Johnson
1ada65c34f pdf: remove unused variable 2016-07-03 10:39:08 +09:30
Adrian Johnson
1c5ec6e380 Fix PS record-neg-extents test failure 2016-06-05 20:43:36 +09:30
Adrian Johnson
14fa88fd02 pdf: fix record-replay-extend test failures 2016-06-05 20:43:36 +09:30
Adrian Johnson
a736fd8699 Fix PDF record-neg-extents test failure
Modify PDF surface to allow surface extents to have negative x, y.
When emitting recording surfaces, set the surface extents to the
recording extents.
2016-06-05 20:43:36 +09:30
Adrian Johnson
1e07ced66d pdf: change from pdf coordinates to cairo coordinates
When an unbounded recording surface is used multiple times with
different extents for each operation we need the XObject containing
the recording surface to have the same origin for each operation. This
is not possible when the recording surface is converted to PDF
coordinates because each operation has different extents resulting in
a different origin when the Y-axis is flipped (since the flip matrix
depends on the recording surface height which for unbounded surfaces
depends on the extents of the operation that paints the recording
surface).

Switching to cairo coordinates by emitting a Y-axis flip matrix as the
first object of each page allows the recording surface to be emitted
in cairo coordinates. This results in the same origin for all
operations using the recording surface XObject.
2016-06-05 20:43:36 +09:30
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
Adrian Johnson
094f0e0fa0 pdf: fix subsurface recordings 2015-10-17 18:16:33 +10:30
Bryce Harrington
2cf2d8e340 Fix spellings descibed, indicies, stange 2015-04-04 15:49:18 -07:00
Adrian Johnson
e4b78424ac pdf-operators: only wrap text strings for PS output
since the PS Document Structing Conventions impose a 255 character
line limit. PDF does not require wrapping.

pdf-operators is designed to emit the same output for PS and PDF.
Unfortunately some PDF interpreters don't like strings split with
'\\\n' and some PS interpreters don't like strings split with ')('.
So we are forced to make pdf-operators handling string wrapping
differently for PDF and PS.

Bug 85662
2014-10-31 19:26:05 +10:30
Adrian Johnson
1013d18a01 pdf: fix compiler warning 2014-10-19 12:08:55 +10:30
Sylvestre Ledru
247cfaaa25 Fix some memory leaks found by scan-build, the LLVM/Clang static analyzer
Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>
2014-05-16 11:11:34 -07:00
Adrian Johnson
dcbe16eb40 pdf/ps: avoid outputting excess decimal places in matrices
Sometimes as a result of rounding errors in matrix transformations the
matrices in ps/pdf output look like:

    0.000000000000000061 1 1 -0.000000000000000061 0 842 cm

This patch rounds to zero matrix elements that are very small compared to
other elements in the same matrix.
2013-12-07 15:54:49 +10:30
Adrian Johnson
5e6e453671 pdf: stencil masks may be opaque 2013-09-29 22:23:31 +09:30
Adrian Johnson
d3a8d5a9c2 pdf: Support stencil masks with jpeg/jpx/jbig2 embedding 2013-09-29 22:18:06 +09:30
Adrian Johnson
07940ecd60 pdf: combine source and mask images into single image
Since PDF stores the alpha component of images in a separate stream
which can have a different resolution and encoding to the color
components we can optimize the case where the source and mask are both images.

If the source and mask are both images with the same extents and the
source is opaque, combine the images into a single PDF image (ie the
source is written the the image stream and the mask is written to the
smask stream).
2013-09-29 13:08:02 +09:30
Adrian Johnson
5c0caa6f82 pdf: support JBIG2 mime data
JBIG2 images may have shared global data that is stored in a separate
stream in PDF. The CAIRO_MIME_TYPE_JBIG2 mime type is for the JBIG2
data for each image. All images that use global data must also set
CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID to a unique identifier. One of the
images must also set CAIRO_MIME_TYPE_JBIG2_GLOBAL to the global
data. The global data will be shared by all JBIG2 images with the same
CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID.
2013-09-15 20:50:46 +09:30
Adrian Johnson
266d6e7156 pdf: fix embedding of mime data that has been broken since 0a10982f
For some reason the mime-data test is not detecting this failure.
2013-09-13 22:01:02 +09:30
Adrian Johnson
8addb4798c pdf: avoid making groups a transparency group if not required
If the group contains only a combination of clear and opaque alpha and
only OPERATOR_OVER is used in the group and to paint the group, a
transparency group is not required. This allows the pdf viewer to
replay the group in place.
2013-09-11 21:18:45 +09:30
Chris Wilson
f39eef8524 pdf: Fix compiler warning for use of unitialised variable along error path
cairo-pdf-surface.c: In function '_cairo_pdf_surface_add_source_surface.isra.20':
cairo-pdf-surface.c:1461:10: warning: 'unique_id' may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-06-20 11:11:20 +01:00
Chris Wilson
80641f4adc pdf: Improve consistency in use of cairo_int_status_t
Suppress several compiler warning for mixing
cairo_status_t/cairo_int_status_t enums.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-06-20 11:09:53 +01:00
Bryce W. Harrington
aa764a3bbc pdf: Assure compiler that data, data_size will always be initialized
There are only three possible color states:  COLOR, GRAYSCALE, or
MONOCHROME thus data and data_size will always be set to some value,
so assert the default is never reached.

Fixes these warning:
  cairo-pdf-surface.c:2517:32: warning: ‘data_size’ may be used
   uninitialized in this function [-Wuninitialized]
  cairo-pdf-surface.c:2338:19: note: ‘data_size’ was declared here
  cairo-pdf-surface.c:2446:11: warning: ‘data’ may be used uninitialized
   in this function [-Wuninitialized]
  cairo-pdf-surface.c:2337:11: note: ‘data’ was declared here

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
2013-06-20 11:00:23 +01:00
Adrian Johnson
9e0748e223 pdf: fix typo in bbox check
http://lists.cairographics.org/archives/cairo/2013-March/024186.html
2013-03-27 08:08:32 +10:30
Jana Saout
4f00d2344c pdf: Fix crash
Bug 61451
2013-03-01 20:10:28 +10:30
Adrian Johnson
446a3dc5c0 pdf: add missing 'endobj' to shading dict
https://bugs.launchpad.net/ubuntu/+source/libcairo/+bug/1051939
2013-02-19 20:59:16 +10:30
Adrian Johnson
0210499578 pdf: fix the offset of padded images
Bug 50598
2012-06-02 19:01:18 +09:30
Chris Wilson
f1b546b1a2 Erradicate internal use of cairo_surface_get_type()
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-01 18:17:33 +01:00
Chris Wilson
e23d179e08 Erradicate internal use of cairo_surface_get_content()
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-01 17:46:25 +01:00
Adrian Johnson
3f325764e5 pdf: Don't use extents when acquiring a RASTER_SOURCE pattern
because the pdf surface reuses the image each time the pattern is used.
2012-05-31 17:46:31 +09:30
Adrian Johnson
f3ae830207 pdf: merge _emit_recording_surface and _emit_recording_subsurface into the one function 2012-05-27 22:59:13 +09:30
Adrian Johnson
fcfa45c9f7 pdf: fix smask gradient bbox 2012-05-27 11:55:09 +09:30
Adrian Johnson
50f08352f4 pdf: check if EXTEND_PAD group can be painted with EXTEND_NONE
to avoid the fallback
2012-05-16 20:57:47 +09:30
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
Jeff Mahoney
f736cd1443 pdf: Fix wrong allocation in _cairo_pdf_surface_add_source_surface
_cairo_pdf_surface_add_source_surface allocates unique_id with
size unique_id_length but then copies surface_key.unique_id_length into it.

This causes e.g. evince to crash predictably while trying to print with:
*** buffer overflow detected ***: evince terminated

We should be using surface_key.unique_id_length instead.

Reported-by: Dominique Leuenberger <dominique-freedesktop.org@leuenberger.net>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49089
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2012-04-23 22:13:57 +01:00
Adrian Johnson
33f9e433ee pdf: support all image types
If the image is not rgb24/argb32/a8/a1, create a new image with the
same CAIRO_CONTENT and paint image to the new image.
2012-04-23 13:21:52 +09:30
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
Chris Wilson
93d42e82a4 Revert accidental push of ps debugging API.
This reverts commits
   6ad8c96fd8,
   a3f97d1d2e,
   25abe58298

I should know better by now than to push without checking for outstanding
changes.
2012-04-14 14:54:07 +01:00
Chris Wilson
25abe58298 pdf (debug API): Export the ability to force fallbacks
We need to occasionally force fallbacks whilst testing the PDF
output, so export a debug interface to do so in order to avoid poking
around inside cairo internals.

References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-12 12:22:17 +01:00
Adrian Johnson
038e499191 pdf: avoid unnecessary use of patterns in mask groups 2012-04-09 21:27:08 +09:30
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
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
Adrian Johnson
2d3a1c7318 pdf: ensure all transparency groups are isolated 2012-02-25 16:57:58 +10:30
Chris Wilson
7154f646d3 pdf,ps: The device offset only needs to taken into account for raster patterns
Ordinary patterns have their device offsets pre-baked into the pattern
matrix. The difference with raster patterns is that the surface is
generated upon use by the pdf,ps and so its device offset is not known
until then.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-24 16:15:31 +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
Adrian Johnson
0f40cdea1b api: add cairo_surface_supports_mime_type
to allow querying if a surface supports a particular mime type.
2012-01-19 19:09:10 +10:30
Adrian Johnson
0a10982f8c pdf: support RASTER_SOURCE patterns 2012-01-11 23:06:34 +10:30
Adrian Johnson
a8cbb00784 pdf: avoid using pdf patterns to paint/fill translucent linear/radial gradients 2011-12-06 20:47:14 +10:30
Adrian Johnson
79f430e7ad pdf: avoid using pdf patterns to paint/fill opaque linear/radial gradients
Patterns are slower and use more memory to print. For painting and
filling we can use the shading operator to draw gradients.
2011-12-06 20:46:49 +10:30