summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-09-05 17:44:10 +0900
committerCedric Bail <cedric.bail@free.fr>2013-10-17 20:48:25 +0900
commitf758f65e7f83591f826c6838e0dba27663150f43 (patch)
treee793b1ea857b33fc99e7db5297e21a6f74200879
parentd4e3f815030dc58798671390303425d54958e329 (diff)
downloadefl-f758f65e7f83591f826c6838e0dba27663150f43.tar.gz
evas/cserve2: Drop pre-emptive load of large images
When the image is too large, let's not preload it unless specifically requested by the application. Value 320x320 is completely arbitrary.
-rw-r--r--src/bin/evas/evas_cserve2.h2
-rw-r--r--src/bin/evas/evas_cserve2_cache.c21
-rw-r--r--src/bin/evas/evas_cserve2_requests.c32
-rw-r--r--src/bin/evas/evas_cserve2_shm_debug.c7
4 files changed, 59 insertions, 3 deletions
diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index fda088fbce..3b0ec1544c 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -331,6 +331,8 @@ void cserve2_request_cancel(Slave_Request *req, Client *client, Error_Type err);
void cserve2_request_cancel_all(Slave_Request *req, Error_Type err);
void cserve2_requests_init(void);
void cserve2_requests_shutdown(void);
+void cserve2_request_dependents_drop(Slave_Request *req, Slave_Request_Type type);
+void cserve2_entry_request_drop(void *data, Slave_Request_Type type);
void cserve2_font_init(void);
void cserve2_font_shutdown(void);
diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c
index 83923d48c9..30f4cf530f 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -154,6 +154,8 @@ static int unused_mem_usage = 0;
static int max_font_usage = 10 * 4 * 1024; /* in kbytes */
static int font_mem_usage = 0;
+#define MAX_PREEMPTIVE_LOAD_SIZE (320*320*4)
+
#ifdef DEBUG_LOAD_TIME
static int
_timeval_sub(const struct timeval *tv2, const struct timeval *tv1)
@@ -603,8 +605,10 @@ static Msg_Opened *
_open_request_response(Entry *entry, Slave_Msg_Image_Opened *resp, int *size)
{
File_Data *fd;
+ Slave_Request *req;
_entry_load_finish(entry);
+ req = entry->request;
entry->request = NULL;
fd = _file_data_find(entry->id);
@@ -629,9 +633,26 @@ _open_request_response(Entry *entry, Slave_Msg_Image_Opened *resp, int *size)
}
fd->valid = EINA_TRUE;
+
+ // If the image is too large, cancel pre-emptive load.
+ if (fd->w * fd->h * 4 >= MAX_PREEMPTIVE_LOAD_SIZE)
+ {
+ DBG("Not pre-loading this image ");
+ cserve2_request_dependents_drop(req, CSERVE2_REQ_IMAGE_SPEC_LOAD);
+ }
+
return _image_opened_msg_create(fd, size);
}
+void
+cserve2_entry_request_drop(void *data, Slave_Request_Type type EINA_UNUSED)
+{
+ Entry *e = data;
+
+ if (!e) return;
+ e->request = NULL;
+}
+
static void
_request_failed(Entry *e, Error_Type type EINA_UNUSED)
{
diff --git a/src/bin/evas/evas_cserve2_requests.c b/src/bin/evas/evas_cserve2_requests.c
index ab63db88f5..9a8eb2f4c0 100644
--- a/src/bin/evas/evas_cserve2_requests.c
+++ b/src/bin/evas/evas_cserve2_requests.c
@@ -289,6 +289,38 @@ cserve2_request_cancel_all(Slave_Request *req, Error_Type err)
}
void
+cserve2_request_dependents_drop(Slave_Request *req, Slave_Request_Type type)
+{
+ Slave_Request *dep;
+ Eina_List *l, *l_next;
+
+ if (type != CSERVE2_REQ_IMAGE_SPEC_LOAD)
+ {
+ CRIT("Only CSERVE2_REQ_IMAGE_SPEC_LOAD is supported.");
+ return;
+ }
+
+ EINA_LIST_FOREACH_SAFE(req->dependents, l, l_next, dep)
+ {
+ if (dep->type == type)
+ {
+ req->dependents = eina_list_remove_list(req->dependents, l);
+
+ if (dep->processing)
+ dep->cancelled = EINA_TRUE;
+ else
+ {
+ cserve2_entry_request_drop(dep->data, type);
+ requests[type].waiting = eina_inlist_remove(
+ requests[type].waiting, EINA_INLIST_GET(dep));
+ dep->funcs->msg_free(dep->msg, dep->data);
+ free(dep);
+ }
+ }
+ }
+}
+
+void
cserve2_requests_init(void)
{
DBG("Initializing requests.");
diff --git a/src/bin/evas/evas_cserve2_shm_debug.c b/src/bin/evas/evas_cserve2_shm_debug.c
index 49bae201f0..882864618e 100644
--- a/src/bin/evas/evas_cserve2_shm_debug.c
+++ b/src/bin/evas/evas_cserve2_shm_debug.c
@@ -467,13 +467,14 @@ _images_all_print_full(void)
printf("Refcount %d\n", id->refcount);
printf("Sparse alpha %s\n"
"Unused: %s\n"
- "Load requested: %s\n",
+ "Load requested: %s\n"
+ "Valid: %s\n",
id->alpha_sparse ? "YES" : "NO",
id->unused ? "YES" : "NO",
- id->doload ? "YES" : "NO");
+ id->doload ? "YES" : "NO",
+ id->valid ? "YES" : "NO");
printf("Shm Path: '%s'\n",
id->shm_id ? _shared_string_get(id->shm_id) : "");
-
printf("LoadOpts: width %d\n", id->opts.w);
printf(" height %d\n", id->opts.h);
printf(" degree %d\n", id->opts.degree);