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));
}
    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;
    }
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();
}
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));
}
    void TearDown()
    {
       //print_lmc_get_scene();
       t_ilm_layer* layers = NULL;
       t_ilm_int numLayer=0;
       EXPECT_EQ(ILM_SUCCESS, ilm_getLayerIDs(&numLayer, &layers));
       for (t_ilm_int i=0; i<numLayer; i++)
       {
           EXPECT_EQ(ILM_SUCCESS, ilm_layerRemove(layers[i]));
       };
       free(layers);

       t_ilm_surface* surfaces = NULL;
       t_ilm_int numSurfaces=0;
       EXPECT_EQ(ILM_SUCCESS, ilm_getSurfaceIDs(&numSurfaces, &surfaces));
       for (t_ilm_int i=0; i<numSurfaces; i++)
       {
           EXPECT_EQ(ILM_SUCCESS, ilm_surfaceRemove(surfaces[i]));
       };
       free(surfaces);

       EXPECT_EQ(ILM_SUCCESS, ilm_commitChanges());
       EXPECT_EQ(ILM_SUCCESS, ilmClient_destroy());
       EXPECT_EQ(ILM_SUCCESS, ilm_destroy());
    }
TEST_F(NotificationTest, ilm_layerAddNotificationWithoutCallback)
{
    // create a layer
    t_ilm_uint layer = 89;

    ASSERT_EQ(ILM_SUCCESS,ilm_layerCreateWithDimension(&layer, 800, 480));
    ASSERT_EQ(ILM_SUCCESS,ilm_commitChanges());
    // add notification

    printf("test calling ilm_layerAddNotification\n");
    //ASSERT_EQ(ILM_SUCCESS,ilm_commitChanges());
    ASSERT_EQ(ILM_SUCCESS, ilm_layerAddNotification(layer,NULL));

    ASSERT_EQ(ILM_SUCCESS,ilm_layerRemove(layer));
    ASSERT_EQ(ILM_SUCCESS,ilm_commitChanges());

}
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();
}
Beispiel #8
0
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, DoNotSendNotificationsAfterRemoveLayer)
{
    ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
    // get called once
    ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
    ilm_commitChanges();
    assertCallbackcalled();

    ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));

    // change a lot of things
    t_ilm_float opacity = 0.789;
    ilm_layerSetOpacity(layer,opacity);
    ilm_layerSetVisibility(layer,true);
    ilm_layerSetDestinationRectangle(layer,133,1567,155,199);
    ilm_layerSetSourceRectangle(layer,33,567,55,99);
    ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
    ilm_commitChanges();

    // assert that we have not been notified
    assertNoCallbackIsCalled();

}
Beispiel #10
0
/**
 * @Description Initialize the xevent management module
 *
 * @param dpy X11 Display
 * @param Surface ID of the surface to control
 * @param x Initial destination x position of the surface
 * @param y Initial destination y position of the surface
 * @param width Initial width of the surface destination
 * @param height Initial height of the surface destination
 *
 */
void xeventInitialiaze(Display* dpy, t_ilm_surface surfaceid, t_ilm_int x, t_ilm_int y, t_ilm_int width, t_ilm_int height)
{
    t_ilm_surface surf;

    g_surfPosX = x;
    g_surfPosY = y;
    g_surfWidthOrig = width;
    g_surfHeightOrig = height;

    g_x11Display = dpy;
    g_surfaceid = surfaceid;
    g_surfMoveDirection = move_right;

    /***********************************************************************/
    /* Deal with LayerManager Input Framework to demonstrate possibilities */

    /*
     * By default, a surface accept input events from all type of devices. (See type ilmInputDevice)
     * It is anyway possible to override this setting device by device.
     * Note1: ilmInputDevice can be used as a bit mask
     * Note2: ilm_UpdateInputEventAcceptanceOn() is assynchronous
     */

    // Accept events from keyboard & mouse
    ilm_UpdateInputEventAcceptanceOn(   SURFACE_EXAMPLE_GLXX11_APPLICATION,
                                        ILM_INPUT_DEVICE_KEYBOARD | ILM_INPUT_DEVICE_POINTER,
                                        ILM_TRUE);
    // Refuse events from touch devices
    ilm_UpdateInputEventAcceptanceOn(   SURFACE_EXAMPLE_GLXX11_APPLICATION,
                                        ILM_INPUT_DEVICE_TOUCH,
                                        ILM_FALSE);

    // Apply the changes
    ilm_commitChanges();


    /*
     * The keyboard is managed by a focus. Only the surface which has the focus will receive
     * keyboard events. (if it is set to receive keyboard events)
     * ilm_SetKeyboardFocusOn() can be used to control which surface has the keyboard focus
     * ilm_GetKeyboardFocusSurfaceId() can be used to know which surface has the keyboard focus
     * Note1: ilm_SetKeyboardFocusOn() & ilm_GetKeyboardFocusSurfaceId() are synchronous
     */
     ilm_SetKeyboardFocusOn(SURFACE_EXAMPLE_GLXX11_APPLICATION);

     // Play with ilm_SetKeyboardFocusOn();
     ilm_GetKeyboardFocusSurfaceId(&surf);
     assert(SURFACE_EXAMPLE_GLXX11_APPLICATION == surf);
}
TEST_F(NotificationTest, NotifyOnLayerSetOpacity)
{
    ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
    // change something
    t_ilm_float opacity = 0.789;
    ilm_layerSetOpacity(layer,opacity);
    ilm_commitChanges();

    // expect callback to have been called
    assertCallbackcalled();

    EXPECT_EQ(layer,callbackLayerId);
    EXPECT_NEAR(0.789, LayerProperties.opacity, 0.1);
    EXPECT_EQ(ILM_NOTIFICATION_OPACITY,mask);

    ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
}
TEST_F(NotificationTest, NotifyOnSurfaceSetOrientation)
{
    ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
    // change something
    e_ilmOrientation orientation = ILM_ONEHUNDREDEIGHTY;
    ilm_surfaceSetOrientation(surface,orientation);
    ilm_commitChanges();

    // expect callback to have been called
    assertCallbackcalled();

    EXPECT_EQ(surface,callbackSurfaceId);
    EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,SurfaceProperties.orientation);
    EXPECT_EQ(ILM_NOTIFICATION_ORIENTATION,mask);

    ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
}
TEST_F(NotificationTest, NotifyOnLayerSetVisibility)
{
    ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
    // change something
    t_ilm_bool value = ILM_TRUE;
    ilm_layerSetVisibility(layer,value);
    ilm_commitChanges();

    // expect callback to have been called
    assertCallbackcalled();

    EXPECT_EQ(layer,callbackLayerId);
    EXPECT_TRUE(LayerProperties.visibility);
    EXPECT_EQ(ILM_NOTIFICATION_VISIBILITY,mask);

    ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
}
TEST_F(NotificationTest, NotifyOnLayerSetOrientation)
{
    ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
    // change something
    e_ilmOrientation orientation = ILM_ONEHUNDREDEIGHTY;
    ilm_layerSetOrientation(layer,orientation);
    ilm_commitChanges();

    // expect callback to have been called
    assertCallbackcalled();

    EXPECT_EQ(layer,callbackLayerId);
    EXPECT_EQ(ILM_ONEHUNDREDEIGHTY,LayerProperties.orientation);
    EXPECT_EQ(ILM_NOTIFICATION_ORIENTATION,mask);

    ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
}
TEST_F(NotificationTest, NotifyOnSurfaceSetVisibility)
{
    ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
    // change something
    t_ilm_bool value = ILM_TRUE;
    ilm_surfaceSetVisibility(surface,value);
    ilm_commitChanges();

    // expect callback to have been called
    assertCallbackcalled();

    EXPECT_EQ(surface,callbackSurfaceId);
    EXPECT_TRUE(SurfaceProperties.visibility);
    EXPECT_EQ(ILM_NOTIFICATION_VISIBILITY,mask);

    ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
}
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, NotifyOnSurfaceSetSourceRectangle)
{
    ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
    // change something
    ilm_surfaceSetSourceRectangle(surface,33,567,55,99);
    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_NOTIFICATION_SOURCE_RECT,mask);

    ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
}
TEST_F(NotificationTest, NotifyOnLayerSetSourceRectangle)
{
    ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
    // change something
    ilm_layerSetSourceRectangle(layer,33,567,55,99);
    ilm_commitChanges();

    // expect callback to have been called
    assertCallbackcalled();

    EXPECT_EQ(layer,callbackLayerId);
    EXPECT_EQ(33u,LayerProperties.sourceX);
    EXPECT_EQ(567u,LayerProperties.sourceY);
    EXPECT_EQ(55u,LayerProperties.sourceWidth);
    EXPECT_EQ(99u,LayerProperties.sourceHeight);
    EXPECT_EQ(ILM_NOTIFICATION_SOURCE_RECT,mask);

    ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
}
TEST_F(NotificationTest, NotifyOnLayerSetDimension)
{
    ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
    // change something
    t_ilm_uint* pos = new t_ilm_uint[2];
    pos[0] = 70;
    pos[1] = 22;
    ilm_layerSetDimension(layer,pos);
    ilm_commitChanges();

    // expect callback to have been called
    assertCallbackcalled();

    EXPECT_EQ(layer,callbackLayerId);
    EXPECT_EQ(70u,LayerProperties.destWidth);
    EXPECT_EQ(22u,LayerProperties.destHeight);
    EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);

    ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
}
TEST_F(NotificationTest, NotifyOnSurfaceSetDimension)
{
    ASSERT_EQ(ILM_SUCCESS,ilm_surfaceAddNotification(surface,&SurfaceCallbackFunction));
    // change something
    t_ilm_uint* pos = new t_ilm_uint[2];
    pos[0] = 70;
    pos[1] = 22;
    ilm_surfaceSetDimension(surface,pos);
    ilm_commitChanges();

    // expect callback to have been called
    assertCallbackcalled();

    EXPECT_EQ(surface,callbackSurfaceId);
    EXPECT_EQ(70u,SurfaceProperties.destWidth);
    EXPECT_EQ(22u,SurfaceProperties.destHeight);
    EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT,mask);

    ASSERT_EQ(ILM_SUCCESS,ilm_surfaceRemoveNotification(surface));
}
Beispiel #21
0
static void zoomSurface(t_ilm_int x, t_ilm_int y)
{
	t_ilm_int width;
	t_ilm_int height;
	struct ilmSurfaceProperties surfaceProperties;

	ilm_getPropertiesOfSurface(g_surfaceid, &surfaceProperties);

	width =  (t_ilm_int) ((float) surfaceProperties.sourceWidth)  / ZOOM_FACTOR;
	height = (t_ilm_int) ((float) surfaceProperties.sourceHeight) / ZOOM_FACTOR;

	// Center the zoom on the x,y position
	x -=  width / 2;
	x = x < 0 ? 0 : x;
	x = x + width > g_surfWidthOrig ? g_surfWidthOrig - width - 1: x;

	y -= height / 2;
	y = y < 0 ? 0 : y;
	y = y + height > g_surfHeightOrig ? g_surfHeightOrig - height - 1: y;

	ilm_surfaceSetSourceRectangle(g_surfaceid, x, y, width, height);
	ilm_commitChanges();
}
    void TearDown()
    {
        //print_lmc_get_scene();
        t_ilm_layer* layers = NULL;
        t_ilm_int numLayer=0;
        EXPECT_EQ(ILM_SUCCESS, ilm_getLayerIDs(&numLayer, &layers));
        for (t_ilm_int i=0; i<numLayer; i++)
        {
            EXPECT_EQ(ILM_SUCCESS, ilm_layerRemove(layers[i]));
        };
        free(layers);

        for (std::vector<iviSurface>::reverse_iterator it = iviSurfaces.rbegin();
             it != iviSurfaces.rend();
             ++it)
        {
            ivi_surface_destroy((*it).surface);
        }
        iviSurfaces.clear();

        EXPECT_EQ(ILM_SUCCESS, ilm_commitChanges());
        EXPECT_EQ(ILM_SUCCESS, ilm_destroy());
    }
TEST_F(NotificationTest, NotifyOnLayerMultipleValues2)
{
    ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));
    // change something
    t_ilm_float opacity = 0.789;
    ilm_layerSetOpacity(layer,opacity);
    ilm_layerSetVisibility(layer,true);
    ilm_layerSetDestinationRectangle(layer,33,567,55,99);
    ilm_commitChanges();

    // expect callback to have been called
    assertCallbackcalled(3);

    EXPECT_EQ(layer,callbackLayerId);
    EXPECT_TRUE(LayerProperties.visibility);
    EXPECT_NEAR(0.789, LayerProperties.opacity, 0.1);
    EXPECT_EQ(33u,LayerProperties.destX);
    EXPECT_EQ(567u,LayerProperties.destY);
    EXPECT_EQ(55u,LayerProperties.destWidth);
    EXPECT_EQ(99u,LayerProperties.destHeight);
    EXPECT_EQ(ILM_NOTIFICATION_DEST_RECT|ILM_NOTIFICATION_VISIBILITY|ILM_NOTIFICATION_OPACITY,mask);

    ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
}
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));
}
Beispiel #25
0
static void moveSurface()
{
	static t_ilm_uint screenWidth = 0;
	static t_ilm_uint screenHeight = 0;
	static t_ilm_int surfWidth = 0;
	static t_ilm_int surfHeight = 0;
	struct ilmSurfaceProperties surfaceProperties;

	// Init
	if (!screenWidth || !screenHeight)
	{
		ilm_getScreenResolution(0, &screenWidth, &screenHeight);
	}
	if (!surfWidth || !surfHeight)
	{
		ilm_getPropertiesOfSurface(g_surfaceid, &surfaceProperties);
		surfWidth = (t_ilm_int) surfaceProperties.destWidth;
		surfHeight = (t_ilm_int) surfaceProperties.destHeight;
	}

	// Do the real job
	switch (g_surfMoveDirection)
	{
		case move_right:
			g_surfPosX += SURFACE_MOVE_STEP;
			if (g_surfPosX >= (t_ilm_int) (screenWidth - surfWidth))
			{
				g_surfPosX = screenWidth - surfWidth;
				g_surfMoveDirection = move_down;
			}
			break;

		case move_down:
			g_surfPosY += SURFACE_MOVE_STEP;
			if (g_surfPosY >= (t_ilm_int) (screenHeight - surfHeight))
			{
				g_surfPosY = screenHeight - surfHeight;
				g_surfMoveDirection = move_left;
			}
			break;

		case move_left:
			g_surfPosX -= SURFACE_MOVE_STEP;
			if (g_surfPosX <= 0)
			{
				g_surfPosX = 0;
				g_surfMoveDirection = move_up;
			}
			break;

		case move_up:
			g_surfPosY -= SURFACE_MOVE_STEP;
			if (g_surfPosY <= 0)
			{
				g_surfPosY = 0;
				g_surfMoveDirection = move_right;
			}
			break;

		default:
			break;
	}

	ilm_surfaceSetDestinationRectangle(g_surfaceid, g_surfPosX, g_surfPosY, surfWidth, surfHeight);
	ilm_commitChanges();
}
Beispiel #26
0
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;
}
Beispiel #27
0
int main(int argc, char *argv[])
{
    ilmErrorTypes result = ILM_FAILED;
    t_ilm_layer layerid = (t_ilm_layer)LAYER_CHROMAKEY;
    t_ilm_surface surfaceid = (t_ilm_surface)SURFACE_CHROMAKEY;
    char* bitmapFile = NULL;
    int o;
    static const char opts[] = "f:c:h";
    static const struct option longopts[] = {
        { "file",  1, NULL, 'f' },
        { "color", 1, NULL, 'c' },
        { "help",  1, NULL, 'h' },
        { NULL, }
    };
    unsigned int rgb[] = {255, 255, 255}; /* Default color key is 'White' */

    while (o = getopt_long(argc, argv, opts, longopts, &o), o > 0) {
        switch (o) {
        case 'f':
            bitmapFile = optarg;
            break;
        case 'c':
            sscanf(optarg, "%d,%d,%d", &rgb[0], &rgb[1], &rgb[2]);
            break;
        case 'h':
            print_usage();
            return 0;
        }
    }

    if (bitmapFile == NULL) {
        print_usage();
        return -1;
    }

    printf("[INFO] bitmap file = %s\n", bitmapFile);
    printf("[INFO] color key   = R(%d),G(%d),B(%d)\n", rgb[0], rgb[1], rgb[2]);

    /* signal handling */
    signal(SIGINT,  sigFunc);
    signal(SIGKILL, sigFunc);

    gRun = 1;
    memset(&g_wlContextStruct, 0x00, sizeof(g_wlContextStruct));

    g_wlContextStruct.ctx_bmp = bmpaccessor_open(bitmapFile);
    if (NULL == g_wlContextStruct.ctx_bmp)
    {
        printf("Failed to create bmp accessor\n");
        return -1;
    }

    do {
        createWLContext();

        result = ilm_init();
        if (ILM_SUCCESS == result)
        {
            printf("ilm_init success\n");
        }
        else
        {
            printf("ilm_init failed\n");
            break;
        }
        result = createILMAttribute(&layerid, &surfaceid, rgb);
        if (result != ILM_SUCCESS)
        {
            break;
        }

        t_ilm_layer layer[] = {1000, 2000, 3000, LAYER_CHROMAKEY};
        ilm_displaySetRenderOrder(0, &layer[0], 4);

        ilm_commitChanges();

        while(gRun) {
            drawImage();
        }

        ilm_surfaceRemove(surfaceid);
        ilm_layerRemove(layerid);
    } while(0);

    ilm_destroy();
    destroyWLContext();

    bmpaccessor_close(g_wlContextStruct.ctx_bmp);

    return 0;
}
Beispiel #28
0
static void unzoomSurface()
{
	ilm_surfaceSetSourceRectangle(g_surfaceid, 0, 0, g_surfWidthOrig, g_surfHeightOrig);
	ilm_commitChanges();
}
CommandResult ExpressionInterpreter::interpretCommand(string userInput)
{
    CommandResult result = CommandSuccess;
    string text;
    stringstream ss;
    ss << userInput;

    ExpressionList currentState;
    currentState.push_back(mpRoot);
    ExpressionList nextState;

    while (result == CommandSuccess && !ss.eof())
    {
        ss >> text;
        transform(text.begin(), text.end(), text.begin(), ::tolower);

        ExpressionList::const_iterator iter = currentState.begin();
        ExpressionList::const_iterator end = currentState.end();
        for (; iter != end; ++iter)
        {
            Expression* expr = *iter;
            ExpressionList exprNextList = expr->getNextExpressionClosure(text);
            nextState.splice(nextState.end(), exprNextList);
        }

        if (nextState.size() > 0)
        {
            currentState = nextState;
            nextState.clear();
        }
        else
        {
            mErrorText = "'" + text + "' not recognized.";
            result = CommandInvalid;
        }
    }

    //remove impossible expressions in the final state before checking for ambiguity
    nextState.clear();
    ExpressionList::const_iterator iter = currentState.begin();
    ExpressionList::const_iterator end = currentState.end();
    for (; iter != end; ++iter)
    {
        Expression* expr = *iter;
        if (expr->isExecutable())
        {
            nextState.push_back(expr);
        }
        else
        {
            ExpressionList children = expr->getNextExpressions();

            bool flag = false;

            ExpressionList::const_iterator iter = children.begin();
            ExpressionList::const_iterator end = children.end();
            for (; iter != end; ++iter)
            {
                if ((*iter)->getName()[0] == '[')
                {
                    flag = true;
                }
            }

            if (flag || children.size() == 0)
            {
                nextState.push_back(expr);
            }
        }
    }

    currentState = nextState;

    if (currentState.size() != 1)
    {
        mErrorText = "'" + text + "' ambiguous or incomplete.";
        result = CommandInvalid;
    }

    //run command if executable and non-ambiguous
    if (result == CommandSuccess)
    {
        Expression* expr = *(currentState.begin());

        ExpressionList executables = expr->getClosureExecutables(false);
        if (executables.size() == 1)
        {
            ilmErrorTypes initResult = ilm_init();
            if (ILM_SUCCESS != initResult)
            {
                mErrorText = ILM_ERROR_STRING(initResult);
                result = CommandExecutionFailed;
            }
            else
            {
                Expression* exec = executables.front();
                exec->execute();
                ilm_commitChanges();
                ilm_destroy();
            }
        }
        else if (executables.size() == 0)
        {
            mErrorText = "command is incomplete.";
            result = CommandIncomplete;
        }
        else
        {
            mErrorText = "command is ambiguous.";
            result = CommandIncomplete;
        }
    }

    return result;
}
Beispiel #30
0
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;
}