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_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(IlmInputTest, ilm_input_focus) {
    const uint32_t surfaceCount = 4;
    t_ilm_surface surfaces[] = {iviSurfaces[0].surface_id,
                                iviSurfaces[1].surface_id,
                                iviSurfaces[2].surface_id,
                                iviSurfaces[3].surface_id};
    t_ilm_surface *surfaceIDs;
    ilmInputDevice *bitmasks;
    t_ilm_uint num_ids;
    t_ilm_uint layer = 0xbeef;

    /* We have to add surfaces to a layer. Otherwise, they would not have a view.
       We need a view to be able to set pointer focus. */
    ASSERT_EQ(ILM_SUCCESS, ilm_layerCreateWithDimension(&layer, 800, 480));
    EXPECT_EQ(ILM_SUCCESS, ilm_layerSetRenderOrder(layer, surfaces, surfaceCount));

    ASSERT_EQ(ILM_SUCCESS, ilm_getInputFocus(&surfaceIDs, &bitmasks, &num_ids));
    /* All the surfaces are returned */
    ASSERT_EQ(num_ids, iviSurfaces.size());
    int surfaces_found = 0;

    for (unsigned int i = 0; i < num_ids; i++) {
        /* The bitmasks all start unset */
        EXPECT_EQ(bitmasks[i], 0);
        if (contains(surfaceIDs, iviSurfaces.size(), iviSurfaces[i].surface_id))
            surfaces_found++;
    }
    free(surfaceIDs);
    free(bitmasks);
    /* The surfaces returned are the correct ones */
    ASSERT_EQ(surfaces_found, iviSurfaces.size());

    /* Can set all focus to keyboard */
    ASSERT_EQ(ILM_SUCCESS, ilm_setInputFocus(&surfaces[0], surfaceCount, ILM_INPUT_DEVICE_KEYBOARD, ILM_TRUE));

    ASSERT_EQ(ILM_SUCCESS, ilm_getInputFocus(&surfaceIDs, &bitmasks, &num_ids));
    for (unsigned int i = 0; i < num_ids; i++) {
        /* All surfaces now have keyboard focus */
        for (unsigned int j = 0; j < surfaceCount; j++) {
            if (surfaceIDs[i] == surfaces[j])
                EXPECT_EQ(bitmasks[i], ILM_INPUT_DEVICE_KEYBOARD);
        }
    }
    free(surfaceIDs);
    free(bitmasks);

    /* Can remove keyboard focus from one surface */
    ASSERT_EQ(ILM_SUCCESS, ilm_setInputFocus(&surfaces[0], 1, ILM_INPUT_DEVICE_KEYBOARD, ILM_FALSE));
    ASSERT_EQ(ILM_SUCCESS, ilm_getInputFocus(&surfaceIDs, &bitmasks, &num_ids));
    /* keyboard focus now removed for surfaces[0] */
    for (unsigned int i = 0; i < num_ids; i++)
        if (surfaceIDs[i] == surfaces[0])
            EXPECT_EQ(bitmasks[i], 0);
    free(surfaceIDs);
    free(bitmasks);

    /* Pointer focus set for surfaces[1] */
    ASSERT_EQ(ILM_SUCCESS, ilm_setInputFocus(&surfaces[1], 1, ILM_INPUT_DEVICE_POINTER, ILM_TRUE));
    ASSERT_EQ(ILM_SUCCESS, ilm_getInputFocus(&surfaceIDs, &bitmasks, &num_ids));
    /* surfaces[1] now has pointer and keyboard focus */
    for (unsigned int i = 0; i < num_ids; i++)
        if (surfaceIDs[i] == surfaces[1])
            EXPECT_EQ(bitmasks[i], ILM_INPUT_DEVICE_POINTER | ILM_INPUT_DEVICE_KEYBOARD);
    free(surfaceIDs);
    free(bitmasks);

    /* Touch focus set for surfaces[2] */
    ASSERT_EQ(ILM_SUCCESS, ilm_setInputFocus(&surfaces[2], 1, ILM_INPUT_DEVICE_TOUCH, ILM_TRUE));
    ASSERT_EQ(ILM_SUCCESS, ilm_getInputFocus(&surfaceIDs, &bitmasks, &num_ids));
    /* surfaces[2] now has keyboard and touch focus */
    for (unsigned int i = 0; i < num_ids; i++)
        if (surfaceIDs[i] == surfaces[2])
            EXPECT_EQ(bitmasks[i], ILM_INPUT_DEVICE_KEYBOARD | ILM_INPUT_DEVICE_TOUCH);
    free(surfaceIDs);
    free(bitmasks);
}
예제 #4
0
파일: chromakey.c 프로젝트: Airtau/genivi
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;
}