diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2013-09-06 11:53:28 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2013-10-28 15:47:15 +0900 |
commit | 0d506a7b7369aad8376336497e755092cbe8cb40 (patch) | |
tree | 87c6926fafb4ddef6c6ca45352dc4292ddba61d5 /src/lib/evas/cserve2/evas_cs2_client.c | |
parent | 85cd382725ab877a62d935d9fb37368d4b868f59 (diff) |
evas/cserve2: Fix images indexing (File_Entry stuff)
High-level problem:
cserve2 does not support load_opts properly when opening an image.
As a result, when (pre)loading a JPEG file with specific load
options (eg. w, h, region and orientation), the image buffer might
have the wrong dimensions.
So, we need to use load_opts when computing file hash key.
And, pass these load options to the loader slave,
and use them while OPENING the image. This will set
properly the geometry.
Fixes test "Preload and Prescale" in elementary_test.
Diffstat (limited to '')
-rw-r--r-- | src/lib/evas/cserve2/evas_cs2_client.c | 80 |
1 files changed, 63 insertions, 17 deletions
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c index 566bd0655a..e6f43a73cb 100644 --- a/src/lib/evas/cserve2/evas_cs2_client.c +++ b/src/lib/evas/cserve2/evas_cs2_client.c | |||
@@ -23,6 +23,22 @@ | |||
23 | #define HKEY_LOAD_OPTS_STR_LEN 215 | 23 | #define HKEY_LOAD_OPTS_STR_LEN 215 |
24 | typedef void (*Op_Callback)(void *data, const void *msg, int size); | 24 | typedef void (*Op_Callback)(void *data, const void *msg, int size); |
25 | 25 | ||
26 | static const Evas_Image_Load_Opts empty_lo = { | ||
27 | { 0, 0, 0, 0 }, | ||
28 | { | ||
29 | 0, 0, 0, 0, | ||
30 | 0, 0, | ||
31 | 0, | ||
32 | 0 | ||
33 | }, | ||
34 | 0.0, | ||
35 | 0, 0, | ||
36 | 0, | ||
37 | 0, | ||
38 | |||
39 | EINA_FALSE | ||
40 | }; | ||
41 | |||
26 | struct _File_Entry { | 42 | struct _File_Entry { |
27 | unsigned int file_id; | 43 | unsigned int file_id; |
28 | unsigned int server_file_id; | 44 | unsigned int server_file_id; |
@@ -2053,26 +2069,45 @@ _shared_string_get(int id) | |||
2053 | do { if (!_shared_index_remap_check(&(si), sizeof(typ))) { \ | 2069 | do { if (!_shared_index_remap_check(&(si), sizeof(typ))) { \ |
2054 | CRIT("Failed to remap index"); return NULL; } } while (0) | 2070 | CRIT("Failed to remap index"); return NULL; } } while (0) |
2055 | 2071 | ||
2056 | static const char * | 2072 | |
2057 | _shared_file_data_hkey_get(char *hkey, const char *file, const char *key, | 2073 | static Eina_Bool |
2058 | size_t hkey_size) | 2074 | _evas_image_load_opts_empty(Evas_Image_Load_Opts *lo) |
2059 | { | 2075 | { |
2060 | size_t keylen = 0, filelen; | 2076 | if (!lo) return EINA_TRUE; |
2061 | 2077 | ||
2062 | if (key) keylen = strlen(key) + 1; | 2078 | return ((lo->scale_down_by == 0) |
2063 | filelen = strlen(file); | 2079 | && (lo->dpi == 0.0) |
2080 | && (lo->w == 0) && (lo->h == 0) | ||
2081 | && (lo->region.x == 0) && (lo->region.y == 0) | ||
2082 | && (lo->region.w == 0) && (lo->region.h == 0) | ||
2083 | && (lo->orientation == 0)); | ||
2084 | } | ||
2064 | 2085 | ||
2065 | if (filelen + keylen + 1 > hkey_size) | 2086 | static void |
2066 | return NULL; | 2087 | _file_hkey_get(char *buf, size_t sz, const char *path, const char *key, |
2088 | Evas_Image_Load_Opts *lo) | ||
2089 | { | ||
2090 | // Same as _evas_cache_image_loadopts_append() but not optimized :) | ||
2091 | if (lo && _evas_image_load_opts_empty(lo)) | ||
2092 | lo = NULL; | ||
2067 | 2093 | ||
2068 | memcpy(hkey, file, filelen); | 2094 | if (!lo) |
2069 | hkey[filelen] = ':'; | 2095 | snprintf(buf, sz, "%s:%s", path, key); |
2070 | if (key) | ||
2071 | memcpy(hkey + filelen + 1, key, keylen); | ||
2072 | else | 2096 | else |
2073 | memcpy(hkey + filelen + 1, "(null)", 7); | 2097 | { |
2074 | 2098 | if (lo->orientation) | |
2075 | return hkey; | 2099 | { |
2100 | snprintf(buf, sz, "%s:%s//@/%d/%f/%dx%d/%d+%d.%dx%d", | ||
2101 | path, key, lo->scale_down_by, lo->dpi, lo->w, lo->h, | ||
2102 | lo->region.x, lo->region.y, lo->region.w, lo->region.h); | ||
2103 | } | ||
2104 | else | ||
2105 | { | ||
2106 | snprintf(buf, sz, "%s:%s//@/%d/%f/%dx%d/%d+%d.%dx%d/o", | ||
2107 | path, key, lo->scale_down_by, lo->dpi, lo->w, lo->h, | ||
2108 | lo->region.x, lo->region.y, lo->region.w, lo->region.h); | ||
2109 | } | ||
2110 | } | ||
2076 | } | 2111 | } |
2077 | 2112 | ||
2078 | static const File_Data * | 2113 | static const File_Data * |
@@ -2104,7 +2139,7 @@ _shared_image_entry_file_data_find(Image_Entry *ie) | |||
2104 | } | 2139 | } |
2105 | 2140 | ||
2106 | // Check hash | 2141 | // Check hash |
2107 | _shared_file_data_hkey_get(hkey, ie->file, ie->key, PATH_MAX); | 2142 | _file_hkey_get(hkey, sizeof(hkey), ie->file, ie->key, &ie->load_opts); |
2108 | fdata = eina_hash_find(_index.files.entries_by_hkey, hkey); | 2143 | fdata = eina_hash_find(_index.files.entries_by_hkey, hkey); |
2109 | if (fdata) | 2144 | if (fdata) |
2110 | return fdata; | 2145 | return fdata; |
@@ -2116,6 +2151,7 @@ _shared_image_entry_file_data_find(Image_Entry *ie) | |||
2116 | const char *file, *key; | 2151 | const char *file, *key; |
2117 | const File_Data *fd; | 2152 | const File_Data *fd; |
2118 | char fd_hkey[PATH_MAX]; | 2153 | char fd_hkey[PATH_MAX]; |
2154 | Evas_Image_Load_Opts lo = empty_lo; | ||
2119 | 2155 | ||
2120 | fd = &(_index.files.entries.filedata[k]); | 2156 | fd = &(_index.files.entries.filedata[k]); |
2121 | if (!fd->id) break; | 2157 | if (!fd->id) break; |
@@ -2136,7 +2172,17 @@ _shared_image_entry_file_data_find(Image_Entry *ie) | |||
2136 | (key > _index.strings_entries.data + _index.strings_entries.size)) | 2172 | (key > _index.strings_entries.data + _index.strings_entries.size)) |
2137 | key = _shared_string_get(fd->key); | 2173 | key = _shared_string_get(fd->key); |
2138 | 2174 | ||
2139 | _shared_file_data_hkey_get(fd_hkey, file, key, PATH_MAX); | 2175 | lo.region.x = fd->lo.region.x; |
2176 | lo.region.y = fd->lo.region.y; | ||
2177 | lo.region.w = fd->lo.region.w; | ||
2178 | lo.region.h = fd->lo.region.h; | ||
2179 | lo.dpi = fd->lo.dpi; | ||
2180 | lo.w = fd->lo.w; | ||
2181 | lo.h = fd->lo.h; | ||
2182 | lo.scale_down_by = fd->lo.scale_down_by; | ||
2183 | lo.orientation = fd->lo.orientation; | ||
2184 | |||
2185 | _file_hkey_get(fd_hkey, sizeof(fd_hkey), file, key, &lo); | ||
2140 | 2186 | ||
2141 | if (add_to_hash) | 2187 | if (add_to_hash) |
2142 | { | 2188 | { |