summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-08-25 10:51:40 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-08-25 10:51:40 -0700
commit46767819fdfeafeacbfa816bcf66a8e231730ee8 (patch)
tree2f596f92952e33451471bfb18a2ffaa50a9d0a7f
parentaebeed445485a049d14c6a392b4acc777e8e8c02 (diff)
evas: find a best possible output to manage an object to get pixels from.
The code shouldn't really need an output for getting the pixels, it just happen that some of the backend function really need one to get a GL context.
-rw-r--r--src/lib/evas/canvas/evas_object_image.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c
index 2fb8d656a0..1ba3971a7a 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -128,6 +128,29 @@ evas_object_image_render_prepare(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Pr
128 // XXX: if image is a proxy, PREPEND to prerender list in evas canvas 128 // XXX: if image is a proxy, PREPEND to prerender list in evas canvas
129} 129}
130 130
131static void *
132_evas_object_image_output_find(Evas_Object_Protected_Data *obj)
133{
134 Efl_Canvas_Output *output;
135 Eina_List *l;
136 const Eina_Rectangle geometry = {
137 obj->cur->geometry.x,
138 obj->cur->geometry.y,
139 obj->cur->geometry.w,
140 obj->cur->geometry.h
141 };
142
143 EINA_LIST_FOREACH(obj->layer->evas->outputs, l, output)
144 {
145 if (eina_rectangles_intersect(&output->geometry, &geometry))
146 return output->output;
147 }
148
149 // Always return an output, as evas rely on that even if the object is out of screen.
150 output = eina_list_data_get(obj->layer->evas->outputs);
151 return output->output;
152}
153
131void 154void
132_evas_image_cleanup(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o) 155_evas_image_cleanup(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o)
133{ 156{
@@ -861,14 +884,16 @@ _efl_canvas_image_internal_efl_file_save(const Eo *eo_obj, Evas_Image_Data *o, c
861 int imagew, imageh, uvw, uvh; 884 int imagew, imageh, uvw, uvh;
862 Eina_Rw_Slice slice = {}; 885 Eina_Rw_Slice slice = {};
863 DATA32 *data = NULL; 886 DATA32 *data = NULL;
864 void *pixels = NULL; 887 void *pixels;
888 void *output;
865 889
866 obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); 890 obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
867 891
868 EINA_SAFETY_ON_NULL_RETURN_VAL(file, EINA_FALSE); 892 EINA_SAFETY_ON_NULL_RETURN_VAL(file, EINA_FALSE);
869 evas_object_async_block(obj); 893 evas_object_async_block(obj);
870 894
871 pixels = _evas_image_pixels_get((Eo *)eo_obj, obj, ENC, ENDT, NULL, NULL, 895 output = _evas_object_image_output_find(obj);
896 pixels = _evas_image_pixels_get((Eo *)eo_obj, obj, ENC, output, NULL, NULL,
872 0, 0, 897 0, 0,
873 &imagew, &imageh, &uvw, &uvh, EINA_TRUE, EINA_TRUE); 898 &imagew, &imageh, &uvw, &uvh, EINA_TRUE, EINA_TRUE);
874 if (!pixels) goto no_pixels; 899 if (!pixels) goto no_pixels;
@@ -3068,6 +3093,7 @@ evas_object_image_is_inside(Evas_Object *eo_obj,
3068 int imagew, imageh, uvw, uvh, ix, iy, iw, ih, idw, idh, idx, idy; 3093 int imagew, imageh, uvw, uvh, ix, iy, iw, ih, idw, idh, idx, idy;
3069 int is_inside = 0; 3094 int is_inside = 0;
3070 void *pixels; 3095 void *pixels;
3096 void *output;
3071 3097
3072 // FIXME: The below loop is incredibly dubious and probably should be simplified. 3098 // FIXME: The below loop is incredibly dubious and probably should be simplified.
3073 // We're looking for one single pixel, not a random series of positions. 3099 // We're looking for one single pixel, not a random series of positions.
@@ -3075,7 +3101,8 @@ evas_object_image_is_inside(Evas_Object *eo_obj,
3075 /* the following code is similar to evas_object_image_render(), but doesn't 3101 /* the following code is similar to evas_object_image_render(), but doesn't
3076 * draw, just get the pixels so we can check the transparency. 3102 * draw, just get the pixels so we can check the transparency.
3077 */ 3103 */
3078 pixels = _evas_image_pixels_get(eo_obj, obj, ENC, ENDT, NULL, NULL, 0, 0, 3104 output = _evas_object_image_output_find(obj);
3105 pixels = _evas_image_pixels_get(eo_obj, obj, ENC, output, NULL, NULL, 0, 0,
3079 &imagew, &imageh, &uvw, &uvh, EINA_TRUE, EINA_FALSE); 3106 &imagew, &imageh, &uvw, &uvh, EINA_TRUE, EINA_FALSE);
3080 if (!pixels) return is_inside; 3107 if (!pixels) return is_inside;
3081 3108