summaryrefslogtreecommitdiffstats
path: root/gfx/cairo/add-a-stash-of-cairo_t-s.patch
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /gfx/cairo/add-a-stash-of-cairo_t-s.patch
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'gfx/cairo/add-a-stash-of-cairo_t-s.patch')
-rw-r--r--gfx/cairo/add-a-stash-of-cairo_t-s.patch75
1 files changed, 75 insertions, 0 deletions
diff --git a/gfx/cairo/add-a-stash-of-cairo_t-s.patch b/gfx/cairo/add-a-stash-of-cairo_t-s.patch
new file mode 100644
index 000000000..c6fcdd9d8
--- /dev/null
+++ b/gfx/cairo/add-a-stash-of-cairo_t-s.patch
@@ -0,0 +1,75 @@
+commit dfec2c249915560cedd2b49326c6629ad8a0b0f2
+Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
+Date: Tue Mar 2 16:01:41 2010 -0500
+
+ add a stash of cairo_t's
+
+diff --git a/src/cairo.c b/src/cairo.c
+index 3c9d892..4b27b83 100644
+--- a/src/cairo.c
++++ b/src/cairo.c
+@@ -119,7 +119,63 @@ _cairo_set_error (cairo_t *cr, cairo_status_t status)
+ _cairo_status_set_error (&cr->status, _cairo_error (status));
+ }
+
+-#if HAS_ATOMIC_OPS
++#if defined(_MSC_VER)
++#pragma intrinsic(_BitScanForward)
++static __forceinline int
++ffs(int x)
++{
++ unsigned long i;
++
++ if (_BitScanForward(&i, x) != 0)
++ return i + 1;
++
++ return 0;
++}
++#endif
++
++
++#if CAIRO_NO_MUTEX
++/* We keep a small stash of contexts to reduce malloc pressure */
++#define CAIRO_STASH_SIZE 4
++static struct {
++ cairo_t pool[CAIRO_STASH_SIZE];
++ int occupied;
++} _context_stash;
++
++static cairo_t *
++_context_get (void)
++{
++ int avail, old, new;
++
++ old = _context_stash.occupied;
++ avail = ffs (~old) - 1;
++ if (avail >= CAIRO_STASH_SIZE)
++ return malloc (sizeof (cairo_t));
++
++ new = old | (1 << avail);
++ _context_stash.occupied = new;
++
++ return &_context_stash.pool[avail];
++}
++
++static void
++_context_put (cairo_t *cr)
++{
++ int old, new, avail;
++
++ if (cr < &_context_stash.pool[0] ||
++ cr >= &_context_stash.pool[CAIRO_STASH_SIZE])
++ {
++ free (cr);
++ return;
++ }
++
++ avail = ~(1 << (cr - &_context_stash.pool[0]));
++ old = _context_stash.occupied;
++ new = old & avail;
++ _context_stash.occupied = new;
++}
++#elif HAS_ATOMIC_OPS
+ /* We keep a small stash of contexts to reduce malloc pressure */
+ #define CAIRO_STASH_SIZE 4
+ static struct {