cedric pushed a commit to branch master.

commit 46b7baa3790e700c941c62431e3e2c06ef5550bb
Author: Jean-Philippe Andre <[email protected]>
Date:   Wed Jul 3 15:49:59 2013 +0900

    evas/cserve2: merge SETOPTS into OPEN
    
    When opening an image, OPEN and SETOPTS were always sent
    consecutively. Merging these two messages may improve the
    performance a bit (not measured), but also simplify the
    whole thing.
    
    Note: cserve2 debug tools have not been fixed yet.
---
 src/bin/evas/evas_cserve2.h             |  6 +--
 src/bin/evas/evas_cserve2_cache.c       | 84 +++++++++++++++++---------------
 src/bin/evas/evas_cserve2_client.c      | 21 ++------
 src/bin/evas/evas_cserve2_main.c        | 86 +++++++++++----------------------
 src/bin/evas/evas_cserve2_slave.c       | 21 +++-----
 src/lib/evas/cache2/evas_cache2.c       |  2 +-
 src/lib/evas/cserve2/evas_cs2.h         | 20 ++------
 src/lib/evas/cserve2/evas_cs2_client.c  | 77 ++++++-----------------------
 src/lib/evas/cserve2/evas_cs2_private.h |  2 +-
 9 files changed, 110 insertions(+), 209 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index ac7ba0a..52232f0 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -79,11 +79,9 @@ typedef enum {
 } Slave_Command;
 
 struct _Slave_Msg_Image_Open {
-   Eina_Bool has_opts : 1;
    Eina_Bool has_loader_data : 1;
    // Optionally followed by:
-   // Evas_Image_Load_Opts opts;
-   // const char *loader;
+   // const char loader[];
 };
 
 struct _Slave_Msg_Image_Opened {
@@ -293,7 +291,7 @@ void cserve2_cache_client_new(Client *client);
 void cserve2_cache_client_del(Client *client);
 int cserve2_cache_file_open(Client *client, unsigned int client_file_id, const 
char *path, const char *key, unsigned int rid);
 void cserve2_cache_file_close(Client *client, unsigned int client_file_id);
-int cserve2_cache_image_opts_set(Client *client, Msg_Setopts *msg);
+int cserve2_cache_image_opts_set(Client *client, int rid, unsigned int 
file_id, unsigned int image_id, Evas_Image_Load_Opts *opts);
 void cserve2_rgba_image_scale_do(void *src_data, void *dst_data, int src_x, 
int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, 
int alpha, int smooth);
 void cserve2_cache_image_load(Client *client, unsigned int client_image_id, 
unsigned int rid);
 void cserve2_cache_image_preload(Client *client, unsigned int client_image_id, 
unsigned int rid);
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index ca9c2b9..21e5ecf 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -594,15 +594,15 @@ _img_opts_id_get(Image_Data *im, char *buf, int size)
 {
    uintptr_t image_id;
 
-   // FIXME: Add degree here?
    snprintf(buf, size,
-            "%u:%0.3f:%dx%d:%d:%d,%d+%dx%d:!([%d,%d:%dx%d]-[%dx%d:%d]):%d",
+            "%u:%0.3f:%dx%d:%d:%d,%d+%dx%d:!([%d,%d:%dx%d]-[%dx%d:%d]):%d:%d",
             im->file_id, im->opts.dpi, im->opts.w, im->opts.h,
             im->opts.scale_down_by, im->opts.region.x, im->opts.region.y,
             im->opts.region.w, im->opts.region.h,
             im->opts.scale_load.src_x, im->opts.scale_load.src_y,
             im->opts.scale_load.src_w, im->opts.scale_load.src_h,
-            im->opts.scale_load.dst_w, im->opts.scale_load.dst_h, 
im->opts.scale_load.smooth,
+            im->opts.scale_load.dst_w, im->opts.scale_load.dst_h,
+            im->opts.scale_load.smooth, im->opts.degree,
             im->opts.orientation);
 
    image_id = (uintptr_t)eina_hash_find(image_ids, buf);
@@ -1039,23 +1039,25 @@ cserve2_cache_client_del(Client *client)
 }
 
 static Image_Data *
-_image_msg_new(Client *client, Msg_Setopts *msg)
+_image_msg_new(Client *client, int rid,
+               unsigned int file_id, unsigned int image_id,
+               Evas_Image_Load_Opts *opts)
 {
    Reference *ref;
    Image_Data *im_entry;
 
-   ref = eina_hash_find(client->files.referencing, &msg->file_id);
+   ref = eina_hash_find(client->files.referencing, &file_id);
    if (!ref)
      {
         ERR("Couldn't find file id: %d, for image id: %d",
-            msg->file_id, msg->image_id);
-        cserve2_client_error_send(client, msg->base.rid,
+            file_id, image_id);
+        cserve2_client_error_send(client, rid,
                                   CSERVE2_INVALID_CACHE);
         return NULL;
      }
    if (((File_Data *)ref->entry)->invalid)
      {
-        cserve2_client_error_send(client, msg->base.rid,
+        cserve2_client_error_send(client, rid,
                                   CSERVE2_FILE_CHANGED);
         return NULL;
      }
@@ -1064,24 +1066,27 @@ _image_msg_new(Client *client, Msg_Setopts *msg)
    im_entry->base.type = CSERVE2_IMAGE_DATA;
    im_entry->file_id = ref->entry->id;
    im_entry->file = (File_Data *)ref->entry;
-   im_entry->opts.dpi = msg->opts.dpi;
-   im_entry->opts.w = msg->opts.w;
-   im_entry->opts.h = msg->opts.h;
-   im_entry->opts.scale_down_by = msg->opts.scale_down_by;
-   im_entry->opts.region.x = msg->opts.region.x;
-   im_entry->opts.region.y = msg->opts.region.y;
-   im_entry->opts.region.w = msg->opts.region.w;
-   im_entry->opts.region.h = msg->opts.region.h;
-   im_entry->opts.scale_load.src_x = msg->opts.scale_load.src_x;
-   im_entry->opts.scale_load.src_y = msg->opts.scale_load.src_y;
-   im_entry->opts.scale_load.src_w = msg->opts.scale_load.src_w;
-   im_entry->opts.scale_load.src_h = msg->opts.scale_load.src_h;
-   im_entry->opts.scale_load.dst_w = msg->opts.scale_load.dst_w;
-   im_entry->opts.scale_load.dst_h = msg->opts.scale_load.dst_h;
-   im_entry->opts.scale_load.smooth = msg->opts.scale_load.smooth;
-   im_entry->opts.scale_load.scale_hint = msg->opts.scale_load.scale_hint;
-   im_entry->opts.degree = msg->opts.degree;
-   im_entry->opts.orientation = msg->opts.orientation;
+   if (opts)
+     {
+        im_entry->opts.dpi = opts->dpi;
+        im_entry->opts.w = opts->w;
+        im_entry->opts.h = opts->h;
+        im_entry->opts.scale_down_by = opts->scale_down_by;
+        im_entry->opts.region.x = opts->region.x;
+        im_entry->opts.region.y = opts->region.y;
+        im_entry->opts.region.w = opts->region.w;
+        im_entry->opts.region.h = opts->region.h;
+        im_entry->opts.scale_load.src_x = opts->scale_load.src_x;
+        im_entry->opts.scale_load.src_y = opts->scale_load.src_y;
+        im_entry->opts.scale_load.src_w = opts->scale_load.src_w;
+        im_entry->opts.scale_load.src_h = opts->scale_load.src_h;
+        im_entry->opts.scale_load.dst_w = opts->scale_load.dst_w;
+        im_entry->opts.scale_load.dst_h = opts->scale_load.dst_h;
+        im_entry->opts.scale_load.smooth = opts->scale_load.smooth;
+        im_entry->opts.scale_load.scale_hint = opts->scale_load.scale_hint;
+        im_entry->opts.degree = opts->degree;
+        im_entry->opts.orientation = opts->orientation;
+     }
 
    return im_entry;
 }
@@ -2080,7 +2085,9 @@ cserve2_cache_file_close(Client *client, unsigned int 
client_file_id)
 }
 
 int
-cserve2_cache_image_opts_set(Client *client, Msg_Setopts *msg)
+cserve2_cache_image_opts_set(Client *client, int rid,
+                             unsigned int file_id, unsigned int 
client_image_id,
+                             Evas_Image_Load_Opts *opts)
 {
    Image_Data *entry;
    File_Data *fentry = NULL;
@@ -2088,10 +2095,10 @@ cserve2_cache_image_opts_set(Client *client, 
Msg_Setopts *msg)
    unsigned int image_id;
    char buf[4096];
 
-   oldref = eina_hash_find(client->images.referencing, &msg->image_id);
+   oldref = eina_hash_find(client->images.referencing, &client_image_id);
 
    // search whether the image is already loaded by another client
-   entry = _image_msg_new(client, msg);
+   entry = _image_msg_new(client, rid, file_id, client_image_id, opts);
    if (!entry)
      return -1;
    image_id = _img_opts_id_get(entry, buf, sizeof(buf));
@@ -2099,14 +2106,13 @@ cserve2_cache_image_opts_set(Client *client, 
Msg_Setopts *msg)
      {  // if so, just update the references
         free(entry);
         DBG("found image_id %d for client image id %d",
-            image_id, msg->image_id);
+            image_id, client_image_id);
         entry = eina_hash_find(image_entries, &image_id);
         if (!entry)
           {
              ERR("image id %d is in file_ids hash, but not in entries hash"
-                 "with entry id %d.", msg->image_id, image_id);
-             cserve2_client_error_send(client, msg->base.rid,
-                                       CSERVE2_INVALID_CACHE);
+                 "with entry id %d.", client_image_id, image_id);
+             cserve2_client_error_send(client, rid, CSERVE2_INVALID_CACHE);
              return -1;
           }
 
@@ -2123,12 +2129,12 @@ cserve2_cache_image_opts_set(Client *client, 
Msg_Setopts *msg)
         if (oldref && (oldref->entry->id == image_id))
           return 0;
 
-        ref = _entry_reference_add((Entry *)entry, client, msg->image_id);
+        ref = _entry_reference_add((Entry *)entry, client, client_image_id);
 
         if (oldref)
-          eina_hash_del_by_key(client->images.referencing, &msg->image_id);
+          eina_hash_del_by_key(client->images.referencing, &client_image_id);
 
-        eina_hash_add(client->images.referencing, &msg->image_id, ref);
+        eina_hash_add(client->images.referencing, &client_image_id, ref);
 
         return 0;
      }
@@ -2140,11 +2146,11 @@ cserve2_cache_image_opts_set(Client *client, 
Msg_Setopts *msg)
    entry->base.id = image_id;
    eina_hash_add(image_entries, &image_id, entry);
    eina_hash_add(image_ids, buf, (void *)(intptr_t)image_id);
-   ref = _entry_reference_add((Entry *)entry, client, msg->image_id);
+   ref = _entry_reference_add((Entry *)entry, client, client_image_id);
 
    if (oldref)
-     eina_hash_del_by_key(client->images.referencing, &msg->image_id);
-   eina_hash_add(client->images.referencing, &msg->image_id, ref);
+     eina_hash_del_by_key(client->images.referencing, &client_image_id);
+   eina_hash_add(client->images.referencing, &client_image_id, ref);
 
    fentry = entry->file;
    fentry->images = eina_list_append(fentry->images, entry);
diff --git a/src/bin/evas/evas_cserve2_client.c 
b/src/bin/evas/evas_cserve2_client.c
index 7a377df..071a10c 100644
--- a/src/bin/evas/evas_cserve2_client.c
+++ b/src/bin/evas/evas_cserve2_client.c
@@ -67,6 +67,8 @@ parse_input_open(int *size)
    char *buf;
    int file_id;
 
+   // TODO: Add load opts
+
    _read_line(line, sizeof(line));
    path_len = _read_line(path, sizeof(path));
    key_len = _read_line(key, sizeof(key));
@@ -88,11 +90,9 @@ parse_input_open(int *size)
    *size = sizeof(msg) + path_len + key_len;
 
    return buf;
-}
 
-static void *
-parse_input_setopts(int *size)
-{
+#if 0
+   // TODO: Adapt the following code
    Msg_Setopts *msg;
    char line[4096];
    int file_id, image_id;
@@ -183,6 +183,7 @@ parse_input_setopts(int *size)
    *size = sizeof(*msg);
 
    return msg;
+#endif
 }
 
 static void *
@@ -283,13 +284,6 @@ parse_answer_opened(const void *buf)
 }
 
 static void
-parse_answer_setoptsed(const void *buf)
-{
-   const Msg_Setoptsed *msg = buf;
-   printf("SETOPTSED rid = %d\n", msg->base.rid);
-}
-
-static void
 parse_answer_loaded(const void *buf)
 {
    const Msg_Loaded *msg = buf;
@@ -321,9 +315,6 @@ parse_answer(const void *buf)
       case CSERVE2_OPENED:
          parse_answer_opened(buf);
          break;
-      case CSERVE2_SETOPTSED:
-         parse_answer_setoptsed(buf);
-         break;
       case CSERVE2_LOADED:
          parse_answer_loaded(buf);
          break;
@@ -342,8 +333,6 @@ static struct {
 } _msg_types[] = {
    { "OPEN", CSERVE2_OPEN, parse_input_open },
    { "OPENED", CSERVE2_OPENED, NULL },
-   { "SETOPTS", CSERVE2_SETOPTS, parse_input_setopts },
-   { "SETOPTSED", CSERVE2_SETOPTSED, NULL },
    { "LOAD", CSERVE2_LOAD, parse_input_load },
    { "LOADED", CSERVE2_LOADED, NULL },
    { "PRELOAD", CSERVE2_PRELOAD, parse_input_preload },
diff --git a/src/bin/evas/evas_cserve2_main.c b/src/bin/evas/evas_cserve2_main.c
index 075fefc..a71c864 100644
--- a/src/bin/evas/evas_cserve2_main.c
+++ b/src/bin/evas/evas_cserve2_main.c
@@ -36,21 +36,6 @@ cserve2_client_error_send(Client *client, unsigned int rid, 
int error_code)
 }
 
 static void
-_cserve2_client_image_setoptsed(Client *client, unsigned int rid)
-{
-   int size;
-   Msg_Setoptsed msg;
-
-   memset(&msg, 0, sizeof(msg));
-   msg.base.rid = rid;
-   msg.base.type = CSERVE2_SETOPTSED;
-
-   size = sizeof(msg);
-   cserve2_client_send(client, &size, sizeof(size));
-   cserve2_client_send(client, &msg, size);
-}
-
-static void
 _cserve2_client_close(Client *client)
 {
    Msg_Close *msg = (Msg_Close *)client->msg.buf;
@@ -88,40 +73,12 @@ _cserve2_client_load(Client *client)
 {
    Msg_Load *msg = (Msg_Load *)client->msg.buf;
 
-   INF("Received LOAD command: RID=%d, Image_ID: %d", msg->base.rid, 
msg->image_id);
+   INF("Received LOAD command: RID=%d, Image_ID: %d",
+       msg->base.rid, msg->image_id);
    cserve2_cache_image_load(client, msg->image_id, msg->base.rid);
 }
 
 static void
-_cserve2_client_setopts(Client *client)
-{
-   Msg_Setopts *msg = (Msg_Setopts *)client->msg.buf;
-
-   INF("Received SETOPTS command: RID=%d", msg->base.rid);
-   INF("File_ID: %d, Image_ID: %d", msg->file_id, msg->image_id);
-   INF("Load Options:");
-   INF("\tdpi: %03.1f", msg->opts.dpi);
-   INF("\tsize: %dx%d", msg->opts.w, msg->opts.h);
-   INF("\tscale down: %d", msg->opts.scale_down_by);
-   INF("\tregion: %d,%d + %dx%d",
-       msg->opts.region.x, msg->opts.region.y, msg->opts.region.w, 
msg->opts.region.h);
-   INF("\toriginal image's source coord: %d,%d",
-       msg->opts.scale_load.src_x, msg->opts.scale_load.src_y);
-   INF("\toriginal image size: %dx%d",
-       msg->opts.scale_load.src_w, msg->opts.scale_load.src_h);
-   INF("\tscale size: %dx%d", msg->opts.scale_load.dst_w, 
msg->opts.scale_load.dst_h);
-   INF("\tscale smooth: %d", msg->opts.scale_load.smooth);
-   INF("\tscale hint: %d", msg->opts.scale_load.scale_hint);
-   INF("\tdegree: %d", msg->opts.degree);
-   INF("\torientation: %d", msg->opts.orientation);
-
-   if (cserve2_cache_image_opts_set(client, msg) != 0)
-     return;
-
-   _cserve2_client_image_setoptsed(client, msg->base.rid);
-}
-
-static void
 _cserve2_client_open(Client *client)
 {
    Msg_Open *msg = (Msg_Open *)client->msg.buf;
@@ -137,17 +94,33 @@ _cserve2_client_open(Client *client)
    cserve2_cache_file_open(client, msg->file_id, path, key, msg->base.rid);
 
    if (!msg->has_load_opts)
+     cserve2_cache_image_opts_set(client, msg->base.rid,
+                                  msg->file_id, msg->image_id, NULL);
+   else
      {
-        /* FIXME: We should remove this fake call to setopts and do the
-         * appropriate work instead. (split functions) */
-        Msg_Setopts optsmsg;
-
-        memset(&optsmsg, 0, sizeof(optsmsg));
-        optsmsg.base.rid  = msg->base.rid;
-        optsmsg.base.type = CSERVE2_SETOPTS;
-        optsmsg.file_id   = msg->file_id;
-        optsmsg.image_id  = msg->image_id;
-        cserve2_cache_image_opts_set(client, &optsmsg);
+        // FIXME: Check message size first?
+        Evas_Image_Load_Opts *opts =
+              (Evas_Image_Load_Opts*) (key + strlen(key) + 1);
+
+        DBG("Load Options:");
+        DBG("\tdpi: %03.1f", opts->dpi);
+        DBG("\tsize: %dx%d", opts->w, opts->h);
+        DBG("\tscale down: %d", opts->scale_down_by);
+        DBG("\tregion: %d,%d + %dx%d",
+            opts->region.x, opts->region.y, opts->region.w, opts->region.h);
+        DBG("\toriginal image's source coord: %d,%d",
+            opts->scale_load.src_x, opts->scale_load.src_y);
+        DBG("\toriginal image size: %dx%d",
+            opts->scale_load.src_w, opts->scale_load.src_h);
+        DBG("\tscale size: %dx%d",
+            opts->scale_load.dst_w, opts->scale_load.dst_h);
+        DBG("\tscale smooth: %d", opts->scale_load.smooth);
+        DBG("\tscale hint: %d", opts->scale_load.scale_hint);
+        DBG("\tdegree: %d", opts->degree);
+        DBG("\torientation: %d", opts->orientation);
+
+        cserve2_cache_image_opts_set(client, msg->base.rid,
+                                     msg->file_id, msg->image_id, opts);
      }
 }
 
@@ -238,9 +211,6 @@ cserve2_command_run(Client *client, Message_Type type)
       case CSERVE2_OPEN:
          _cserve2_client_open(client);
          break;
-      case CSERVE2_SETOPTS:
-         _cserve2_client_setopts(client);
-         break;
       case CSERVE2_LOAD:
          _cserve2_client_load(client);
          break;
diff --git a/src/bin/evas/evas_cserve2_slave.c 
b/src/bin/evas/evas_cserve2_slave.c
index f4948a0..a5391e4 100644
--- a/src/bin/evas/evas_cserve2_slave.c
+++ b/src/bin/evas/evas_cserve2_slave.c
@@ -336,7 +336,7 @@ _image_file_header(Eina_File *fd, Eina_Stringshare *key, 
Evas_Image_Load_Opts *l
 }
 
 static Error_Type
-image_open(const char *file, const char *key, Evas_Image_Load_Opts *load_opts,
+image_open(const char *file, const char *key,
            Slave_Msg_Image_Opened *result, const char **use_loader)
 {
    Evas_Module *module;
@@ -346,6 +346,9 @@ image_open(const char *file, const char *key, 
Evas_Image_Load_Opts *load_opts,
    unsigned int i;
    Error_Type ret = CSERVE2_NONE;
    Eina_Stringshare *skey = eina_stringshare_add(key);
+   Evas_Image_Load_Opts load_opts;
+
+   memset(&load_opts, 0, sizeof(load_opts));
 
    fd = eina_file_open(file, EINA_FALSE);
    if (!fd)
@@ -360,7 +363,7 @@ image_open(const char *file, const char *key, 
Evas_Image_Load_Opts *load_opts,
    module = evas_module_find_type(EVAS_MODULE_TYPE_IMAGE_LOADER, loader);
    if (module)
      {
-        if (_image_file_header(fd, skey, load_opts, result, module))
+        if (_image_file_header(fd, skey, &load_opts, result, module))
           goto success;
      }
 
@@ -380,7 +383,7 @@ try_extension:
    if (loader)
      {
         module = evas_module_find_type(EVAS_MODULE_TYPE_IMAGE_LOADER, loader);
-        if (_image_file_header(fd, skey, load_opts, result, module))
+        if (_image_file_header(fd, skey, &load_opts, result, module))
           goto success;
         loader = NULL;
         module = NULL;
@@ -392,7 +395,7 @@ try_extension:
         loader = loaders_name[i];
         module = evas_module_find_type(EVAS_MODULE_TYPE_IMAGE_LOADER, loader);
         if (!module) continue;
-        if (_image_file_header(fd, skey, load_opts, result, module))
+        if (_image_file_header(fd, skey, &load_opts, result, module))
           goto success;
      }
 
@@ -507,7 +510,6 @@ handle_image_open(int wfd, void *params)
 {
    Slave_Msg_Image_Open *p;
    Slave_Msg_Image_Opened result;
-   Evas_Image_Load_Opts opts;
    Error_Type err;
    const char *loader = NULL, *file, *key, *ptr;
    char *resp;
@@ -517,18 +519,11 @@ handle_image_open(int wfd, void *params)
    file = (const char *)(p + sizeof(Slave_Msg_Image_Open));
    key = file + strlen(file) + 1;
    ptr = key + strlen(key) + 1;
-   if (p->has_opts)
-     {
-        //opts = (Evas_Image_Load_Opts *)ptr;
-        memcpy(&opts, ptr, sizeof(opts));
-        ptr += sizeof(opts);
-     }
-   else memset(&opts, 0, sizeof(opts));
    if (p->has_loader_data)
      loader = ptr;
 
    memset(&result, 0, sizeof(result));
-   if ((err = image_open(file, key, &opts, &result, &loader))
+   if ((err = image_open(file, key, &result, &loader))
        != CSERVE2_NONE)
      {
         printf("OPEN failed at %s:%d\n", __FUNCTION__, __LINE__);
diff --git a/src/lib/evas/cache2/evas_cache2.c 
b/src/lib/evas/cache2/evas_cache2.c
index f753233..302c658 100644
--- a/src/lib/evas/cache2/evas_cache2.c
+++ b/src/lib/evas/cache2/evas_cache2.c
@@ -259,7 +259,7 @@ _evas_cache_image_entry_new(Evas_Cache2 *cache,
    if (lo) ie->load_opts = *lo;
    if (ie->file)
      {
-        if (!evas_cserve2_image_load(ie, ie->file, ie->key, &(ie->load_opts)))
+        if (!evas_cserve2_image_load(ie))
           {
              ERR("couldn't load '%s' '%s' with cserve2!",
                  ie->file, ie->key ? ie->key : "");
diff --git a/src/lib/evas/cserve2/evas_cs2.h b/src/lib/evas/cserve2/evas_cs2.h
index b35af47..ad36b4e 100644
--- a/src/lib/evas/cserve2/evas_cs2.h
+++ b/src/lib/evas/cserve2/evas_cs2.h
@@ -10,8 +10,6 @@
 typedef enum {
    CSERVE2_OPEN = 1,
    CSERVE2_OPENED,
-   CSERVE2_SETOPTS,
-   CSERVE2_SETOPTSED,
    CSERVE2_LOAD,
    CSERVE2_LOADED,
    CSERVE2_PRELOAD,
@@ -59,6 +57,11 @@ struct _Msg_Open {
    unsigned int image_id;
 
    Eina_Bool has_load_opts : 1;
+
+   // Followed by:
+   // const char file[];
+   // const char key[];
+   // Evas_Image_Load_Opts opts; // if has_load_opts
 };
 
 struct _Msg_Opened {
@@ -72,17 +75,6 @@ struct _Msg_Opened {
    } image;
 };
 
-struct _Msg_Setopts {
-   Msg_Base base;
-   unsigned int file_id;
-   unsigned int image_id;
-   Evas_Image_Load_Opts opts;
-};
-
-struct _Msg_Setoptsed {
-   Msg_Base base;
-};
-
 struct _Msg_Load {
    Msg_Base base;
    unsigned int image_id;
@@ -277,8 +269,6 @@ struct _Msg_Error {
 
 typedef struct _Msg_Open Msg_Open;
 typedef struct _Msg_Opened Msg_Opened;
-typedef struct _Msg_Setopts Msg_Setopts;
-typedef struct _Msg_Setoptsed Msg_Setoptsed;
 typedef struct _Msg_Load Msg_Load;
 typedef struct _Msg_Loaded Msg_Loaded;
 typedef struct _Msg_Preload Msg_Preload;
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index ccfc456..d2cb490 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -221,7 +221,6 @@ _server_send(const void *buf, int size, Op_Callback cb, 
void *data)
    switch (msg->type)
      {
       case CSERVE2_OPEN:
-      case CSERVE2_SETOPTS:
       case CSERVE2_LOAD:
       case CSERVE2_PRELOAD:
       case CSERVE2_FONT_LOAD:
@@ -616,7 +615,8 @@ _build_absolute_path(const char *path, char buf[], int size)
 }
 
 static unsigned int
-_image_open_server_send(Image_Entry *ie, const char *file, const char *key, 
Eina_Bool has_load_opts)
+_image_open_server_send(Image_Entry *ie, const char *file, const char *key,
+                        Evas_Image_Load_Opts *opts)
 {
    int flen, klen;
    int size;
@@ -656,7 +656,6 @@ _image_open_server_send(Image_Entry *ie, const char *file, 
const char *key, Eina
         return 0;
      }
 
-
    memset(&msg_open, 0, sizeof(msg_open));
 
    fentry->file_id = ++_file_id;
@@ -667,10 +666,12 @@ _image_open_server_send(Image_Entry *ie, const char 
*file, const char *key, Eina
    msg_open.file_id = fentry->file_id;
    msg_open.path_offset = 0;
    msg_open.key_offset = flen;
-   msg_open.has_load_opts = has_load_opts;
+   msg_open.has_load_opts = (opts != NULL);
    msg_open.image_id = ++_data_id;
 
    size = sizeof(msg_open) + flen + klen;
+   if (opts)
+     size += sizeof(*opts);
    buf = malloc(size);
    if (!buf)
      {
@@ -681,6 +682,8 @@ _image_open_server_send(Image_Entry *ie, const char *file, 
const char *key, Eina
    memcpy(buf, &msg_open, sizeof(msg_open));
    memcpy(buf + sizeof(msg_open), filebuf, flen);
    memcpy(buf + sizeof(msg_open) + flen, key, klen);
+   if (opts)
+     memcpy(buf + sizeof(msg_open) + flen + klen, opts, sizeof(*opts));
 
    if (!_server_send(buf, size, _image_opened_cb, ie))
      {
@@ -700,55 +703,6 @@ _image_open_server_send(Image_Entry *ie, const char *file, 
const char *key, Eina
    return msg_open.base.rid;
 }
 
-static unsigned int
-_image_setopts_server_send(Image_Entry *ie)
-{
-   File_Entry *fentry = ie->data1;
-   Data_Entry *dentry = ie->data2;
-   Msg_Setopts msg;
-
-   if (cserve2_init == 0)
-     return 0;
-
-   if (!fentry || !dentry)
-     return 0;
-
-   memset(&msg, 0, sizeof(msg));
-
-   msg.base.rid = _next_rid();
-   msg.base.type = CSERVE2_SETOPTS;
-   msg.file_id = fentry->file_id;
-   msg.image_id = dentry->image_id;
-
-   msg.opts.scale_down_by = ie->load_opts.scale_down_by;
-   msg.opts.dpi = ie->load_opts.dpi;
-   msg.opts.w = ie->load_opts.w;
-   msg.opts.h = ie->load_opts.h;
-   msg.opts.region.x = ie->load_opts.region.x;
-   msg.opts.region.y = ie->load_opts.region.y;
-   msg.opts.region.w = ie->load_opts.region.w;
-   msg.opts.region.h = ie->load_opts.region.h;
-   msg.opts.scale_load.src_x = ie->load_opts.scale_load.src_x;
-   msg.opts.scale_load.src_y = ie->load_opts.scale_load.src_y;
-   msg.opts.scale_load.src_w = ie->load_opts.scale_load.src_w;
-   msg.opts.scale_load.src_h = ie->load_opts.scale_load.src_h;
-   msg.opts.scale_load.dst_w = ie->load_opts.scale_load.dst_w;
-   msg.opts.scale_load.dst_h = ie->load_opts.scale_load.dst_h;
-   msg.opts.scale_load.smooth = ie->load_opts.scale_load.smooth;
-   msg.opts.scale_load.scale_hint = ie->load_opts.scale_load.scale_hint;
-   msg.opts.degree = ie->load_opts.degree;
-   msg.opts.orientation = ie->load_opts.orientation;
-
-   if (!_server_send(&msg, sizeof(msg), NULL, NULL))
-     {
-        free(dentry);
-        ie->data2 = NULL;
-        return 0;
-     }
-
-   return msg.base.rid;
-}
-
 unsigned int
 _image_load_server_send(Image_Entry *ie)
 {
@@ -887,26 +841,25 @@ _image_unload_server_send(Image_Entry *ie)
 }
 
 Eina_Bool
-evas_cserve2_image_load(Image_Entry *ie, const char *file, const char *key, 
Evas_Image_Load_Opts *lopt)
+evas_cserve2_image_load(Image_Entry *ie)
 {
    unsigned int rid;
-   Eina_Bool has_load_opts;
+   const char *file, *key;
+   Evas_Image_Load_Opts *opts = NULL;
 
    if (!ie)
      return EINA_FALSE;
 
-   has_load_opts = !_memory_zero_cmp(lopt, sizeof(*lopt));
-   rid = _image_open_server_send(ie, file, key, has_load_opts);
+   file = ie->file;
+   key = ie->key;
+   if (!_memory_zero_cmp(&ie->load_opts, sizeof(ie->load_opts)))
+     opts = &ie->load_opts;
+   rid = _image_open_server_send(ie, file, key, opts);
    if (!rid)
      return EINA_FALSE;
 
    ie->open_rid = rid;
 
-   if (has_load_opts)
-     _image_setopts_server_send(ie);
-
-   // _server_dispatch_until(rid);
-
    if (ie->data1)
      return EINA_TRUE;
    else
diff --git a/src/lib/evas/cserve2/evas_cs2_private.h 
b/src/lib/evas/cserve2/evas_cs2_private.h
index b055d1b..1cb59a3 100644
--- a/src/lib/evas/cserve2/evas_cs2_private.h
+++ b/src/lib/evas/cserve2/evas_cs2_private.h
@@ -23,7 +23,7 @@ typedef struct _Font_Entry Font_Entry;
 int evas_cserve2_init(void);
 int evas_cserve2_shutdown(void);
 EAPI int evas_cserve2_use_get(void);
-Eina_Bool evas_cserve2_image_load(Image_Entry *ie, const char *file, const 
char *key, Evas_Image_Load_Opts *lopt);
+Eina_Bool evas_cserve2_image_load(Image_Entry *ie);
 int evas_cserve2_image_load_wait(Image_Entry *ie);
 Eina_Bool evas_cserve2_image_data_load(Image_Entry *ie);
 int evas_cserve2_image_load_data_wait(Image_Entry *ie);

-- 

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

Reply via email to