summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-08-18 11:27:17 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-08-18 18:31:39 +0900
commitea001c3ec1fb6cfb01a794fc9a56c2609488f8f8 (patch)
treebc7f7487adaa9ddbe8ba1fbaf428120e12a2fed8 /src/lib/evas/common
parent6124d0733657e425001ce51f526aea3bb8dc54e7 (diff)
Evas: Add debug env var EVAS_IMAGE_NO_MMAP
Looking for image buffer memory leaks with Valgrind is impossible when all images are mmaped. This is intended as a DEBUG environment variable only.
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_image_main.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/lib/evas/common/evas_image_main.c b/src/lib/evas/common/evas_image_main.c
index 9c7f9df..5cf5335 100644
--- a/src/lib/evas/common/evas_image_main.c
+++ b/src/lib/evas/common/evas_image_main.c
@@ -28,6 +28,7 @@ static Evas_Cache_Image * eci = NULL;
28static Evas_Cache2 * eci2 = NULL; 28static Evas_Cache2 * eci2 = NULL;
29#endif 29#endif
30static int reference = 0; 30static int reference = 0;
31static int evas_image_no_mmap = -1;
31 32
32/* static RGBA_Image *evas_rgba_line_buffer = NULL; */ 33/* static RGBA_Image *evas_rgba_line_buffer = NULL; */
33 34
@@ -125,6 +126,14 @@ _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h,
125 int siz, block_size = 8; 126 int siz, block_size = 8;
126 Eina_Bool reset_borders = EINA_TRUE; 127 Eina_Bool reset_borders = EINA_TRUE;
127 128
129 if (EINA_UNLIKELY(evas_image_no_mmap == -1))
130 {
131 const char *s = getenv("EVAS_IMAGE_NO_MMAP");
132 evas_image_no_mmap = s && (atoi(s));
133 if (evas_image_no_mmap)
134 WRN("EVAS_IMAGE_NO_MMAP is set, use this only for debugging purposes!");
135 }
136
128 switch (cspace) 137 switch (cspace)
129 { 138 {
130 case EVAS_COLORSPACE_GRY8: siz = w * h * sizeof(DATA8); break; 139 case EVAS_COLORSPACE_GRY8: siz = w * h * sizeof(DATA8); break;
@@ -162,7 +171,8 @@ _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h,
162 if (b) *b = 0; 171 if (b) *b = 0;
163 } 172 }
164 173
165 if (siz < PAGE_SIZE) return siz; 174 if ((siz < PAGE_SIZE) || evas_image_no_mmap)
175 return siz;
166 176
167 return ALIGN_TO_PAGE(siz); 177 return ALIGN_TO_PAGE(siz);
168 178
@@ -187,7 +197,7 @@ _evas_common_rgba_image_surface_mmap(Image_Entry *ie, unsigned int w, unsigned i
187 if (siz < 0) 197 if (siz < 0)
188 return NULL; 198 return NULL;
189 199
190 if (siz < PAGE_SIZE) 200 if ((siz < PAGE_SIZE) || evas_image_no_mmap)
191 return malloc(siz); 201 return malloc(siz);
192 202
193 if (siz > ((HUGE_PAGE_SIZE * 75) / 100)) 203 if (siz > ((HUGE_PAGE_SIZE * 75) / 100))
@@ -211,7 +221,7 @@ _evas_common_rgba_image_surface_munmap(void *data, unsigned int w, unsigned int
211 size_t siz; 221 size_t siz;
212 222
213 siz = _evas_common_rgba_image_surface_size(w, h, cspace, NULL, NULL, NULL, NULL); 223 siz = _evas_common_rgba_image_surface_size(w, h, cspace, NULL, NULL, NULL, NULL);
214 if (siz < PAGE_SIZE) 224 if ((siz < PAGE_SIZE) || evas_image_no_mmap)
215 free(data); 225 free(data);
216 else 226 else
217 munmap(data, siz); 227 munmap(data, siz);