From 31874b5e90325d6e9b1166c1a04fe3280adb7549 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 28 Oct 2016 11:20:20 +0900 Subject: [PATCH] evas/engine: handle ector surface creation failure Change-Id: Ie338360669513021a837ba38ae93b35510f7340c --- src/lib/evas/canvas/evas_object_vg.c | 12 ++++++++-- src/lib/evas/include/evas_private.h | 2 +- src/modules/evas/engines/gl_generic/evas_engine.c | 16 +++++++++---- .../evas/engines/software_generic/evas_engine.c | 28 +++++++++++++--------- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index aa5d53d..a885103 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -231,6 +231,7 @@ _svg_data_render(Evas_Object_Protected_Data *obj, Ector_Surface *ector; RGBA_Draw_Context *ct; Eina_Bool async_unref; + Eina_Bool error = EINA_FALSE; // if the size changed in between path set and the draw call; if (!(svg->w == obj->cur->geometry.w && @@ -258,7 +259,10 @@ _svg_data_render(Evas_Object_Protected_Data *obj, NULL, svg->w, svg->h, - EINA_TRUE); + EINA_TRUE, &error); + if (error) + return; // surface creation error + //3. draw into the buffer ct = evas_common_draw_context_new(); evas_common_draw_context_set_render_op(ct, _EVAS_RENDER_COPY); @@ -300,6 +304,7 @@ evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED, { Evas_VG_Data *vd = type_private_data; Ector_Surface *ector = evas_ector_get(obj->layer->evas); + Eina_Bool error = EINA_FALSE; // FIXME: Set context (that should affect Ector_Surface) and // then call Ector_Renderer render from bottom to top. Get the @@ -339,7 +344,10 @@ evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED, vd->backing_store, obj->cur->geometry.w, obj->cur->geometry.h, - EINA_FALSE); + EINA_FALSE, &error); + if (error) + return; // surface creation error + if (!vd->backing_store) { obj->layer->evas->engine.func->ector_begin(output, context, ector, surface, diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index 94d336f..39a3aa6 100755 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1477,7 +1477,7 @@ struct _Evas_Func void (*ector_begin) (void *data, void *context, Ector_Surface *ector, void *surface, int x, int y, Eina_Bool do_async); void (*ector_renderer_draw) (void *data, void *context, void *surface, Ector_Renderer *r, Eina_Array *clips, Eina_Bool do_async); void (*ector_end) (void *data, void *context, Ector_Surface *ector, void *surface, Eina_Bool do_async); - void *(*ector_surface_create) (void *data, void *surface, int w, int h, Eina_Bool force); + void *(*ector_surface_create) (void *data, void *surface, int w, int h, Eina_Bool force, int *error); void (*ector_surface_cache_set) (void *data, void *key, void *surface); void *(*ector_surface_cache_get) (void *data, void *key); }; diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index de9c283..e83ed3a 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -2529,11 +2529,13 @@ eng_ector_end(void *data EINA_UNUSED, void *context EINA_UNUSED, Ector_Surface * } static void* -eng_ector_surface_create(void *data, void *surface, int width, int height, Eina_Bool force EINA_UNUSED) +eng_ector_surface_create(void *data, void *surface, int width, int height, Eina_Bool force EINA_UNUSED, int *error) { Evas_GL_Image *glim; int cur_w=0 , cur_h=0; + *error = EINA_FALSE; + if (surface) { glim = surface; @@ -2544,9 +2546,15 @@ eng_ector_surface_create(void *data, void *surface, int width, int height, Eina_ } surface = eng_image_new_from_copied_data(data, width, height, NULL, EINA_TRUE, EVAS_COLORSPACE_ARGB8888); - //Use this hint for ZERO COPY texture upload. - if (surface) - eng_image_content_hint_set(data, surface, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); + if (!surface) + { + *error = EINA_TRUE; + } + else + { + //Use this hint for ZERO COPY texture upload. + eng_image_content_hint_set(data, surface, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); + } return surface; } diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index e48c206..8b2e955 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -3892,31 +3892,37 @@ _draw_thread_ector_surface_set(void *data) } static void * -eng_ector_surface_create(void *data, void *surface, int width, int height, Eina_Bool force) +eng_ector_surface_create(void *data, void *surface, int width, int height, Eina_Bool force, int *error) { RGBA_Image *im; void *pixels = NULL; int cur_w=0 , cur_h=0; + *error = EINA_FALSE; + if (!force) return NULL; if (surface) { im = surface; eng_image_size_get(data, im, &cur_w, &cur_h); - if ((width != cur_w) || (height == cur_h)) - { - eng_image_free(data, surface); - surface = NULL; - } + if ((width == cur_w) && (height == cur_h)) return surface; + eng_image_free(data, surface); + surface = NULL; } - if (!surface) - surface = eng_image_new_from_copied_data(data, width, height, NULL, EINA_TRUE, EVAS_COLORSPACE_ARGB8888); + surface = eng_image_new_from_copied_data(data, width, height, NULL, EINA_TRUE, EVAS_COLORSPACE_ARGB8888); - im = surface; - pixels = evas_cache_image_pixels(&im->cache_entry); - memset(pixels, 0, (width * height * 4)); + if (!surface) + { + *error = EINA_TRUE; + } + else + { + im = surface; + pixels = evas_cache_image_pixels(&im->cache_entry); + memset(pixels, 0, (width * height * 4)); + } return surface; } -- 2.7.4