gl_x11: Do KHR Partial Damage properly
authorDerek Foreman <derekf@osg.samsung.com>
Thu, 20 Oct 2016 19:13:49 +0000 (14:13 -0500)
committerDerek Foreman <derekf@osg.samsung.com>
Thu, 20 Oct 2016 19:30:00 +0000 (14:30 -0500)
KHR partial damage must be set once at the beginning of rendering with
buffer damage for the entire scene to be rendered.  Doing otherwise can
result in graphical anomalies on some GL implementations.

src/modules/evas/engines/gl_x11/evas_engine.c
src/modules/evas/engines/gl_x11/evas_engine.h
src/modules/evas/engines/gl_x11/evas_x_main.c

index 5685625..2d4fde9 100644 (file)
@@ -1751,7 +1751,11 @@ eng_setup(Evas *eo_e, void *in)
                                                 eng_outbuf_get_rot,
                                                 eng_outbuf_reconfigure,
                                                 eng_outbuf_region_first_rect,
+#ifdef GL_GLES
+                                                eng_outbuf_damage_region_set,
+#else
                                                 NULL,
+#endif
                                                 eng_outbuf_new_region_for_update,
                                                 eng_outbuf_push_updated_region,
                                                 eng_outbuf_push_free_region_for_update,
index fae6ad4..5f18dc6 100644 (file)
@@ -187,6 +187,9 @@ void      eng_gl_context_use(Context_3D *context);
 void eng_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth);
 int eng_outbuf_get_rot(Outbuf *ob);
 Render_Engine_Swap_Mode eng_outbuf_swap_mode(Outbuf *ob);
+#ifdef GL_GLES
+void eng_outbuf_damage_region_set(Outbuf *ob, Tilebuf_Rect *damage);
+#endif
 Eina_Bool eng_outbuf_region_first_rect(Outbuf *ob);
 void *eng_outbuf_new_region_for_update(Outbuf *ob,
                                        int x, int y, int w, int h,
index 207cb06..612cb45 100644 (file)
@@ -1479,20 +1479,24 @@ _convert_to_glcoords(int *result, Outbuf *ob, int x, int y, int w, int h)
      }
 }
 
-static void
-_set_damage_rect(Outbuf *ob, int x, int y, int w, int h)
+void
+eng_outbuf_damage_region_set(Outbuf *ob, Tilebuf_Rect *damage)
 {
-   int rects[4];
-
-   if ((x==0) && (y==0) &&
-       (((w == ob->gl_context->w) && (h == ob->gl_context->h))
-        || ((h == ob->gl_context->w) && (w == ob->gl_context->h))))
+   if (glsym_eglSetDamageRegionKHR)
      {
-        return;
-     }
+        Tilebuf_Rect *tr;
+        int *rect, *rects, count;
 
-   _convert_to_glcoords(rects, ob, x, y, w, h);
-   glsym_eglSetDamageRegionKHR(ob->egl_disp, ob->egl_surface[0], rects, 1);
+        count = eina_inlist_count(EINA_INLIST_GET(damage));
+        rects = alloca(sizeof(int) * 4 * count);
+        rect = rects;
+        EINA_INLIST_FOREACH(damage, tr)
+          {
+             _convert_to_glcoords(rect, ob, tr->x, tr->y, tr->w, tr->h);
+             rect += 4;
+          }
+        glsym_eglSetDamageRegionKHR(ob->egl_disp, ob->egl_surface[0], rects, count);
+     }
 }
 #endif
 
@@ -1513,10 +1517,6 @@ eng_outbuf_new_region_for_update(Outbuf *ob,
         ob->gl_context->master_clip.y = y;
         ob->gl_context->master_clip.w = w;
         ob->gl_context->master_clip.h = h;
-#ifdef GL_GLES
-        if (glsym_eglSetDamageRegionKHR)
-          _set_damage_rect(ob, x, y, w, h);
-#endif
      }
    return ob->gl_context->def_surface;
 }