image: Quell warning about signed/unsigned int comparison.

Restore (int) cast that was dropped in e7e1ac23.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
recording: Fix inconsistent usage of types for indices

We were wantonly mixing unsigned/signed integers for our index and
counters, leading to compiler warnings. Be bold, and use unsigned
consistently.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
perf: Rudimentary histogram printing for cairo-perf-print

If you call ./cairo-perf-print --histogram results.txt, it will then
print a histogram of the results, one per test. Ideally, you should see
a skewed distribution (with a negative skew representing that most results
run in optimal time), but random sampling errors (scheduling,
throttling, general inefficiency etc) will push it more towards a normal
distribution.

For example,
|                                                             x                |
|                                                             x xx             |
|                                                             x xx             |
|                                                             x xx             |
|                                                             xxxx             |
|                                                             xxxx x           |
|                                                          x  xxxxxx           |
|                                                          x  xxxxxx           |
|                                                          xxxxxxxxx           |
|                                                          xxxxxxxxx           |
|                                                          xxxxxxxxx           |
|                                                         xxxxxxxxxxxx         |
|                                                         xxxxxxxxxxxx         |
|                                                         xxxxxxxxxxxx         |
|                                                        xxxxxxxxxxxxxx        |
|x                                                       xxxxxxxxxxxxxx        |
|x x                                                     xxxxxxxxxxxxxxx       |
|x x                                                     xxxxxxxxxxxxxxx       |
|x x                                                    xxxxxxxxxxxxxxxxx      |
|xxx                                                 x xxxxxxxxxxxxxxxxxxx     |
|xxx                                                xxxxxxxxxxxxxxxxxxxxxxxxx  |
|xxxxxx xxxx x x x   x xxx xx xxxxx xxx x xxx x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
.------------------------------------------------------------------------------.
 xlib           firefox-fishtank  8298.44 1.53% (829/946)

Starts off reasonably, but quickly deteriorates as the integrated CPU/GPU
overheats and is forced to throttle.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
perf: Rescale the histogram for the terminal

If running ./cairo-perf-print in a terminal, query the terminal size and
rescale the histogram to use the maximum available space.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
perf: Avoid vertically stretching the histogram

If we have more rows than the max_count in any column, we end up
stretching the histogram vertically, which makes it harder to read.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
perf: Remove a debug artifact

Remove the intentional #error for non-UNIX path used to remind me to fix
up configure.ac.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
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>
svg: Unwrap recording surfaces

As a first step towards bring SVG uptodate with the various new
patterns, first we need to prevent SVG crashing when it mishandles an
unknown recording surface.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
xml: Handle clip-boxes in the updated cairo_clip_t

Edward Zimmerman pointed out that the xml surface had bitrotted slightly
and no longer understand the new clip layout - in particular that we can
have clips without a path, but just with boxes instead.

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