Commit graph

228 commits

Author SHA1 Message Date
Andrea Canciani
bbaca95982 quartz: Unify DO_SHADING, DO_IMAGE and DO_TILED_IMAGE
DO_SHADING, DO_IMAGE and DO_TILED_IMAGE sources all require the source
to be painted over the whole surface (inside the clip region), thus can
share the same code path in drawing functions.
2010-10-13 00:27:01 +02:00
Andrea Canciani
51a6ae9d71 quartz: Unify DO_SOLID and DO_PATTERN
Both DO_SOLID and DO_PATTERN setup the underlying CGContext to directly
use the chosen color/pattern when filling and stroking, thus require no
additional drawing operations and can share the same drawing code.
2010-10-13 00:27:01 +02:00
Andrea Canciani
c22e75e9f6 quartz: Set operator when setting up source
Share some code between the drawing functions by saving the state
and setting the operator when setting up the source and by restoring
the state during teardown.
Based on a patch by Robert O'Callahan <robert@ocallahan.org>.
See https://bugzilla.mozilla.org/show_bug.cgi?id=522859
2010-10-13 00:27:01 +02:00
Andrea Canciani
6bc1376cf5 quartz: Remove DO_NOTHING and DO_UNSUPPORTED actions
DO_NOTHING and DO_UNSUPPORTED are not actual actions and are better
handled by returning an appropriate cairo_int_status_t (and falling
back, if needed).
2010-10-13 00:26:57 +02:00
Andrea Canciani
08c59c6bf3 quartz: Improve gradient quality
Instead of extending the range of the interpolation parameter to make
sure that pixels exactly on the edge get drawn, we are now asking
quartz to extend the gradient.
2010-10-12 23:18:13 +02:00
Andrea Canciani
620c43f50c quartz: Fix EXTEND_PAD gradients
Make PAD extended gardients more robust, by computing the color
explicitly like for REPEAT and REFLECT extend modes.
This removes a hack introducing a small but non-0 negative value
that ensured that the gradient started with the correct color (but
not that it ended with the correct one, too).

Fixes linear-gradient-large.
2010-10-12 23:18:13 +02:00
Andrea Canciani
2af3ae92eb quartz: Improve gradient consistency
By keeping "virtual extents", quartz surfaces now keep track of
the extents where they want the gradients to be consistent.
This works across various API for surface creation and editing:
 - cairo_surface_create_for_rectangle
 - cairo_surface_create_similar + cairo_surface_set_device_offset
 - cairo_push_group/cairo_pop_group

This method does not use clip extents, so it also makes gradient
rasterization independent of clip/path extents.
2010-10-12 23:18:13 +02:00
Andrea Canciani
1c36766d27 quartz: Remove unused code
The gradient fallback path is not used anymore.
2010-10-12 20:19:39 +02:00
Andrea Canciani
2cea2bb085 quartz: Make radial gradients follow PDF specification
Pixman master (soon to become pixman 0.20) implements radial
gradients based on the PDF specification (section 8.7.4.5.4).
Quartz natively implements them, so falling back is not needed
anymore.
2010-10-12 20:19:39 +02:00
Andrea Canciani
5054727927 quartz: Remove linear gradient fallback
Degenerate linear gradients are reduced to solid gradients in
gstate, so backends do not need to handle them.
2010-10-12 20:19:39 +02:00
Andrea Canciani
5500d072e0 quartz: Handle failures in _cairo_quartz_setup_fallback_source
If the fallback surface creation or painting fail, the fallback
surface needs to be destroyed.
2010-10-07 20:44:50 +02:00
Andrea Canciani
17bb0f8b1f quartz: Improve _cg function types 2010-10-07 20:44:50 +02:00
Andrea Canciani
3b4f7c3662 quartz: Improve handling of surface creation failure
Don't paint on a surface whose status is not SUCCESS.
2010-10-07 20:44:50 +02:00
Andrea Canciani
b13a8035c1 quartz: Remove useless code
The condition is always true (since surface creation returns non-NULL
even upon failure).
2010-10-07 20:44:50 +02:00
Andrea Canciani
f156f89db0 quartz: Simplify cairo_quartz_surface_create_for_cg_context
Only retaining the context when the surface cration is successful
avoids needless retaining and simplifies the code.
2010-10-07 20:44:50 +02:00
Andrea Canciani
c5fc8fa62f quartz: Use NOTHING_TO_DO instead of SUCCESS where appropriate
Returning CAIRO_INT_STATUS_NOTHING_TO_DO removes some code that
specifically handles it to convert to CAIRO_STATUS_SUCCESS. This
is already performed out of the backend, in the upper layers, so
it is not needed here.
2010-10-07 20:44:50 +02:00
Andrea Canciani
eae5fafc89 quartz: Beautify code
Remove redundant parentheses and reference/dereferences.
2010-10-07 20:44:50 +02:00
Andrea Canciani
f93603fda0 quartz: Whitespace cleanup 2010-10-07 20:44:50 +02:00
Andrea Canciani
6ff5cbd8a9 quartz: Mark failures as unlikely 2010-10-07 20:44:50 +02:00
Andrea Canciani
2f4a47c6bf quartz: Fix function call coding style
Cairo coding style specifies a single space between the function
name and the parentheses.
2010-10-07 20:44:49 +02:00
Andrea Canciani
692f20a859 quartz: Don't typecast surfaces
Casting to (cairo_surface_t *) is considered bad practice. The
correct way to get a reference to the generic surface information
is &(surface->base)
2010-10-07 20:44:49 +02:00
Andrea Canciani
b922477e4e quartz: Check for valid patterns
The pattern handling code ensures that 0 stops patterns are reduced
to clear solid patterns before being passed down to the backend.
An assertion is used to make sure that the assumption actually holds,
removing the duplication of the reduce-to-solid-clear logic.
2010-10-07 20:44:49 +02:00
Andrea Canciani
c9aa393a4d quartz: Assert upon invalid enum values
Invalid enum values were being ignored (and replaced by a default
value). This behavior is not desirable on development builds,
because an explicit failure is much easier to track.
Assertions allow release builds to keep on with the old behaviour,
while development builds fail as soon as the invalid operaiton is
performed.
2010-10-07 20:44:49 +02:00
Andrea Canciani
9c22f97ebd quartz: Remove unused argument from _cairo_surface_to_cgimage 2010-10-07 20:44:49 +02:00
Andrea Canciani
de606af5d6 quartz: improve backend detection
Quartz previously crashed with NULL backends and didn't check for
the backend type when getting a CGContext from a quartz surface,
returning meaningless data for subsurfaces.
2010-08-07 12:37:22 +02:00
Andrea Canciani
056ce165c4 quartz: fix solid masking fallback
Falling back when painting would ignore the alpha value (which is
needed to have the correct mask opacity).
_cairo_quartz_surface_paint_cg doesn't fallback, so the usual mask
fallback path is now taken, as expected.
2010-08-07 12:21:06 +02:00
Andrea Canciani
bdeade14ea quartz: fix stroking with unbounded operators
Self-intersecting strokes were drawn incorrectly when an unbounded
operator was used, since the fixup operation also cleared the
intersection.

Fixes clip-stroke-unbounded.
2010-08-06 20:24:52 +02:00
Andrea Canciani
c1fcbd0322 quartz: fix REFLECT radial gradients
The interpolation range of repeating radial gradients can safely be
reflected around any integer (previously 0), but for reflect-extended
radial gradients can only be reflected around odd integers if the
appearance is to be the same, thus reflecting around 1 is correct for both.

Fixes radial-gradient.
2010-07-26 11:39:27 +02: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
Andrea Canciani
7d69100143 quartz: remove unused declarations 2010-06-28 17:12:41 +02:00
Andrea Canciani
bd4c14b94e quartz: remove unused os version info
It was previously used to activate a workaround for text transformation
whenrunning on some os versions. Now the workaround is not needed anymore.
2010-06-28 16:55:57 +02:00
Andrea Canciani
b26f72fef9 quartz: check return status
If the font backend is unable to tell the extents of the operation,
consider it unbound.
2010-06-28 16:55:57 +02:00
Andrea Canciani
9c0d761bfc quartz: improve text transform handling
Use scale instead of manually compositing font_matrix and ctm and
composite it with the context ctm, so that no workaround for clipping
is needed anymore.
2010-06-28 16:55:57 +02:00
Andrea Canciani
53260148ea quartz: fix repeating radial gradients on 64 bits
Quartz API uses the type CGFloat, which is double on 64 bits,
float on 32 bits architectures
2010-05-17 22:12:36 +02:00
Andrea Canciani
0104976dc8 quartz: silence compiler warnings
All the possible enum values have to be explicitly handled in switch statements.
2010-05-17 22:12:36 +02:00
Andrea Canciani
ac94a00a4d quartz: fallback for A1 images on little endian archs
Quartz uses a bit ordering that is consistent with cairo on big
endian architectures, but isn't on little endian architectures.

Fixes a1-mask and large-source-roi (on little endian)
2010-05-17 22:09:06 +02:00
Robert O'Callahan
d65e8064c0 Ensure the quartz backend returns the first stop for negative positions on the gradient line of a nonrepeating linear gradient.
I discovered a small bug in cairo-quartz gradients. If you have multiple stops
at position 0, then cairo-quartz pads with the *last* stop at position 0,
instead of the first stop at position 0. This patch fixes that.

From https://bugzilla.mozilla.org/show_bug.cgi?id=513395
2010-05-11 13:59:58 -04:00
Robert O'Callahan
ce27db9a55 Don't repeat a Quartz gradient more times than necessary, to avoid Quartz quality problems when there are lots of repeated color stops.
-- Add a parameter to _cairo_quartz_setup_source so we can pass down the
extents of the object we're drawing
-- Compute fill/stroke/glyph extents and pass them down in the cases we need to
(repeating/reflecting gradients)
-- Pass those extents on down to where we set up the gradients
-- Make _cairo_quartz_setup_linear_source fall back to pixman for the
degenerate case where the linear gradient vector has no length
-- In CreateRepeatingRadialGradientFunction and
CreateRepeatingLinearGradientFunction, use the object extents (or surface
extents, for the paint() case) instead of the clip box to calculate the
parameters for the gradient
-- I've changed the way CreateRepeatingLinearGradientFunction calculates the
repetition count. The new approach gives much more precise bounds on the number
of repetitions needed (and is very similar to what we do for radial gradients).
This is important because if we specify a much larger input range than we
really need for our gradient color function, Quartz samples it too coarsely
over the range we actually care about, and the gradients look bad.

For example, suppose start = (5,0), end = (6,10), the CTM is identity and the
bounds we want to cover is (0,0)-(10,10). I think the current approach sets up
the gradient to be repeated 10 times. In fact only 3 repetitions are needed.

Also, using 'width' here didn't look right:
-       y_rep_end = (int) ceil((surface->extents.width - MAX(mstart.y, mend.y))
/ dy

From https://bugzilla.mozilla.org/show_bug.cgi?id=508730
2010-05-11 13:59:52 -04:00
Robert O'Callahan
7b4e63d5b8 Clean up Quartz gradient code by moving some local variables to static const globals.
From https://bugzilla.mozilla.org/show_bug.cgi?id=508730
2010-05-11 13:59:43 -04:00
Robert O'Callahan
8302952dcf quartz: Don't fallback to pixman for repeating radial gradients.
Figuring out where the outer circle should move to is tricky. I hope the
algebra in there is understandable.

This is a nice performance improvement, probably because we avoid painting the
gradient over the entire clipBox (which is usually the entire surface).

I tried to write reftests that compared a repeating radial gradient to a
non-repeating gradient with manually repeated stops, but it didn't work because
the rasterization was slightly different --- I'm not sure why.

This patch also forces us to use pixman for all degenerate cases where the
circles intersect. This at least makes us consistent across platforms.

From https://bugzilla.mozilla.org/show_bug.cgi?id=508227
2010-05-11 13:58:10 -04:00
Metal Sonic
30d358e098 Update license blocks to use "Mozilla Foundation" instead of "Mozilla Corporation"
From https://bugzilla.mozilla.org/show_bug.cgi?id=507387
2010-05-06 16:07:43 -04:00
Andrea Canciani
ebe6f2ac69 quartz: Assert success of path creation
Path creation can only fail because of the callbacks, but in quartz
they all return CAIRO_STATUS_SUCCESS. Therefore we can just assert
that path creation was successful and simplify calling functions
(as they don't have to handle potential errors anymore).
2010-04-27 12:24:43 +02:00
Andrea Canciani
f67b600927 quartz: Simplify path creation
If paths are created before changing the ctm (when stroking) no
multiplication is needed in the path construction code.
2010-04-27 12:24:43 +02:00
Andrea Canciani
3b2ceff050 quartz: Stroke without ctm_inverse multiplication
If the CTM is not changed before creating the path, no multiplication
needs to be made between points and the inverse of the CTM.
2010-04-27 12:24:42 +02: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
Kristian Rietveld
ded3a9639b quartz: Define cairo_quartz_float_t and use instead of float
On Mac OS 10.6 and newer cairo_quartz_float_t is defined to be a
CGFloat, resolving issues with the 64-bit builds.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=25814
2010-04-04 12:34:29 +02:00
Andrea Canciani
b1829a47bf [quartz] Unbreak mask fallback path
_cairo_quartz_surface_paint will never fail as it falls back to image
when CoreGraphics can't handle the requested operation. This means that
upon fallback the ClipImage set by the masking code gets ignored, thus
the mask fallback path is broken. Using the _cg function ensures that
masking is either completely done by CoreGraphics, or the fallback path
passes the mask operation to image.
2010-02-03 11:43:29 +01:00
Andrea Canciani
e2be50c722 [quartz] Fix UNSUPPORTED operations
The fallback path shouldn't be used anymore, thus fallbacks are now
handled by passing unsupported ops to the image backend.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-02-02 19:48:47 +01:00
Andrea Canciani
3e69c38fe6 [quartz] Fix surface to CGImage conversion
Snapshotting a surface doesn't produce a cairo_image_surface_t.
Acquiring (and later releasing) the surface is needed to access
its image data.
2010-02-02 18:26:52 +01:00
Andrea Canciani
7aba47e9d8 [quartz] Silence compiler warnings 2010-02-02 18:26:52 +01:00