void SetUp() { ASSERT_EQ(ILM_SUCCESS, ilm_initWithNativedisplay((t_ilm_nativedisplay)wlDisplay)); ASSERT_EQ(ILM_SUCCESS, ilmClient_init((t_ilm_nativedisplay)wlDisplay)); // set default values callbackLayerId = -1; LayerProperties = ilmLayerProperties(); mask = static_cast<t_ilm_notification_mask>(0); surface = -1; SurfaceProperties = ilmSurfaceProperties(); // create a layer layer = 345; ilm_layerRemove(layer); ilm_commitChanges(); ilm_layerCreateWithDimension(&layer, 800, 480); ilm_commitChanges(); // create a surface surface = 456; ilm_surfaceRemove(surface); ilm_commitChanges(); ilm_surfaceCreate((t_ilm_nativehandle)wlSurfaces[0],10,10,ILM_PIXELFORMAT_RGBA_8888,&surface); ilm_commitChanges(); timesCalled=0; callbackLayerId = INVALID_ID; callbackSurfaceId = INVALID_ID; }
t_ilm_bool createGLXContext(t_ilm_int width, t_ilm_int height) { int glxMajor; int glxMinor; g_glxContextStruct.glxContext = glXCreateContext( g_x11ContextStruct.x11Display, g_x11ContextStruct.x11Visual, 0, GL_TRUE); glXMakeCurrent(g_x11ContextStruct.x11Display, g_x11ContextStruct.x11Window, g_glxContextStruct.glxContext); // do egl stuff glXQueryVersion(g_x11ContextStruct.x11Display, &glxMajor, &glxMinor); printf("GLX-Version %d.%d\n", glxMajor, glxMinor); if (glXIsDirect(g_x11ContextStruct.x11Display, g_glxContextStruct.glxContext)) { printf("DRI enabled\n"); } else { printf("no DRI available\n"); } t_ilm_layer layerid = (t_ilm_layer) LAYER_EXAMPLE_X_APPLICATIONS; // TODO: remove all C stylec asts in C++ code t_ilm_surface surfaceid = (t_ilm_surface) SURFACE_EXAMPLE_GLXX11_APPLICATION; printf("create a surface %lu\n", (t_ilm_nativehandle) (g_x11ContextStruct.x11Window)); ilm_surfaceCreate((t_ilm_nativehandle) g_x11ContextStruct.x11Window, width, height, ILM_PIXELFORMAT_RGBA_8888, &surfaceid); printf("set surface dest region\n"); ilm_surfaceSetDestinationRectangle(surfaceid, 0, 0, width, height); printf("set surface src region\n"); ilm_surfaceSetSourceRectangle(surfaceid, 0, 0, width, height); printf("add surface to layer\n"); ilm_layerAddSurface(layerid, surfaceid); printf("Set surface visible\n"); ilm_surfaceSetVisibility(surfaceid, ILM_TRUE); printf("Set surface opacity\n"); ilm_surfaceSetOpacity(surfaceid, 0.75f); xeventInitialiaze(g_x11ContextStruct.x11Display, surfaceid, 0, 0, width, height); printf("commit\n"); // commit will indicate error, if any command failed ilmErrorTypes error = ilm_commitChanges(); return (error != ILM_FAILED) ? ILM_TRUE : ILM_FALSE; }
TEST_F(NotificationTest, ilm_surfaceAddNotificationWithoutCallback) { // create a layer t_ilm_uint surface = 67; ilm_surfaceCreate((t_ilm_nativehandle)wlSurfaces[1],10,10,ILM_PIXELFORMAT_RGBA_8888,&surface); ilm_commitChanges(); // add notification ilmErrorTypes status = ilm_surfaceAddNotification(surface,NULL); ASSERT_EQ(ILM_SUCCESS, status); ilm_surfaceRemove(surface); ilm_commitChanges(); }
bool WLSurface::CreateIlmSurface(t_ilm_surface* surfaceId, t_ilm_int width, t_ilm_int height) { ilmErrorTypes rtnv; // Creates surfce rtnv = ilm_surfaceCreate((t_ilm_nativehandle)m_wlSurface, width, height, ILM_PIXELFORMAT_RGBA_8888, surfaceId); if (rtnv != ILM_SUCCESS){ return false; } m_ilmSurfaceId = *surfaceId; return true; }
t_ilm_bool createEGLContext(t_ilm_int width, t_ilm_int height) { g_eglContextStruct.eglDisplay = NULL; g_eglContextStruct.eglSurface = NULL; g_eglContextStruct.eglContext = NULL; g_eglContextStruct.eglDisplay = eglGetDisplay((EGLNativeDisplayType) g_x11ContextStruct.x11Display); // TODO: remove all C style casts in C++ code; use C++ casts EGLint eglstatus = eglGetError(); if (!g_eglContextStruct.eglDisplay) { printf("Error: eglGetDisplay() failed.\n"); } EGLint iMajorVersion, iMinorVersion; if (!eglInitialize(g_eglContextStruct.eglDisplay, &iMajorVersion, &iMinorVersion)) { printf("Error: eglInitialize() failed.\n"); } eglBindAPI(EGL_OPENGL_ES_API); eglstatus = eglGetError(); if (eglstatus != EGL_SUCCESS) { printf("Error: eglBindAPI() failed.\n"); } EGLint pi32ConfigAttribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_RED_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_NONE }; int iConfigs; if (!eglChooseConfig(g_eglContextStruct.eglDisplay, pi32ConfigAttribs, &g_eglContextStruct.eglConfig, 1, &iConfigs) || (iConfigs != 1)) { printf("Error: eglChooseConfig() failed.\n"); } g_eglContextStruct.eglSurface = eglCreateWindowSurface( g_eglContextStruct.eglDisplay, g_eglContextStruct.eglConfig, (EGLNativeWindowType) g_x11ContextStruct.x11Window, NULL); eglstatus = eglGetError(); if (eglstatus != EGL_SUCCESS) { printf("Error: eglCreateWindowSurface() failed.\n"); // TODO: do not use printf directly here } g_eglContextStruct.eglContext = eglCreateContext( g_eglContextStruct.eglDisplay, g_eglContextStruct.eglConfig, NULL, contextAttribs); eglstatus = eglGetError(); if (eglstatus != EGL_SUCCESS) { printf("Error: eglCreateContext() failed.\n"); } eglMakeCurrent(g_eglContextStruct.eglDisplay, g_eglContextStruct.eglSurface, g_eglContextStruct.eglSurface, g_eglContextStruct.eglContext); eglSwapInterval(g_eglContextStruct.eglDisplay, 1); eglstatus = eglGetError(); if (eglstatus != EGL_SUCCESS) { printf("Error: eglMakeCurrent() failed.\n"); } // register surfaces to layermanager t_ilm_layer layerid = (t_ilm_layer)LAYER_EXAMPLE_GLES_APPLICATIONS; t_ilm_surface surfaceid = (t_ilm_surface)SURFACE_EXAMPLE_EGLX11_APPLICATION; printf("create a surface %lu\n", (t_ilm_nativehandle) g_x11ContextStruct.x11Window); ilm_surfaceCreate( (t_ilm_nativehandle) g_x11ContextStruct.x11Window, width, height, ILM_PIXELFORMAT_RGBA_8888, &surfaceid); printf("set surface dest region\n"); ilm_surfaceSetDestinationRectangle(surfaceid, 0, 0, width, height); printf("set surface src region\n"); ilm_surfaceSetSourceRectangle(surfaceid, 0, 0, width, height); printf("add surface to layer\n"); ilm_layerAddSurface(layerid, surfaceid); printf("Set surface visible\n"); ilm_surfaceSetVisibility(surfaceid, ILM_TRUE); printf("Set surface opacity\n"); ilm_surfaceSetOpacity(surfaceid, 0.75f); printf("commit\n"); return (ILM_SUCCESS == ilm_commitChanges()) ? ILM_TRUE : ILM_FALSE; }
static ilmErrorTypes createILMAttribute(t_ilm_layer *pLayerId, t_ilm_surface *pSurfaceId, unsigned int colorkey[]) { ilmErrorTypes error = ILM_FAILED; t_ilm_layer layerid = *pLayerId; t_ilm_surface surfaceid = *pSurfaceId; do { printf("Creating Layer... "); error = ilm_layerCreateWithDimension(&layerid, g_wlContextStruct.ctx_bmp->width, g_wlContextStruct.ctx_bmp->height); CHECK_ILM_ERROR(error); printf("Setting Layer destination rectangle(0, 0, %d, %d)... \n", g_wlContextStruct.ctx_bmp->width, g_wlContextStruct.ctx_bmp->height); error = ilm_layerSetDestinationRectangle(layerid, 0, 0, g_wlContextStruct.ctx_bmp->width, g_wlContextStruct.ctx_bmp->height); CHECK_ILM_ERROR(error); printf("Setting Layer source rectangle(0, 0, %d, %d)... \n", g_wlContextStruct.ctx_bmp->width, g_wlContextStruct.ctx_bmp->height); error = ilm_layerSetSourceRectangle(layerid, 0, 0, g_wlContextStruct.ctx_bmp->width, g_wlContextStruct.ctx_bmp->height); CHECK_ILM_ERROR(error); printf("Setting Layer visibility(%d)... \n", 1); error = ilm_layerSetVisibility(layerid, ILM_TRUE); CHECK_ILM_ERROR(error); error = ilm_layerSetOpacity(layerid, 1.0f); CHECK_ILM_ERROR(error); struct wl_object* p_obj = (struct wl_object*)g_wlContextStruct.wlSurface; t_ilm_nativehandle native_ilm_handle = (g_wlContextStruct.connect_id << 16) | (uint32_t)p_obj->id; error = ilm_surfaceCreate(native_ilm_handle, g_wlContextStruct.ctx_bmp->width, g_wlContextStruct.ctx_bmp->height, ILM_PIXELFORMAT_RGBA_8888, &surfaceid); CHECK_ILM_ERROR(error); printf("set surface dest region\n"); error = ilm_surfaceSetDestinationRectangle(surfaceid, 0, 0, g_wlContextStruct.ctx_bmp->width, g_wlContextStruct.ctx_bmp->height); CHECK_ILM_ERROR(error); printf("set surface src region\n"); error = ilm_surfaceSetSourceRectangle(surfaceid, 0, 0, g_wlContextStruct.ctx_bmp->width, g_wlContextStruct.ctx_bmp->height); CHECK_ILM_ERROR(error); printf("add surface to layer\n"); error = ilm_layerAddSurface(layerid, surfaceid); CHECK_ILM_ERROR(error); printf("Set surface visible\n"); error = ilm_surfaceSetVisibility(surfaceid, ILM_TRUE); CHECK_ILM_ERROR(error); printf("Set surface opacity\n"); error = ilm_surfaceSetOpacity(surfaceid, 0.7f); CHECK_ILM_ERROR(error); printf("Set surface chromakey\n"); //unsigned int col[3] = {255, 242, 0}; error = ilm_surfaceSetChromaKey(surfaceid, colorkey); CHECK_ILM_ERROR(error); printf("commit\n"); error = ilm_commitChanges(); CHECK_ILM_ERROR(error); } while (0); *pLayerId = layerid; *pSurfaceId = surfaceid; return error; }