summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung W. Park <sungwoo@gmail.com>2014-02-15 02:33:47 +0900
committerSung W. Park <sungwoo@gmail.com>2014-02-15 02:33:47 +0900
commit2b4a7b438def96d01a5c0bb85d2c9636773d333d (patch)
treee5653377fe56388eb7be4748735bac61ac119b39
parent1fae9e5e214491c2c62ce10d11e10b080744cab5 (diff)
evas gl: added partial rendering support for qcom extension
When running in direct rendering mode, properly support partial rendering if the extension is properly supported. Also, fixed the SwapBufferwWithDamage rectangle coordinate bug. It wasn't properly y-inverted before.
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api.c28
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h9
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c58
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core.c132
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core.h13
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core_private.h10
-rw-r--r--src/modules/evas/engines/gl_x11/evas_engine.c86
-rw-r--r--src/modules/evas/engines/wayland_egl/evas_engine.c14
8 files changed, 298 insertions, 52 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api.c b/src/modules/evas/engines/gl_common/evas_gl_api.c
index d831f9d73d..0555b4a783 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api.c
@@ -56,7 +56,9 @@ void
56_evgl_glBindFramebuffer(GLenum target, GLuint framebuffer) 56_evgl_glBindFramebuffer(GLenum target, GLuint framebuffer)
57{ 57{
58 EVGL_Context *ctx = NULL; 58 EVGL_Context *ctx = NULL;
59 EVGL_Resource *rsc;
59 60
61 rsc = _evgl_tls_resource_get();
60 ctx = _evgl_current_context_get(); 62 ctx = _evgl_current_context_get();
61 63
62 if (!ctx) 64 if (!ctx)
@@ -69,13 +71,35 @@ _evgl_glBindFramebuffer(GLenum target, GLuint framebuffer)
69 if (framebuffer==0) 71 if (framebuffer==0)
70 { 72 {
71 if (_evgl_direct_enabled()) 73 if (_evgl_direct_enabled())
72 glBindFramebuffer(target, 0); 74 {
75 glBindFramebuffer(target, 0);
76
77 if (rsc->direct.partial.enabled)
78 {
79 if (!ctx->partial_render)
80 {
81 evgl_direct_partial_render_start();
82 ctx->partial_render = 1;
83 }
84 }
85 }
73 else 86 else
74 glBindFramebuffer(target, ctx->surface_fbo); 87 {
88 glBindFramebuffer(target, ctx->surface_fbo);
89 }
75 ctx->current_fbo = 0; 90 ctx->current_fbo = 0;
76 } 91 }
77 else 92 else
78 { 93 {
94 if (_evgl_direct_enabled())
95 {
96 if (ctx->current_fbo == 0)
97 {
98 if (rsc->direct.partial.enabled)
99 evgl_direct_partial_render_end();
100 }
101 }
102
79 glBindFramebuffer(target, framebuffer); 103 glBindFramebuffer(target, framebuffer);
80 104
81 // Save this for restore when doing make current 105 // Save this for restore when doing make current
diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h
index 9e1579ad00..a6b624d76b 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -531,6 +531,8 @@ struct _Evas_Engine_GL_Context
531 void *egldisp; 531 void *egldisp;
532 void *eglctxt; 532 void *eglctxt;
533#endif 533#endif
534
535 GLuint preserve_bit;
534}; 536};
535 537
536struct _Evas_GL_Texture_Pool 538struct _Evas_GL_Texture_Pool
@@ -692,7 +694,12 @@ void evas_gl_common_context_free(Evas_Engine_GL_Context *gc);
692void evas_gl_common_context_use(Evas_Engine_GL_Context *gc); 694void evas_gl_common_context_use(Evas_Engine_GL_Context *gc);
693void evas_gl_common_context_newframe(Evas_Engine_GL_Context *gc); 695void evas_gl_common_context_newframe(Evas_Engine_GL_Context *gc);
694void evas_gl_common_context_resize(Evas_Engine_GL_Context *gc, int w, int h, int rot); 696void evas_gl_common_context_resize(Evas_Engine_GL_Context *gc, int w, int h, int rot);
697void evas_gl_common_tiling_start(Evas_Engine_GL_Context *gc,
698 int rot, int gw, int gh,
699 int cx, int cy, int cw, int ch,
700 int bitmask);
695void evas_gl_common_context_done(Evas_Engine_GL_Context *gc); 701void evas_gl_common_context_done(Evas_Engine_GL_Context *gc);
702void evas_gl_common_tiling_done(Evas_Engine_GL_Context *gc);
696void evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc, Evas_GL_Image *surface); 703void evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc, Evas_GL_Image *surface);
697 704
698void evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc, 705void evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc,
@@ -818,7 +825,7 @@ void evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_P
818 825
819void evas_gl_common_line_draw(Evas_Engine_GL_Context *gc, int x1, int y1, int x2, int y2); 826void evas_gl_common_line_draw(Evas_Engine_GL_Context *gc, int x1, int y1, int x2, int y2);
820 827
821int evas_gl_common_buffer_dump(Evas_Engine_GL_Context *gc, const char* dname, const char* fname, int frame); 828int evas_gl_common_buffer_dump(Evas_Engine_GL_Context *gc, const char* dname, const char* fname, int frame, const char* suffix);
822 829
823extern void (*glsym_glGenFramebuffers) (GLsizei a, GLuint *b); 830extern void (*glsym_glGenFramebuffers) (GLsizei a, GLuint *b);
824extern void (*glsym_glBindFramebuffer) (GLenum a, GLuint b); 831extern void (*glsym_glBindFramebuffer) (GLenum a, GLuint b);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c b/src/modules/evas/engines/gl_common/evas_gl_context.c
index 5626ce4c86..2e447d9925 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -158,7 +158,8 @@ gl_symbols(void)
158 158
159 FINDSYM(glsym_glStartTiling, "glStartTilingQCOM", glsym_func_void); 159 FINDSYM(glsym_glStartTiling, "glStartTilingQCOM", glsym_func_void);
160 FINDSYM(glsym_glStartTiling, "glStartTiling", glsym_func_void); 160 FINDSYM(glsym_glStartTiling, "glStartTiling", glsym_func_void);
161 161 FINDSYM(glsym_glStartTiling, "glActivateTileQCOM", glsym_func_void);
162
162 FINDSYM(glsym_glEndTiling, "glEndTilingQCOM", glsym_func_void); 163 FINDSYM(glsym_glEndTiling, "glEndTilingQCOM", glsym_func_void);
163 FINDSYM(glsym_glEndTiling, "glEndTiling", glsym_func_void); 164 FINDSYM(glsym_glEndTiling, "glEndTiling", glsym_func_void);
164 165
@@ -1046,6 +1047,43 @@ evas_gl_common_context_resize(Evas_Engine_GL_Context *gc, int w, int h, int rot)
1046} 1047}
1047 1048
1048void 1049void
1050evas_gl_common_tiling_start(Evas_Engine_GL_Context *gc EINA_UNUSED,
1051 int rot, int gw, int gh,
1052 int cx, int cy, int cw, int ch,
1053 int bitmask)
1054{
1055 if (!glsym_glStartTiling) return;
1056 switch (rot)
1057 {
1058 case 0: // UP this way: ^
1059 glsym_glStartTiling(cx, cy, cw, ch, bitmask);
1060 break;
1061 case 90: // UP this way: <
1062 glsym_glStartTiling(gh - (cy + ch), cx, ch, cw, bitmask);
1063 break;
1064 case 180: // UP this way: v
1065 glsym_glStartTiling(gw - (cx + cw), gh - (cy + ch), cw, ch, bitmask);
1066 break;
1067 case 270: // UP this way: >
1068 glsym_glStartTiling(cy, gw - (cx + cw), ch, cw, bitmask);
1069 break;
1070 default: // assume up is up
1071 glsym_glStartTiling(cx, cy, cw, ch, bitmask);
1072 break;
1073 }
1074}
1075
1076void
1077evas_gl_common_tiling_done(Evas_Engine_GL_Context *gc EINA_UNUSED)
1078{
1079 if (glsym_glEndTiling)
1080 {
1081 glsym_glEndTiling(GL_COLOR_BUFFER_BIT0_QCOM);
1082 }
1083}
1084
1085
1086void
1049evas_gl_common_context_done(Evas_Engine_GL_Context *gc) 1087evas_gl_common_context_done(Evas_Engine_GL_Context *gc)
1050{ 1088{
1051 if (gc->master_clip.used) 1089 if (gc->master_clip.used)
@@ -2836,10 +2874,16 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
2836 if (!gc->master_clip.used) 2874 if (!gc->master_clip.used)
2837 { 2875 {
2838 if (!fbo) 2876 if (!fbo)
2839 start_tiling(gc, gc->rot, gw, gh, 2877 {
2840 gc->master_clip.x, 2878 start_tiling(gc, gc->rot, gw, gh,
2841 gh - gc->master_clip.y - gc->master_clip.h, 2879 gc->master_clip.x,
2842 gc->master_clip.w, gc->master_clip.h, 0); 2880 gh - gc->master_clip.y - gc->master_clip.h,
2881 gc->master_clip.w, gc->master_clip.h,
2882 gc->preserve_bit);
2883
2884 if (!gc->preserve_bit)
2885 gc->preserve_bit = GL_COLOR_BUFFER_BIT0_QCOM;
2886 }
2843 else 2887 else
2844 start_tiling(gc, 0, gw, gh, 2888 start_tiling(gc, 0, gw, gh,
2845 gc->master_clip.x, gc->master_clip.y, 2889 gc->master_clip.x, gc->master_clip.y,
@@ -3195,14 +3239,14 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
3195} 3239}
3196 3240
3197int 3241int
3198evas_gl_common_buffer_dump(Evas_Engine_GL_Context *gc, const char* dname, const char* buf_name, int frame) 3242evas_gl_common_buffer_dump(Evas_Engine_GL_Context *gc, const char* dname, const char* buf_name, int frame, const char *suffix)
3199{ 3243{
3200 RGBA_Image *im = NULL; 3244 RGBA_Image *im = NULL;
3201 DATA32 *data1, *data2; 3245 DATA32 *data1, *data2;
3202 char fname[100]; 3246 char fname[100];
3203 int ok = 0; 3247 int ok = 0;
3204 3248
3205 sprintf(fname, "./%s/evas_win_%s-fc_%03d.png", dname, buf_name, frame); 3249 sprintf(fname, "./%s/win_%s-fc_%03d_%s.png", dname, buf_name, frame, suffix);
3206 3250
3207 data1 = (DATA32 *)malloc(gc->w * gc->h * sizeof(DATA32)); 3251 data1 = (DATA32 *)malloc(gc->w * gc->h * sizeof(DATA32));
3208 data2 = (DATA32 *)malloc(gc->w * gc->h * sizeof(DATA32)); 3252 data2 = (DATA32 *)malloc(gc->w * gc->h * sizeof(DATA32));
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.c b/src/modules/evas/engines/gl_common/evas_gl_core.c
index c74754f390..f8e703723a 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.c
@@ -1409,7 +1409,7 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h)
1409{ 1409{
1410 EVGL_Surface *sfc = NULL; 1410 EVGL_Surface *sfc = NULL;
1411 char *s = NULL; 1411 char *s = NULL;
1412 int direct_override = 0; 1412 int direct_override = 0, direct_mem_opt = 0;
1413 1413
1414 // Check if engine is valid 1414 // Check if engine is valid
1415 if (!evgl_engine) 1415 if (!evgl_engine)
@@ -1441,6 +1441,16 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h)
1441 evgl_engine->direct_override = 1; 1441 evgl_engine->direct_override = 1;
1442 } 1442 }
1443 1443
1444 // Check if Direct Rendering Memory Optimzation flag is on
1445 // Creates resources on demand when it fallsback to fbo rendering
1446 if (!evgl_engine->direct_mem_opt)
1447 if ((s = getenv("EVAS_GL_DIRECT_MEM_OPT")))
1448 {
1449 direct_mem_opt = atoi(s);
1450 if (direct_mem_opt == 1)
1451 evgl_engine->direct_mem_opt = 1;
1452 }
1453
1444 // Allocate surface structure 1454 // Allocate surface structure
1445 sfc = calloc(1, sizeof(EVGL_Surface)); 1455 sfc = calloc(1, sizeof(EVGL_Surface));
1446 if (!sfc) 1456 if (!sfc)
@@ -1672,6 +1682,12 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
1672 // Unset 1682 // Unset
1673 if ((!sfc) && (!ctx)) 1683 if ((!sfc) && (!ctx))
1674 { 1684 {
1685 if (rsc->current_ctx)
1686 {
1687 if (rsc->direct.partial.enabled)
1688 evgl_direct_partial_render_end();
1689 }
1690
1675 if (!evgl_engine->funcs->make_current(eng_data, NULL, NULL, 0)) 1691 if (!evgl_engine->funcs->make_current(eng_data, NULL, NULL, 0))
1676 { 1692 {
1677 ERR("Error doing make_current(NULL, NULL)."); 1693 ERR("Error doing make_current(NULL, NULL).");
@@ -1687,6 +1703,12 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
1687 return 1; 1703 return 1;
1688 } 1704 }
1689 1705
1706 // Disable partial rendering for previous context
1707 if ((rsc->current_ctx) && (rsc->current_ctx != ctx))
1708 {
1709 evas_gl_common_tiling_done(NULL);
1710 rsc->current_ctx->partial_render = 0;
1711 }
1690 1712
1691 // Allocate or free resources depending on what mode (direct of fbo) it's 1713 // Allocate or free resources depending on what mode (direct of fbo) it's
1692 // running only if the env var EVAS_GL_DIRECT_MEM_OPT is set. 1714 // running only if the env var EVAS_GL_DIRECT_MEM_OPT is set.
@@ -1707,15 +1729,22 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
1707 } 1729 }
1708 else 1730 else
1709 { 1731 {
1710 // Create internal buffers if not yet created 1732 if (evgl_engine->direct_override)
1711 if (!sfc->buffers_allocated) 1733 {
1734 DBG("Not creating fallback surfaces even though it should. Use at OWN discretion!");
1735 }
1736 else
1712 { 1737 {
1713 if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, 1)) 1738 // Create internal buffers if not yet created
1739 if (!sfc->buffers_allocated)
1714 { 1740 {
1715 ERR("Unable Create Specificed Surfaces. Unsupported format!"); 1741 if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, 1))
1716 return 0; 1742 {
1743 ERR("Unable Create Specificed Surfaces. Unsupported format!");
1744 return 0;
1745 };
1746 sfc->buffers_allocated = 1;
1717 } 1747 }
1718 sfc->buffers_allocated = 1;
1719 } 1748 }
1720 } 1749 }
1721 } 1750 }
@@ -1742,6 +1771,20 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
1742 glBindFramebuffer(GL_FRAMEBUFFER, 0); 1771 glBindFramebuffer(GL_FRAMEBUFFER, 0);
1743 ctx->current_fbo = 0; 1772 ctx->current_fbo = 0;
1744 } 1773 }
1774
1775 if (ctx->current_fbo == 0)
1776 {
1777 // If master clip is set and clip is greater than 0, do partial render
1778 if (rsc->direct.partial.enabled)
1779 {
1780 if (!ctx->partial_render)
1781 {
1782 evgl_direct_partial_render_start();
1783 ctx->partial_render = 1;
1784 }
1785 }
1786 }
1787
1745 rsc->direct.rendered = 1; 1788 rsc->direct.rendered = 1;
1746 } 1789 }
1747 else 1790 else
@@ -1749,10 +1792,22 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
1749 // Attach fbo and the buffers 1792 // Attach fbo and the buffers
1750 if (ctx->current_sfc != sfc) 1793 if (ctx->current_sfc != sfc)
1751 { 1794 {
1752 if (!_surface_buffers_fbo_set(sfc, ctx->surface_fbo)) 1795 if ((evgl_engine->direct_mem_opt) && (evgl_engine->direct_override))
1753 { 1796 {
1754 ERR("Attaching buffers to context fbo failed. Engine: %p Surface: %p Context FBO: %u", evgl_engine, sfc, ctx->surface_fbo); 1797 DBG("Not creating fallback surfaces even though it should. Use at OWN discretion!");
1755 return 0; 1798 }
1799 else
1800 {
1801 // If it's transitioning from direct render to fbo render
1802 // Call end tiling
1803 if (rsc->direct.partial.enabled)
1804 evgl_direct_partial_render_end();
1805
1806 if (!_surface_buffers_fbo_set(sfc, ctx->surface_fbo))
1807 {
1808 ERR("Attaching buffers to context fbo failed. Engine: %p Surface: %p Context FBO: %u", evgl_engine, sfc, ctx->surface_fbo);
1809 return 0;
1810 }
1756 } 1811 }
1757 1812
1758 // Bind to the previously bound buffer 1813 // Bind to the previously bound buffer
@@ -1879,6 +1934,28 @@ evgl_api_get()
1879 return &gl_funcs; 1934 return &gl_funcs;
1880} 1935}
1881 1936
1937
1938void
1939evgl_direct_partial_info_set(int pres)
1940{
1941 EVGL_Resource *rsc;
1942
1943 if (!(rsc=_evgl_tls_resource_get())) return;
1944
1945 rsc->direct.partial.enabled = EINA_TRUE;
1946 rsc->direct.partial.preserve = pres;
1947}
1948
1949void
1950evgl_direct_partial_info_clear()
1951{
1952 EVGL_Resource *rsc;
1953
1954 if (!(rsc=_evgl_tls_resource_get())) return;
1955
1956 rsc->direct.partial.enabled = EINA_FALSE;
1957}
1958
1882void 1959void
1883evgl_direct_override_get(int *override, int *force_off) 1960evgl_direct_override_get(int *override, int *force_off)
1884{ 1961{
@@ -1886,6 +1963,41 @@ evgl_direct_override_get(int *override, int *force_off)
1886 *force_off = evgl_engine->direct_force_off; 1963 *force_off = evgl_engine->direct_force_off;
1887} 1964}
1888 1965
1966void
1967evgl_direct_partial_render_start()
1968{
1969 EVGL_Resource *rsc;
1970
1971 if (!(rsc=_evgl_tls_resource_get())) return;
1972
1973 evas_gl_common_tiling_start(NULL,
1974 rsc->direct.rot,
1975 rsc->direct.win_w,
1976 rsc->direct.win_h,
1977 rsc->direct.clip.x,
1978 rsc->direct.win_h - rsc->direct.clip.y - rsc->direct.clip.h,
1979 rsc->direct.clip.w,
1980 rsc->direct.clip.h,
1981 rsc->direct.partial.preserve);
1982
1983 if (!rsc->direct.partial.preserve)
1984 rsc->direct.partial.preserve = GL_COLOR_BUFFER_BIT0_QCOM;
1985}
1986
1987void
1988evgl_direct_partial_render_end()
1989{
1990 EVGL_Context *ctx;
1991 ctx = _evgl_current_context_get();
1992
1993 if (!ctx) return;
1994
1995 if (ctx->partial_render)
1996 {
1997 evas_gl_common_tiling_done(NULL);
1998 ctx->partial_render = 0;
1999 }
2000}
1889//-----------------------------------------------------// 2001//-----------------------------------------------------//
1890 2002
1891 2003
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.h b/src/modules/evas/engines/gl_common/evas_gl_core.h
index 587e8b0405..9ff5c06417 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.h
@@ -31,11 +31,16 @@ const char *evgl_string_query(int name);
31void *evgl_proc_address_get(const char *name); 31void *evgl_proc_address_get(const char *name);
32int evgl_native_surface_get(EVGL_Surface *sfc, Evas_Native_Surface *ns); 32int evgl_native_surface_get(EVGL_Surface *sfc, Evas_Native_Surface *ns);
33Evas_GL_API *evgl_api_get(); 33Evas_GL_API *evgl_api_get();
34int evgl_direct_rendered();
35
36void evgl_direct_info_set(int win_w, int win_h, int rot, int img_x, int img_y, int img_w, int img_h, int clip_x, int clip_y, int clip_w, int clip_h);
37void evgl_direct_info_clear();
38 34
35int evgl_direct_rendered();
39void evgl_direct_override_get(int *override, int *force_off); 36void evgl_direct_override_get(int *override, int *force_off);
37void evgl_direct_info_set(int win_w, int win_h, int rot,
38 int img_x, int img_y, int img_w, int img_h,
39 int clip_x, int clip_y, int clip_w, int clip_h);
40void evgl_direct_info_clear();
40 41
42void evgl_direct_partial_info_set(int pres);
43void evgl_direct_partial_info_clear();
44void evgl_direct_partial_render_start();
45void evgl_direct_partial_render_end();
41#endif //_EVAS_GL_CORE_H 46#endif //_EVAS_GL_CORE_H
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core_private.h b/src/modules/evas/engines/gl_common/evas_gl_core_private.h
index 85ccf9e265..fce0fab11c 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core_private.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_core_private.h
@@ -134,6 +134,9 @@ struct _EVGL_Context
134 int viewport_updated; 134 int viewport_updated;
135 int viewport_coord[4]; 135 int viewport_coord[4];
136 136
137 // Partial Rendering
138 int partial_render;
139
137 EVGL_Surface *current_sfc; 140 EVGL_Surface *current_sfc;
138}; 141};
139 142
@@ -225,9 +228,14 @@ struct _EVGL_Resource
225 int x, y, w, h; 228 int x, y, w, h;
226 } clip; 229 } clip;
227 230
228 Eina_Bool enabled : 1; 231 struct {
232 int preserve;
233 Eina_Bool enabled : 1;
234 } partial;
229 235
236 Eina_Bool enabled : 1;
230 } direct; 237 } direct;
238
231}; 239};
232 240
233struct _EVGL_Engine 241struct _EVGL_Engine
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c
index d4185cd136..d899ad94bd 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.c
+++ b/src/modules/evas/engines/gl_x11/evas_engine.c
@@ -1414,6 +1414,8 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i
1414 rect = (Tilebuf_Rect *)re->cur_rect; 1414 rect = (Tilebuf_Rect *)re->cur_rect;
1415 if (re->rects) 1415 if (re->rects)
1416 { 1416 {
1417 re->win->gl_context->preserve_bit = GL_COLOR_BUFFER_BIT0_QCOM;
1418
1417 switch (re->mode) 1419 switch (re->mode)
1418 { 1420 {
1419 case MODE_COPY: 1421 case MODE_COPY:
@@ -1574,13 +1576,15 @@ eng_output_flush(void *data, Evas_Render_Mode render_mode)
1574 if (swap_buffer_debug) 1576 if (swap_buffer_debug)
1575 { 1577 {
1576 char fname[100]; 1578 char fname[100];
1579 char suffix[100];
1577 int ret = 0; 1580 int ret = 0;
1578 snprintf(fname, sizeof(fname), "%p", (void*)re->win); 1581 snprintf(fname, sizeof(fname), "%p", (void*)re->win);
1579 1582
1580 ret = evas_gl_common_buffer_dump(re->win->gl_context, 1583 ret = evas_gl_common_buffer_dump(re->win->gl_context,
1581 (const char*)dname, 1584 (const char*)dname,
1582 (const char*)fname, 1585 (const char*)fname,
1583 re->frame_cnt); 1586 re->frame_cnt,
1587 suffix);
1584 if (!ret) swap_buffer_debug_mode = 0; 1588 if (!ret) swap_buffer_debug_mode = 0;
1585 } 1589 }
1586 } 1590 }
@@ -1616,31 +1620,31 @@ eng_output_flush(void *data, Evas_Render_Mode render_mode)
1616 { 1620 {
1617 case 0: 1621 case 0:
1618 rects[i + 0] = r->x; 1622 rects[i + 0] = r->x;
1619 rects[i + 1] = gh - r->y; 1623 rects[i + 1] = gh - (r->y + r->h);
1620 rects[i + 2] = r->w; 1624 rects[i + 2] = r->w;
1621 rects[i + 3] = r->h; 1625 rects[i + 3] = r->h;
1622 break; 1626 break;
1623 case 90: 1627 case 90:
1624 rects[i + 0] = r->y; 1628 rects[i + 0] = r->y;
1625 rects[i + 1] = gw - (gw - (r->x + r->w)); 1629 rects[i + 1] = r->x;
1626 rects[i + 2] = r->h; 1630 rects[i + 2] = r->h;
1627 rects[i + 3] = r->w; 1631 rects[i + 3] = r->w;
1628 break; 1632 break;
1629 case 180: 1633 case 180:
1630 rects[i + 0] = gw - (r->x + r->w); 1634 rects[i + 0] = gw - (r->x + r->w);
1631 rects[i + 1] = gh - (gh - (r->y + r->h)); 1635 rects[i + 1] = r->y;
1632 rects[i + 2] = r->w; 1636 rects[i + 2] = r->w;
1633 rects[i + 3] = r->h; 1637 rects[i + 3] = r->h;
1634 break; 1638 break;
1635 case 270: 1639 case 270:
1636 rects[i + 0] = gh - (r->y + r->h); 1640 rects[i + 0] = gh - (r->y + r->h);
1637 rects[i + 1] = gw - r->x; 1641 rects[i + 1] = gw - (r->x + r->w);
1638 rects[i + 2] = r->h; 1642 rects[i + 2] = r->h;
1639 rects[i + 3] = r->w; 1643 rects[i + 3] = r->w;
1640 break; 1644 break;
1641 default: 1645 default:
1642 rects[i + 0] = r->x; 1646 rects[i + 0] = r->x;
1643 rects[i + 1] = gh - r->y; 1647 rects[i + 1] = gh - (r->y + r->h);
1644 rects[i + 2] = r->w; 1648 rects[i + 2] = r->w;
1645 rects[i + 3] = r->h; 1649 rects[i + 3] = r->h;
1646 break; 1650 break;
@@ -3007,21 +3011,42 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x,
3007 3011
3008 re->win->gl_context->dc = context; 3012 re->win->gl_context->dc = context;
3009 3013
3010 // Set necessary info for direct rendering 3014 if (re->func.get_pixels)
3011 evgl_direct_info_set(re->win->gl_context->w, 3015 {
3012 re->win->gl_context->h, 3016 if ((re->win->gl_context->master_clip.enabled) &&
3013 re->win->gl_context->rot, 3017 (re->win->gl_context->master_clip.w > 0) &&
3014 dst_x, dst_y, dst_w, dst_h, 3018 (re->win->gl_context->master_clip.h > 0))
3015 re->win->gl_context->dc->clip.x, 3019 {
3016 re->win->gl_context->dc->clip.y, 3020 // Pass the preserve flag info the evas_gl
3017 re->win->gl_context->dc->clip.w, 3021 evgl_direct_partial_info_set(re->win->gl_context->preserve_bit);
3018 re->win->gl_context->dc->clip.h); 3022 }
3019 3023
3020 // Call pixel get function 3024 // Set necessary info for direct rendering
3021 re->func.get_pixels(re->func.get_pixels_data, re->func.obj); 3025 evgl_direct_info_set(re->win->gl_context->w,
3026 re->win->gl_context->h,
3027 re->win->gl_context->rot,
3028 dst_x, dst_y, dst_w, dst_h,
3029 re->win->gl_context->dc->clip.x,
3030 re->win->gl_context->dc->clip.y,
3031 re->win->gl_context->dc->clip.w,
3032 re->win->gl_context->dc->clip.h);
3033
3034 // Call pixel get function
3035 re->func.get_pixels(re->func.get_pixels_data, re->func.obj);
3036
3037 // Call end tile if it's being used
3038 if ((re->win->gl_context->master_clip.enabled) &&
3039 (re->win->gl_context->master_clip.w > 0) &&
3040 (re->win->gl_context->master_clip.h > 0))
3041 {
3042 evgl_direct_partial_render_end();
3043 evgl_direct_partial_info_clear();
3044 re->win->gl_context->preserve_bit = GL_COLOR_BUFFER_BIT0_QCOM;
3045 }
3022 3046
3023 // Clear direct rendering info 3047 // Reset direct rendering info
3024 evgl_direct_info_clear(); 3048 evgl_direct_info_clear();
3049 }
3025 } 3050 }
3026 else 3051 else
3027 { 3052 {
@@ -3278,10 +3303,23 @@ eng_gl_context_destroy(void *data, void *context)
3278static int 3303static int
3279eng_gl_make_current(void *data, void *surface, void *context) 3304eng_gl_make_current(void *data, void *surface, void *context)
3280{ 3305{
3306 Render_Engine *re = (Render_Engine *)data;
3281 EVGL_Surface *sfc = (EVGL_Surface *)surface; 3307 EVGL_Surface *sfc = (EVGL_Surface *)surface;
3282 EVGL_Context *ctx = (EVGL_Context *)context; 3308 EVGL_Context *ctx = (EVGL_Context *)context;
3283 3309
3284 EVGLINIT(data, 0); 3310 EVGLINIT(data, 0);
3311 if ((sfc) && (ctx))
3312 {
3313 if ((re->win->gl_context->havestuff) ||
3314 (re->win->gl_context->master_clip.used))
3315 {
3316 eng_window_use(re->win);
3317 evas_gl_common_context_flush(re->win->gl_context);
3318 if (re->win->gl_context->master_clip.used)
3319 evas_gl_common_context_done(re->win->gl_context);
3320 }
3321 }
3322
3285 return evgl_make_current(data, sfc, ctx); 3323 return evgl_make_current(data, sfc, ctx);
3286} 3324}
3287 3325
@@ -3544,8 +3582,14 @@ eng_context_flush(void *data)
3544 Render_Engine *re; 3582 Render_Engine *re;
3545 re = (Render_Engine *)data; 3583 re = (Render_Engine *)data;
3546 3584
3547 eng_window_use(re->win); 3585 if ((re->win->gl_context->havestuff) ||
3548 evas_gl_common_context_flush(re->win->gl_context); 3586 (re->win->gl_context->master_clip.used))
3587 {
3588 eng_window_use(re->win);
3589 evas_gl_common_context_flush(re->win->gl_context);
3590 if (re->win->gl_context->master_clip.used)
3591 evas_gl_common_context_done(re->win->gl_context);
3592 }
3549} 3593}
3550 3594
3551static int 3595static int
diff --git a/src/modules/evas/engines/wayland_egl/evas_engine.c b/src/modules/evas/engines/wayland_egl/evas_engine.c
index ea6c7d357b..2de02765a2 100644
--- a/src/modules/evas/engines/wayland_egl/evas_engine.c
+++ b/src/modules/evas/engines/wayland_egl/evas_engine.c
@@ -1231,13 +1231,15 @@ eng_output_flush(void *data, Evas_Render_Mode render_mode)
1231 if (swap_buffer_debug) 1231 if (swap_buffer_debug)
1232 { 1232 {
1233 char fname[100]; 1233 char fname[100];
1234 char suffix[100];
1234 int ret = 0; 1235 int ret = 0;
1235 sprintf(fname, "%p", (void*)re->win); 1236 sprintf(fname, "%p", (void*)re->win);
1236 1237
1237 ret = evas_gl_common_buffer_dump(re->win->gl_context, 1238 ret = evas_gl_common_buffer_dump(re->win->gl_context,
1238 (const char*)dname, 1239 (const char*)dname,
1239 (const char*)fname, 1240 (const char*)fname,
1240 re->frame_cnt); 1241 re->frame_cnt,
1242 suffix);
1241 if (!ret) swap_buffer_debug_mode = 0; 1243 if (!ret) swap_buffer_debug_mode = 0;
1242 } 1244 }
1243 } 1245 }
@@ -1272,31 +1274,31 @@ eng_output_flush(void *data, Evas_Render_Mode render_mode)
1272 { 1274 {
1273 case 0: 1275 case 0:
1274 rects[i + 0] = r->x; 1276 rects[i + 0] = r->x;
1275 rects[i + 1] = gh - r->y; 1277 rects[i + 1] = gh - (r->y + r->h);
1276 rects[i + 2] = r->w; 1278 rects[i + 2] = r->w;
1277 rects[i + 3] = r->h; 1279 rects[i + 3] = r->h;
1278 break; 1280 break;
1279 case 90: 1281 case 90:
1280 rects[i + 0] = r->y; 1282 rects[i + 0] = r->y;
1281 rects[i + 1] = gw - (gw - (r->x + r->w)); 1283 rects[i + 1] = r->x;
1282 rects[i + 2] = r->h; 1284 rects[i + 2] = r->h;
1283 rects[i + 3] = r->w; 1285 rects[i + 3] = r->w;
1284 break; 1286 break;
1285 case 180: 1287 case 180:
1286 rects[i + 0] = gw - (r->x + r->w); 1288 rects[i + 0] = gw - (r->x + r->w);
1287 rects[i + 1] = gh - (gh - (r->y + r->h)); 1289 rects[i + 1] = r->y;
1288 rects[i + 2] = r->w; 1290 rects[i + 2] = r->w;
1289 rects[i + 3] = r->h; 1291 rects[i + 3] = r->h;
1290 break; 1292 break;
1291 case 270: 1293 case 270:
1292 rects[i + 0] = gh - (r->y + r->h); 1294 rects[i + 0] = gh - (r->y + r->h);
1293 rects[i + 1] = gw - r->x; 1295 rects[i + 1] = gw - (r->x + r->w);
1294 rects[i + 2] = r->h; 1296 rects[i + 2] = r->h;
1295 rects[i + 3] = r->w; 1297 rects[i + 3] = r->w;
1296 break; 1298 break;
1297 default: 1299 default:
1298 rects[i + 0] = r->x; 1300 rects[i + 0] = r->x;
1299 rects[i + 1] = gh - r->y; 1301 rects[i + 1] = gh - (r->y + r->h);
1300 rects[i + 2] = r->w; 1302 rects[i + 2] = r->w;
1301 rects[i + 3] = r->h; 1303 rects[i + 3] = r->h;
1302 break; 1304 break;