summaryrefslogtreecommitdiffstats
path: root/external/cairo/pixman/pixman-0.24.4.patch
blob: a5d32f88f82f3a0ea280285c040e3c92573f6667 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
--- misc/pixman-0.24.4/Makefile.in	2011-11-06 22:11:25.000000000 +0100
+++ misc/build/pixman-0.24.4/Makefile.in	2011-12-16 09:06:45.317211035 +0100
@@ -385,7 +385,7 @@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = pixman demos test
+SUBDIRS = pixman
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = pixman-1.pc
 GPGKEY = 3892336E
--- misc/pixman-0.24.4/pixman/pixman-utils.c
+++ misc/build/pixman-0.24.4/pixman/pixman-utils.c
@@ -27,6 +27,7 @@
 #endif
 #include <stdio.h>
 #include <stdlib.h>
+#include <limits.h>
 
 #include "pixman-private.h"

--- misc/pixman-0.24.4/pixman/pixman-glyph.c	2015-06-30 05:48:31.000000000 -0400
+++ misc/build/pixman-0.24.4/pixman/pixman-glyph.c	2017-11-25 13:26:33.075558418 -0500
@@ -38,6 +38,7 @@

 /* XXX: These numbers are arbitrary---we've never done any measurements.
  */
+#define N_PIXELS_HIGH_WATER  (4 * 1024 * 1024)
 #define N_GLYPHS_HIGH_WATER  (16384)
 #define N_GLYPHS_LOW_WATER   (8192)
 #define HASH_SIZE (2 * N_GLYPHS_HIGH_WATER)
@@ -58,6 +59,7 @@
     int			n_glyphs;
     int			n_tombstones;
     int			freeze_count;
+    long        n_pixels;
     pixman_list_t	mru;
     glyph_t *		glyphs[HASH_SIZE];
 };
@@ -133,6 +135,7 @@
     if (*loc == TOMBSTONE)
 	cache->n_tombstones--;
     cache->n_glyphs++;
+    cache->n_pixels += glyph->image->bits.width * glyph->image->bits.height;

     *loc = glyph;
 }
@@ -150,6 +153,7 @@
     cache->glyphs[idx & HASH_MASK] = TOMBSTONE;
     cache->n_tombstones++;
     cache->n_glyphs--;
+    cache->n_pixels -= glyph->image->bits.width * glyph->image->bits.height;

     /* Eliminate tombstones if possible */
     if (cache->glyphs[(idx + 1) & HASH_MASK] == NULL)
@@ -180,6 +184,7 @@

     cache->n_glyphs = 0;
     cache->n_tombstones = 0;
+    cache->n_pixels = 0;
 }

 PIXMAN_EXPORT pixman_glyph_cache_t *
@@ -194,6 +199,7 @@
     cache->n_glyphs = 0;
     cache->n_tombstones = 0;
     cache->freeze_count = 0;
+    cache->n_pixels = 0;

     pixman_list_init (&cache->mru);

@@ -220,9 +226,9 @@
 pixman_glyph_cache_thaw (pixman_glyph_cache_t  *cache)
 {
     if (--cache->freeze_count == 0					&&
-	cache->n_glyphs + cache->n_tombstones > N_GLYPHS_HIGH_WATER)
+	(cache->n_glyphs + cache->n_tombstones > N_GLYPHS_HIGH_WATER || cache->n_pixels > N_PIXELS_HIGH_WATER))
     {
-	if (cache->n_tombstones > N_GLYPHS_HIGH_WATER)
+	if (cache->n_tombstones > N_GLYPHS_LOW_WATER)
 	{
 	    /* More than half the entries are
 	     * tombstones. Just dump the whole table.
@@ -230,7 +236,7 @@
 	    clear_table (cache);
 	}

-	while (cache->n_glyphs > N_GLYPHS_LOW_WATER)
+	while (cache->n_glyphs > N_GLYPHS_LOW_WATER || cache->n_pixels > N_PIXELS_HIGH_WATER)
 	{
 	    glyph_t *glyph = CONTAINER_OF (glyph_t, mru_link, cache->mru.tail);