Commit graph

77 commits

Author SHA1 Message Date
Chris Wilson
bed2701e1c Remove clip handling from generic surface layer.
Handling clip as part of the surface state, as opposed to being part of
the operation state, is cumbersome and a hindrance to providing true proxy
surface support. For example, the clip must be copied from the surface
onto the fallback image, but this was forgotten causing undue hassle in
each backend. Another example is the contortion the meta surface
endures to ensure the clip is correctly recorded. By contrast passing the
clip along with the operation is quite simple and enables us to write
generic handlers for providing surface wrappers. (And in the future, we
should be able to write more esoteric wrappers, e.g. automatic 2x FSAA,
trivially.)

In brief, instead of the surface automatically applying the clip before
calling the backend, the backend can call into a generic helper to apply
clipping. For raster surfaces, clip regions are handled automatically as
part of the composite interface. For vector surfaces, a clip helper is
introduced to replay and callback into an intersect_clip_path() function
as necessary.

Whilst this is not primarily a performance related change (the change
should just move the computation of the clip from the moment it is applied
by the user to the moment it is required by the backend), it is important
to track any potential regression:

ppc:
Speedups
========
image-rgba         evolution-20090607-0    1026085.22 0.18% -> 672972.07 0.77%:  1.52x speedup
▌
image-rgba         evolution-20090618-0    680579.98 0.12% -> 573237.66  0.16%:  1.19x speedup
▎
image-rgba      swfdec-fill-rate-4xaa-0    460296.92 0.36% -> 407464.63  0.42%:  1.13x speedup
▏
image-rgba      swfdec-fill-rate-2xaa-0    128431.95 0.47% -> 115051.86  0.42%:  1.12x speedup
▏
Slowdowns
=========
image-rgba     firefox-periodic-table-0    56837.61 0.78% -> 66055.17    3.20%:  1.09x slowdown
▏
2009-07-23 15:32:14 +01:00
Chris Wilson
3da32e35af [analysis] Restore nops for the analysis null surface
Joonas reported that adding the extra routines to the null-surface as used
by the analysis surface broke user-fonts. So create a separate null
backend to be exported via the test-null surface.
2009-06-19 00:28:58 +01:00
Chris Wilson
e5727e20f5 Expose _cairo_null_surface_create() via a test surface
Using a null surface is a convenient method to measure the overhead of the
performance testing framework, so export it although as a test-surface so
that it will only be available in development builds and not pollute
distributed libraries.
2009-06-15 12:03:37 +01:00
Chris Wilson
1496c5cf51 [analysis] Use _cairo_region_init()
Avoid secondary allocations of the thin region wrappers during surface
creation by embedding them into the parent structure. This has the
satisfactory side-effect of not requiring status checks which current code
lacks.
2009-04-16 09:34:02 +01:00
Søren Sandmann Pedersen
4b3245481c [region] Expand rect to rectangle in a couple of names
Specifically,

	cairo_region_union_rect  ->  cairo_region_union_rectangle
	cairo_region_create_rect ->  cairo_region_create_rectangle

Also delete cairo_region_clear() which is not that useful.
2009-03-28 18:02:57 -04:00
Søren Sandmann
e29103c081 [region] Move region function prototypes to cairo.h along with helper types.
Move struct _cairo_region to cairoint.h and delete
cairo-region-private.h. Delete cairo_private from the function
definitions that had it.
2009-03-28 18:02:57 -04:00
Søren Sandmann
1cca5a1348 [region] Remove underscores from _cairo_region_* 2009-03-28 18:02:07 -04:00
Søren Sandmann Pedersen
df883aa937 [region] Add a cairo_region_overlap_t type 2009-03-28 18:01:19 -04:00
Søren Sandmann
e3e1b35eb9 [region] Make cairo_region_t a malloced object. 2009-03-28 17:58:48 -04:00
Chris Wilson
778ced4879 [path] Rename _cairo_path_fixed_approximate_extents()
Rename approximate_extents() to approximate_clip_extents() so that it is
consistent with the fill and stroke variants and clearer under what
circumstances you may wish to use it.
2009-01-29 10:10:39 +00:00
Chris Wilson
0100856226 [path] Remove tolerance from path bounders
With Behdad's analytical analysis of the spline bbox, tolerance is now
redundant for the path extents and the approximate bounds, so remove it
from the functions parameters.
2008-12-29 12:55:09 +00:00
Chris Wilson
813cbf13dd [path] Separate the approx. bounds into 3 distinct functions
Based on feedback from Jeff Muizelaar, there is a case for a very quick
and dirty extents approximation based solely on the curve control points
(for example when computing the clip intersect rectangle of a path) and
by moving the stroke extension into a core function we can clean up the
interface for all users, and centralise the logic of approximating the
stroke extents.
2008-12-18 14:55:20 +00:00
Chris Wilson
dea40e61ba [path] Return the fixed-point bounds of the path
When analysing the stroke extents, we need the original fixed-point
extents so that we do not incur an OBO when we round-to-integer a second
time. We also need a more accurate estimate than simply using the control
points of the curve, so pass in tolerance and decompose until someone
discovers a cheaper algorithm to determine the precise aligned bounding
box of a bezier curve.
2008-12-18 12:06:47 +00:00
Chris Wilson
ce0b136a44 Query the backend to see if we can repaint the solid pattern.
If we are dithering on the Xlib backend we can not simply repaint the
surface used for a solid pattern and must recreate it from scratch.
However, for ordinary XRender usage we do not want to have to pay that
price - so query the backend to see if we can reuse the surface.
2008-12-18 12:06:45 +00:00
Chris Wilson
25a4677200 [analysis] Use approximate extents.
Use the approximate path based extents to avoid tessellation.
2008-12-18 10:40:13 +00:00
M Joonas Pihlaja
4a9b274eeb [cairo-spans] Add a check/create_span_renderer backend methods.
A surface will have the chance to use span rendering at cairo_fill()
time by creating a renderer for a specific combination of
pattern/dst/op before the path is scan converted.  The protocol is to
first call check_span_renderer() to see if the surface wants to render
with spans and then later call create_span_renderer() to create the
renderer for real once the extents of the path are known.

No backends have an implementation yet.
2008-12-06 14:04:36 +02:00
Chris Wilson
e6963a5bfe Mark allocation failures as unlikely.
Use the gcc likelihood annotation to indicate that allocation failures are
extremely unlikely.
2008-11-29 11:20:34 +00:00
Chris Wilson
d1801c23fa Mark if(status) as being unlikely.
The error paths should be hit very rarely during normal operation, so mark
them as being unlikely so gcc may emit better code.
2008-11-29 11:20:33 +00:00
Chris Wilson
06fabd6cbd [path] Fix up extents.
Forgot to round the box to the integer rectangle and missed why only
testing on image. Very naughty.
2008-11-25 12:54:58 +00:00
Chris Wilson
59de6fb89e [path] Compute approximate extents.
When computing the bounds of the clip path, we care more for a fast result
than absolute precision as the extents are only used as a guide to trim
the future operations. So computing the extents of the path suffices.
2008-11-25 10:16:32 +00:00
Adrian Johnson
fb7cfdd94d Make meta-surface store and replay extents of each operation
To be able to provide the extents of each operation to the backend
during the render phase the meta-surface needs to store the extents
computed by the analysis surface during the analysis phase.

The extents argument is either a pointer to the extents of the operation
stored in the meta-surface or NULL. During analysis the analysis surface
writes the extents to the meta-surface. During the render phase the extents
is made available to paginated surface backends.
2008-11-02 20:12:29 +10:30
Adrian Johnson
d682d275b9 Add an extents argument to the high level surface backend functions
Add a "cairo_rectangle_int_t *extents" argument to to the following
backend functions:
  paint
  mask,
  stroke
  fill
  show_glyphs
  show_text_glyphs

This will be used to pass the extents of each operation computed by
the analysis surface to the backend. This is required for implementing
EXTEND_PAD.
2008-11-02 20:12:22 +10:30
Chris Wilson
2836be6f75 Cleanup 'status && status != UNSUPPORTED'
Replace instances of 'status && status != UNSUPPORTED' with the more
readable _cairo_status_is_error().
2008-10-30 17:52:12 +00:00
Chris Wilson
7944601864 [pattern] Avoid needless copying of patterns.
Only copy the pattern if we need to modify it, e.g. preserve a copy in a
snapshot or a soft-mask, or to modify the matrix. Otherwise we can
continue to use the original pattern and mark it as const in order to
generate compiler warnings if we do attempt to write to it.
2008-10-30 17:52:05 +00:00
Chris Wilson
540f555840 [analysis] Only limit to mask extends if bounded by mask.
The extents of cairo_mask() is only limited to the mask if the operation
is bounded by the mask.
2008-10-30 16:19:54 +00:00
Chris Wilson
4b29988939 Review users of cairo_rectangle_int_t for incorrect unsigned promotion.
Adrian Johnson discovered cases where we mistakenly compared the result
of unsigned arithmetic where we need signed quantities. Look for similar
cases in the users of cairo_rectangle_int_t.
2008-10-30 16:19:38 +00:00
Chris Wilson
c76a8481f3 [analysis] Check for error surfaces.
If the target surface is an error surface, ensure that we return the
appropriate error surface. Likewise, avoid writing to error surfaces.
2008-10-19 09:36:52 +01:00
Chris Wilson
681424cbaf [analysis] Merge two analysis status codes.
Since there is an implicit precedence in the ranking of the analysis
return codes, provide a function to centralize the logic within the
analysis surface and isolate the backends from the complexity.
2008-09-26 13:42:28 +01:00
Carl Worth
69635bc054 Fix the analysis of mask operations (fixing mask-transformed-similar test case)
The primary bug here was some missing braces. The code was conditionally
assigning to backend_status, but then unconditionally checking for the
value assigned. The result was the leaking of an internal status value
(CAIRO_INT_STATUS_ANALYZE_META_SURFACE) which finally resulted in
an incomplete PDF file in the mask-transformed-similar test case.

While fixing this, also avoid re-using the backend_status variable so
much so that the code is more readable.
2008-09-25 02:09:40 -07:00
Carl Worth
5599b08dfa Drop _cairo_analysis_surface prefix from some static functions
Since these functions are static we don't really need the full
name. And these two functions were both so long that they were
causing some serious line-wrap issues.
2008-09-25 01:42:03 -07:00
Chris Wilson
c36a242303 [traps] Replace open-coding of box->rectangle->box
Use the utility functions _cairo_box_from_rectangle and
_cairo_box_round_to_rectangle() instead of open-coding. Simultaneously
tweak the whitespace so that all users of traps look similar.
2008-09-24 11:45:13 +01:00
Behdad Esfahbod
1fe7088a11 [show_text_glyphs] Replace the bool backward with cairo_text_cluster_flags
Chris rightfully complained that having a boolean function argument is
new in cairo_show_text_glyphs, and indeed avoiding them has been one
of the API design criteria for cairo.  Trying to come up with alternatives,
Owen suggested using a flag type which nicely solves the problem AND
future-proofs such a complex API.

Please welcome _flags_t APIs to cairo.h
2008-09-18 00:26:07 -04:00
Behdad Esfahbod
00bc650455 Add new public API cairo_surface_has_show_text_glyphs()
We added cairo_has_show_text_glyphs() before.  Since this is really a
surface property, should have the surface method too.  Like we added
cairo_surface_show_page()...
2008-08-18 14:54:21 -04:00
Behdad Esfahbod
7c9536b653 [analysis-surface] Fix crashers introduced in my previous commit
Oops!
2008-07-03 18:06:01 -04:00
Behdad Esfahbod
85de817e09 [analysis-surface] Fallback between show_glyphs and show_text_glyphs
This is needed because analysis-surface takes any UNSUPPORTED returns
as a signal for using image fallbacks.  So the fallback mechanism in
_cairo_surface_show_text_glyphs() is not enough.  Reported by Adrian
Johnson.
2008-07-02 19:21:50 -04:00
Behdad Esfahbod
8f02cadf3d [analysis-surface] Implement show_text_glyphs 2008-06-26 16:44:59 -04:00
Chris Wilson
74c1e9b545 Trivial warning fixes to silence the compiler. 2008-06-13 21:37:58 +01:00
Behdad Esfahbod
cf473f4a75 [cairo-xlib] Fix show_glyphs when failing to upload a glyph
Originally reported here:
http://lists.cairographics.org/archives/cairo/2008-May/014032.html
and analyized later in the thread.

Change (font and surface) backend show_glyphs() API to take a
int *remaining_glyphs argument.  It's used to communicate to the caller,
by way of setting remaining_glyphs and returning INT_STATUS_UNSUPPORTED,
that some of the glyphs were shown but not the others.  The xlib backend
now correctly uses this to handle failure to upload a glyph to the server.
So the large-font test passes now.

An alternative approach could be to add some public value for glyphs
indices that are not shown.  -1 perhaps (the xlib backend already uses
that value internally).  Then instead of remaining_glyphs, a backend
could simply set glyph indices of glyphs shown to that -1 value.
2008-05-23 20:03:49 -04:00
Behdad Esfahbod
11a0884168 Add CAIRO_INTERNAL_SURFACE_TYPE_NULL and cairo_nul_surface_create()
It creates a surface that does nothing.  This can be used with
cairo-analysis-surface, to compute bounds of cairo drawings without doing any
actual drawings.
2008-05-09 15:54:19 +02:00
Behdad Esfahbod
af1e168bbb [cairo-meta/analysis-surface] Make width/height of -1,-1 mean unbounded surface 2008-05-09 15:54:12 +02:00
Behdad Esfahbod
a6eb9be106 [_cairo_surface_get_extents()] return UNSUPPORTED if surface has no bounds
and set the extents to the infinite bounds.

A surface has no bounds if it does not provide get_extents(), or if its
get_extents() returns UNSUPPORTED.
2008-05-09 15:54:12 +02:00
Behdad Esfahbod
d37788f995 [cairo-analysis-surface] Initialize page bounding box
If there was no operations played to the analysis surface, page_bbox
was being left uninitialized.
2008-05-09 15:54:12 +02:00
Behdad Esfahbod
440b339da7 [cairo-analysis-surface] Hold reference to target surface 2008-05-09 15:54:12 +02:00
Behdad Esfahbod
4d77dfc78d [cairo-analysis-surface] Add _cairo_analysis_surface_[gs]et_ctm()
The functionality was there.  Just add getter/setter for the ctm.
2008-05-09 15:54:12 +02:00
Behdad Esfahbod
ad7cfb4af9 [cairo-analysis-surface] Use _cairo_matrix_transform_bounding_box_fixed()
and other conversion functions.
2008-05-09 15:54:12 +02:00
Adrian Johnson
ae9635bf33 Fix assertion in PS/PDF/Win32-print when fallback image is off the page
If during analysis the bounding box of an operation or the number of
traps is 0, the operation is marked as natively supported. The problem
here is if the operation is unsupported by the backend, we get an
assertion when the operation is replayed during
CAIRO_PAGINATED_MODE_RENDER.

This bug was found in Inkscape when printing to the
win32_printing_surface a page that has been layed out as landscape but
landscape paper had not been selected in the print dialog.

Fix this by being careful not to mark unsupported operations as
supported during analysis even they may not be visible on the page.
2008-03-24 12:16:20 +10:30
Chris Wilson
127d7f43ea [cairo-path-bounds] _cairo_path_fixed_bounds() can fail...
I was wrong in my assertion that the call to
_cairo_path_fixed_interpret_flat() could not possibly fail with the
given _cairo_path_bounder_* callbacks - as I had missed the implicit
spline decomposition. (An interesting exercise would be to avoid the
spline allocation...) As a result we do have to check and propagate the
status return through the call stack.
2008-02-27 09:47:35 +00:00
Adrian Johnson
eae259168f Using correct surface size and clip when analyzing meta surface patterns
The surface size and clip needs to be saved before and restored after
replaying meta surface patterns back to the analysis surface. The clip
is reset and the correct surface size is set before replaying the meta
surface.
2008-02-22 21:07:31 +10:30
Vladimir Vukicevic
02970ac8cf Fix usage of cairo_rectangle_int16_t leading to memory corruption
cairo_rectangle_int16_t was being used in a number of places instead
of cairo_rectangle_int_t, which led to memory corruption when cairo was
using a fixed point format with a bigger space than 16.16 (such as 24.8).
2008-01-22 15:32:11 -08:00
Brian Ewins
d923457c0f [path-fixed] make _cairo_path_fixed_bounds use _cairo_path_fixed_interpret_flat
_cairo_path_fixed_bounds can use the new _interpret_flat mechanism; this
results in tighter bounds; previously the bounds followed the control
points of the beziers, whereas now they are the bounds of the curve.
2008-01-21 12:01:44 -08:00