diff options
author | Nicolas Aguirre <aguirre.nicolas@gmail.com> | 2016-05-31 21:58:57 +0200 |
---|---|---|
committer | Nicolas Aguirre <aguirre.nicolas@gmail.com> | 2016-05-31 22:05:13 +0200 |
commit | 02ba99f2d6a19655392ec65604f197e461c86559 (patch) | |
tree | 91ae4f91e9809f1985a25f574c645c10f3ed0351 | |
parent | ce93b27d5f3d84c82da992931a67e272acc1acb6 (diff) | |
download | efl-devs/captainigloo/eglfs_rpi.tar.gz |
eglfs: Remove specific code for libhybris/android portdevs/captainigloo/eglfs_rpi
-rw-r--r-- | src/modules/evas/engines/eglfs/evas_engine.c | 103 | ||||
-rw-r--r-- | src/modules/evas/engines/eglfs/evas_engine.h | 3 | ||||
-rw-r--r-- | src/modules/evas/engines/eglfs/evas_outbuf.c | 216 |
3 files changed, 81 insertions, 241 deletions
diff --git a/src/modules/evas/engines/eglfs/evas_engine.c b/src/modules/evas/engines/eglfs/evas_engine.c index 648b54f89a..25446f39d2 100644 --- a/src/modules/evas/engines/eglfs/evas_engine.c +++ b/src/modules/evas/engines/eglfs/evas_engine.c @@ -1,5 +1,8 @@ #include "config.h" #include "evas_engine.h" +#include "../gl_common/evas_gl_define.h" +#include "../software_generic/evas_native_common.h" + #include <wayland-client.h> #ifdef HAVE_DLSYM @@ -36,14 +39,6 @@ struct _Render_Engine Render_Engine_GL_Generic generic; }; -typedef struct _Native Native; -struct _Native -{ - Evas_Native_Surface ns; - struct wl_buffer *wl_buf; - void *egl_surface; -}; - /* local function prototype types */ typedef void (*_eng_fn)(void); typedef _eng_fn (*glsym_func_eng_fn)(); @@ -329,18 +324,12 @@ evgl_eng_make_current(void *data, void *surface, void *context, int flush) return 1; } -static void _hwc_present_cb(void *user_data, struct ANativeWindow *window, - struct ANativeWindowBuffer *buffer) -{ - -} static void * evgl_eng_native_window_create(void *data) { Render_Engine *re; Evas_Engine_Info_Eglfs *info; - struct ANativeWindow *native_window; re = (Render_Engine *)data; if (!re) @@ -355,9 +344,8 @@ evgl_eng_native_window_create(void *data) ERR("Invalid Evas Engine Eglfs Info!"); return NULL; } - EGLNativeWindowType win; - win = create_hwcomposernativewindow(); - return (void *)win; + /* FIXME : eglfs has no native window ? */ + return NULL; } static int @@ -377,8 +365,6 @@ evgl_eng_native_window_destroy(void *data, void *native_window) return 0; } - HWCNativeWindowDestroy(native_window); - return 1; } @@ -398,7 +384,7 @@ evgl_eng_window_surface_create(void *data, void *native_window) // Create resource surface for EGL surface = eglCreateWindowSurface(eng_get_ob(re)->egl.disp, eng_get_ob(re)->egl.config, - (EGLNativeWindowType)native_window, + NULL, NULL); if (!surface) { @@ -579,6 +565,8 @@ _re_winfree(Render_Engine *re) evas_outbuf_unsurf(eng_get_ob(re)); } + + static void _native_cb_bind(void *image) { @@ -590,13 +578,12 @@ _native_cb_bind(void *image) if (n->ns.type == EVAS_NATIVE_SURFACE_WL) { - if (n->egl_surface) + if (n->ns_data.wl_surface.surface) { if (glsym_glEGLImageTargetTexture2DOES) { - glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface); - if (eglGetError() != EGL_SUCCESS) - ERR("glEGLImageTargetTexture2DOES() failed."); + glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->ns_data.wl_surface.surface); + GLERRV("glsym_glEGLImageTargetTexture2DOES"); } else ERR("Try glEGLImageTargetTexture2DOES on EGL with no support"); @@ -617,6 +604,16 @@ _native_cb_unbind(void *image) if (!(img = image)) return; if (!(n = img->native.data)) return; + if (n->ns.type == EVAS_NATIVE_SURFACE_WL_DMABUF) + { + if (n->ns_data.wl_surface_dmabuf.image) + glsym_eglDestroyImage(img->native.disp, n->ns_data.wl_surface_dmabuf.image); + n->ns_data.wl_surface_dmabuf.image = NULL; + } + else if (n->ns.type == EVAS_NATIVE_SURFACE_WL) + { + //glBindTexture(GL_TEXTURE_2D, 0); //really need? + } else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) glBindTexture(GL_TEXTURE_2D, 0); @@ -633,19 +630,31 @@ _native_cb_free(void *image) if (!(img = image)) return; if (!(n = img->native.data)) return; - if (!img->native.shared) return; + if (!(img->native.shared)) return; - if (n->ns.type == EVAS_NATIVE_SURFACE_WL) + if (n->ns.type == EVAS_NATIVE_SURFACE_WL_DMABUF) { - wlid = n->wl_buf; + wlid = n->ns_data.wl_surface_dmabuf.resource; eina_hash_del(img->native.shared->native_wl_hash, &wlid, img); - if (n->egl_surface) + if (n->ns_data.wl_surface.surface) + { + if (glsym_eglDestroyImage && n->ns_data.wl_surface_dmabuf.image) + { + glsym_eglDestroyImage(img->native.disp, n->ns_data.wl_surface_dmabuf.image); + GLERRV("eglDestroyImage() failed."); + } + } + } + else if (n->ns.type == EVAS_NATIVE_SURFACE_WL) + { + wlid = (void*)n->ns_data.wl_surface.wl_buf; + eina_hash_del(img->native.shared->native_wl_hash, &wlid, img); + if (n->ns_data.wl_surface.surface) { if (glsym_eglDestroyImage) { - glsym_eglDestroyImage(img->native.disp, n->egl_surface); - if (eglGetError() != EGL_SUCCESS) - ERR("eglDestroyImage() failed."); + glsym_eglDestroyImage(img->native.disp, n->ns_data.wl_surface.surface); + GLERRV("eglDestroyImage() failed."); } else ERR("Try eglDestroyImage on EGL with no support"); @@ -698,7 +707,7 @@ eng_setup(Evas *evas, void *in) Render_Engine *re; Render_Engine_Swap_Mode swap_mode = MODE_FULL; const char *s = NULL; - + printf("eng_setup\n"); /* try to cast to our engine info structure */ if (!(info = (Evas_Engine_Info_Eglfs *)in)) return 0; @@ -776,6 +785,7 @@ eng_setup(Evas *evas, void *in) ob = evas_outbuf_new(info, epd->output.w, epd->output.h, swap_mode); if (!ob) { + printf("Can't create new outbuf\n"); free(re); return 0; } @@ -817,6 +827,8 @@ eng_setup(Evas *evas, void *in) merge_mode = MERGE_BOUNDING; else if ((!strcmp(s, "full")) || (!strcmp(s, "f"))) merge_mode = MERGE_FULL; + else if ((!strcmp(s, "smart")) || (!strcmp(s, "s"))) + merge_mode = MERGE_SMART; } evas_render_engine_software_generic_merge_mode_set(&re->generic.software, merge_mode); @@ -1103,15 +1115,16 @@ eng_image_native_set(void *data, void *image, void *native) attribs[2] = EGL_NONE; memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); - glsym_eglQueryWaylandBufferWL(ob->egl.disp, wl_buf, - EGL_WAYLAND_Y_INVERTED_WL, - &yinvert); + if (glsym_eglQueryWaylandBufferWL(ob->egl.disp, wl_buf, + EGL_WAYLAND_Y_INVERTED_WL, + &yinvert) == EGL_FALSE) + yinvert = 1; eina_hash_add(ob->gl_context->shared->native_wl_hash, &wlid, img); - n->wl_buf = wl_buf; + n->ns_data.wl_surface.wl_buf = wl_buf; if (glsym_eglCreateImage) - n->egl_surface = glsym_eglCreateImage(ob->egl.disp, + n->ns_data.wl_surface.surface = glsym_eglCreateImage(ob->egl.disp, NULL, EGL_WAYLAND_BUFFER_WL, wl_buf, attribs); @@ -1125,7 +1138,7 @@ eng_image_native_set(void *data, void *image, void *native) return NULL; } - if (!n->egl_surface) + if (!n->ns_data.wl_surface.surface) { ERR("eglCreatePixmapSurface() for %p failed", wl_buf); eina_hash_del(ob->gl_context->shared->native_wl_hash, @@ -1161,10 +1174,12 @@ eng_image_native_set(void *data, void *image, void *native) eina_hash_add(ob->gl_context->shared->native_tex_hash, &texid, img); - n->egl_surface = 0; + n->ns_data.opengl.surface = 0; img->native.yinvert = 0; img->native.loose = 0; + img->native.disp = ob->egl.disp; + img->native.shared = ob->gl_context->shared; img->native.data = n; img->native.func.bind = _native_cb_bind; img->native.func.unbind = _native_cb_unbind; @@ -1186,12 +1201,14 @@ eng_image_native_set(void *data, void *image, void *native) static int module_open(Evas_Module *em) { + printf("module eglfs open\n"); /* check for valid evas module */ if (!em) return 0; - + printf("inherit gl_generic\n"); /* get whatever engine module we inherit from */ - if (!_evas_module_engine_inherit(&pfunc, "gl_generic")) return 0; - + if (!_evas_module_engine_inherit(&pfunc, "gl_generic")) + return 0; + printf("gl_generic loaded \n"); /* try to create eina logging domain */ if (_evas_engine_eglfs_log_dom < 0) { @@ -1218,8 +1235,6 @@ module_open(Evas_Module *em) EVAS_API_OVERRIDE(output_dump, &func, eng_); EVAS_API_OVERRIDE(image_native_set, &func, eng_); - setenv("EGL_PLATFORM", "fbdev", 1); - gl_symbols(); /* now advertise out own api */ diff --git a/src/modules/evas/engines/eglfs/evas_engine.h b/src/modules/evas/engines/eglfs/evas_engine.h index e02acb0d03..12aa07f810 100644 --- a/src/modules/evas/engines/eglfs/evas_engine.h +++ b/src/modules/evas/engines/eglfs/evas_engine.h @@ -15,9 +15,6 @@ # include <EGL/eglmesaext.h> # include <GLES2/gl2.h> # include <GLES2/gl2ext.h> -# include <hwcomposer.h> -# include <hardware/hardware.h> -# include <hardware/hwcomposer.h> # include "../gl_generic/Evas_Engine_GL_Generic.h" extern int _evas_engine_eglfs_log_dom; diff --git a/src/modules/evas/engines/eglfs/evas_outbuf.c b/src/modules/evas/engines/eglfs/evas_outbuf.c index aa3cd8a1b2..9cc7834e42 100644 --- a/src/modules/evas/engines/eglfs/evas_outbuf.c +++ b/src/modules/evas/engines/eglfs/evas_outbuf.c @@ -1,113 +1,6 @@ #include "evas_engine.h" +#include "../gl_common/evas_gl_define.h" -#include <hybris/hwcomposerwindow/hwcomposer.h> -#include <hardware/hwcomposer.h> -#include <hardware/hardware.h> -#include <android-config.h> - -static hwc_layer_1_t *fblayer; -static hwc_composer_device_1_t *hwcDevicePtr; -static hwc_display_contents_1_t **mList; - -void present(void *user_data, struct ANativeWindow *window, - struct ANativeWindowBuffer *buffer) -{ - - int oldretire = mList[0]->retireFenceFd; - mList[0]->retireFenceFd = -1; - fblayer->handle = buffer->handle; - fblayer->acquireFenceFd = HWCNativeBufferGetFence(buffer); - fblayer->releaseFenceFd = -1; - int err = hwcDevicePtr->prepare(hwcDevicePtr, HWC_NUM_DISPLAY_TYPES, mList); - //assert(err == 0); - - err = hwcDevicePtr->set(hwcDevicePtr, HWC_NUM_DISPLAY_TYPES, mList); - //assert(err == 0); - HWCNativeBufferSetFence(buffer, fblayer->releaseFenceFd); - - if (oldretire != -1) - { - sync_wait(oldretire, -1); - close(oldretire); - } -} - - -EGLNativeWindowType create_hwcomposernativewindow(void) -{ - int err; - hw_module_t *hwcModule = 0; - hwcDevicePtr = 0; - - err = hw_get_module(HWC_HARDWARE_MODULE_ID, (const hw_module_t **) &hwcModule); - //assert(err == 0); - - err = hwc_open_1(hwcModule, &hwcDevicePtr); - //assert(err == 0); - - hwcDevicePtr->blank(hwcDevicePtr, 0, 0); - - uint32_t configs[5]; - size_t numConfigs = 5; - - err = hwcDevicePtr->getDisplayConfigs(hwcDevicePtr, 0, configs, &numConfigs); - //assert (err == 0); - - int32_t attr_values[2]; - uint32_t attributes[] = { HWC_DISPLAY_WIDTH, HWC_DISPLAY_HEIGHT, HWC_DISPLAY_NO_ATTRIBUTE }; - - hwcDevicePtr->getDisplayAttributes(hwcDevicePtr, 0, - configs[0], attributes, attr_values); - - size_t size = sizeof(hwc_display_contents_1_t) + 2 * sizeof(hwc_layer_1_t); - hwc_display_contents_1_t *list = (hwc_display_contents_1_t *) malloc(size); - mList = (hwc_display_contents_1_t **) malloc(HWC_NUM_DISPLAY_TYPES * sizeof(hwc_display_contents_1_t *)); - const hwc_rect_t r = { 0, 0, attr_values[0], attr_values[1] }; - - int counter = 0; - for (; counter < HWC_NUM_DISPLAY_TYPES; counter++) - mList[counter] = NULL; - // Assign buffer only to the first item, otherwise you get tearing - // if passed the same to multiple places - mList[0] = list; - - fblayer = &list->hwLayers[0]; - memset(fblayer, 0, sizeof(hwc_layer_1_t)); - fblayer->compositionType = HWC_FRAMEBUFFER; - fblayer->hints = 0; - fblayer->flags = 0; - fblayer->handle = 0; - fblayer->transform = 0; - fblayer->blending = HWC_BLENDING_NONE; - fblayer->sourceCrop = r; - fblayer->displayFrame = r; - fblayer->visibleRegionScreen.numRects = 1; - fblayer->visibleRegionScreen.rects = &fblayer->displayFrame; - fblayer->acquireFenceFd = -1; - fblayer->releaseFenceFd = -1; - fblayer = &list->hwLayers[1]; - memset(fblayer, 0, sizeof(hwc_layer_1_t)); - fblayer->compositionType = HWC_FRAMEBUFFER_TARGET; - fblayer->hints = 0; - fblayer->flags = 0; - fblayer->handle = 0; - fblayer->transform = 0; - fblayer->blending = HWC_BLENDING_NONE; - fblayer->sourceCrop = r; - fblayer->displayFrame = r; - fblayer->visibleRegionScreen.numRects = 1; - fblayer->visibleRegionScreen.rects = &fblayer->displayFrame; - fblayer->acquireFenceFd = -1; - fblayer->releaseFenceFd = -1; - - list->retireFenceFd = -1; - list->flags = HWC_GEOMETRY_CHANGED; - list->numHwLayers = 2; - - EGLNativeWindowType win = NULL; - win = (EGLNativeWindowType)HWCNativeWindowCreate(attr_values[0], attr_values[1], HAL_PIXEL_FORMAT_RGBA_8888, present, NULL); - return win; -} /* local variables */ static Outbuf *_evas_eglfs_window = NULL; @@ -137,10 +30,6 @@ _evas_outbuf_make_current(void *data, void *doit) return EINA_TRUE; } -void _hwcomposer_present_cb(void *user_data, struct ANativeWindow *window, struct ANativeWindowBuffer *buffer) -{ -} - static Eina_Bool _evas_outbuf_egl_setup(Outbuf *ob) { @@ -173,84 +62,6 @@ _evas_outbuf_egl_setup(Outbuf *ob) else cfg_attr[n++] = 0; cfg_attr[n++] = EGL_NONE; - int err; - hw_module_t *hwcModule = 0; - hwc_composer_device_1_t *hwcDevicePtr = 0; - - err = hw_get_module(HWC_HARDWARE_MODULE_ID, (const hw_module_t **) &hwcModule); - if (err != 0) - { - ERR("hw_get_module() fail. code=%d", err); - return EINA_FALSE; - } - err = hwc_open_1(hwcModule, &hwcDevicePtr); - if (err != 0) - { - ERR("hwc_open_1 fail. code=%d", err); - return EINA_FALSE; - } - hwcDevicePtr->blank(hwcDevicePtr, 0, 0); - - uint32_t configs[5]; - size_t numConfigs = 5; - - err = hwcDevicePtr->getDisplayConfigs(hwcDevicePtr, 0, configs, &numConfigs); - if (err != 0) - { - ERR("getDisplayConfig. code=%d", err); - return EINA_FALSE; - } - - int32_t attr_values[2]; - uint32_t attributes[] = { HWC_DISPLAY_WIDTH, HWC_DISPLAY_HEIGHT, HWC_DISPLAY_NO_ATTRIBUTE }; - - hwcDevicePtr->getDisplayAttributes(hwcDevicePtr, 0, - configs[0], attributes, attr_values); - - DBG("width: %i height: %i\n", attr_values[0], attr_values[1]); - - size_t size = sizeof(hwc_display_contents_1_t) + 2 * sizeof(hwc_layer_1_t); - hwc_display_contents_1_t *list = (hwc_display_contents_1_t *) malloc(size); - hwc_display_contents_1_t **mList = (hwc_display_contents_1_t **) malloc(HWC_NUM_DISPLAY_TYPES * sizeof(hwc_display_contents_1_t *)); - const hwc_rect_t r = { 0, 0, attr_values[0], attr_values[1] }; - - int counter = 0; - for (; counter < HWC_NUM_DISPLAY_TYPES; counter++) - mList[counter] = NULL; - mList[0] = list; - - hwc_layer_1_t *layer = &list->hwLayers[0]; - memset(layer, 0, sizeof(hwc_layer_1_t)); - layer->compositionType = HWC_FRAMEBUFFER; - layer->hints = 0; - layer->flags = 0; - layer->handle = 0; - layer->transform = 0; - layer->blending = HWC_BLENDING_NONE; - layer->sourceCrop = r; - layer->displayFrame = r; - layer->visibleRegionScreen.numRects = 1; - layer->visibleRegionScreen.rects = &layer->displayFrame; - layer->acquireFenceFd = -1; - layer->releaseFenceFd = -1; - layer = &list->hwLayers[1]; - memset(layer, 0, sizeof(hwc_layer_1_t)); - layer->compositionType = HWC_FRAMEBUFFER_TARGET; - layer->hints = 0; - layer->flags = 0; - layer->handle = 0; - layer->transform = 0; - layer->blending = HWC_BLENDING_NONE; - layer->sourceCrop = r; - layer->displayFrame = r; - layer->visibleRegionScreen.numRects = 1; - layer->visibleRegionScreen.rects = &layer->displayFrame; - layer->acquireFenceFd = -1; - layer->releaseFenceFd = -1; - - list->retireFenceFd = -1; - list->flags = HWC_GEOMETRY_CHANGED; - list->numHwLayers = 2; ob->egl.disp = eglGetDisplay(NULL); if (ob->egl.disp == EGL_NO_DISPLAY) @@ -292,13 +103,30 @@ _evas_outbuf_egl_setup(Outbuf *ob) return EINA_FALSE; } - // First is always best... - ob->egl.config = cfgs[0]; + for (; i < ncfg; ++i) + { + EGLint format; + + if (!eglGetConfigAttrib(ob->egl.disp, cfgs[i], EGL_NATIVE_VISUAL_ID, + &format)) + { + ERR("eglGetConfigAttrib() fail. code=%#x", eglGetError()); + return EINA_FALSE; + } + + DBG("Config Format: %d", format); + DBG("OB Format: %d", ob->info->info.format); + + if (format == (int)ob->info->info.format) + { + ob->egl.config = cfgs[i]; + break; + } + } - EGLNativeWindowType win = create_hwcomposernativewindow(); ob->egl.surface[0] = eglCreateWindowSurface(ob->egl.disp, ob->egl.config, - (EGLNativeWindowType)win, NULL); + NULL, NULL); if (ob->egl.surface[0] == EGL_NO_SURFACE) { |