Commit graph

11485 commits

Author SHA1 Message Date
Adrian Johnson
9bfa9df2bb ps: fix padded image crash 2017-11-09 22:02:05 +10:30
Adrian Johnson
f7d6d78f94 ps: prevent self-copy infinite loop 2017-11-09 22:02:05 +10:30
Adrian Johnson
71746c37d4 test: use CAIRO_MIME_TYPE_UNIQUE_ID with record-text-transform
The PS output from this test is > 100MB due to the duplicated images.
Using CAIRO_MIME_TYPE_UNIQUE_ID reduces the PS output to 650k, runs
considerably faster, and now produces correct output.
2017-11-09 22:02:05 +10:30
Adrian Johnson
5ffbaf9e2f ps: add CAIRO_MIME_TYPE_EPS mime type for embedding EPS files 2017-11-09 22:02:05 +10:30
Adrian Johnson
7d3ba77b6c ps: use Reusable streams for forms in Level 3
to avoid emitting image data as strings
2017-11-09 22:01:40 +10:30
Adrian Johnson
b1c7a087b5 ps: use forms for surfaces with UNIQUE_ID mime type
to ensure the surfaces are emitted only once.

fixes mime-unique-id PS output
2017-11-09 22:01:40 +10:30
Adrian Johnson
638d64a702 ps: don't acquire image or snapshot in acquire_source_image_from_pattern
otherwise emit_surface may not see the mime data
2017-11-09 22:01:40 +10:30
Adrian Johnson
fcc037a76e ps: use << >> for dictionaries instead of dict begin end 2017-11-09 22:01:40 +10:30
Adrian Johnson
632232c3ce ps: remove unused prolog 2017-11-09 22:01:40 +10:30
Adrian Johnson
9d372ca91a ps: emit base85 strings instead of strings of base85
When image data is emitted as strings (required when an image is used
in a PaintProc), the base85 encoded data was emitted inside PS strings
(...) and the image filters included an ASCI85Decode filter.

This has been changed to emit the strings as ASCII85 strings <~...~>
and remove the ASCII85Decode filter since the base85 is decoded when
the string is parsed.

Also factor out the string data source procedure into the prolog.
2017-11-09 22:01:40 +10:30
Adrian Johnson
d5cb45013b pdf: fix mime-unique-id jpeg attached to recording test
- Restructure the emit_surface code so that mime types are checked first.

- Add a test parameter to emit_surface to test if the surface will be emitted
  as an image or recording instead checking the surface type as the attached
  mime may override this.

- Mark surface as not clear when mime is attached to avoid optimizing away
  "clear" surfaces that have mime attached.

- Include entire surface in analysis if mime attached (also fixes bug with
  calculating the extents CONTENT_COLOR surfaces)
2017-11-09 22:01:40 +10:30
Adrian Johnson
bff47b43c4 pdf: fix mime-unique-id unbounded recording test
PDF XObjects need to specify the bounding box. Emit unbounded surfaces
when finishing as at this point the extents of all uses of the
unbounded surface are known.
2017-11-09 20:52:36 +10:30
Adrian Johnson
cf9a070352 pdf: fix mime-unique-id bounded recording test
The embedded bounded recording surface was being clipped to the
extents of its first use.
2017-11-09 20:52:36 +10:30
Adrian Johnson
5e4707a10d Add mime-unique-id test
to check that PS/PDF embeds images with CAIRO_MIME_TYPE_UNIQUE_ID only
once.
2017-11-09 20:52:36 +10:30
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
Bryce Harrington
35fccff6ec Un-doxygen disabled cairo_set_opacity
The cairo_set_opacity() routine has been disabled since 2010.  There
appears to be support for it internally in the backend, so it is unclear
why it is not enabled or what might break if it were re-enabled.  Given
the lack of bug reports about its omission, it may be vestigal.  For
now, just hide the doxygen for it to suppress warnings.  It may be worth
deeper review to either re-enable it or remove it entirely.

Reported-by: Rafał Mużyło (See fdo bugzilla #82741)
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2017-11-06 12:18:37 -08:00
Bryce Harrington
8d89fc573e configure: Check for typeof
Check via the AC_C_TYPEOF macro if GCC's typeof is available.  If it is
available via a different spelling, define typeof to that spelling.

Patch from and issue reported by Richard Palo.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=93027
2017-11-06 11:35:24 -08:00
Adrian Johnson
3322580f04 pdf: remove old comment
These issues have been fixed.
2017-10-24 21:44:08 +10:30
Adrian Johnson
1674d2b885 pdf: set default create date 2017-10-24 21:44:08 +10:30
Adrian Johnson
378e8e2f59 pdf: set ca/CA instead of using an smask when the mask has constant alpha 2017-10-24 07:01:14 +10:30
Carlos Garcia Campos
5fd0b8710f scaled-font: Fix assert when destroying glyph page
This happens when _cairo_ft_scaled_glyph_init() returns
CAIRO_INT_STATUS_UNSUPPORTED when called from
_cairo_scaled_glyph_lookup(). In those cases
_cairo_scaled_font_free_last_glyph() is called to release the glyph that
has just been allocated. If there aren't more glyphs,
_cairo_scaled_glyph_page_destroy() is called. The problem is that
_cairo_scaled_glyph_lookup() should always be called with the cache
frozen, and _cairo_scaled_glyph_page_destroy() without the cache
frozen. We can simply thaw/freeze the font before calling
_cairo_scaled_glyph_page_destroy().

https://bugs.freedesktop.org/show_bug.cgi?id=103335
2017-10-22 11:09:02 +10:30
Adrian Johnson
87dfd0c16f Allow mime image to be different size to cairo image
Previously it was assumed the mime image size is the same as the cairo
image surface size. When using the 1 bpp formats (CCITT, JBIG2),
creating a cairo image of the same size will have very large memory
requirements and in some case may exceed the pixman image size
limits. In these cases it is useful to allow the mime image to have a
different resolution to the cairo image and in the PDF/PS output scale
the mime image to be the same physical size as the cairo image.

In PDF, this is easy as all PDF images are scaled to 1x1 unit and the
CTM is used to scale the image to the required size. The PS surface
has been changed to also scale images to 1x1 and use the CTM to get
the required size.
2017-10-22 08:59:58 +10:30
Adrian Johnson
e1a02b180d Add CCITT_FAX mime type for PDF and PS surfaces
This completes the full set of PDF/PS image filters allowing image
data to be passed though without decompressing then recompresssing in
a less efficient format.

The difficulty with CCITT_FAX is it needs some decoding parameters
that are not stored inside the image data. This is achieved by using
an additional mime type CCITT_FAX_PARAMS that contains the params in
key=value format.
2017-10-22 08:42:36 +10:30
Adrian Johnson
4ae7f411c8 util/font-view: fix build error 2017-10-21 20:05:56 +10:30
Adrian Johnson
9ffbf63d37 fix warning: inlining failed in call to '_csi_stack_push' 2017-10-21 13:08:39 +10:30
Adrian Johnson
b092b63119 fix warning: variable X might be clobbered by 'longjmp'
Move calls to setjmp into separate function to avoid clobbering
local variables.
2017-10-21 13:08:30 +10:30
Adrian Johnson
132794f683 svg: recording_surface is needed even if not emitted 2017-10-16 20:18:49 +10:30
Adrian Johnson
27990e3910 fix unused function warnings 2017-10-16 20:18:49 +10:30
Adrian Johnson
fc929d7005 ft: prevent unused var warning when freetype < 2.8 2017-10-16 19:42:16 +10:30
Adrian Johnson
1d58e0f818 svg2png: remove unused headers 2017-10-15 19:42:08 +10:30
Mikhail Fludkov
90104809b0 Surround initialisations with atomic critical section
Fixes the race condition when one thread uses cairo_mask_compositor_t
pointer returned by _cairo_image_mask_compositor_get, while another one
started but has not finished it's initialisation yet

Usage:
static cairo_atomic_once_t once = CAIRO_ATOMIC_ONCE_INIT;
if (_cairo_atomic_init_once_enter(&once)) {
    /* Initialization code */
    _cairo_atomic_init_once_leave(&once);
}

https://bugs.freedesktop.org/show_bug.cgi?id=103037
2017-10-15 18:51:04 +10:30
Adrian Johnson
79e0e25e44 svg: source surface hash table does not need to hold the source 2017-10-15 07:57:54 +10:30
Adrian Johnson
965ba86bbf svg: use hash table instead of user_data to track emitted surfaces
Setting a key on the source surface->user_data prevents the surface
from being reused to create another svg file.

The hash table also supports CAIRO_MIME_TYPE_UNIQUE_ID.

https://lists.cairographics.org/archives/cairo/2017-October/028406.html
2017-10-14 20:53:01 +10:30
Adrian Johnson
bb10bd1013 truetype: limit font name to 127 chars
Some broken fonts have long strings of garbage in the font name

https://bugs.freedesktop.org/show_bug.cgi?id=103249
2017-10-13 19:50:24 +10:30
Adrian Johnson
202a9ed64e output-stream: allow %s strings larger than 512 chars
https://bugs.freedesktop.org/show_bug.cgi?id=103249
2017-10-13 19:33:30 +10:30
Bryce Harrington
d5b634da61 Factor out the ISFINITE() macro 2017-10-11 19:13:46 -07:00
Adrian Johnson
5a9dba9929 svg: fix painting an unbounded recording surface
https://lists.cairographics.org/archives/cairo/2017-October/028395.html
2017-10-05 20:50:19 +10:30
Adrian Johnson
bec8c7508e Prevent curved strokes in small ctms from being culled from vector surfaces
The combination of both curved strokes and ignoring the ctm in the thin
line check caused some fill-strokes in this test case to be culled.

Modify the thin line check to take the ctm into account and increase
the minimum width to 1 point to prevent curved lines such as tiny dots
from being culled.

https://bugs.freedesktop.org/show_bug.cgi?id=103071
2017-10-03 22:27:25 +10:30
Adrian Johnson
dccbed7d78 truetype: clarify glyph count variables
- move num_glyphs_in_face to base struct as it is the number in the font
- move num_glyphs to the subset variables as it is the num glyphs in the subset
- move widths to subset variables as it uses the subset id as the array index
2017-09-22 20:25:59 +09:30
Adrian Johnson
52cbf42b74 truetype: reserve space in subset arrays for .notdef
Subset array sizes are allocated based on the number of glyphs in the
font. In this bug the fonts did not contain the mandatory .notdef
glyph, hence the subset arrays were not large enough.

https://bugs.freedesktop.org/show_bug.cgi?id=102922
2017-09-22 20:10:10 +09:30
Adrian Johnson
e773dd744e factor out ascii to double code in cff-subset into _cairo_strtod 2017-09-22 18:17:25 +09:30
Aleksander Morgado
871c518121 build: fix minor typo in autogen.sh
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=102452
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-09-20 11:44:29 -07:00
Adrian Johnson
1220e3c6b8 replace _BSD_SOURCE with _DEFAULT_SOURCE
fixes the warning:

warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
2017-09-16 10:04:57 +09:30
Adrian Johnson
117a3c27d4 build: use _WIN32 instead of windows.h to check for windows build
ifdef _WIN32 is the recommended way to check for a windows build [1]
and avoids identifying cygwin as windows.

based on the patch at [2]

[1] https://lists.gnu.org/archive/html/autoconf/2012-02/msg00008.html
[2] https://lists.gnu.org/archive/html/autoconf/2012-02/msg00009.html
2017-09-16 10:04:57 +09:30
Bryce Harrington
8ff3019f51 gl: Add support for OpenGL ES 3.0
This improves the OpenGL ES support to extend it to version 3.0.
A number of new features are available in glesv3 including creation of
multi-sampled renderbuffers.  These renderbuffers can be blitted to
single sample textures (but not the other way around).  Other features
such as PBO for image uploading, are left as followon work.

For this preliminary implementation, glesv3 backends always create
renderbuffers, which can be set as single sample or multisample.  The
renderbuffer's content is blitted to the texture only when used as a
source or a mask.

Images uploaded to a texture stay there until the surface is used as a
rendering target, at which point its painted to the renderbuffer.

This patch is heavily based off of Henry Song's initial GLESv3 patch
6f7f3795 from his cairogles fork of Cairo, and incorporates subsequent
fixes and pertinent refactorings from his trunk and review feedback from
Uli.

This implements the *functional* support for glesv3, excluding the
various optimization work to utilize its features.  Rendering and
performance should not be expected to improve notably from pure glesv2.
As the GL backend for Cairo remains "experimental", these changes should
likewise be considered as such.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2017-09-13 15:18:04 -07:00
Bryce Harrington
d1f941d7ee gl: Make _cairo_gl_ensure_framebuffer a private shared routine
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2017-09-13 15:17:55 -07:00
Bryce Harrington
4b164bc898 gl: Convert images to rgba or a8 formats when uploading with GLESv2
The GLESv2 backend supports only GL_RGBA and GL_ALPHA as supported
texture formats.  So, make _cairo_gl_get_image_format_and_type_gles2
force conversion of other image formats to either of these two as
appropriate when uploading images.

Patch originally from Henry Song <henry.song@samsung.com>

Bryce Harrington <bryce@osg.samsung.com>

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2017-09-13 15:17:55 -07:00
Behdad Esfahbod
99427c3f4f Handle SOURCE and CLEAR operators when painting color glyphs
In cairo, most operators are composited this way:

  ((src IN mask) OP dst) LERP_clip dst

but SOURCE and CLEAR operators are composited this way:

  (src OP dst) LERP_(clip IN mask) dst

(why is this not specified anywhere in the docs or source tree?)

With color glyphs, we were not special-casing SOURCE and CLEAR.
We do now.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=102661
2017-09-12 01:35:15 -04:00
Behdad Esfahbod
7f6b57a238 Fix undefined-behavior with integer math
As reported to me:

"A calculation on signed integers has undefined behaviour if the result is not
representable in the type. In this case, it's trying to negate int_min, aka
-2^31 but the range of an int is [-2^31, 2^31-1] so it doesn't fit. Instead,
cast to unsigned which has 2's complement wrap-around arithmetic which is what
this particular function expects."
2017-09-11 22:00:00 -07:00
Bryce Harrington
1af18610ba glesv2: Fix regression in gles version detection
Revert the _cairo_gl_get_flavor() portion of the change from commit
eb523200.  This caused GLES to be enabled only if the hardware reported
version 2 exactly; if the hardware supported version 2 and 3 then no ES
support would be enabled.
2017-09-11 19:56:06 -07:00