TEST_F(NotificationTest, MultipleRegistrationsLayer)
{
    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();

    // register for notifications again
    ASSERT_EQ(ILM_SUCCESS,ilm_layerAddNotification(layer,&LayerCallbackFunction));

    ilm_layerSetOrientation(layer,ILM_ZERO);
    ilm_commitChanges();
    assertCallbackcalled();

    ASSERT_EQ(ILM_SUCCESS,ilm_layerRemoveNotification(layer));
}
TEST_F(NotificationTest, NotifyOnLayerAllValues)
{
    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,133,1567,155,199);
    ilm_layerSetSourceRectangle(layer,33,567,55,99);
    ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
    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_ONEHUNDREDEIGHTY,LayerProperties.orientation);

    EXPECT_TRUE(LayerProperties.visibility);
    EXPECT_NEAR(opacity, LayerProperties.opacity, 0.1);
    EXPECT_EQ(133u,LayerProperties.destX);
    EXPECT_EQ(1567u,LayerProperties.destY);
    EXPECT_EQ(155u,LayerProperties.destWidth);
    EXPECT_EQ(199u,LayerProperties.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_layerRemoveNotification(layer));
}
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, DefaultIsNotToReceiveNotificationsLayer)
{
    // get called once
    ilm_layerSetOrientation(layer,ILM_ONEHUNDREDEIGHTY);
    ilm_commitChanges();

    // 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();
}
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();

    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));
}
Example #6
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;
}