recording: Prevent invalid memory access with zero length command array

If we try to sort a zero length array, we access invalid memory.
However, for a zero length command array, we can trivially compute the
number of visible indices, 0.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
scaled-font: Prevent a recursive mutex lock for removing a failed glyph

If we fail to create a glyph, and it is the only one in the glyph page,
we then pluck that page out of the global glyph cache. The cache destroy
callback tries to take the scaled_font lock again, causing a lockup.
Rework the error path to avoid taking that lock in this case - still a
potential lock ordering issue remains.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
type1-subset: Quell warning about uninitialized array_start

Since we explicitly set font->subset_subrs to false, there's no way the
warned code will be executed, but perhaps the compiler is confused by
the goto jump.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
type1-subset: Fix typos in function comment

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
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>
gl: Quell warning about incompatible pointer type

mask is a cairo_surface_t pointer, and is cast to a cairo_gl_surface_t
pointer in the _cairo_gl_surface_draw_image() call.
texture.owns_surface also expects mask to be a cairo_gl_surface_t
pointer, so apply the same cast here as well.

Fixes the following warning:

 cairo-gl-traps-compositor.c:370:35: warning: assignment from
  incompatible pointer type [enabled by default]

Ref.: 38bf7a65

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
test: Note naming scheme for XFAIL images in README

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
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>
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>
image: Mark the data as owned after stealing the snapshot's image

Victor Goya found that we ended up leaking memory after reading a PNG
into an image surface and drawing that onto a PDF surface. In
particular, he discovered that

commit 0bfd2acd35547fc2bd0de99cc67d153f0170697d
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Aug 13 01:34:12 2012 +0100

	xlib: Implement SHM fallbacks and fast upload paths

introduced a path to steal the image data for a snapshot (and thereby
avoid a redundant copy), but that path then lead to the leak of the
"owned" data.

Reported-by: Victor Goya <victor.goya@af83.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
test/get-path-extents: Check exact matches within tolerance

When we refine geometry, we do so to a tolerance as specified by the
user. This means that we can not expect tessellated results to have
exact results, but always they should match within the specified
tolerance.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
gstate: Speed up stroked path extents

We can skip the intermediate evaluation of the trapezoids for
determining the extents of a stroked path by using the relatively new
functions for computing the contours of the stroke. Then we can simply
use the bbox of the points within the contours to retrieve the path
extents - which is already provided by the polygon holding the contours
of the stroke. This provides a faster result with less numerical
inaccuracy due to fewer stages required in the computation

References: https://bugs.freedesktop.org/show_bug.cgi?id=62375
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>