TEST_F(NotificationTest, MultipleRegistrationsSurface) { ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction)); // get called once ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY); ilm_commitChanges(); assertCallbackcalled(); ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface)); // change a lot of things t_ilm_float opacity = 0.789; ilm_surfaceSetOpacity(surface,opacity); ilm_surfaceSetVisibility(surface,true); ilm_surfaceSetDestinationRectangle(surface,133,1567,155,199); ilm_surfaceSetSourceRectangle(surface,33,567,55,99); ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY); ilm_commitChanges(); // assert that we have not been notified assertNoCallbackIsCalled(); // register for notifications again ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction)); ilm_surfaceSetOrientation(surface,ILM_ZERO); ilm_commitChanges(); assertCallbackcalled(); ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface)); }
TEST_F(NotificationTest, NotifyOnSurfaceAllValues) { ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction)); // change something t_ilm_float opacity = 0.789; ilm_surfaceSetOpacity(surface,opacity); ilm_surfaceSetVisibility(surface,true); ilm_surfaceSetDestinationRectangle(surface,133,1567,155,199); ilm_surfaceSetSourceRectangle(surface,33,567,55,99); ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY); ilm_commitChanges(); // expect callback to have been called assertCallbackcalled(); EXPECT_EQ(surface,callbackSurfaceId); EXPECT_EQ(33u,SurfaceProperties.sourceX); EXPECT_EQ(567u,SurfaceProperties.sourceY); EXPECT_EQ(55u,SurfaceProperties.sourceWidth); EXPECT_EQ(99u,SurfaceProperties.sourceHeight); EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,SurfaceProperties.orientation); EXPECT_TRUE(SurfaceProperties.visibility); EXPECT_NEAR(opacity, SurfaceProperties.opacity, 0.1); EXPECT_EQ(133u,SurfaceProperties.destX); EXPECT_EQ(1567u,SurfaceProperties.destY); EXPECT_EQ(155u,SurfaceProperties.destWidth); EXPECT_EQ(199u,SurfaceProperties.destHeight); EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT|ILM_NOTIFICATION_VISIBILITY|ILM_NOTIFICATION_OPACITY|ILM_NOTIFICATION_SOURCE_RECT|ILM_NOTIFICATION_ORIENTATION,mask); ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface)); }
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, NotifyOnSurfaceSetOpacity) { ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction)); // change something t_ilm_float opacity = 0.789; ilm_surfaceSetOpacity(surface,opacity); ilm_commitChanges(); // expect callback to have been called assertCallbackcalled(); EXPECT_EQ(surface,callbackSurfaceId); EXPECT_NEAR(0.789, SurfaceProperties.opacity, 0.1); EXPECT_EQ(ILM_NOTIFICATION_OPACITY,mask); ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface)); }
TEST_F(NotificationTest, DefaultIsNotToReceiveNotificationsSurface) { // get called once ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY); ilm_commitChanges(); // change a lot of things t_ilm_float opacity = 0.789; ilm_surfaceSetOpacity(surface,opacity); ilm_surfaceSetVisibility(surface,true); ilm_surfaceSetDestinationRectangle(surface,133,1567,155,199); ilm_surfaceSetSourceRectangle(surface,33,567,55,99); ilm_surfaceSetOrientation(surface,ILM_ONEHUNDREDEIGHTY); ilm_commitChanges(); // assert that we have not been notified assertNoCallbackIsCalled(); }
TEST_F(NotificationTest, NotifyOnSurfaceMultipleValues2) { ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction)); // change something t_ilm_float opacity = 0.789; ilm_surfaceSetOpacity(surface,opacity); ilm_surfaceSetVisibility(surface,true); ilm_surfaceSetDestinationRectangle(surface,33,567,55,99); ilm_commitChanges(); // expect callback to have been called assertCallbackcalled(); EXPECT_EQ(surface,callbackSurfaceId); EXPECT_TRUE(SurfaceProperties.visibility); EXPECT_NEAR(0.789, SurfaceProperties.opacity, 0.1); EXPECT_EQ(33u,SurfaceProperties.destX); EXPECT_EQ(567u,SurfaceProperties.destY); EXPECT_EQ(55u,SurfaceProperties.destWidth); EXPECT_EQ(99u,SurfaceProperties.destHeight); EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT|ILM_NOTIFICATION_VISIBILITY|ILM_NOTIFICATION_OPACITY,mask); ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface)); }
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; }