summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-09-23 17:51:06 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 15:47:15 +0900
commit1e82480c9a074163ec6788a8a60ead403f7b0658 (patch)
tree0c1458c5a0a0149c0f4a16e11f4d3523934cdb74 /src
parentfc73405c40653a5fc0166690e3657ffd87069efc (diff)
evas/cserve2: Use scalecache with cserve2
Let's reuse the logic from scalecache and call cserve2 functions when the scalecache should be used. So, now, cserve2 server will not scale any image... This is too computationally intensive for the server's main thread. This is not optimal but makes a hell of a lot more sense for the moment. (since cserve2 manages the SHM segments)
Diffstat (limited to '')
-rw-r--r--src/bin/evas/evas_cserve2.h2
-rw-r--r--src/bin/evas/evas_cserve2_cache.c24
-rw-r--r--src/bin/evas/evas_cserve2_scale.c6
-rw-r--r--src/lib/evas/cache2/evas_cache2.c3
-rw-r--r--src/lib/evas/canvas/evas_object_image.c56
-rw-r--r--src/lib/evas/common/evas_image_scalecache.c20
-rw-r--r--src/lib/evas/cserve2/evas_cs2.h4
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c54
8 files changed, 68 insertions, 101 deletions
diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index b1b6d6882e..2a3a40eb67 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -320,7 +320,7 @@ void cserve2_cache_client_del(Client *client);
320int cserve2_cache_file_open(Client *client, unsigned int client_file_id, const char *path, const char *key, unsigned int rid, Evas_Image_Load_Opts *lo); 320int cserve2_cache_file_open(Client *client, unsigned int client_file_id, const char *path, const char *key, unsigned int rid, Evas_Image_Load_Opts *lo);
321void cserve2_cache_file_close(Client *client, unsigned int client_file_id); 321void cserve2_cache_file_close(Client *client, unsigned int client_file_id);
322int cserve2_cache_image_entry_create(Client *client, int rid, unsigned int client_file_id, unsigned int image_id, Evas_Image_Load_Opts *opts); 322int cserve2_cache_image_entry_create(Client *client, int rid, unsigned int client_file_id, unsigned int image_id, Evas_Image_Load_Opts *opts);
323void 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); 323void cserve2_rgba_image_scale_do(void *src_data, int src_full_w, int src_full_h, 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);
324void cserve2_cache_image_load(Client *client, unsigned int client_image_id, unsigned int rid); 324void cserve2_cache_image_load(Client *client, unsigned int client_image_id, unsigned int rid);
325void cserve2_cache_image_preload(Client *client, unsigned int client_image_id, unsigned int rid); 325void cserve2_cache_image_preload(Client *client, unsigned int client_image_id, unsigned int rid);
326void cserve2_cache_image_unload(Client *client, unsigned int client_image_id); 326void cserve2_cache_image_unload(Client *client, unsigned int client_image_id);
diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c
index 5361c137a1..e86643df54 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -506,6 +506,8 @@ _image_loaded_msg_create(Image_Entry *ientry, Image_Data *idata, int *size)
506 msg->shm.mmap_size = cserve2_shm_map_size_get(ientry->shm); 506 msg->shm.mmap_size = cserve2_shm_map_size_get(ientry->shm);
507 msg->shm.image_size = cserve2_shm_size_get(ientry->shm); 507 msg->shm.image_size = cserve2_shm_size_get(ientry->shm);
508 msg->alpha_sparse = idata->alpha_sparse; 508 msg->alpha_sparse = idata->alpha_sparse;
509 msg->image.w = idata->w;
510 msg->image.h = idata->h;
509 511
510 if (idata->shm_id) 512 if (idata->shm_id)
511 { 513 {
@@ -805,7 +807,9 @@ _scaling_do(Shm_Handle *scale_shm, Image_Data *idata, Image_Entry *original)
805 char *scale_map, *orig_map; 807 char *scale_map, *orig_map;
806 void *src_data, *dst_data; 808 void *src_data, *dst_data;
807 File_Data *fd; 809 File_Data *fd;
810 Image_Data *orig_idata;
808 811
812#warning FIXME Remove this call, add alpha flag to Image_Data
809 fd = _file_data_find(idata->file_id); 813 fd = _file_data_find(idata->file_id);
810 if (!fd) 814 if (!fd)
811 { 815 {
@@ -814,6 +818,13 @@ _scaling_do(Shm_Handle *scale_shm, Image_Data *idata, Image_Entry *original)
814 return -1; 818 return -1;
815 } 819 }
816 820
821 orig_idata = _image_data_find(original->base.id);
822 if (!orig_idata)
823 {
824 ERR("Could not find image %u", original->base.id);
825 return -1;
826 }
827
817 scale_map = cserve2_shm_map(scale_shm); 828 scale_map = cserve2_shm_map(scale_shm);
818 if (scale_map == MAP_FAILED) 829 if (scale_map == MAP_FAILED)
819 { 830 {
@@ -833,14 +844,16 @@ _scaling_do(Shm_Handle *scale_shm, Image_Data *idata, Image_Entry *original)
833 src_data = orig_map + cserve2_shm_map_offset_get(original->shm); 844 src_data = orig_map + cserve2_shm_map_offset_get(original->shm);
834 dst_data = scale_map + cserve2_shm_map_offset_get(scale_shm); 845 dst_data = scale_map + cserve2_shm_map_offset_get(scale_shm);
835 846
836 DBG("Scaling image ([%d,%d:%dx%d] --> [%d,%d:%dx%d])", 847 DBG("Scaling image ([%dx%d]:[%d,%d:%dx%d] --> [%d,%d:%dx%d])",
848 orig_idata->w, orig_idata->h,
837 idata->opts.scale_load.src_x, idata->opts.scale_load.src_y, 849 idata->opts.scale_load.src_x, idata->opts.scale_load.src_y,
838 idata->opts.scale_load.src_w, idata->opts.scale_load.src_h, 850 idata->opts.scale_load.src_w, idata->opts.scale_load.src_h,
839 0, 0, 851 0, 0,
840 idata->opts.scale_load.dst_w, idata->opts.scale_load.dst_h); 852 idata->opts.scale_load.dst_w, idata->opts.scale_load.dst_h);
841 853
842 cserve2_rgba_image_scale_do( 854 cserve2_rgba_image_scale_do(
843 src_data, dst_data, 855 src_data, orig_idata->w, orig_idata->h,
856 dst_data,
844 idata->opts.scale_load.src_x, idata->opts.scale_load.src_y, 857 idata->opts.scale_load.src_x, idata->opts.scale_load.src_y,
845 idata->opts.scale_load.src_w, idata->opts.scale_load.src_h, 858 idata->opts.scale_load.src_w, idata->opts.scale_load.src_h,
846 0, 0, 859 0, 0,
@@ -875,6 +888,8 @@ _scaling_prepare_and_do(Image_Entry *ientry, Image_Data *idata)
875 cserve2_shared_string_del(idata->shm_id); 888 cserve2_shared_string_del(idata->shm_id);
876 ientry->shm = scale_shm; 889 ientry->shm = scale_shm;
877 idata->shm_id = 0; 890 idata->shm_id = 0;
891 idata->w = idata->opts.scale_load.dst_w;
892 idata->h = idata->opts.scale_load.dst_h;
878 893
879 return 0; 894 return 0;
880} 895}
@@ -895,6 +910,9 @@ _load_request_response(Image_Entry *ientry,
895 if (!idata->doload) 910 if (!idata->doload)
896 DBG("Entry %d loaded by speculative preload.", idata->id); 911 DBG("Entry %d loaded by speculative preload.", idata->id);
897 912
913 idata->w = resp->w;
914 idata->h = resp->h;
915
898 if (_scaling_needed(idata, resp)) 916 if (_scaling_needed(idata, resp))
899 { 917 {
900 DBG("About to scale image %u", idata->id); 918 DBG("About to scale image %u", idata->id);
@@ -2781,7 +2799,7 @@ do_scaling:
2781 CSERVE2_REQ_IMAGE_LOAD, 2799 CSERVE2_REQ_IMAGE_LOAD,
2782 0, NULL, 0, &_load_funcs, orig_entry); 2800 0, NULL, 0, &_load_funcs, orig_entry);
2783 } 2801 }
2784 if (orig_entry->base.request || !orig_entry->shm) 2802 if (orig_entry->base.request || !orig_entry->shm || !orig_data->valid)
2785 return -1; // Not loaded yet 2803 return -1; // Not loaded yet
2786 2804
2787 if (ientry->shm) 2805 if (ientry->shm)
diff --git a/src/bin/evas/evas_cserve2_scale.c b/src/bin/evas/evas_cserve2_scale.c
index 9324432f13..dd909db235 100644
--- a/src/bin/evas/evas_cserve2_scale.c
+++ b/src/bin/evas/evas_cserve2_scale.c
@@ -32,7 +32,8 @@ _cserve2_rgba_image_set(RGBA_Image *im, void *data, int w, int h, int alpha)
32} 32}
33 33
34void 34void
35cserve2_rgba_image_scale_do(void *src_data, void *dst_data, 35cserve2_rgba_image_scale_do(void *src_data, int src_full_w, int src_full_h,
36 void *dst_data,
36 int src_x, int src_y, int src_w, int src_h, 37 int src_x, int src_y, int src_w, int src_h,
37 int dst_x, int dst_y, int dst_w, int dst_h, 38 int dst_x, int dst_y, int dst_w, int dst_h,
38 int alpha, int smooth) 39 int alpha, int smooth)
@@ -40,8 +41,7 @@ cserve2_rgba_image_scale_do(void *src_data, void *dst_data,
40 RGBA_Image src, dst; 41 RGBA_Image src, dst;
41 RGBA_Draw_Context ct; 42 RGBA_Draw_Context ct;
42 43
43 _cserve2_rgba_image_set(&src, src_data, src_w, src_h, alpha); 44 _cserve2_rgba_image_set(&src, src_data, src_full_w, src_full_h, alpha);
44
45 _cserve2_rgba_image_set(&dst, dst_data, dst_w, dst_h, alpha); 45 _cserve2_rgba_image_set(&dst, dst_data, dst_w, dst_h, alpha);
46 dst.flags = RGBA_IMAGE_NOTHING; 46 dst.flags = RGBA_IMAGE_NOTHING;
47 47
diff --git a/src/lib/evas/cache2/evas_cache2.c b/src/lib/evas/cache2/evas_cache2.c
index fc7982d5ba..b6b1eadd1f 100644
--- a/src/lib/evas/cache2/evas_cache2.c
+++ b/src/lib/evas/cache2/evas_cache2.c
@@ -799,7 +799,8 @@ evas_cache2_image_open_wait(Image_Entry *im)
799} 799}
800 800
801static Image_Entry * 801static Image_Entry *
802_scaled_image_find(Image_Entry *im, int src_x, int src_y, int src_w, int src_h, int dst_w, int dst_h, int smooth) 802_scaled_image_find(Image_Entry *im, int src_x, int src_y, int src_w,
803 int src_h, int dst_w, int dst_h, int smooth)
803{ 804{
804 size_t pathlen, keylen, size; 805 size_t pathlen, keylen, size;
805 char *hkey; 806 char *hkey;
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c
index 5178e1b1a7..4e5cd3d391 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -3998,53 +3998,15 @@ evas_object_image_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, v
3998 (o->cur->border.b == 0) && 3998 (o->cur->border.b == 0) &&
3999 (o->cur->border.fill != 0)) 3999 (o->cur->border.fill != 0))
4000 { 4000 {
4001#ifdef EVAS_CSERVE2 4001 _draw_image
4002 if (evas_cserve2_use_get()) 4002 (obj, output, context, surface, pixels,
4003 { 4003 0, 0,
4004 Image_Entry *ie; 4004 imagew, imageh,
4005 void *data = pixels; 4005 obj->cur->geometry.x + ix + x,
4006 int w = imagew, h = imageh; 4006 obj->cur->geometry.y + iy + y,
4007 Eina_Bool mustclose = EINA_FALSE; 4007 iw, ih,
4008 4008 o->cur->smooth_scale,
4009 ie = evas_cache2_image_scale_load 4009 do_async);
4010 ((Image_Entry *)pixels,
4011 0, 0,
4012 imagew, imageh,
4013 iw, ih, o->cur->smooth_scale);
4014 if (ie != &((RGBA_Image *)pixels)->cache_entry)
4015 {
4016 data = ie;
4017 w = iw;
4018 h = ih;
4019 mustclose = EINA_TRUE;
4020 }
4021
4022 _draw_image
4023 (obj, output, context, surface, data,
4024 0, 0,
4025 w, h,
4026 obj->cur->geometry.x + ix + x,
4027 obj->cur->geometry.y + iy + y,
4028 iw, ih,
4029 o->cur->smooth_scale,
4030 do_async);
4031
4032 if (mustclose)
4033 evas_cache2_image_close(ie);
4034 }
4035 else
4036#endif
4037 {
4038 _draw_image
4039 (obj, output, context, surface, pixels,
4040 0, 0,
4041 imagew, imageh,
4042 obj->cur->geometry.x + ix + x,
4043 obj->cur->geometry.y + iy + y,
4044 iw, ih,
4045 o->cur->smooth_scale,
4046 do_async);
4047 }
4048 } 4010 }
4049 else 4011 else
4050 { 4012 {
diff --git a/src/lib/evas/common/evas_image_scalecache.c b/src/lib/evas/common/evas_image_scalecache.c
index fc907614c8..3802f0cce5 100644
--- a/src/lib/evas/common/evas_image_scalecache.c
+++ b/src/lib/evas/common/evas_image_scalecache.c
@@ -759,6 +759,26 @@ evas_common_rgba_image_scalecache_do_cbs(Image_Entry *ie, RGBA_Image *dst,
759 } 759 }
760 } 760 }
761 } 761 }
762
763#ifdef EVAS_CSERVE2
764 if (sci->populate_me && (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
765 && evas_cserve2_use_get() && evas_cache2_image_cached(&im->cache_entry))
766 {
767 RGBA_Image *im2 = (RGBA_Image *) evas_cache2_image_scale_load
768 (&im->cache_entry, src_region_x, src_region_y,
769 src_region_w, src_region_h, dst_region_w, dst_region_h, smooth);
770 SLKL(cache_lock);
771 if (im2 != im)
772 {
773 sci->im = im2;
774 sci->populate_me = 0;
775 cache_list = eina_inlist_append(cache_list, (Eina_Inlist *)sci);
776 didpop = 1;
777 }
778 SLKU(cache_lock);
779 }
780#endif
781
762 if (sci->populate_me) 782 if (sci->populate_me)
763 { 783 {
764// INF("##! populate!"); 784// INF("##! populate!");
diff --git a/src/lib/evas/cserve2/evas_cs2.h b/src/lib/evas/cserve2/evas_cs2.h
index 6cc8804e29..5378790999 100644
--- a/src/lib/evas/cserve2/evas_cs2.h
+++ b/src/lib/evas/cserve2/evas_cs2.h
@@ -90,6 +90,9 @@ struct _Msg_Loaded {
90 int mmap_size; 90 int mmap_size;
91 int image_size; 91 int image_size;
92 } shm; 92 } shm;
93 struct {
94 unsigned int w, h; // Real dimensions of this image. May differ from Msg_Opened::image::{w,h} after scaling.
95 } image;
93 Eina_Bool alpha_sparse : 1; 96 Eina_Bool alpha_sparse : 1;
94}; 97};
95 98
@@ -354,6 +357,7 @@ struct _Image_Data {
354 uint32_t file_id; 357 uint32_t file_id;
355 string_t shm_id; 358 string_t shm_id;
356 Evas_Image_Load_Opts opts; 359 Evas_Image_Load_Opts opts;
360 uint32_t w, h;
357 Eina_Bool alpha_sparse : 1; 361 Eina_Bool alpha_sparse : 1;
358 Eina_Bool unused : 1; 362 Eina_Bool unused : 1;
359 Eina_Bool doload : 1; 363 Eina_Bool doload : 1;
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index 577d3af4b0..57766ef34c 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -1352,52 +1352,14 @@ eng_image_draw(void *data EINA_UNUSED, void *context, void *surface, void *image
1352#endif 1352#endif
1353 else 1353 else
1354 { 1354 {
1355#if 0 1355 evas_common_rgba_image_scalecache_prepare
1356#ifdef EVAS_CSERVE2 1356 (&im->cache_entry, surface, context, smooth,
1357 if (evas_cserve2_use_get()) 1357 src_x, src_y, src_w, src_h,
1358 { 1358 dst_x, dst_y, dst_w, dst_h);
1359 evas_cache2_image_load_data(&im->cache_entry); 1359 evas_common_rgba_image_scalecache_do
1360 goto image_loaded; 1360 (&im->cache_entry, surface, context, smooth,
1361 } 1361 src_x, src_y, src_w, src_h,
1362#endif 1362 dst_x, dst_y, dst_w, dst_h);
1363 if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
1364 evas_cache_image_load_data(&im->cache_entry);
1365 evas_common_image_colorspace_normalize(im);
1366
1367image_loaded:
1368#endif
1369#ifdef EVAS_CSERVE2
1370 if (evas_cserve2_use_get())
1371 {
1372 if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
1373 evas_cache2_image_load_data(&im->cache_entry);
1374
1375 if (!im->cache_entry.flags.loaded) return EINA_FALSE;
1376 evas_common_image_colorspace_normalize(im);
1377
1378 if (smooth)
1379 evas_common_scale_rgba_in_to_out_clip_smooth
1380 (im, surface, context,
1381 src_x, src_y, src_w, src_h,
1382 dst_x, dst_y, dst_w, dst_h);
1383 else
1384 evas_common_scale_rgba_in_to_out_clip_sample
1385 (im, surface, context,
1386 src_x, src_y, src_w, src_h,
1387 dst_x, dst_y, dst_w, dst_h);
1388 }
1389 else
1390#endif
1391 {
1392 evas_common_rgba_image_scalecache_prepare
1393 (&im->cache_entry, surface, context, smooth,
1394 src_x, src_y, src_w, src_h,
1395 dst_x, dst_y, dst_w, dst_h);
1396 evas_common_rgba_image_scalecache_do
1397 (&im->cache_entry, surface, context, smooth,
1398 src_x, src_y, src_w, src_h,
1399 dst_x, dst_y, dst_w, dst_h);
1400 }
1401 1363
1402 evas_common_cpu_end_opt(); 1364 evas_common_cpu_end_opt();
1403 } 1365 }