From ca5d174568e7ebae829899811d36f48bf0dc9d6e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 3 Jul 2013 13:32:39 +0900 Subject: [PATCH] evas/cserve2: use Evas_Image_Load_Opts directly Image_Data contained a similar struct to the standard Evas struct, let's not duplicate it uselessly. --- src/Makefile_Evas.am | 6 ++ src/bin/evas/evas_cserve2.h | 3 + src/bin/evas/evas_cserve2_cache.c | 86 ++++++++++++-------------- src/bin/evas/evas_cserve2_client.c | 32 ++++++---- src/bin/evas/evas_cserve2_main.c | 15 ++--- src/bin/evas/evas_cserve2_slave.c | 12 ++-- src/lib/evas/cserve2/evas_cs2.h | 14 +---- src/lib/evas/cserve2/evas_cs2_client.c | 27 ++++---- 8 files changed, 99 insertions(+), 96 deletions(-) diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 1682128fe5..924e0e159b 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -1017,6 +1017,7 @@ lib/evas/cserve2/evas_cs2_utils.h \ lib/evas/cserve2/evas_cs2_utils.c bin_evas_evas_cserve2_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +-I$(top_srcdir)/src/lib/evas \ -I$(top_srcdir)/src/lib/evas/include \ -I$(top_srcdir)/src/lib/evas/cserve2 \ -DPACKAGE_BIN_DIR=\"$(bindir)\" \ @@ -1030,6 +1031,7 @@ bin_evas_evas_cserve2_DEPENDENCIES = @USE_EVAS_INTERNAL_LIBS@ bin_evas_evas_cserve2_client_SOURCES = \ bin/evas/evas_cserve2_client.c bin_evas_evas_cserve2_client_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +-I$(top_srcdir)/src/lib/evas \ -I$(top_srcdir)/src/lib/evas/cserve2 \ @EINA_CFLAGS@ bin_evas_evas_cserve2_client_LDADD = @USE_EINA_LIBS@ @@ -1038,6 +1040,7 @@ bin_evas_evas_cserve2_client_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ bin_evas_evas_cserve2_usage_SOURCES = \ bin/evas/evas_cserve2_usage.c bin_evas_evas_cserve2_usage_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +-I$(top_srcdir)/src/lib/evas \ -I$(top_srcdir)/src/lib/evas/cserve2 \ @EINA_CFLAGS@ bin_evas_evas_cserve2_usage_LDADD = @USE_EINA_LIBS@ @@ -1046,6 +1049,7 @@ bin_evas_evas_cserve2_usage_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ bin_evas_evas_cserve2_debug_SOURCES = \ bin/evas/evas_cserve2_debug.c bin_evas_evas_cserve2_debug_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +-I$(top_srcdir)/src/lib/evas \ -I$(top_srcdir)/src/lib/evas/cserve2 \ @EINA_CFLAGS@ bin_evas_evas_cserve2_debug_LDADD = @USE_EINA_LIBS@ @@ -1057,6 +1061,7 @@ bin/evas/evas_cserve2_utils.c \ $(lib_evas_file_SOURCES) bin_evas_evas_cserve2_slave_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +-I$(top_srcdir)/src/lib/evas \ -I$(top_srcdir)/src/lib/evas/include \ -I$(top_srcdir)/src/lib/evas/cserve2 \ -DPACKAGE_BIN_DIR=\"$(bindir)\" \ @@ -1075,6 +1080,7 @@ bin_evas_dummy_slave_SOURCES = \ bin/evas/dummy_slave.c bin_evas_dummy_slave_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +-I$(top_srcdir)/src/lib/evas \ -I$(top_srcdir)/src/lib/evas/include \ -I$(top_srcdir)/src/lib/evas/cserve2 \ @EVAS_CFLAGS@ diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h index 48ecc5d260..ac7ba0a0d1 100644 --- a/src/bin/evas/evas_cserve2.h +++ b/src/bin/evas/evas_cserve2.h @@ -81,6 +81,9 @@ typedef enum { 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; }; struct _Slave_Msg_Image_Opened { diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c index 8090da237b..ca9c2b9b53 100644 --- a/src/bin/evas/evas_cserve2_cache.c +++ b/src/bin/evas/evas_cserve2_cache.c @@ -12,6 +12,8 @@ #include "evas_cserve2.h" #include "evas_cs2_utils.h" +#include + typedef struct _Entry Entry; typedef struct _Reference Reference; typedef struct _File_Data File_Data; @@ -61,17 +63,7 @@ struct _Image_Data { Entry base; unsigned int file_id; File_Data *file; - struct { - double dpi; // dpi < -1 - int w, h; // w and h < -1 - int scale_down; // scale_down < -1 - int rx, ry, rw, rh; // rx, ry, rw, rh < -1 - int scale_src_x, scale_src_y, scale_src_w, scale_src_h; - int scale_dst_w, scale_dst_h; - int scale_smooth; - int scale_hint; - Eina_Bool orientation; // orientation == 0 - } opts; + Evas_Image_Load_Opts opts; Shm_Handle *shm; Eina_Bool alpha_sparse : 1; Eina_Bool unused : 1; @@ -340,6 +332,7 @@ _open_request_build(File_Data *f, int *bufsize) pathlen = strlen(f->path) + 1; keylen = strlen(f->key) + 1; + memset(&msg, 0, sizeof(msg)); msg.has_loader_data = !!f->loader_data; loaderlen = msg.has_loader_data ? (strlen(f->loader_data) + 1) : 0; @@ -347,7 +340,6 @@ _open_request_build(File_Data *f, int *bufsize) buf = malloc(size); if (!buf) return NULL; - memset(&msg, 0, sizeof(msg)); memcpy(buf, &msg, sizeof(msg)); memcpy(buf + sizeof(msg), f->path, pathlen); memcpy(buf + sizeof(msg) + pathlen, f->key, keylen); @@ -457,11 +449,11 @@ _load_request_build(Image_Data *i, int *bufsize) msg.alpha = i->file->alpha; msg.opts.w = i->opts.w; msg.opts.h = i->opts.h; - msg.opts.rx = i->opts.rx; - msg.opts.ry = i->opts.ry; - msg.opts.rw = i->opts.rw; - msg.opts.rh = i->opts.rh; - msg.opts.scale_down_by = i->opts.scale_down; + msg.opts.rx = i->opts.region.x; + msg.opts.ry = i->opts.region.y; + msg.opts.rw = i->opts.region.w; + msg.opts.rh = i->opts.region.h; + msg.opts.scale_down_by = i->opts.scale_down_by; msg.opts.dpi = i->opts.dpi; msg.opts.orientation = i->opts.orientation; @@ -493,9 +485,9 @@ _load_request_build(Image_Data *i, int *bufsize) static inline Eina_Bool _scaling_needed(Image_Data *entry, Slave_Msg_Image_Loaded *resp) { - return (((entry->opts.scale_dst_w) && (entry->opts.scale_dst_h)) && - ((entry->opts.scale_dst_w != resp->w) || - (entry->opts.scale_dst_h != resp->h))); + return (((entry->opts.scale_load.dst_w) && (entry->opts.scale_load.dst_h)) && + ((entry->opts.scale_load.dst_w != resp->w) || + (entry->opts.scale_load.dst_h != resp->h))); } static int @@ -524,17 +516,17 @@ _scaling_do(Shm_Handle *scale_shm, Image_Data *entry) dst_data = scale_map + cserve2_shm_map_offset_get(scale_shm); DBG("Scaling image ([%d,%d:%dx%d] --> [%d,%d:%dx%d])", - entry->opts.scale_src_x, entry->opts.scale_src_y, - entry->opts.scale_src_w, entry->opts.scale_src_h, + entry->opts.scale_load.src_x, entry->opts.scale_load.src_y, + entry->opts.scale_load.src_w, entry->opts.scale_load.src_h, 0, 0, - entry->opts.scale_dst_w, entry->opts.scale_dst_h); + entry->opts.scale_load.dst_w, entry->opts.scale_load.dst_h); cserve2_rgba_image_scale_do(src_data, dst_data, - entry->opts.scale_src_x, entry->opts.scale_src_y, - entry->opts.scale_src_w, entry->opts.scale_src_h, + entry->opts.scale_load.src_x, entry->opts.scale_load.src_y, + entry->opts.scale_load.src_w, entry->opts.scale_load.src_h, 0, 0, - entry->opts.scale_dst_w, entry->opts.scale_dst_h, - entry->file->alpha, entry->opts.scale_smooth); + entry->opts.scale_load.dst_w, entry->opts.scale_load.dst_h, + entry->file->alpha, entry->opts.scale_load.smooth); cserve2_shm_unmap(entry->shm); cserve2_shm_unmap(scale_shm); @@ -550,7 +542,7 @@ _scaling_prepare_and_do(Image_Data *orig) DBG("Original image's shm path %s", cserve2_shm_name_get(orig->shm)); scale_shm = - cserve2_shm_request(orig->opts.scale_dst_w * orig->opts.scale_dst_h * 4); + cserve2_shm_request(orig->opts.scale_load.dst_w * orig->opts.scale_load.dst_h * 4); DBG("Scale image's shm path %s", cserve2_shm_name_get(scale_shm)); @@ -602,14 +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", im->file_id, im->opts.dpi, im->opts.w, im->opts.h, - im->opts.scale_down, im->opts.rx, im->opts.ry, - im->opts.rw, im->opts.rh, - im->opts.scale_src_x, im->opts.scale_src_y, - im->opts.scale_src_w, im->opts.scale_src_h, - im->opts.scale_dst_w, im->opts.scale_dst_h, im->opts.scale_smooth, + 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.orientation); image_id = (uintptr_t)eina_hash_find(image_ids, buf); @@ -1074,19 +1067,20 @@ _image_msg_new(Client *client, Msg_Setopts *msg) 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 = msg->opts.scale_down; - im_entry->opts.rx = msg->opts.rx; - im_entry->opts.ry = msg->opts.ry; - im_entry->opts.rw = msg->opts.rw; - im_entry->opts.rh = msg->opts.rh; - im_entry->opts.scale_src_x = msg->opts.scale_src_x; - im_entry->opts.scale_src_y = msg->opts.scale_src_y; - im_entry->opts.scale_src_w = msg->opts.scale_src_w; - im_entry->opts.scale_src_h = msg->opts.scale_src_h; - im_entry->opts.scale_dst_w = msg->opts.scale_dst_w; - im_entry->opts.scale_dst_h = msg->opts.scale_dst_h; - im_entry->opts.scale_smooth = msg->opts.scale_smooth; - im_entry->opts.scale_hint = msg->opts.scale_hint; + 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; return im_entry; diff --git a/src/bin/evas/evas_cserve2_client.c b/src/bin/evas/evas_cserve2_client.c index a36940ba8a..7a377df2f8 100644 --- a/src/bin/evas/evas_cserve2_client.c +++ b/src/bin/evas/evas_cserve2_client.c @@ -104,6 +104,7 @@ parse_input_setopts(int *size) int scale_dst_w, scale_dst_h; int scale_smooth; int scale_hint; + int degree; int orientation; // reading file_id, image_id @@ -146,6 +147,10 @@ parse_input_setopts(int *size) _read_line(line, sizeof(line)); sscanf(line, "%d", &scale_hint); + // reading degree + _read_line(line, sizeof(line)); + sscanf(line, "%d", °ree); + // reading orientation _read_line(line, sizeof(line)); sscanf(line, "%d", &orientation); @@ -159,19 +164,20 @@ parse_input_setopts(int *size) msg->opts.dpi = dpi; msg->opts.w = w; msg->opts.h = h; - msg->opts.scale_down = scale; - msg->opts.rx = rx; - msg->opts.ry = ry; - msg->opts.rw = rw; - msg->opts.rh = rh; - msg->opts.scale_src_x = scale_src_x; - msg->opts.scale_src_y = scale_src_y; - msg->opts.scale_src_w = scale_src_w; - msg->opts.scale_src_h = scale_src_h; - msg->opts.scale_dst_w = scale_dst_w; - msg->opts.scale_dst_h = scale_dst_h; - msg->opts.scale_smooth = scale_smooth; - msg->opts.scale_hint = scale_hint; + msg->opts.scale_down_by = scale; + msg->opts.region.x = rx; + msg->opts.region.y = ry; + msg->opts.region.w = rw; + msg->opts.region.h = rh; + msg->opts.scale_load.src_x = scale_src_x; + msg->opts.scale_load.src_y = scale_src_y; + msg->opts.scale_load.src_w = scale_src_w; + msg->opts.scale_load.src_h = scale_src_h; + msg->opts.scale_load.dst_w = scale_dst_w; + msg->opts.scale_load.dst_h = scale_dst_h; + msg->opts.scale_load.smooth = scale_smooth; + msg->opts.scale_load.scale_hint = scale_hint; + msg->opts.degree = degree; msg->opts.orientation = !!orientation; *size = sizeof(*msg); diff --git a/src/bin/evas/evas_cserve2_main.c b/src/bin/evas/evas_cserve2_main.c index ad71d81e0b..075fefc7a6 100644 --- a/src/bin/evas/evas_cserve2_main.c +++ b/src/bin/evas/evas_cserve2_main.c @@ -102,16 +102,17 @@ _cserve2_client_setopts(Client *client) 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); + INF("\tscale down: %d", msg->opts.scale_down_by); INF("\tregion: %d,%d + %dx%d", - msg->opts.rx, msg->opts.ry, msg->opts.rw, msg->opts.rh); + 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_src_x, msg->opts.scale_src_y); + msg->opts.scale_load.src_x, msg->opts.scale_load.src_y); INF("\toriginal image size: %dx%d", - msg->opts.scale_src_w, msg->opts.scale_src_h); - INF("\tscale size: %dx%d", msg->opts.scale_dst_w, msg->opts.scale_dst_h); - INF("\tscale smooth: %d", msg->opts.scale_smooth); - INF("\tscale hint: %d", msg->opts.scale_hint); + 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) diff --git a/src/bin/evas/evas_cserve2_slave.c b/src/bin/evas/evas_cserve2_slave.c index e19de86e8f..f4948a0187 100644 --- a/src/bin/evas/evas_cserve2_slave.c +++ b/src/bin/evas/evas_cserve2_slave.c @@ -507,8 +507,7 @@ handle_image_open(int wfd, void *params) { Slave_Msg_Image_Open *p; Slave_Msg_Image_Opened result; - Image_Load_Opts *opts = NULL; - Evas_Image_Load_Opts load_opts; + Evas_Image_Load_Opts opts; Error_Type err; const char *loader = NULL, *file, *key, *ptr; char *resp; @@ -520,15 +519,16 @@ handle_image_open(int wfd, void *params) ptr = key + strlen(key) + 1; if (p->has_opts) { - opts = (Image_Load_Opts *)ptr; - ptr += sizeof(Image_Load_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)); - _image_load_opts_copy(&load_opts, opts); - if ((err = image_open(file, key, &load_opts, &result, &loader)) + if ((err = image_open(file, key, &opts, &result, &loader)) != CSERVE2_NONE) { printf("OPEN failed at %s:%d\n", __FUNCTION__, __LINE__); diff --git a/src/lib/evas/cserve2/evas_cs2.h b/src/lib/evas/cserve2/evas_cs2.h index 9b38c75784..b35af47348 100644 --- a/src/lib/evas/cserve2/evas_cs2.h +++ b/src/lib/evas/cserve2/evas_cs2.h @@ -5,6 +5,8 @@ #ifdef EVAS_CSERVE2 +#include + typedef enum { CSERVE2_OPEN = 1, CSERVE2_OPENED, @@ -74,17 +76,7 @@ struct _Msg_Setopts { Msg_Base base; unsigned int file_id; unsigned int image_id; - struct { - double dpi; - int w, h; - int scale_down; - int rx, ry, rw, rh; - int scale_src_x, scale_src_y, scale_src_w, scale_src_h; - int scale_dst_w, scale_dst_h; - int scale_smooth; - int scale_hint; - Eina_Bool orientation; - } opts; + Evas_Image_Load_Opts opts; }; struct _Msg_Setoptsed { diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c index 4433e5507f..ccfc456b59 100644 --- a/src/lib/evas/cserve2/evas_cs2_client.c +++ b/src/lib/evas/cserve2/evas_cs2_client.c @@ -720,22 +720,23 @@ _image_setopts_server_send(Image_Entry *ie) msg.file_id = fentry->file_id; msg.image_id = dentry->image_id; - msg.opts.scale_down = ie->load_opts.scale_down_by; + 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.rx = ie->load_opts.region.x; - msg.opts.ry = ie->load_opts.region.y; - msg.opts.rw = ie->load_opts.region.w; - msg.opts.rh = ie->load_opts.region.h; - msg.opts.scale_src_x = ie->load_opts.scale_load.src_x; - msg.opts.scale_src_y = ie->load_opts.scale_load.src_y; - msg.opts.scale_src_w = ie->load_opts.scale_load.src_w; - msg.opts.scale_src_h = ie->load_opts.scale_load.src_h; - msg.opts.scale_dst_w = ie->load_opts.scale_load.dst_w; - msg.opts.scale_dst_h = ie->load_opts.scale_load.dst_h; - msg.opts.scale_smooth = ie->load_opts.scale_load.smooth; - msg.opts.scale_hint = ie->load_opts.scale_load.scale_hint; + 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))