I had a look at how complex would it be to add correct downscaling to
Cairo now that Pixman supports convolution filters. It turns out it
this is rather easy. Here is an initial, minimal attempt. It uses
convolution filters only if the image is being downscaled by more than
half a pixel in at least one dimension.
Some discussion:
1. The sampling and reconstruction kernels are picked in a way that
gives comparable quality when upscaling and downscaling. I paired box
sampling with bilinear reconstruction and impulse (point) sampling
with box reconstruction. This gives the expected result for NEAREST
filter. BEST filter uses Lanczos3 for both kernels.
> Do we need to use a reconstruction filter for NEAREST at all? Or maybe
> differentiate between NEAREST and FAST in that case?
If impulse (point) sampling is used, there must be some reconstruction
filter, otherwise no image is produced. That's because the sampling
grid does not match the data grid, and since there is no
reconstruction filter, values between data points are undefined. The
alternative is to use box sampling + no reconstruction.
2. Subsampling bits are always set to 1, since this doesn't seem to
affect quality at all.
3. I am not sure whether this code works correctly for matrices with a
skew component. It should be OK for any combination of scale, rotation
and translation.
4. This patch causes new failures in the test suite:
- recording-surface*: possibly an effect of improved quality.
- surface-pattern-scale-down*, surface-pattern-big-scale-down: the
reference images should be updated.
- pthread-same-source: I have no idea why this is failing, since this
test shouldn't even trigger the new code.
- large-source-roi: this test attempts to downscale an image which is
30000 pixels wide down to 7 pixels. The filter parameters seem to be
created correctly, but they might trigger an overflow somewhere in the
convolution code; the output rectangle is white instead of red, as if
nothing was drawn.
- device-offset-scale: there are subtle differences which look like
convolution-related smoothing; I'm not sure whether this is OK or not.
Based on a patch and analysis by Michael Henning.
When we create a similar-image surface for win32, we set up a couple of
back references from the image to the win32 surface, and vice versa. We
need to be careful when decoupling the reference cycle to avoid chasing
around the loop upon destruction. Currently we handled destroying the
similar-image via the parent win32 surface, but similar precaution is
required when destroying the surface via the similar-image.
Reported-by: Michael Henning <drawoc@darkrefraction.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=63787
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
When creating a texture surface that is larger than the maximum
framebuffer or texture dimensions of the context, return a surface in
error. Previously the code failed an assertion, but this prevents an
application from easily detecting when to fall back.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
This fixes a crash in the api-special-cases with xlib-xcb when calling
cairo_clip_extents() on a context that refers to a finished surface.
The crash was a simple NULL pointer dereference, because the underlying xcb
surface that was used in xlib-xcb was gone and set to NULL already.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Make cairo_push_group() fail when the context's target surface is finished.
This fixes the api-special-cases for the xcb backend:
Detected error during xcb run: error=9, seqno=0x13c, major=53, minor=0
The problem was that the Pixmap for the cairo surface was already freed and
cairo still tried to use it again as the drawable in a CreatePixmap request.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Finished surfaces and surfaces with an error status must not be usable anymore,
so refuse to work on them.
This improves the result for api-special-cases.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68014
Signed-off-by: Uli Schlachter <psychon@znc.in>
When the latin subset contains glyphs that use the seac operator to
combine two glyphs, additional non winansi glyphs are added to the
subset. These extra glyphs do not have a winansi name so they can't
be renamed.
Based on a patch by Salvador Ortiz.
Bug 67324
When blitting the framebuffer during transitions to and from
multi-sampling mode, we need to disable the stencil and scissor test so
that the entire surface is preserved. This fixes the bitmap-font test
for the MSAA compositor.
If subpixel rendering is enabled, but FT returns a 8bit gray bitmap
(perhaps because the font has 8bit embedded bitmaps) we were hitting
the assertions because the assumptions made were wrong. Fix up.
In some obscure conditions that I don't really understand, the image compositor
did not finish a span renderer that it created. This could then cause the last
row of the span to be ignored.
Fixes: clip-complex-bug61492
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=61592
Signed-off-by: Uli Schlachter <psychon@znc.in>
The lookup of the string names has significant overhead, which is why GL
gives you glGetUniformLocation so that you reference uniforms by
constant integers in your high performance path.
Reduces cairo-perf-trace runtime of firefox-planet-gnome by 1.06767% +/-
0.289265% (n=72) on my IVB macbook air.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
The test-traps and test-base surfaces are used for generating the
reference results, and so they should opt for using the best rendering
paths through the traps- and base-compositors.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
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>
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>
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>
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 0bfd2acd35
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>
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>
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>
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>
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>
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>
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>
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>
Otherwise we leave dangling pointers in the visual list, leading to
memory corruption when using low bitdepth servers.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
We need to be more careful when trying to discard a clip to be sure that
it is truly not required. In particular, we need to not throw a way a
clip region when it has more than one box intersecting the mask.
Reported-by: Alexander Larsson
Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=697357
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Make _cairo_gl_context_bind_framebuffer handle different types of GLES
surfaces properly Since, the multisampling setting of a surface never changes
in for GLES, so the first thing we do when setting the destination is to
ignore the requested multisampling setting. This simplifies all
following logic.
Fix more fallout from separating framebuffer binding from setting the
destination. In some cases it is sufficient to call
glDrawBuffer/glReadBuffer before binding the framebuffer, but the
masking-filling-stroking test of cairo-gl-smoke-tests fails if the order
is incorrect.