Commit graph

299 commits

Author SHA1 Message Date
Chris Wilson
b132fae5e8 clip: Rudimentary support for clip-polygon extraction
Step 1, fix the failings sighted recently by tracking clip-boxes as an
explicit property of the clipping and of composition.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-19 21:14:34 +01:00
Chris Wilson
2458120dee pattern: Add observer hooks
In order for custom context to automatically track when a pattern is
modify after being set on the context (and before it is used in an
operator), we need for there to be a callback when the pattern is
modified.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-15 11:05:19 +01:00
Chris Wilson
83bfd85a13 Implement cairo_backend_t
Allow a backend to completely reimplement the Cairo API as it wants. The
goal is to pass operations to the native backends such as Quartz,
Direct2D, Qt, Skia, OpenVG with no overhead. And to permit complete
logging contexts, and whatever else the imagination holds. Perhaps to
experiment with double-paths?

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-15 11:05:19 +01:00
Chris Wilson
41b5469b95 image: Only discard the outer boxes
This is necessary as the callers do not propagate the clip extents after
finding the singular clip path. *sigh*

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-14 17:34:51 +01:00
Benjamin Otte
00de16b7ac image: Don't crash on weird pixman formats
_pixel_to_solid() used to assert that it got a known cairo_format_t.
However, this might not be the case when backends decide to use a pixman
format that is not representable by a cairo format (X and DirectFB are
examples for backends that do that).

This patch makes _pixel_to_solid() return NULL in that case and fixes
the callers to deal with it.

https://bugs.freedesktop.org/show_bug.cgi?id=37916
2011-06-08 16:01:03 +02:00
Chris Wilson
5559dd0bbc image: Fix pixman format to RGB30 conversion
Søren Sandmann Pedersen spotted that we had reversed the channel order
in the conversion back from the pixman format codes to
CAIRO_FORMAT_RGB30.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-04 08:02:56 +01:00
Jesse Barnes
356c4ed9cc Expose 30bpp/10bpc support: CAIRO_FORMAT_RGB30
This is a common format used by framebuffers to drive 10bpc displays
and is often hardware accelerated by XRender with underlying support
from pixman's x2r10g10b10 format (which provides coercion paths for
fallbacks).

Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-01 09:00:14 +01:00
Uli Schlachter
a80bf9ed43 image: Don't use the fast path if it's wrong
Fixes the new "operator-source" test and the original report from:
http://lists.cairographics.org/archives/cairo/2011-March/021827.html

I tested this code path with all operators and "source" is the only one which
causes issues with rendering outside of the boxes.

Possibly fixes: https://bugs.freedesktop.org/show_bug.cgi?id=35407

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-31 15:47:45 +02:00
Andrea Canciani
628ef17aca image: Silence gcc warning
gcc does not know thta num_glyph is guaranteed to be strictly
positive, so it complains that:

cairo-image-surface.c:3787: warning: ‘status’ may be used uninitialized in this function
2011-03-18 17:54:54 +01:00
Andrea Canciani
e0444a458a image: Silence missing enum value warning
cairo-image-surface.c:101: warning: enumeration value ‘PIXMAN_x14r6g6b6’ not handled in switch
2011-03-18 17:54:54 +01:00
Andrea Canciani
47f70537b8 image: Fix surface acquisition if PIXMAN_HAS_ATOMIC_OPS
If PIXMAN_HAS_ATOMIC_OPS, ix and iy will be changed if the source
surface is of subsurface type. They need to be reset to 0 before being
passed to _cairo_matrix_to_pixman_matrix_offset() or the acquired
surface will have an incorrect offset .
2011-02-19 19:26:20 +01:00
M Joonas Pihlaja
71e8a4c230 image: Avoid reusing pixman images for threadsafety.
The pixman_image_ref() and pixman_image_unref() functions
aren't threadsafe in current pixman, so we can't share
pixman images across contexts where they may end up
moving between threads.  The main use of these functions
is in keeping a global cache of pixman_image_ts for
solid colours and reusing the same pixman_image_t for
patterns pointing to the same image data where possible.

This patch removes those uses from cairo by wrapping
them in a PIXMAN_HAS_ATOMIC_OPS conditional.  There is
no automatic test this, so we will have to manually
turn this code back on when pixman does gain atomic
ops.

The only two remaining calls to pixman_image_ref() are
done on locally created images so they are safe.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=34177
2011-02-19 18:01:27 +02:00
Chris Wilson
d558f40c44 image: Limit span rendering to bounded extents
We make the presumption that the incoming geometry is appropriately
clipped to the bounded extents and can simply memset without being out
of bounds.

However, this was not always the case as we were removing the clip boxes
in order to optimise the common case where the operation is naturally
limited to the surface.

(This is a candidate for 1.10)

Bugzilla: https://bugs.launchpad.net/ubuntu/+source/cairo/+bug/710072
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-06 14:19:23 +00:00
Andrea Canciani
32241cde01 doc: Add links to flush() and mark_dirty() in direct access functions
cairo_image_get_data() and other direct access functions are often
misused by applications because they don't call cairo_surface_flush()
and/or cairo_surface_mark_dirty() around the code which accesses the
surface data directly.

Although this information is already available in the description of
the cairo_surface_t type, adding a reminder about it in the direct
access functions should make it easier to use them correctly.
2011-01-16 18:40:42 +01:00
Andrea Canciani
38dce5d144 pattern: Factor out pattern rescaling
The same code was duplicated (incorrectly and with some minor
differences) in pattern, image, xlib and xcb.

_cairo_gradient_pattern_max_val() abstracts that code in a function
that can be used whenever a gradients extremes need to be rescaled to
fit within a given range.

Fixes huge-linear, huge-radial.

Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
2011-01-02 18:32:13 +01:00
Andrea Canciani
51594d9787 matrix: Cairo matrix to pixman transform/offset conversion
Xlib, XCB and image use the same code to convert a cairo_matrix_t to a
backend-specific transform.

The code did not handle correctly some matrices, thus a new function
that performs the conversion in a more generic way was added and used
in the backends instead of fixing the repeated code.

Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
2011-01-02 18:31:42 +01:00
Andrea Canciani
8df122cb4b Add mesh gradient rasterizer
Add an implementation of a fast and reasonably accurate
non-antialiased mesh gradient rasterizer.
2011-01-01 13:05:12 +01:00
Andrea Canciani
85a489f0f2 polygon: Merge _cairo_polygon_init and _cairo_polygon_limit
_cairo_polygon_limit() had to be called immediately after
_cairo_polygon_init() (or never at all).

Merging the two calls is a simple way to enforce this rule.
2010-12-10 11:04:48 +01:00
Andrea Canciani
8d7486a6ea image: Fix _pixel_to_solid
An A1 image with full alpha should be opaque black, not opaque white.

Use specialized solid black image instead of the generic constructor
for an A8 image with full alpha (it is likely to be cached).
2010-11-28 18:37:16 +01:00
Andrea Canciani
72b0a44a1f image: Fix compositing of unaligned boxes
The input of _fill_unaligned_boxes is (supposed to be) composed only
of disjoint rectangles, that can safely be passed to the rectilinear
span converter, but this function artificially introduces intersecting
rectangles when drawing non-aligned boxes.

Using non-intersecting rectangles is easy and makes the code correct.

Fixes rectilinear-grid.

Reviewed-by: Uli Schlachter <psychon@znc.in>
2010-11-28 18:35:16 +01:00
Adrian Johnson
59661f8af4 Fix fallback-resolution test
The recording surface source image painted onto fallback images always
had the resolution 72ppi instead of the fallback resolution of the
target surface. Fix this by passing adding a new
acquire_source_image_transformed backend function for the recording
surface to use and passing the target device transform through to the
recording surface when the image is acquired.

Based on Carl Worth's experimental acquired_source_image_transformed
branch.

https://bugs.freedesktop.org/show_bug.cgi?id=24692
2010-11-28 03:38:29 +10:30
Andrea Canciani
c7027c9d89 image: Use correct size for allocation
In 06e9caf861 the type of the variables
was changed, but the type used to compute the allocation size was not.

Fixes a crash in user-font-mask (test-fallback backend).
2010-11-01 21:20:29 +01:00
Andrea Canciani
e9c1fc3188 path: Do not access flags directly
Use inline accessors to hide the flags in the code.

This ensures that flags that need additional computations (example:
is_rectilinear for the fill case) are always used correctly.
2010-10-29 17:31:21 +02:00
Uli Schlachter
d24e9881de raster backends: Set round_glpyh_positions to ON
This fixes "text-rotate" in the test suite for the image backend and
"overlapping-glyphs" for the xcb backend.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-10-21 22:20:31 +02:00
Chris Wilson
42ecc427f3 xcb,image: Fix a missing clip fini
Spotted by Uli Schlachter when I copied the image glyphs clipping to
xcb.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-10-15 10:40:53 +01:00
Chris Wilson
66ace8cd33 image: The a8 in-place span compositing is only valid for SOURCE
Fixes test/a8-clear.

Reported-by: Jeremy Moles <jeremy@emperorlinux.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-09-29 13:57:15 +01:00
Chris Wilson
ac6fd51fe4 image: Silence a compile warning
cairo-image-surface.c: In function ‘_cairo_image_reset_static_data’:
cairo-image-surface.c:1006: warning: old-style function definition

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-09-29 13:56:58 +01:00
Andrea Canciani
8fda4ab1cc image: add _cairo_image_reset_static_data
Image has static caches which needs to be reset to make
cairo_debug_reset_static_data behave as expected.
Silences a bunch of leak reports by check-valgrind.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-09-09 17:25:00 +02:00
Benjamin Otte
e79acf47a5 subsurface: Make CAIRO_SURFACE_TYPE_SUBSURFACE public 2010-08-26 12:55:39 +02:00
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