When there are no free entries to terminate a search, checking that a
key is not in the table requires probing every entry in the table,
i.e. it degenerates in an O(n) operation.
Rehashing when the number of free entries is less than 25% makes the
expected lookup time O(1).
The hash-table micro benchmark become 4-6x faster.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=17399
A benchmark to test the speed of hash tables when inserting and
removing a huge number of elements.
Although originally hash tables were assumed not to get many
deletions, in practice they are now being used as caches in multiple
places. This means that they often have a fixed number of live
elements and an element is evicted whenever a new element is inserted
(this happens explicitly for cairo_cache_t objects, but also, for
example, in scaled_font_map + holdovers). This access pattern is very
inefficient with the current implementation.
Printing PDFs with large monochrome or grayscale images would result
in the images being blown up to 24-bit color images. Some printers are
very slow to print huge color images.
If the hash value is different, the keys cannot be equal. Testing this
beforehand can avoid a few function calls and shares this optimization
across all cairo-hash uses.
Instead of artificially introducing collisions in the step value by
replacing 0 with 1 (which causes the value 1 to have twice the
frequency of any other value), the step value can simply be computed
as an uniformly distributed value in the range [1, rehash], extremes
included.
This is safe because any step value smaller than the hash modulus is
co-prime with it, hence induces an orbit which includes every integer
in [0, table_size - 1].
Reset the cairo_t to the initial state so that subsequent tests are not
affected by earlier tests.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Bucketing the rectangles together on their top-scanline and then sorting
within that scanline is significantly faster for dragon despite the extra
passes.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Under certain circumstances we will emit identical spans for when the
edge covers the entire pixel and then for the subsequent pixels. These
can be squashed into a single span.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This patch has been generated by the following Coccinelle semantic patch:
// Remove useless checks for NULL before freeing
//
// free (NULL) is a no-op, so there is no need to avoid it
@@
expression E;
@@
+ free (E);
+ E = NULL;
- if (unlikely (E != NULL)) {
- free(E);
(
- E = NULL;
|
- E = 0;
)
...
- }
@@
expression E;
@@
+ free (E);
- if (unlikely (E != NULL)) {
- free (E);
- }
The check for NULL and nil font faces is performed in the shared
code. There is no need to duplicate it (in fact, quartz-font and
ft-font don't do it).
The type field is accessible through the base.type field. This makes
it possible to change the layout of cairo_pattern_t and move the type
field without breaking cairo_pattern_union_t.
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
Similar to the technique used by the other span converters, we can avoid
the frequent error checking by instead throwing an error from the deep
malloc.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
_cairo_clip_get_region() returns NULL both for non-region clips and
for memory allocaiton failures. They must be distinguished by checking
_cairo_clip_is_region().
Fixes get-clip.
The brackets defined by push/pop and save/restore are independent ad
should match properly.
This means that cairo_push()-ed gstates cannot be cairo_restore()-d
and cairo_save()-d gstates cannot be cairo_pop()-ed.
Fixes group-state.
The clip surface is no longer cached on the clip and the caller is
responsible for destroying it after use.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
The build system does not honor the flags set externally and replaces
it with the pthread-only flags when detecting pthread
availability. This breaks the configuration of cairo in some
cross-compilation environments:
conftest.c:1: note: someone does not honour COPTS correctly, passed 0 times
The test for pthread should append the new flags to the old one.
Currently we only emit the format, but if you want to later convert
the images to a normal surface for replay it is handy to have the
content.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
If the clip wholly covers the operation, we do not need to set one, and
if the current clip similarly covers the operation we do not to unset
it.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
If the surface already has a clip set and that clip does not interfere
with the operation then we can leave it set.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
If the extents of the operation is wholly contained within the clip
region, then we can safely not invoke any clipping.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
We need to special case the handling of unaligned clip regions in order
to prevent the treatment of those as a general path requiring a
clip+mask...
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
A mesh pattern is put in CAIRO_STATUS_INVALID_MESH_CONSTRUCTION when
an invalid patch construction operation is performed.
A mesh pattern is put in CAIRO_STATUS_INVALID_INDEX when an operation
is performed with an out-of-bound index.
Any pattern is put in CAIRO_STATUS_INVALID_MATRIX when its matrix is
set to a singular matrix.
In order to have a behavior which is coherent with that of surfaces,
flushing a finished devices should be a no-op and should not affect
the status of the device.