diff options
author | Chris Michael <cp.michael@samsung.com> | 2015-06-04 11:52:22 -0400 |
---|---|---|
committer | Chris Michael <cp.michael@samsung.com> | 2015-06-05 10:00:45 -0400 |
commit | a83bb5e45d9b58788f7a98c2d3f74513495aff68 (patch) | |
tree | a3f0c9adccf481203f95e2e45051d46f3f6b099a /src | |
parent | 35e7d364892a0d30993c600f29c83f9f1e9220c8 (diff) |
evas-gl-drm: Refactor gl_drm engine to not use dumb buffers
@fix
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/evas/engines/gl_drm/evas_engine.c | 127 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_drm/evas_engine.h | 3 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_drm/evas_outbuf.c | 162 |
3 files changed, 168 insertions, 124 deletions
diff --git a/src/modules/evas/engines/gl_drm/evas_engine.c b/src/modules/evas/engines/gl_drm/evas_engine.c index 835417ccbb..ceddf5c537 100644 --- a/src/modules/evas/engines/gl_drm/evas_engine.c +++ b/src/modules/evas/engines/gl_drm/evas_engine.c | |||
@@ -8,6 +8,10 @@ | |||
8 | # error gl_drm should not get compiled if dlsym is not found on the system! | 8 | # error gl_drm should not get compiled if dlsym is not found on the system! |
9 | #endif | 9 | #endif |
10 | 10 | ||
11 | #ifdef EVAS_CSERVE2 | ||
12 | # include "evas_cs2_private.h" | ||
13 | #endif | ||
14 | |||
11 | #define EVAS_GL_NO_GL_H_CHECK 1 | 15 | #define EVAS_GL_NO_GL_H_CHECK 1 |
12 | #include "Evas_GL.h" | 16 | #include "Evas_GL.h" |
13 | 17 | ||
@@ -40,6 +44,15 @@ struct _Native | |||
40 | void *egl_surface; | 44 | void *egl_surface; |
41 | }; | 45 | }; |
42 | 46 | ||
47 | /* local function prototype types */ | ||
48 | typedef void (*_eng_fn)(void); | ||
49 | typedef _eng_fn (*glsym_func_eng_fn)(); | ||
50 | typedef void (*glsym_func_void)(); | ||
51 | typedef void *(*glsym_func_void_ptr)(); | ||
52 | typedef int (*glsym_func_int)(); | ||
53 | typedef unsigned int (*glsym_func_uint)(); | ||
54 | typedef const char *(*glsym_func_const_char_ptr)(); | ||
55 | |||
43 | /* external dynamic loaded Evas_GL function pointers */ | 56 | /* external dynamic loaded Evas_GL function pointers */ |
44 | Evas_GL_Common_Image_Call glsym_evas_gl_common_image_ref = NULL; | 57 | Evas_GL_Common_Image_Call glsym_evas_gl_common_image_ref = NULL; |
45 | Evas_GL_Common_Image_Call glsym_evas_gl_common_image_unref = NULL; | 58 | Evas_GL_Common_Image_Call glsym_evas_gl_common_image_unref = NULL; |
@@ -51,6 +64,7 @@ Evas_GL_Common_Context_Call glsym_evas_gl_common_image_all_unload = NULL; | |||
51 | Evas_GL_Preload glsym_evas_gl_preload_init = NULL; | 64 | Evas_GL_Preload glsym_evas_gl_preload_init = NULL; |
52 | Evas_GL_Preload glsym_evas_gl_preload_shutdown = NULL; | 65 | Evas_GL_Preload glsym_evas_gl_preload_shutdown = NULL; |
53 | EVGL_Engine_Call glsym_evgl_engine_shutdown = NULL; | 66 | EVGL_Engine_Call glsym_evgl_engine_shutdown = NULL; |
67 | EVGL_Current_Native_Context_Get_Call glsym_evgl_current_native_context_get = NULL; | ||
54 | Evas_Gl_Symbols glsym_evas_gl_symbols = NULL; | 68 | Evas_Gl_Symbols glsym_evas_gl_symbols = NULL; |
55 | 69 | ||
56 | Evas_GL_Common_Context_New glsym_evas_gl_common_context_new = NULL; | 70 | Evas_GL_Common_Context_New glsym_evas_gl_common_context_new = NULL; |
@@ -65,14 +79,7 @@ Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_lock = NULL; | |||
65 | Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_unlock = NULL; | 79 | Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_unlock = NULL; |
66 | Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_relax = NULL; | 80 | Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_relax = NULL; |
67 | 81 | ||
68 | /* local function prototype types */ | 82 | glsym_func_void_ptr glsym_evas_gl_common_current_context_get = NULL; |
69 | typedef void (*_eng_fn)(void); | ||
70 | typedef _eng_fn (*glsym_func_eng_fn)(); | ||
71 | typedef void (*glsym_func_void)(); | ||
72 | typedef void *(*glsym_func_void_ptr)(); | ||
73 | typedef int (*glsym_func_int)(); | ||
74 | typedef unsigned int (*glsym_func_uint)(); | ||
75 | typedef const char *(*glsym_func_const_char_ptr)(); | ||
76 | 83 | ||
77 | /* dynamic loaded local egl function pointers */ | 84 | /* dynamic loaded local egl function pointers */ |
78 | _eng_fn (*glsym_eglGetProcAddress)(const char *a) = NULL; | 85 | _eng_fn (*glsym_eglGetProcAddress)(const char *a) = NULL; |
@@ -163,7 +170,9 @@ gl_symbols(void) | |||
163 | LINK2GENERIC(evas_gl_preload_init); | 170 | LINK2GENERIC(evas_gl_preload_init); |
164 | LINK2GENERIC(evas_gl_preload_shutdown); | 171 | LINK2GENERIC(evas_gl_preload_shutdown); |
165 | LINK2GENERIC(evgl_engine_shutdown); | 172 | LINK2GENERIC(evgl_engine_shutdown); |
173 | LINK2GENERIC(evgl_current_native_context_get); | ||
166 | LINK2GENERIC(evas_gl_symbols); | 174 | LINK2GENERIC(evas_gl_symbols); |
175 | LINK2GENERIC(evas_gl_common_current_context_get); | ||
167 | 176 | ||
168 | #define FINDSYM(dst, sym, typ) \ | 177 | #define FINDSYM(dst, sym, typ) \ |
169 | if (glsym_eglGetProcAddress) { \ | 178 | if (glsym_eglGetProcAddress) { \ |
@@ -248,7 +257,7 @@ evgl_eng_display_get(void *data) | |||
248 | } | 257 | } |
249 | 258 | ||
250 | if (eng_get_ob(re)) | 259 | if (eng_get_ob(re)) |
251 | return (void*)eng_get_ob(re)->egl.disp; | 260 | return (void *)eng_get_ob(re)->egl.disp; |
252 | else | 261 | else |
253 | return NULL; | 262 | return NULL; |
254 | } | 263 | } |
@@ -266,7 +275,7 @@ evgl_eng_evas_surface_get(void *data) | |||
266 | } | 275 | } |
267 | 276 | ||
268 | if (eng_get_ob(re)) | 277 | if (eng_get_ob(re)) |
269 | return (void*)eng_get_ob(re)->egl.surface[0]; | 278 | return (void *)eng_get_ob(re)->egl.surface[0]; |
270 | else | 279 | else |
271 | return NULL; | 280 | return NULL; |
272 | } | 281 | } |
@@ -371,6 +380,9 @@ evgl_eng_native_window_destroy(void *data, void *native_window) | |||
371 | } | 380 | } |
372 | 381 | ||
373 | gbm_surface_destroy((struct gbm_surface *)native_window); | 382 | gbm_surface_destroy((struct gbm_surface *)native_window); |
383 | |||
384 | native_window = NULL; | ||
385 | |||
374 | return 1; | 386 | return 1; |
375 | } | 387 | } |
376 | 388 | ||
@@ -468,7 +480,7 @@ evgl_eng_context_create(void *data, void *share_ctx, Evas_GL_Context_Version ver | |||
468 | 480 | ||
469 | if (!context) | 481 | if (!context) |
470 | { | 482 | { |
471 | ERR("Engine Context Creations Failed. Error: %#x.", eglGetError()); | 483 | ERR("eglMakeCurrent() failed! Error Code=%#x", eglGetError()); |
472 | return NULL; | 484 | return NULL; |
473 | } | 485 | } |
474 | 486 | ||
@@ -596,6 +608,8 @@ _native_cb_bind(void *data EINA_UNUSED, void *image) | |||
596 | } | 608 | } |
597 | else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) | 609 | else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) |
598 | glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id); | 610 | glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id); |
611 | |||
612 | /* TODO: NATIVE_SURFACE_TBM and NATIVE_SURFACE_EVASGL */ | ||
599 | } | 613 | } |
600 | 614 | ||
601 | static void | 615 | static void |
@@ -613,6 +627,8 @@ _native_cb_unbind(void *data EINA_UNUSED, void *image) | |||
613 | } | 627 | } |
614 | else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) | 628 | else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) |
615 | glBindTexture(GL_TEXTURE_2D, 0); | 629 | glBindTexture(GL_TEXTURE_2D, 0); |
630 | |||
631 | /* TODO: NATIVE_SURFACE_TBM and NATIVE_SURFACE_EVASGL */ | ||
616 | } | 632 | } |
617 | 633 | ||
618 | static void | 634 | static void |
@@ -669,7 +685,6 @@ eng_gbm_init(Evas_Engine_Info_GL_Drm *info, int w, int h) | |||
669 | if (!info) return EINA_FALSE; | 685 | if (!info) return EINA_FALSE; |
670 | if (!(dev = info->info.dev)) return EINA_FALSE; | 686 | if (!(dev = info->info.dev)) return EINA_FALSE; |
671 | 687 | ||
672 | DBG("Create GBM Device"); | ||
673 | if (!(info->info.gbm = gbm_create_device(dev->drm.fd))) | 688 | if (!(info->info.gbm = gbm_create_device(dev->drm.fd))) |
674 | { | 689 | { |
675 | ERR("Coult not create gbm device: %m"); | 690 | ERR("Coult not create gbm device: %m"); |
@@ -769,7 +784,7 @@ eng_setup(Evas *evas, void *in) | |||
769 | if (!(re = epd->engine.data.output)) | 784 | if (!(re = epd->engine.data.output)) |
770 | { | 785 | { |
771 | Outbuf *ob; | 786 | Outbuf *ob; |
772 | Render_Engine_Merge_Mode merge_mode = MERGE_FULL; | 787 | Render_Engine_Merge_Mode merge_mode = MERGE_BOUNDING; |
773 | 788 | ||
774 | if (!initted) | 789 | if (!initted) |
775 | { | 790 | { |
@@ -850,57 +865,45 @@ eng_setup(Evas *evas, void *in) | |||
850 | (info->info.depth != eng_get_ob(re)->depth) || | 865 | (info->info.depth != eng_get_ob(re)->depth) || |
851 | (info->info.destination_alpha != eng_get_ob(re)->destination_alpha)) | 866 | (info->info.destination_alpha != eng_get_ob(re)->destination_alpha)) |
852 | { | 867 | { |
853 | Outbuf *ob; | 868 | Outbuf *ob, *ob_old; |
854 | 869 | ||
855 | eng_get_ob(re)->gl_context->references++; | 870 | ob_old = re->generic.software.ob; |
871 | re->generic.software.ob = NULL; | ||
856 | gl_wins--; | 872 | gl_wins--; |
857 | 873 | ||
858 | ob = evas_outbuf_new(info, epd->output.w, epd->output.h, swap_mode); | 874 | ob = evas_outbuf_new(info, epd->output.w, epd->output.h, swap_mode); |
859 | 875 | if (!ob) | |
860 | evas_outbuf_free(eng_get_ob(re)); | 876 | { |
861 | re->generic.software.ob = NULL; | 877 | if (ob_old) evas_outbuf_free(ob_old); |
878 | free(re); | ||
879 | return 0; | ||
880 | } | ||
862 | 881 | ||
863 | evas_outbuf_use(ob); | 882 | evas_outbuf_use(ob); |
864 | if (ob) | 883 | if (ob_old) evas_outbuf_free(ob_old); |
865 | { | ||
866 | ob->evas = evas; | ||
867 | 884 | ||
868 | evas_render_engine_software_generic_update(&re->generic.software, ob, | 885 | ob->evas = evas; |
869 | epd->output.w, epd->output.h); | ||
870 | 886 | ||
871 | gl_wins++; | 887 | evas_render_engine_software_generic_update(&re->generic.software, ob, |
872 | eng_get_ob(re)->gl_context->references--; | 888 | epd->output.w, epd->output.h); |
873 | } | 889 | |
890 | gl_wins++; | ||
874 | } | 891 | } |
875 | else if ((eng_get_ob(re)->w != epd->output.w) || | 892 | else if ((eng_get_ob(re)->w != epd->output.w) || |
876 | (eng_get_ob(re)->h != epd->output.h) || | 893 | (eng_get_ob(re)->h != epd->output.h) || |
877 | (info->info.rotation != eng_get_ob(re)->rotation)) | 894 | (info->info.rotation != eng_get_ob(re)->rotation)) |
878 | { | 895 | { |
879 | Outbuf *ob; | 896 | evas_outbuf_reconfigure(eng_get_ob(re), |
880 | 897 | epd->output.w, epd->output.h, | |
881 | eng_get_ob(re)->gl_context->references++; | 898 | info->info.rotation, |
882 | gl_wins--; | 899 | info->info.depth); |
883 | 900 | if (re->generic.software.tb) | |
884 | evas_outbuf_free(eng_get_ob(re)); | 901 | evas_common_tilebuf_free(re->generic.software.tb); |
885 | re->generic.software.ob = NULL; | 902 | re->generic.software.tb = |
886 | 903 | evas_common_tilebuf_new(epd->output.w, epd->output.h); | |
887 | eng_gbm_shutdown(eng_get_ob(re)->info); | 904 | if (re->generic.software.tb) |
888 | if (!eng_gbm_init(info, epd->output.w, epd->output.h)) | 905 | evas_common_tilebuf_set_tile_size(re->generic.software.tb, |
889 | return 0; | 906 | TILESIZE, TILESIZE); |
890 | |||
891 | ob = evas_outbuf_new(info, epd->output.w, epd->output.h, swap_mode); | ||
892 | |||
893 | evas_outbuf_use(ob); | ||
894 | if (ob) | ||
895 | { | ||
896 | ob->evas = evas; | ||
897 | |||
898 | evas_render_engine_software_generic_update(&re->generic.software, ob, | ||
899 | epd->output.w, epd->output.h); | ||
900 | |||
901 | gl_wins++; | ||
902 | eng_get_ob(re)->gl_context->references--; | ||
903 | } | ||
904 | } | 907 | } |
905 | } | 908 | } |
906 | } | 909 | } |
@@ -923,7 +926,8 @@ eng_setup(Evas *evas, void *in) | |||
923 | return 0; | 926 | return 0; |
924 | } | 927 | } |
925 | 928 | ||
926 | evas_render_engine_software_generic_tile_strict_set(&re->generic.software, EINA_TRUE); | 929 | if (re->generic.software.tb) |
930 | evas_render_engine_software_generic_tile_strict_set(&re->generic.software, EINA_TRUE); | ||
927 | 931 | ||
928 | if (!epd->engine.data.context) | 932 | if (!epd->engine.data.context) |
929 | { | 933 | { |
@@ -1208,9 +1212,26 @@ eng_image_native_set(void *data, void *image, void *native) | |||
1208 | } | 1212 | } |
1209 | } | 1213 | } |
1210 | 1214 | ||
1215 | /* TODO: NATIVE_SURFACE_TBM and NATIVE_SURFACE_EVASGL */ | ||
1216 | |||
1211 | return img; | 1217 | return img; |
1212 | } | 1218 | } |
1213 | 1219 | ||
1220 | static void * | ||
1221 | eng_gl_current_context_get(void *data EINA_UNUSED) | ||
1222 | { | ||
1223 | EVGL_Context *ctx; | ||
1224 | EVGLNative_Context context; | ||
1225 | |||
1226 | ctx = glsym_evas_gl_common_current_context_get(); | ||
1227 | if (!ctx) return NULL; | ||
1228 | |||
1229 | context = glsym_evgl_current_native_context_get(ctx); | ||
1230 | if (eglGetCurrentContext() == context) return ctx; | ||
1231 | |||
1232 | return NULL; | ||
1233 | } | ||
1234 | |||
1214 | /* module api functions */ | 1235 | /* module api functions */ |
1215 | static int | 1236 | static int |
1216 | module_open(Evas_Module *em) | 1237 | module_open(Evas_Module *em) |
@@ -1246,10 +1267,12 @@ module_open(Evas_Module *em) | |||
1246 | EVAS_API_OVERRIDE(output_free, &func, eng_); | 1267 | EVAS_API_OVERRIDE(output_free, &func, eng_); |
1247 | EVAS_API_OVERRIDE(output_dump, &func, eng_); | 1268 | EVAS_API_OVERRIDE(output_dump, &func, eng_); |
1248 | EVAS_API_OVERRIDE(image_native_set, &func, eng_); | 1269 | EVAS_API_OVERRIDE(image_native_set, &func, eng_); |
1270 | EVAS_API_OVERRIDE(gl_current_context_get, &func, eng_); | ||
1249 | 1271 | ||
1250 | /* Mesa's EGL driver loads wayland egl by default. (called by eglGetProcaddr() ) | 1272 | /* Mesa's EGL driver loads wayland egl by default. (called by eglGetProcaddr() ) |
1251 | * implicit env set (EGL_PLATFORM=drm) prevent that. */ | 1273 | * implicit env set (EGL_PLATFORM=drm) prevent that. */ |
1252 | setenv("EGL_PLATFORM", "drm", 1); | 1274 | setenv("EGL_PLATFORM", "drm", 1); |
1275 | |||
1253 | gl_symbols(); | 1276 | gl_symbols(); |
1254 | 1277 | ||
1255 | /* now advertise out own api */ | 1278 | /* now advertise out own api */ |
diff --git a/src/modules/evas/engines/gl_drm/evas_engine.h b/src/modules/evas/engines/gl_drm/evas_engine.h index 3aa25e4a33..28928932e7 100644 --- a/src/modules/evas/engines/gl_drm/evas_engine.h +++ b/src/modules/evas/engines/gl_drm/evas_engine.h | |||
@@ -87,7 +87,6 @@ struct _Outbuf | |||
87 | { | 87 | { |
88 | int prev_age, frame_cnt; | 88 | int prev_age, frame_cnt; |
89 | int curr, last, num; | 89 | int curr, last, num; |
90 | Ecore_Drm_Fb *buffer[4]; | ||
91 | struct gbm_bo *bo[4]; | 90 | struct gbm_bo *bo[4]; |
92 | Eina_List *pending_writes; | 91 | Eina_List *pending_writes; |
93 | } priv; | 92 | } priv; |
@@ -127,4 +126,6 @@ _re_wincheck(Outbuf *ob) | |||
127 | return EINA_FALSE; | 126 | return EINA_FALSE; |
128 | } | 127 | } |
129 | 128 | ||
129 | extern unsigned int (*glsym_eglSwapBuffersWithDamage)(EGLDisplay a, void *b, const EGLint *d, EGLint c); | ||
130 | |||
130 | #endif | 131 | #endif |
diff --git a/src/modules/evas/engines/gl_drm/evas_outbuf.c b/src/modules/evas/engines/gl_drm/evas_outbuf.c index 9df628f47f..09f2981b7d 100644 --- a/src/modules/evas/engines/gl_drm/evas_outbuf.c +++ b/src/modules/evas/engines/gl_drm/evas_outbuf.c | |||
@@ -6,18 +6,74 @@ static EGLContext context = EGL_NO_CONTEXT; | |||
6 | static int win_count = 0; | 6 | static int win_count = 0; |
7 | 7 | ||
8 | static void | 8 | static void |
9 | _evas_outbuf_fb_cb_destroy(struct gbm_bo *bo, void *data) | ||
10 | { | ||
11 | Ecore_Drm_Fb *fb; | ||
12 | |||
13 | fb = data; | ||
14 | if (fb) | ||
15 | { | ||
16 | struct gbm_device *gbm; | ||
17 | |||
18 | gbm = gbm_bo_get_device(bo); | ||
19 | drmModeRmFB(gbm_device_get_fd(gbm), fb->id); | ||
20 | free(fb); | ||
21 | } | ||
22 | } | ||
23 | |||
24 | static Ecore_Drm_Fb * | ||
25 | _evas_outbuf_fb_get(Ecore_Drm_Device *dev, struct gbm_bo *bo) | ||
26 | { | ||
27 | int ret; | ||
28 | Ecore_Drm_Fb *fb; | ||
29 | uint32_t format; | ||
30 | uint32_t handles[4], pitches[4], offsets[4]; | ||
31 | |||
32 | fb = gbm_bo_get_user_data(bo); | ||
33 | if (fb) return fb; | ||
34 | |||
35 | if (!(fb = calloc(1, sizeof(Ecore_Drm_Fb)))) return NULL; | ||
36 | |||
37 | format = gbm_bo_get_format(bo); | ||
38 | |||
39 | fb->w = gbm_bo_get_width(bo); | ||
40 | fb->h = gbm_bo_get_height(bo); | ||
41 | fb->hdl = gbm_bo_get_handle(bo).u32; | ||
42 | fb->stride = gbm_bo_get_stride(bo); | ||
43 | fb->size = fb->stride * fb->h; | ||
44 | |||
45 | handles[0] = fb->hdl; | ||
46 | pitches[0] = fb->stride; | ||
47 | offsets[0] = 0; | ||
48 | |||
49 | ret = drmModeAddFB2(dev->drm.fd, fb->w, fb->h, format, | ||
50 | handles, pitches, offsets, &(fb->id), 0); | ||
51 | if (ret) | ||
52 | ret = drmModeAddFB(dev->drm.fd, fb->w, fb->h, 24, 32, | ||
53 | fb->stride, fb->hdl, &(fb->id)); | ||
54 | |||
55 | if (ret) ERR("FAILED TO ADD FB: %m"); | ||
56 | |||
57 | gbm_bo_set_user_data(bo, fb, _evas_outbuf_fb_cb_destroy); | ||
58 | |||
59 | return fb; | ||
60 | } | ||
61 | |||
62 | static void | ||
9 | _evas_outbuf_cb_pageflip(void *data) | 63 | _evas_outbuf_cb_pageflip(void *data) |
10 | { | 64 | { |
11 | Outbuf *ob; | 65 | Outbuf *ob; |
12 | Ecore_Drm_Fb *fb; | 66 | Ecore_Drm_Fb *fb; |
67 | struct gbm_bo *bo; | ||
13 | 68 | ||
14 | if (!(ob = data)) return; | 69 | if (!(ob = data)) return; |
15 | 70 | ||
16 | if ((fb = ob->priv.buffer[ob->priv.curr])) | 71 | bo = ob->priv.bo[ob->priv.curr]; |
17 | { | 72 | |
18 | fb->pending_flip = EINA_FALSE; | 73 | fb = _evas_outbuf_fb_get(ob->info->info.dev, bo); |
19 | gbm_surface_release_buffer(ob->surface, ob->priv.bo[ob->priv.curr]); | 74 | if (fb) fb->pending_flip = EINA_FALSE; |
20 | } | 75 | |
76 | gbm_surface_release_buffer(ob->surface, bo); | ||
21 | 77 | ||
22 | ob->priv.last = ob->priv.curr; | 78 | ob->priv.last = ob->priv.curr; |
23 | ob->priv.curr = (ob->priv.curr + 1) % ob->priv.num; | 79 | ob->priv.curr = (ob->priv.curr + 1) % ob->priv.num; |
@@ -26,15 +82,17 @@ _evas_outbuf_cb_pageflip(void *data) | |||
26 | static void | 82 | static void |
27 | _evas_outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, unsigned int count) | 83 | _evas_outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, unsigned int count) |
28 | { | 84 | { |
29 | Ecore_Drm_Fb *buff; | 85 | Ecore_Drm_Fb *fb; |
30 | |||
31 | buff = ob->priv.buffer[ob->priv.curr]; | ||
32 | 86 | ||
33 | ob->priv.bo[ob->priv.curr] = gbm_surface_lock_front_buffer(ob->surface); | 87 | ob->priv.bo[ob->priv.curr] = gbm_surface_lock_front_buffer(ob->surface); |
34 | 88 | ||
35 | ecore_drm_fb_dirty(buff, rects, count); | 89 | fb = _evas_outbuf_fb_get(ob->info->info.dev, ob->priv.bo[ob->priv.curr]); |
36 | ecore_drm_fb_set(ob->info->info.dev, buff); | 90 | if (fb) |
37 | ecore_drm_fb_send(ob->info->info.dev, buff, _evas_outbuf_cb_pageflip, ob); | 91 | { |
92 | ecore_drm_fb_dirty(fb, rects, count); | ||
93 | ecore_drm_fb_set(ob->info->info.dev, fb); | ||
94 | ecore_drm_fb_send(ob->info->info.dev, fb, _evas_outbuf_cb_pageflip, ob); | ||
95 | } | ||
38 | } | 96 | } |
39 | 97 | ||
40 | static Eina_Bool | 98 | static Eina_Bool |
@@ -117,16 +175,6 @@ _evas_outbuf_egl_setup(Outbuf *ob) | |||
117 | return EINA_FALSE; | 175 | return EINA_FALSE; |
118 | } | 176 | } |
119 | 177 | ||
120 | ob->egl.context[0] = | ||
121 | eglCreateContext(ob->egl.disp, ob->egl.config, context, ctx_attr); | ||
122 | if (ob->egl.context[0] == EGL_NO_CONTEXT) | ||
123 | { | ||
124 | ERR("eglCreateContext() fail. code=%#x", eglGetError()); | ||
125 | return EINA_FALSE; | ||
126 | } | ||
127 | |||
128 | if (context == EGL_NO_CONTEXT) context = ob->egl.context[0]; | ||
129 | |||
130 | ob->egl.surface[0] = | 178 | ob->egl.surface[0] = |
131 | eglCreateWindowSurface(ob->egl.disp, ob->egl.config, | 179 | eglCreateWindowSurface(ob->egl.disp, ob->egl.config, |
132 | (EGLNativeWindowType)ob->surface, NULL); | 180 | (EGLNativeWindowType)ob->surface, NULL); |
@@ -137,6 +185,16 @@ _evas_outbuf_egl_setup(Outbuf *ob) | |||
137 | return EINA_FALSE; | 185 | return EINA_FALSE; |
138 | } | 186 | } |
139 | 187 | ||
188 | ob->egl.context[0] = | ||
189 | eglCreateContext(ob->egl.disp, ob->egl.config, context, ctx_attr); | ||
190 | if (ob->egl.context[0] == EGL_NO_CONTEXT) | ||
191 | { | ||
192 | ERR("eglCreateContext() fail. code=%#x", eglGetError()); | ||
193 | return EINA_FALSE; | ||
194 | } | ||
195 | |||
196 | if (context == EGL_NO_CONTEXT) context = ob->egl.context[0]; | ||
197 | |||
140 | if (eglMakeCurrent(ob->egl.disp, ob->egl.surface[0], | 198 | if (eglMakeCurrent(ob->egl.disp, ob->egl.surface[0], |
141 | ob->egl.surface[0], ob->egl.context[0]) == EGL_FALSE) | 199 | ob->egl.surface[0], ob->egl.context[0]) == EGL_FALSE) |
142 | { | 200 | { |
@@ -179,6 +237,8 @@ _evas_outbuf_egl_setup(Outbuf *ob) | |||
179 | return EINA_FALSE; | 237 | return EINA_FALSE; |
180 | } | 238 | } |
181 | 239 | ||
240 | /* eng_gl_symbols(); */ | ||
241 | |||
182 | ob->gl_context = glsym_evas_gl_common_context_new(); | 242 | ob->gl_context = glsym_evas_gl_common_context_new(); |
183 | if (!ob->gl_context) return EINA_FALSE; | 243 | if (!ob->gl_context) return EINA_FALSE; |
184 | 244 | ||
@@ -201,7 +261,6 @@ evas_outbuf_new(Evas_Engine_Info_GL_Drm *info, int w, int h, Render_Engine_Swap_ | |||
201 | { | 261 | { |
202 | Outbuf *ob; | 262 | Outbuf *ob; |
203 | char *num; | 263 | char *num; |
204 | int i = 0; | ||
205 | 264 | ||
206 | /* try to allocate space for outbuf */ | 265 | /* try to allocate space for outbuf */ |
207 | if (!(ob = calloc(1, sizeof(Outbuf)))) return NULL; | 266 | if (!(ob = calloc(1, sizeof(Outbuf)))) return NULL; |
@@ -236,30 +295,13 @@ evas_outbuf_new(Evas_Engine_Info_GL_Drm *info, int w, int h, Render_Engine_Swap_ | |||
236 | return NULL; | 295 | return NULL; |
237 | } | 296 | } |
238 | 297 | ||
239 | for (; i < ob->priv.num; i++) | ||
240 | { | ||
241 | ob->priv.buffer[i] = | ||
242 | ecore_drm_fb_create(ob->info->info.dev, ob->w, ob->h); | ||
243 | if (!ob->priv.buffer[i]) break; | ||
244 | |||
245 | DBG("Evas Engine Created Dumb Buffer"); | ||
246 | DBG("\tFb: %d", ob->priv.buffer[i]->id); | ||
247 | DBG("\tHandle: %d", ob->priv.buffer[i]->hdl); | ||
248 | DBG("\tStride: %d", ob->priv.buffer[i]->stride); | ||
249 | DBG("\tSize: %d", ob->priv.buffer[i]->size); | ||
250 | DBG("\tW: %d\tH: %d", | ||
251 | ob->priv.buffer[i]->w, ob->priv.buffer[i]->h); | ||
252 | } | ||
253 | |||
254 | ecore_drm_fb_set(info->info.dev, ob->priv.buffer[0]); | ||
255 | |||
256 | return ob; | 298 | return ob; |
257 | } | 299 | } |
258 | 300 | ||
259 | void | 301 | void |
260 | evas_outbuf_free(Outbuf *ob) | 302 | evas_outbuf_free(Outbuf *ob) |
261 | { | 303 | { |
262 | int i = 0, ref = 0; | 304 | int ref = 0; |
263 | 305 | ||
264 | win_count--; | 306 | win_count--; |
265 | evas_outbuf_use(ob); | 307 | evas_outbuf_use(ob); |
@@ -296,9 +338,6 @@ evas_outbuf_free(Outbuf *ob) | |||
296 | context = EGL_NO_CONTEXT; | 338 | context = EGL_NO_CONTEXT; |
297 | } | 339 | } |
298 | 340 | ||
299 | for (; i < ob->priv.num; i++) | ||
300 | ecore_drm_fb_destroy(ob->priv.buffer[i]); | ||
301 | |||
302 | free(ob); | 341 | free(ob); |
303 | } | 342 | } |
304 | 343 | ||
@@ -390,38 +429,19 @@ evas_outbuf_unsurf(Outbuf *ob) | |||
390 | void | 429 | void |
391 | evas_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth) | 430 | evas_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth) |
392 | { | 431 | { |
393 | int i = 0; | 432 | /* if (depth == OUTBUF_DEPTH_INHERIT) depth = ob->depth; */ |
394 | |||
395 | if (depth == OUTBUF_DEPTH_INHERIT) depth = ob->depth; | ||
396 | 433 | ||
397 | /* check for changes */ | 434 | /* check for changes */ |
398 | if ((ob->w == w) && (ob->h == h) && | 435 | /* if ((ob->w == w) && (ob->h == h) && */ |
399 | (ob->destination_alpha == ob->info->info.destination_alpha) && | 436 | /* (ob->destination_alpha == ob->info->info.destination_alpha) && */ |
400 | ((int)ob->rotation == rot) && (ob->depth == depth)) | 437 | /* ((int)ob->rotation == rot) && (ob->depth == depth)) */ |
401 | return; | 438 | /* return; */ |
402 | 439 | ||
403 | ob->w = w; | 440 | ob->w = w; |
404 | ob->h = h; | 441 | ob->h = h; |
405 | ob->depth = depth; | 442 | ob->depth = depth; |
406 | ob->rotation = rot; | 443 | ob->rotation = rot; |
407 | |||
408 | /* destroy the old buffers */ | ||
409 | for (; i < ob->priv.num; i++) | ||
410 | ecore_drm_fb_destroy(ob->priv.buffer[i]); | ||
411 | |||
412 | for (i = 0; i < ob->priv.num; i++) | ||
413 | { | ||
414 | ob->priv.buffer[i] = | ||
415 | ecore_drm_fb_create(ob->info->info.dev, ob->w, ob->h); | ||
416 | if (!ob->priv.buffer[i]) | ||
417 | { | ||
418 | ERR("Failed to create buffer %d", i); | ||
419 | break; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | evas_outbuf_use(ob); | 444 | evas_outbuf_use(ob); |
424 | |||
425 | glsym_evas_gl_common_context_resize(ob->gl_context, w, h, rot); | 445 | glsym_evas_gl_common_context_resize(ob->gl_context, w, h, rot); |
426 | 446 | ||
427 | //TODO: need drm gbm surface destroy & re-create.? | 447 | //TODO: need drm gbm surface destroy & re-create.? |
@@ -532,7 +552,7 @@ evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode | |||
532 | ob->info->callback.pre_swap(ob->info->callback.data, ob->evas); | 552 | ob->info->callback.pre_swap(ob->info->callback.data, ob->evas); |
533 | 553 | ||
534 | // TODO: Check eglSwapBuffersWithDamage for gl_drm and apply | 554 | // TODO: Check eglSwapBuffersWithDamage for gl_drm and apply |
535 | #if 0 | 555 | //#if 0 |
536 | if ((glsym_eglSwapBuffersWithDamage) && (ob->swap_mode != MODE_FULL)) | 556 | if ((glsym_eglSwapBuffersWithDamage) && (ob->swap_mode != MODE_FULL)) |
537 | { | 557 | { |
538 | EGLint num = 0, *result = NULL, i = 0; | 558 | EGLint num = 0, *result = NULL, i = 0; |
@@ -549,7 +569,7 @@ evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode | |||
549 | 569 | ||
550 | gw = ob->gl_context->w; | 570 | gw = ob->gl_context->w; |
551 | gh = ob->gl_context->h; | 571 | gh = ob->gl_context->h; |
552 | switch (ob->rot) | 572 | switch (ob->rotation) |
553 | { | 573 | { |
554 | case 0: | 574 | case 0: |
555 | result[i + 0] = r->x; | 575 | result[i + 0] = r->x; |
@@ -589,7 +609,7 @@ evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode | |||
589 | } | 609 | } |
590 | } | 610 | } |
591 | else | 611 | else |
592 | #endif | 612 | //#endif |
593 | eglSwapBuffers(ob->egl.disp, ob->egl.surface[0]); | 613 | eglSwapBuffers(ob->egl.disp, ob->egl.surface[0]); |
594 | 614 | ||
595 | if (ob->info->callback.post_swap) | 615 | if (ob->info->callback.post_swap) |
@@ -600,7 +620,7 @@ evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode | |||
600 | 620 | ||
601 | ob->priv.frame_cnt++; | 621 | ob->priv.frame_cnt++; |
602 | 622 | ||
603 | end: | 623 | end: |
604 | //TODO: Need render unlock after drm page flip? | 624 | //TODO: Need render unlock after drm page flip? |
605 | glsym_evas_gl_preload_render_unlock(_evas_outbuf_make_current, ob); | 625 | glsym_evas_gl_preload_render_unlock(_evas_outbuf_make_current, ob); |
606 | } | 626 | } |