Commit graph

270 commits

Author SHA1 Message Date
Chris Wilson
3898e46d1d image: Compensate mask origins for glyph clipping
Fixes the regression in bitmap-font and large-font pointed out by Andrea
Canciani since ef067933.
2010-07-23 09:44:00 +01:00
Chris Wilson
ef0679333d image: Manually clip against bounds when rendering directly
This is path is slightly peculiar in that it explicitly avoid the
intermediate mask and the geometry is not pre-clipped.

This in conjunction with the previous commit fixes:

  Clip doesn't work for text
  https://bugs.freedesktop.org/show_bug.cgi?id=29008

which is captured in test/partial-clip-text.
2010-07-12 16:33:42 +01:00
Chris Wilson
679e5a600b Differentiate between reducing clip to composite extents and a rectangle
This is required for handling glyphs when rendering directly to the
surface.
2010-07-12 16:33:38 +01:00
Benjamin Otte
b870cc030d doc: Move tmpl/ docs to inline docs
I did this manually so I could review the docs at the same time.
If anyone finds typos or other mistakes I did, please complain to me (or
better: fix them).
2010-07-08 14:27:16 +02:00
Chris Wilson
7ab9ce1b91 image: Make a local copy of the trap coordinates as the boxes alias.
As we transform the array of trapezoids into an array of boxes in-place,
we must take local copies of the coordinates before writing into the
boxes otherwise we may inadvertently modify the trapezoidal coordinates.

Fixes test/a1-bug.
2010-06-17 15:47:04 +01:00
Chris Wilson
36b4b0631c image: Use consistent rounding modes for a1 rasterisation.
When checking if the traps are equivalent to a set of rectangles, we
need to use the same rounding mode as when converting the traps to a set
of boxes and then filling them. Failure to do leads to a situation where
(-127,-128) was thought to be equivalent to (0,0) but we attempted to
fill from 0 to -1 instead.

References:
  http://lists.cairographics.org/archives/cairo/2010-June/020115.html
2010-06-17 08:55:19 +01:00
Chris Wilson
9b6617a3b3 image: Apply component alpha to composite masks.
If we need to pattern requires component alpha, then we must take a
copy of the image and enable component alpha for pixman.

Fixes test/text-antialias-subpixel on xlib-fallback -- i.e. we will
finally render subpixel antialiased text on ancient XServers.
2010-06-11 22:04:14 +01:00
Benjamin Otte
7bd8d0db1f image: Fix wholly unbounded fixup
Tested by zero-mask test.
2010-05-13 12:11:09 +02:00
Chris Wilson
bd672d080c drm: code dump, sorry.
Lots upon lots of tiny fixes mixed in with experimental code. :(
2010-05-12 20:54:49 +01:00
Chris Wilson
fb6caf08ae image: Propagate error instead of asserting.
Apparently we can get to this point without evaluating the clip surface,
so return the error status rather than assert.
2010-05-06 09:30:41 +01:00
Chris Wilson
4bc54643f5 image: Propagate failure from pixman_image_set_clip_region() 2010-05-05 09:46:35 +01:00
Chris Wilson
6f2d4f5b2a image: Propagate failure from pixman_image_fill_boxes(). 2010-05-04 18:26:06 +01:00
Chris Wilson
38188961b9 image: Check for pixman image allocation failure during glyphs 2010-05-04 13:28:37 +01:00
Chris Wilson
08b9984da9 image: Replace assert with error return
It is possible to encounter an allocation failure here since we may have
tweaked the clip since the last evaluation of the clip region.
2010-05-04 13:28:36 +01:00
Chris Wilson
8e9fd9c017 image: A few missing tests for malloc failure 2010-05-03 19:20:07 +01:00
Benjamin Otte
5672b7a18a fallback: get src_x/y variables right when compositing traps 2010-05-03 13:37:19 +02:00
Benjamin Otte
358f57c876 image: remove useless optimization
The optimization is done way smarter inside
_cairo_matrix_transform_bounding_box()
2010-04-30 23:35:48 +02:00
Benjamin Otte
94aa6d24b6 fallback: Create pixman image for correct rectangle
This was most prominently shown by the a1-image-sample test, but
multiple tests exposed the problem with the xlib-fallback code.
2010-04-30 23:35:48 +02:00
Chris Wilson
4cb733c285 image: Simplify translation of pattern matrix for composite_trapezoids() 2010-04-30 10:16:23 +01:00
Benjamin Otte
6d36f06751 image: Round down when rendering antialiased boxes
Matches Pixman's output when going via pixman_rasterize_trapezoid()
2010-04-29 22:34:28 +02:00
Benjamin Otte
95179a5de9 Remove excessive semicolons
s/;;/;/ basically
2010-04-29 20:45:23 +02:00
Benjamin Otte
8f85c2d77c image: translate source pattern in composite_trapezoids()
Fixes xlib fallback paths as exposed by the clip-push-group test.
2010-04-29 12:12:51 +02:00
Andrea Canciani
d66b1ca1cf atomic: Separate bool and old-value compare-and-exchange
Some implementations only offer one version of compare-and-exchange,
thus we expose both through cairo-atomic, implementing what is missing
through appropriate fallbacks.
*_cmpxchg() now return a boolean (this unbreaks _cairo_atomic_uint_cmpxchg)
*_cmpxchg_return_old() return the old value
Code is updated everywhere to reflect this, by using *_cmpxchg()
wherever the returned value was only tested to check if the exchange
had really taken place.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-04-29 10:52:47 +02:00
Benjamin Otte
06e9caf861 image: pixman_image_fill_rectangles() => pixman_image_fill_boxes() 2010-04-28 20:14:55 +02:00
Benjamin Otte
bc49df3227 pixman_image_composite => pixman_image_composite32
Fix up the remaining callers
2010-04-28 20:14:55 +02:00
Chris Wilson
bb853916f3 image: Generate clear/white/black images when !HAS_ATOMIC_OPS
Andrea reported that b74cc0f broke compilation without atomic ops.
2010-04-28 11:37:59 +01:00
Chris Wilson
b74cc0f6d5 image: Convert 1x1 samples into solid colors.
If the sampled extents of the operation on an image surface is just a
single pixel, we can safely convert to a solid color.
2010-04-28 08:39:21 +01:00
Chris Wilson
a505104013 image: Compute sample extents
In order to reuse the original image as the pixman pattern, then the
entire operation must be wholly contained within the extents of the
image (including subsurfaces) and be reducible to an untransformed
REPEAT_NONE.
2010-04-27 11:07:45 +01:00
Andrea Canciani
b8a7f8621a Update FSF address
I updated the Free Software Foundation address using the following script.

for i in $(git grep Temple | cut -d: -f1 )
do
  sed -e 's/59 Temple Place[, -]* Suite 330, Boston, MA *02111-1307[, ]* USA/51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA/' -i "$i"
done

Fixes http://bugs.freedesktop.org/show_bug.cgi?id=21356
2010-04-27 11:13:38 +02:00
Chris Wilson
4d3632761b clip: Report the surface offset when retrieving the clip mask
Stop the callers from guessing the origin of the clip surface by
reporting it explicitly! This enables the clip to bypass any rectangles
overlaid on top of the clip surface, which is common when the backends
limit the clip to the extents of the operation -- but irrelevant to the
actual content of the clip mask
2010-04-25 09:45:41 +01:00
Benjamin Otte
2bffa2467e Use pixman_image_composite32()
Replace all occurences of pixman_image_composite()
2010-04-15 18:31:01 +02:00
Benjamin Otte
567923d66a image: Make unbounded fixup code not use pixman_fill()
The new pixman_image_fill_boxes() does proper fallbacks for weird pixman
formats.
2010-04-15 18:31:01 +02:00
Oleg Romashin
022291be1c Add back support for CAIRO_FORMAT_RGB16_565
Due to slow memory speed, 16bpp color depth is still very popular on mobile
devices. Maemo5 is also using 16bpp color depth.
2010-03-24 13:12:25 -04:00
Chris Wilson
4c55c87478 image: Free traps after conversion from boxes. 2010-03-23 10:35:17 +00:00
Chris Wilson
e961cdf568 image: Special case wholly unbounded fixups.
In the event of an empty bounded rectangle, the computation of the
unbounded - bounded rectangles leads to negative areas, integer overflow
and death.

[And similarly for the derived surfaces.]
2010-03-22 10:54:08 +00:00
Chris Wilson
f979dd22d8 image: Don't rely on clip regions being clipped to surface extents.
Fixes a crash in test/clip-fill-unbounded [xlib-fallback].
2010-03-02 13:58:02 +00:00
M Joonas Pihlaja
5b7f4bb241 api: Introduce CAIRO_FORMAT_INVALID formally in the API.
We were exposing the actual value of CAIRO_FORMAT_INVALID
through API functions already, so it makes sense to just
go ahead and put it in the cairo_format_t enum.
2010-03-01 01:21:31 +02:00
Chris Wilson
620cd9c2be image: Allow reduction of repeat modes for unity scaled patterns. 2010-02-28 09:09:20 +00:00
M Joonas Pihlaja
9ecb0f3cec image: Fix bug optimizing surface pattern extend modes.
The image surface tries to convert surface pattern's extend
modes to EXTEND_NONE, if it can, when converting a cairo_pattern_t
to a pixman_image_t. The check was not taking into account the
transformation matrix on the pattern, so it was possible to
trick it into using EXTEND_NONE by downscaling the source
pattern enough.  This patch changes the optimization to only
take if the pattern has no transformation.

Fixes surface-pattern-scale-down-extend-{pad,reflect,repeat}
failures in the test suite for the image backend.
2010-02-28 01:49:50 +02:00
Benjamin Otte
8bb06915ed image: split cairo_image_surface_coerce()
Split into a general cairo_image_surface_coerce() that coerces to one of
the 3 supported formats (ARGB32, RGB24, A8) based on content and the
more general cairo_image_surface_coerce_to_format() that coerces to a
specified format.
2010-02-23 21:03:31 +01:00
Chris Wilson
37dbf157f3 clip: Avoiding derefencing NULL clip_region 2010-02-12 14:08:32 +00:00
Chris Wilson
5390df961f clip: Restrict composite extents to clip extents
Fixes test/clip-rectangle-twice.
2010-02-12 12:24:01 +00:00
Benjamin Otte
002e02715c Remove useless pixman version checks
We require pixman >= 0.15.16 in configure.ac, so checks for older
versions aren't required anymore.
2010-01-25 19:42:54 +01:00
Chris Wilson
abcb9d2c39 image: Prevent deref of NULL clip_region
Another stray from surface-fallback, spotted by Carlos:

*INT_cairo_region_get_extents (region=0x0, extents=0xbfffce90) at
cairo-region.c:385
385         if (region->status) {
(gdb) bt
0  *INT_cairo_region_get_extents (region=0x0, extents=0xbfffce90) at
cairo-region.c:385
1  0x0013ba46 in _cairo_image_surface_composite_trapezoids
(op=CAIRO_OPERATOR_OVER, pattern=0xbfffdda8, abstract_dst=0x837de10,
    antialias=CAIRO_ANTIALIAS_DEFAULT, src_x=486, src_y=45, dst_x=0,
dst_y=0, width=15, height=25, traps=0x837f100, num_traps=30,
clip_region=0x0)
    at cairo-image-surface.c:4102
2  0x0015d846 in _cairo_surface_composite_trapezoids
(op=CAIRO_OPERATOR_OVER, pattern=0xbfffdda8, dst=0x837de10,
antialias=CAIRO_ANTIALIAS_DEFAULT,
    src_x=486, src_y=45, dst_x=0, dst_y=0, width=15, height=25,
traps=0x837f100, num_traps=30, clip_region=0x0) at cairo-surface.c:2125
3  0x001607ce in _cairo_surface_fallback_composite_trapezoids
(op=CAIRO_OPERATOR_OVER, pattern=0xbfffdda8, dst=0x837db00,
    antialias=CAIRO_ANTIALIAS_DEFAULT, src_x=486, src_y=45, dst_x=486,
dst_y=45, width=15, height=25, traps=0x837fd78, num_traps=30,
clip_region=0x0)
    at cairo-surface-fallback.c:1641
4  0x0015d8a4 in _cairo_surface_composite_trapezoids
(op=CAIRO_OPERATOR_OVER, pattern=0xbfffdda8, dst=0x837db00,
antialias=CAIRO_ANTIALIAS_DEFAULT,
    src_x=486, src_y=45, dst_x=486, dst_y=45, width=15, height=25,
traps=0x837fd78, num_traps=30, clip_region=0x0) at cairo-surface.c:2137
5  0x001623b0 in _composite_traps_draw_func (closure=0xbfffd350,
op=CAIRO_OPERATOR_OVER, src=0xbfffdda8, dst=0x837db00, dst_x=0, dst_y=0,
    extents=0xbfffdc78, clip_region=0x0) at cairo-surface-fallback.c:546
6  0x00161234 in _clip_and_composite (clip=0x0, op=<value optimized
out>, src=0xbfffdda8, draw_func=0x162310 <_composite_traps_draw_func>,
    draw_closure=0xbfffd350, dst=0x837db00, extents=0xbfffdc78) at
cairo-surface-fallback.c:463
7  0x0016205b in _clip_and_composite_trapezoids (src=<value optimized
out>, op=CAIRO_OPERATOR_OVER, dst=0x837db00, traps=0xbfffd7bc,
    antialias=CAIRO_ANTIALIAS_DEFAULT, clip=0x0, extents=0xbfffdc78) at
cairo-surface-fallback.c:853
8  0x001626ef in _cairo_surface_fallback_stroke (surface=0x837db00,
op=CAIRO_OPERATOR_OVER, source=0xbfffdda8, path=0x1b164c,
stroke_style=0x1b1524,
    ctm=0x1b15b0, ctm_inverse=0x1b15e0, tolerance=0.10000000000000001,
antialias=CAIRO_ANTIALIAS_DEFAULT, clip=0x0) at
cairo-surface-fallback.c:1173
9  0x0015f2f4 in _cairo_surface_stroke (surface=0x837db00,
op=CAIRO_OPERATOR_OVER, source=0xbfffdda8, path=0x1b164c,
stroke_style=0x1b1524, ctm=0x1b15b0,
    ctm_inverse=0x1b15e0, tolerance=0.10000000000000001,
antialias=CAIRO_ANTIALIAS_DEFAULT, clip=0xbfffde88) at
cairo-surface.c:2041
10 0x00134629 in _cairo_gstate_stroke (gstate=0x1b1514, path=0x1b164c)
at cairo-gstate.c:1133
11 0x0012a706 in *INT_cairo_stroke_preserve (cr=0x1b13c0) at
cairo.c:2234
12 0x0012a732 in *INT_cairo_stroke (cr=0x1b13c0) at cairo.c:2207
2010-01-25 09:35:09 +00:00
Andrea Canciani
90ba1242b6 Fix image backend compilation
When HAS_ATOMIC_OPS is not defined, cairo-image-surface.c does not
compile because _pixman_white_image calls _pixman_image_for_solid
which gets defined only later in the code.
2010-01-23 18:13:35 +01:00
Chris Wilson
b9407af6a4 image: Implement high level interface.
Write a dedicated compositor for pixman so that we avoid the
middle-layer syndrome of surface-fallback. The major upshot of this
rewrite is that the image surface is now several times quicker for glyph
compositing, which dramatically improves performance for text rendering
by firefox and friends. It also uses a couple of the new scan
convertors, such as the rectangular scan converter for rectilinear
paths.

Speedups
========
image-rgba          firefox-talos-gfx-0    342050.17 (342155.88 0.02%) -> 69412.44 (69702.90 0.21%):  4.93x speedup
███▉
image-rgba                        vim-0    97518.13 (97696.23 1.21%) -> 30712.63 (31238.65 0.85%):  3.18x speedup
██▏
image-rgba                  evolution-0    69927.77 (110261.08 19.84%) -> 24430.05 (25368.85 1.89%):  2.86x speedup
█▉
image-rgba                    poppler-0    41452.61 (41547.03 2.51%) -> 21195.52 (21656.85 1.08%):  1.96x speedup
█
image-rgba       firefox-planet-gnome-0    217512.61 (217636.80 0.06%) -> 123341.02 (123641.94 0.12%):  1.76x speedup
▊
image-rgba             swfdec-youtube-0    41302.71 (41373.60 0.11%) -> 31343.93 (31488.87 0.23%):  1.32x speedup
▍
image-rgba         swfdec-giant-steps-0    20699.54 (20739.52 0.10%) -> 17360.19 (17375.51 0.04%):  1.19x speedup
▎
image-rgba                       gvim-0    167837.47 (168027.68 0.51%) -> 151105.94 (151635.85 0.18%):  1.11x speedup
▏
image-rgba          firefox-talos-svg-0    375273.43 (388250.94 1.60%) -> 356846.09 (370370.08 1.86%):  1.05x speedup
2010-01-22 23:01:52 +00:00
Chris Wilson
ae25f1c360 Alter definition of cairo_composite_rectangles_t
This is a more useful definition that is able to individually track the
rectangles that compose the composite operation. This will be used by
the specialist compositors as a means to perform the common extents
determination for an operation.
2010-01-22 23:01:51 +00:00
Chris Wilson
9cd9137843 spans: Pass multiple rows of identical spans to the renders.
It is quite common amongst our geometry to have rows of repeated span
data, for example a rounded rectangle will have repeating data between
the top and bottom rounded corners. By passing the repeat length to the
renderers, they may be able to use that information more efficiently,
and the scan converters can avoid recomputing the same span data.
2010-01-22 23:01:51 +00:00
Chris Wilson
f617d5fc98 Add cairo_device_t
The device is a generic method for accessing the underlying interface
with the native graphics subsystem, typically the X connection or
perhaps the GL context. By exposing a cairo_device_t on a surface and
its various methods we enable finer control over interoperability with
external interactions of the device by applications. The use case in
mind is, for example, a multi-threaded gstreamer which needs to serialise
its own direct access to the device along with Cairo's across many
threads.

Secondly, the cairo_device_t is a unifying API for the mismash of
backend specific methods for controlling creation of surfaces with
explicit devices and a convenient hook for debugging and introspection.

The principal components of the API are the memory management of:

  cairo_device_reference(),
  cairo_device_finish() and
  cairo_device_destroy();

along with a pair of routines for serialising interaction:

  cairo_device_acquire() and
  cairo_device_release()

and a method to flush any outstanding accesses:

  cairo_device_flush().

The device for a particular surface may be retrieved using:

  cairo_surface_get_device().

The device returned is owned by the surface.
2010-01-22 23:01:50 +00:00
Chris Wilson
c50c8b90c0 Move _cairo_error() to a standalone header
A pending commit will want to include some utility code from cairo and
so we need to extricate the error handling from the PLT symbol hiding.
2010-01-22 22:30:43 +00:00