summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2015-11-04 11:20:39 -0500
committerChris Michael <cp.michael@samsung.com>2015-11-04 11:20:39 -0500
commit962059dd0a4121ba93c3cb7179173d628b37f8f7 (patch)
tree1129dcc1b0f6c0edcd48e1f43412c7c31973b116
parentb2785f01c52ed7f6919c76ffe2bacfaf98bedeaf (diff)
evas-gl-drm: Implement eglSetDamageRegionKHR
Summary: In efforts to reduce tearing in the gl_drm engine, implement support for eglSetDamageRegionKHR to mark parts of a surface as being damaged. @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r--src/modules/evas/engines/gl_drm/evas_outbuf.c132
1 files changed, 85 insertions, 47 deletions
diff --git a/src/modules/evas/engines/gl_drm/evas_outbuf.c b/src/modules/evas/engines/gl_drm/evas_outbuf.c
index a421b64f15..8c939880d2 100644
--- a/src/modules/evas/engines/gl_drm/evas_outbuf.c
+++ b/src/modules/evas/engines/gl_drm/evas_outbuf.c
@@ -1,4 +1,5 @@
1#include "evas_engine.h" 1#include "evas_engine.h"
2#include "../gl_common/evas_gl_define.h"
2 3
3/* local variables */ 4/* local variables */
4static Outbuf *_evas_gl_drm_window = NULL; 5static Outbuf *_evas_gl_drm_window = NULL;
@@ -379,7 +380,7 @@ evas_outbuf_new(Evas_Engine_Info_GL_Drm *info, int w, int h, Render_Engine_Swap_
379 ob->depth = info->info.depth; 380 ob->depth = info->info.depth;
380 ob->rotation = info->info.rotation; 381 ob->rotation = info->info.rotation;
381 ob->destination_alpha = info->info.destination_alpha; 382 ob->destination_alpha = info->info.destination_alpha;
382 ob->vsync = info->info.vsync; 383 /* ob->vsync = info->info.vsync; */
383 ob->swap_mode = swap_mode; 384 ob->swap_mode = swap_mode;
384 ob->priv.num = 2; 385 ob->priv.num = 2;
385 386
@@ -390,8 +391,8 @@ evas_outbuf_new(Evas_Engine_Info_GL_Drm *info, int w, int h, Render_Engine_Swap_
390 else if (ob->priv.num > 4) ob->priv.num = 4; 391 else if (ob->priv.num > 4) ob->priv.num = 4;
391 } 392 }
392 393
393 if ((num = getenv("EVAS_GL_DRM_VSYNC"))) 394 /* if ((num = getenv("EVAS_GL_DRM_VSYNC"))) */
394 ob->vsync = atoi(num); 395 /* ob->vsync = atoi(num); */
395 396
396 if ((ob->rotation == 0) || (ob->rotation == 180)) 397 if ((ob->rotation == 0) || (ob->rotation == 180))
397 _evas_outbuf_gbm_surface_create(ob, w, h); 398 _evas_outbuf_gbm_surface_create(ob, w, h);
@@ -648,6 +649,58 @@ evas_outbuf_update_region_first_rect(Outbuf *ob)
648 return EINA_FALSE; 649 return EINA_FALSE;
649} 650}
650 651
652static void
653_glcoords_convert(int *result, Outbuf *ob, int x, int y, int w, int h)
654{
655 switch (ob->rotation)
656 {
657 case 0:
658 result[0] = x;
659 result[1] = ob->gl_context->h - (y + h);
660 result[2] = w;
661 result[3] = h;
662 break;
663 case 90:
664 result[0] = y;
665 result[1] = x;
666 result[2] = h;
667 result[3] = w;
668 break;
669 case 180:
670 result[0] = ob->gl_context->w - (x + w);
671 result[1] = y;
672 result[2] = w;
673 result[3] = h;
674 break;
675 case 270:
676 result[0] = ob->gl_context->h - (y + h);
677 result[1] = ob->gl_context->w - (x + w);
678 result[2] = h;
679 result[3] = w;
680 break;
681 default:
682 result[0] = x;
683 result[1] = ob->gl_context->h - (y + h);
684 result[2] = w;
685 result[3] = h;
686 break;
687 }
688}
689
690static void
691_damage_rect_set(Outbuf *ob, int x, int y, int w, int h)
692{
693 int rects[4];
694
695 if ((x == 0) && (y == 0) &&
696 (((w == ob->gl_context->w) && (h == ob->gl_context->h)) ||
697 ((h == ob->gl_context->w) && (w == ob->gl_context->h))))
698 return;
699
700 _glcoords_convert(rects, ob, x, y, w, h);
701 glsym_eglSetDamageRegionKHR(ob->egl.disp, ob->egl.surface[0], rects, 1);
702}
703
651void * 704void *
652evas_outbuf_update_region_new(Outbuf *ob, int x, int y, int w, int h, int *cx EINA_UNUSED, int *cy EINA_UNUSED, int *cw EINA_UNUSED, int *ch EINA_UNUSED) 705evas_outbuf_update_region_new(Outbuf *ob, int x, int y, int w, int h, int *cx EINA_UNUSED, int *cy EINA_UNUSED, int *cw EINA_UNUSED, int *ch EINA_UNUSED)
653{ 706{
@@ -660,6 +713,9 @@ evas_outbuf_update_region_new(Outbuf *ob, int x, int y, int w, int h, int *cx EI
660 ob->gl_context->master_clip.y = y; 713 ob->gl_context->master_clip.y = y;
661 ob->gl_context->master_clip.w = w; 714 ob->gl_context->master_clip.w = w;
662 ob->gl_context->master_clip.h = h; 715 ob->gl_context->master_clip.h = h;
716
717 if (glsym_eglSetDamageRegionKHR)
718 _damage_rect_set(ob, x, y, w, h);
663 } 719 }
664 720
665 return ob->gl_context->def_surface; 721 return ob->gl_context->def_surface;
@@ -682,7 +738,7 @@ evas_outbuf_update_region_free(Outbuf *ob EINA_UNUSED, RGBA_Image *update EINA_U
682} 738}
683 739
684void 740void
685evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode render_mode) 741evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects, Evas_Render_Mode render_mode)
686{ 742{
687 if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) goto end; 743 if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) goto end;
688 744
@@ -703,9 +759,8 @@ evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode
703 if (ob->info->callback.pre_swap) 759 if (ob->info->callback.pre_swap)
704 ob->info->callback.pre_swap(ob->info->callback.data, ob->evas); 760 ob->info->callback.pre_swap(ob->info->callback.data, ob->evas);
705 761
706// TODO: Check eglSwapBuffersWithDamage for gl_drm and apply 762 if ((glsym_eglSwapBuffersWithDamage) && (rects) &&
707#if 0 763 (ob->swap_mode != MODE_FULL))
708 if ((glsym_eglSwapBuffersWithDamage) && (ob->swap_mode != MODE_FULL))
709 { 764 {
710 EGLint num = 0, *result = NULL, i = 0; 765 EGLint num = 0, *result = NULL, i = 0;
711 Tilebuf_Rect *r; 766 Tilebuf_Rect *r;
@@ -717,43 +772,7 @@ evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode
717 result = alloca(sizeof(EGLint) * 4 * num); 772 result = alloca(sizeof(EGLint) * 4 * num);
718 EINA_INLIST_FOREACH(EINA_INLIST_GET(rects), r) 773 EINA_INLIST_FOREACH(EINA_INLIST_GET(rects), r)
719 { 774 {
720 int gw, gh; 775 _glcoords_convert(&result[i], ob, r->x, r->y, r->w, r->h);
721
722 gw = ob->gl_context->w;
723 gh = ob->gl_context->h;
724 switch (ob->rotation)
725 {
726 case 0:
727 result[i + 0] = r->x;
728 result[i + 1] = gh - (r->y + r->h);
729 result[i + 2] = r->w;
730 result[i + 3] = r->h;
731 break;
732 case 90:
733 result[i + 0] = r->y;
734 result[i + 1] = r->x;
735 result[i + 2] = r->h;
736 result[i + 3] = r->w;
737 break;
738 case 180:
739 result[i + 0] = gw - (r->x + r->w);
740 result[i + 1] = r->y;
741 result[i + 2] = r->w;
742 result[i + 3] = r->h;
743 break;
744 case 270:
745 result[i + 0] = gh - (r->y + r->h);
746 result[i + 1] = gw - (r->x + r->w);
747 result[i + 2] = r->h;
748 result[i + 3] = r->w;
749 break;
750 default:
751 result[i + 0] = r->x;
752 result[i + 1] = gh - (r->y + r->h);
753 result[i + 2] = r->w;
754 result[i + 3] = r->h;
755 break;
756 }
757 i += 4; 776 i += 4;
758 } 777 }
759 glsym_eglSwapBuffersWithDamage(ob->egl.disp, ob->egl.surface[0], 778 glsym_eglSwapBuffersWithDamage(ob->egl.disp, ob->egl.surface[0],
@@ -761,14 +780,33 @@ evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode
761 } 780 }
762 } 781 }
763 else 782 else
764#endif
765 eglSwapBuffers(ob->egl.disp, ob->egl.surface[0]); 783 eglSwapBuffers(ob->egl.disp, ob->egl.surface[0]);
766 784
767 if (ob->info->callback.post_swap) 785 if (ob->info->callback.post_swap)
768 ob->info->callback.post_swap(ob->info->callback.data, ob->evas); 786 ob->info->callback.post_swap(ob->info->callback.data, ob->evas);
769 787
770 //Flush GL Surface data to Framebuffer 788 if (rects)
771 _evas_outbuf_buffer_swap(ob, NULL, 0); 789 {
790 Tilebuf_Rect *r;
791 Eina_Rectangle *res;
792 int num, i = 0;
793
794 num = eina_inlist_count(EINA_INLIST_GET(rects));
795 res = alloca(sizeof(Eina_Rectangle) * num);
796 EINA_INLIST_FOREACH(EINA_INLIST_GET(rects), r)
797 {
798 res[i].x = r->x;
799 res[i].y = r->y;
800 res[i].w = r->w;
801 res[i].h = r->h;
802 i++;
803 }
804
805 _evas_outbuf_buffer_swap(ob, res, num);
806 }
807 else
808 //Flush GL Surface data to Framebuffer
809 _evas_outbuf_buffer_swap(ob, NULL, 0);
772 810
773 ob->priv.frame_cnt++; 811 ob->priv.frame_cnt++;
774 812