Beispiel #1
0
int
main( int argc, char *argv[] )
{
     DFBResult  ret;
     IDirectFB *dfb;

     /* Initialize DirectFB. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          D_DERROR( ret, "DFBTest/Init: DirectFBInit() failed!\n" );
          return ret;
     }

     /* Create super interface. */
     ret = DirectFBCreate( &dfb );
     if (ret) {
          D_DERROR( ret, "DFBTest/Init: DirectFBCreate() failed!\n" );
          return ret;
     }

     /* Shutdown DirectFB. */
     ret = dfb->Release( dfb );
     if (ret) {
          D_DERROR( ret, "DFBTest/Init: IDirectFB::Release() failed!\n" );
          return ret;
     }

     return 0;
}
Beispiel #2
0
int
main( int argc, char *argv[] )
{
     DFBResult  ret;
     IDirectFB *dfb;

     /* Initialize DirectFB. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          D_DERROR( ret, "DFBTest/Resize: DirectFBInit() failed!\n" );
          return ret;
     }


     /* Create super interface. */
     ret = DirectFBCreate( &dfb );
     if (ret) {
          D_DERROR( ret, "DFBTest/Resize: DirectFBCreate() failed!\n" );
          return ret;
     }

     /* Required for keyboard access */
     dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );

     TestResize( dfb );



     /* Shutdown DirectFB. */
     dfb->Release( dfb );


     return ret;
}
static DFBResult
Test_Clipboard_Get( IDirectFB *dfb )
{
     DFBResult       ret;
     struct timeval  tv;
     char           *mime_type;
     void           *data;
     unsigned int    data_size;

     ret = dfb->GetClipboardTimeStamp( dfb, &tv );
     if (ret) {
          D_DERROR( ret, "DFBTest/Clipboard: IDirectFB::GetClipboardTimeStamp() failed!\n" );
          return ret;
     }

     ret = dfb->GetClipboardData( dfb, &mime_type, &data, &data_size );
     if (ret) {
          D_DERROR( ret, "DFBTest/Clipboard: IDirectFB::GetClipboardData() failed!\n" );
          return ret;
     }

     direct_log_printf( NULL, "Got clipboard data of mime type '%s' with data '%s'\n", mime_type, (const char*) data );
     direct_log_printf( NULL, "Got clipboard timestamp %ld.%06ld\n", tv.tv_sec, tv.tv_usec );

     return ret;
}
Beispiel #4
0
static DFBResult
wm_add_window( CoreWindowStack *stack,
               void            *wm_data,
               void            *stack_data,
               CoreWindow      *window,
               void            *window_data )
{
     DFBResult   ret;
     StackData  *sdata  = stack_data;
     WindowData *data   = window_data;
     WMData     *wmdata = wm_data;

     D_ASSERT( stack != NULL );
     D_ASSERT( wm_data != NULL );
     D_ASSERT( stack_data != NULL );
     D_ASSERT( window != NULL );
     D_ASSERT( window_data != NULL );

     D_MAGIC_ASSERT( sdata, StackData );
     D_MAGIC_ASSERT( sdata->context, UniqueContext );

     data->context = sdata->context;

     /* Create the unique window. */
     ret = unique_window_create( wmdata->core, window, data->context,
                                 window->caps, &window->config, &data->window );
     if (ret) {
          D_DERROR( ret, "WM/UniQuE: Could not create window!\n" );
          return ret;
     }

     /* Attach the global window listener. */
     ret = unique_window_attach_global( data->window,
                                        UNIQUE_WM_MODULE_WINDOW_LISTENER,
                                        data, &data->window_reaction );
     if (ret) {
          unique_window_unref( data->window );
          D_DERROR( ret, "WM/UniQuE: Could not attach global window listener!\n" );
          return ret;
     }

     /* Inherit all local references from the layer window. */
     ret = unique_window_inherit( data->window, window );
     unique_window_unref( data->window );
     if (ret) {
          unique_window_detach_global( data->window, &data->window_reaction );
          D_DERROR( ret, "WM/UniQuE: Could not inherit from core window!\n" );
          return ret;
     }

     unique_window_get_config( data->window, &window->config );


     D_MAGIC_SET( data, WindowData );

     return DFB_OK;
}
DFBResult
ILayer_Requestor::GetPrimaryContext(
                    bool                                       activate,
                    CoreLayerContext                         **ret_context
)
{
    DFBResult           ret = DFB_OK;
    CoreLayerContext *context = NULL;
    char        args_static[FLUXED_ARGS_BYTES];
    char        return_args_static[FLUXED_ARGS_BYTES];
    CoreLayerGetPrimaryContext       *args = (CoreLayerGetPrimaryContext*) args_alloc( args_static, sizeof(CoreLayerGetPrimaryContext) );
    CoreLayerGetPrimaryContextReturn *return_args;

    if (!args)
        return (DFBResult) D_OOM();

    return_args = (CoreLayerGetPrimaryContextReturn*) args_alloc( return_args_static, sizeof(CoreLayerGetPrimaryContextReturn) );

    if (!return_args) {
        args_free( args_static, args );
        return (DFBResult) D_OOM();
    }

    D_DEBUG_AT( DirectFB_CoreLayer, "ILayer_Requestor::%s()\n", __FUNCTION__ );

    D_ASSERT( ret_context != NULL );

    args->activate = activate;

    ret = (DFBResult) CoreLayer_Call( obj, FCEF_NONE, CoreLayer_GetPrimaryContext, args, sizeof(CoreLayerGetPrimaryContext), return_args, sizeof(CoreLayerGetPrimaryContextReturn), NULL );
    if (ret) {
        D_DERROR( ret, "%s: CoreLayer_Call( CoreLayer_GetPrimaryContext ) failed!\n", __FUNCTION__ );
        goto out;
    }

    if (return_args->result) {
        /*D_DERROR( return_args->result, "%s: CoreLayer_GetPrimaryContext failed!\n", __FUNCTION__ );*/
        ret = return_args->result;
        goto out;
    }


    ret = (DFBResult) CoreLayerContext_Catch( core, return_args->context_ptr, &context );
    if (ret) {
         D_DERROR( ret, "%s: Catching context by ID %u failed!\n", __FUNCTION__, return_args->context_id );
         goto out;
    }

    *ret_context = context;


out:
    args_free( return_args_static, return_args );
    args_free( args_static, args );
    return ret;
}
Beispiel #6
0
int
main( int argc, char *argv[] )
{
     DFBResult         ret;
     int               i;
     IDirectFB        *dfb;
     DFBInputDeviceID  device_id = 0;

     /* Initialize DirectFB. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          D_DERROR( ret, "DFBTest/Input: DirectFBInit() failed!\n" );
          return ret;
     }

     /* Parse arguments. */
     for (i=1; i<argc; i++) {
          const char *arg = argv[i];

          if (strcmp( arg, "-h" ) == 0 || strcmp (arg, "--help") == 0)
               return print_usage( argv[0] );
          else if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
               fprintf (stderr, "dfbtest_input version %s\n", DIRECTFB_VERSION);
               return false;
          }
          else if (strcmp (arg, "-d") == 0 || strcmp (arg, "--device") == 0) {
               if (++i == argc) {
                    print_usage (argv[0]);
                    return false;
               }

               if (!parse_id( argv[i], &device_id ))
                    return false;
          }
          else
               return print_usage( argv[0] );
     }

     /* Create super interface. */
     ret = DirectFBCreate( &dfb );
     if (ret) {
          D_DERROR( ret, "DFBTest/Input: DirectFBCreate() failed!\n" );
          return ret;
     }

     Test_Sensitivity( dfb, device_id );

     /* Shutdown DirectFB. */
     ret = dfb->Release( dfb );
     if (ret) {
          D_DERROR( ret, "DFBTest/Input: IDirectFB::Release() failed!\n" );
          return ret;
     }

     return 0;
}
DFBResult
ICore_Requestor::GetSurface(
                    u32                                        surface_id,
                    CoreSurface                              **ret_surface
)
{
    DFBResult           ret = DFB_OK;
    CoreSurface *surface = NULL;
    char        args_static[FLUXED_ARGS_BYTES];
    char        return_args_static[FLUXED_ARGS_BYTES];
    CoreDFBGetSurface       *args = (CoreDFBGetSurface*) args_alloc( args_static, sizeof(CoreDFBGetSurface) );
    CoreDFBGetSurfaceReturn *return_args;

    if (!args)
        return (DFBResult) D_OOM();

    return_args = (CoreDFBGetSurfaceReturn*) args_alloc( return_args_static, sizeof(CoreDFBGetSurfaceReturn) );

    if (!return_args) {
        args_free( args_static, args );
        return (DFBResult) D_OOM();
    }

    D_DEBUG_AT( DirectFB_CoreDFB, "ICore_Requestor::%s()\n", __FUNCTION__ );

    D_ASSERT( ret_surface != NULL );

    args->surface_id = surface_id;

    ret = (DFBResult) CoreDFB_Call( obj, FCEF_NONE, CoreDFB_GetSurface, args, sizeof(CoreDFBGetSurface), return_args, sizeof(CoreDFBGetSurfaceReturn), NULL );
    if (ret) {
        D_DERROR( ret, "%s: CoreDFB_Call( CoreDFB_GetSurface ) failed!\n", __FUNCTION__ );
        goto out;
    }

    if (return_args->result) {
        /*D_DERROR( return_args->result, "%s: CoreDFB_GetSurface failed!\n", __FUNCTION__ );*/
        ret = return_args->result;
        goto out;
    }


    ret = (DFBResult) CoreSurface_Catch( core, return_args->surface_ptr, &surface );
    if (ret) {
         D_DERROR( ret, "%s: Catching surface by ID %u failed!\n", __FUNCTION__, return_args->surface_id );
         goto out;
    }

    *ret_surface = surface;


out:
    args_free( return_args_static, return_args );
    args_free( args_static, args );
    return ret;
}
int
main( int argc, char *argv[] )
{
     int                    i;
     DFBResult              ret;
     IDirectFB             *dfb;
     IDirectFBDisplayLayer *layer  = NULL;
     App                    apps[1];
     DFBDisplayLayerConfig  config;

     /* Parse arguments. */
     for (i=1; i<argc; i++) {
          if (!strcmp( argv[i], "-h" ))
               return show_usage( argv[0] );
     }

     /* Initialize DirectFB. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          D_DERROR( ret, "DFBTest/WindowFlip: DirectFBInit() failed!\n" );
          return ret;
     }

     /* Create super interface. */
     ret = DirectFBCreate( &dfb );
     if (ret) {
          D_DERROR( ret, "DFBTest/WindowFlip: DirectFBCreate() failed!\n" );
          return ret;
     }

     /* Get primary layer. */
     ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );
     if (ret) {
          D_DERROR( ret, "DFBTest/WindowFlip: IDirectFB::GetDisplayLayer( PRIMARY ) failed!\n" );
          goto out;
     }

     
     layer->GetConfiguration( layer, &config );

     app_init( &apps[0], layer, 100, 50, config.width-300, config.height-150, 0 );

     while (true) {
          direct_thread_sleep( 1000000 );

          app_update( &apps[0] );
     }


out:
     /* Shutdown DirectFB. */
     dfb->Release( dfb );

     return ret;
}
gfxDirectFBSurface::gfxDirectFBSurface(const gfxIntSize& size, gfxImageFormat format) :
    mDFB(nsnull), mDFBSurface(nsnull)
{
    DFBResult             ret;
    DFBSurfaceDescription desc;

    if (!CheckSurfaceSize(size) || size.width <= 0 || size.height <= 0)
        return;

    /* Lightweight, getting singleton */
    ret = DirectFBCreate( &mDFB );
    if (ret) {
        D_DERROR( (DirectResult) ret, "gfxDirectFBSurface: DirectFBCreate() failed!\n" );
        return;
    }

    desc.flags  = (DFBSurfaceDescriptionFlags)( DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT );
    desc.width  = size.width;
    desc.height = size.height;

    switch (format) {
    case gfxASurface::ImageFormatARGB32:
        desc.pixelformat = DSPF_ARGB;
        break;

    case gfxASurface::ImageFormatRGB24:
        desc.pixelformat = DSPF_RGB32;
        break;

    case gfxASurface::ImageFormatA8:
        desc.pixelformat = DSPF_A8;
        break;

    case gfxASurface::ImageFormatA1:
        desc.pixelformat = DSPF_A1;
        break;

    default:
        D_BUG( "unknown format" );
        return;
    }

    ret = mDFB->CreateSurface( mDFB, &desc, &mDFBSurface );
    if (ret) {
        D_DERROR( (DirectResult) ret, "gfxDirectFBSurface: "
                  "IDirectFB::CreateSurface( %dx%d ) failed!\n", desc.width, desc.height );
        return;
    }

    cairo_surface_t *surface = cairo_directfb_surface_create(mDFB, mDFBSurface);

    Init(surface);
}
Beispiel #10
0
static void *
TestThread( DirectThread *thread,
            void         *arg )
{
     DFBResult         ret;
     IDirectFBSurface *surface = arg;
     DFBRectangle      rect    = { 0, 0, 500, 1 };

     while (!quit) {
          void *data;
          int   pitch;

          ret = surface->Lock( surface, DSLF_WRITE, &data, &pitch );

          if (ret) {
               D_DERROR( ret, "DFBTest/Resize: Lock() failed!\n" );
               return NULL;
          }

          if (!data) {
               D_DERROR( ret, "DFBTest/Resize:invalid pointer!\n" );
               return NULL;
          }

          memset( data, 0, pitch * 400 );

          surface->Unlock( surface );

          data = malloc( pitch );

          ret = surface->Read( surface, &rect, data, pitch );

          if (ret) {
               D_DERROR( ret, "DFBTest/Resize: Read() failed!\n" );
               free (data);
               return NULL;
          }

          ret = surface->Write( surface, &rect, data, pitch );
          if (ret) {
               D_DERROR( ret, "DFBTest/Resize: Write() failed!\n" );
               free(data);
               return NULL;
          }

          free(data);
     }

     return NULL;
}
Beispiel #11
0
DFBResult
DaleDFB::showOSK(const Rectangle& rect, TextInputMode mode)
{
    ILOG_TRACE_F(ILX_DALEDFB);

    if (getOSKComp() == DFB_FAILURE)
        return DFB_FAILURE;

    OSKRequest request;
    request.inputRect = rect.dfbRect();
    request.mode = mode;
    request.process = getpid();

    void *ptr;
    __coma->GetLocal(__coma, sizeof(OSKRequest), &ptr);
    OSKRequest* req = (OSKRequest*) ptr;
    *req = request;

    int ret_val;
    DirectResult ret = __oskComp->Call(__oskComp, 0, (void*) req, &ret_val);
    if (ret)
    {
        D_DERROR(ret, "WebKit/DFB: %s() failed!\n", __FUNCTION__);
        return (DFBResult) ret;
    }
    return DFB_OK;
}
Beispiel #12
0
static DFBResult
update_screen( CoreSurface *surface, int x, int y, int w, int h )
{
     DFBResult              ret;
     void                  *src;
     CoreSurfaceBufferLock  lock;

     D_ASSERT( surface != NULL );

     ret = dfb_surface_lock_buffer( surface, CSBR_FRONT, CSAF_CPU_READ, &lock );
     if (ret) {
          D_DERROR( ret, "DirectFB/RTD: Couldn't lock layer surface!\n" );
          return ret;
     }

     src = lock.addr; /* + DFB_BYTES_PER_LINE( surface->config.format, x ) + y * lock.pitch;*/


     switch(surface->config.format) {
     case DSPF_RGB16:
       libk_copyrect_16(src, lock.pitch, x, y, w, h);
       break;
     case DSPF_RGB32:
     case DSPF_ARGB:
       libk_copyrect_32(src, lock.pitch, x, y, w, h);
       break;
     default:
       printf("bad pixel format %d\n", surface->config.format);
       break;
     }

     dfb_surface_unlock_buffer( surface, &lock );

     return DFB_OK;
}
Beispiel #13
0
static DFBResult
InitGL( Test *test )
{
     DFBResult ret;

     /* 
      * Bind the OpenGL rendering context to our primary surface
      */
     ret = test->gl2context->Bind( test->gl2context, test->primary, test->primary );
     if (ret) {
          D_DERROR( ret, "IDirectFBGL2Context::Bind() failed!\n" );
          return ret;
     }

     gears_init();

     /* Update the projection matrix */
     perspective(ProjectionMatrix, 60.0, test->size.w / (float)test->size.h, 1.0, 1024.0);

     /* Setup the viewport */
     glViewport( 0, 0, (GLint) test->size.w, (GLint) test->size.h );

     /* Unbind the OpenGL rendering context */
     test->gl2context->Unbind( test->gl2context );

     return DFB_OK;
}
Beispiel #14
0
EGLint
Surface::SwapBuffers()
{
     D_DEBUG_AT( DFBEGL_Surface, "EGL::Surface::%s( %p )\n", __FUNCTION__, this );

     if (surface == NULL) {
          D_DEBUG_AT( DFBEGL_Surface, "  -> NO SURFACE\n" );
          return EGL_BAD_SURFACE;
     }

     if (gfx_peer) {
          DFBResult ret;

          ret = gfx_peer->Flip( NULL, DSFLIP_NONE );
          if (ret) {
               D_DERROR( ret, "DFBEGL/Display: Graphics::SurfacePeer::Flip() failed!\n" );
               return EGL_BAD_SURFACE;
          }
     }
     else
          D_DEBUG_AT( DFBEGL_Surface, "  -> NO PEER\n" );

     Dispatch< Surface::SwapBuffersFunc >( "SwapBuffers", this );

     return EGL_SUCCESS;
}
Beispiel #15
0
static DFBResult
x11JoinPool( CoreDFB                    *core,
             CoreSurfacePool            *pool,
             void                       *pool_data,
             void                       *pool_local,
             void                       *system_data )
{
     DFBResult         ret;
     x11PoolLocalData *local = pool_local;
     DFBX11           *x11   = system_data;

     D_DEBUG_AT( X11_Surfaces, "%s()\n", __FUNCTION__ );

     D_MAGIC_ASSERT( pool, CoreSurfacePool );

     local->x11 = x11;

     ret = direct_hash_create( 7, &local->hash );
     if (ret) {
          D_DERROR( ret, "X11/Surfaces: Could not create local hash table!\n" );
          return ret;
     }

     pthread_mutex_init( &local->lock, NULL );

     return DFB_OK;
}
DFBResult
IInputDevice_Requestor__ReloadKeymap( CoreInputDevice *obj

)
{
    DFBResult           ret;
    CoreInputDeviceReloadKeymap       *args = (CoreInputDeviceReloadKeymap*) alloca( sizeof(CoreInputDeviceReloadKeymap) );
    CoreInputDeviceReloadKeymapReturn *return_args = (CoreInputDeviceReloadKeymapReturn*) alloca( sizeof(CoreInputDeviceReloadKeymapReturn) );

    D_DEBUG_AT( DirectFB_CoreInputDevice, "IInputDevice_Requestor::%s()\n", __FUNCTION__ );



    ret = (DFBResult) CoreInputDevice_Call( obj, FCEF_NONE, _CoreInputDevice_ReloadKeymap, args, sizeof(CoreInputDeviceReloadKeymap), return_args, sizeof(CoreInputDeviceReloadKeymapReturn), NULL );
    if (ret) {
        D_DERROR( ret, "%s: CoreInputDevice_Call( CoreInputDevice_ReloadKeymap ) failed!\n", __FUNCTION__ );
        return ret;
    }

    if (return_args->result) {
         /*D_DERROR( return_args->result, "%s: CoreInputDevice_ReloadKeymap failed!\n", __FUNCTION__ );*/
         return return_args->result;
    }


    return DFB_OK;
}
Beispiel #17
0
void
direct_processor_post( DirectProcessor *processor,
                       void            *data )
{
     ProcessorCommand *command = (ProcessorCommand*) data - 1;

     D_MAGIC_ASSERT( processor, DirectProcessor );
     D_MAGIC_ASSERT( command, ProcessorCommand );

     D_DEBUG_AT( Direct_Processor_Post, "%s( %p '%s' <---= %p )\n", __FUNCTION__, processor, processor->name, data );

     if (processor->direct) {
          DirectResult                ret;
          const DirectProcessorFuncs *funcs;

//          D_ASSUME( !processor->commands.count );

          funcs = processor->funcs;
          D_ASSERT( funcs != NULL );
          D_ASSERT( funcs->Process != NULL );
          
          ret = funcs->Process( processor, data, processor->context );
          if (ret)
               D_DERROR( ret, "Direct/Processor: Processing directly failed! (%s)\n", processor->name );
     }
     else
          direct_fifo_push( &processor->commands, &command->item );
}
Beispiel #18
0
DFBResult
ICoreSlave_Requestor__PutData( CoreSlave *obj,
                    void*                                      address,
                    u32                                        bytes,
                    const u8                                  *data
)
{
    DFBResult           ret;
    CoreSlavePutData       *args = (CoreSlavePutData*) alloca( sizeof(CoreSlavePutData) + bytes * sizeof(u8) );
    CoreSlavePutDataReturn *return_args = (CoreSlavePutDataReturn*) alloca( sizeof(CoreSlavePutDataReturn) );

    D_DEBUG_AT( DirectFB_CoreSlave, "ICoreSlave_Requestor::%s()\n", __FUNCTION__ );


    args->address = address;
    args->bytes = bytes;
    direct_memcpy( (char*) (args + 1), data, bytes * sizeof(u8) );

    ret = (DFBResult) CoreSlave_Call( obj, FCEF_NONE, _CoreSlave_PutData, args, sizeof(CoreSlavePutData) + bytes * sizeof(u8), return_args, sizeof(CoreSlavePutDataReturn), NULL );
    if (ret) {
        D_DERROR( ret, "%s: CoreSlave_Call( CoreSlave_PutData ) failed!\n", __FUNCTION__ );
        return ret;
    }

    if (return_args->result) {
         /*D_DERROR( return_args->result, "%s: CoreSlave_PutData failed!\n", __FUNCTION__ );*/
         return return_args->result;
    }


    return DFB_OK;
}
Beispiel #19
0
DFBResult
dfb_surface_init_palette( CoreDFB     *core,
                          CoreSurface *surface )
{
     DFBResult    ret;
     CorePalette *palette;

     ret = dfb_palette_create( core,
                               1 << DFB_COLOR_BITS_PER_PIXEL( surface->config.format ),
                               &palette );
     if (ret) {
          D_DERROR( ret, "Core/Surface: Error creating palette!\n" );
          return ret;
     }

     switch (surface->config.format) {
          case DSPF_LUT8:
               dfb_palette_generate_rgb332_map( palette );
               break;

          case DSPF_ALUT44:
               dfb_palette_generate_rgb121_map( palette );
               break;

          default:
               break;
     }

     dfb_surface_set_palette( surface, palette );

     dfb_palette_unref( palette );

     return DFB_OK;
}
DFBResult
IInputDevice_Requestor__SetKeymapEntry( CoreInputDevice *obj,
                    s32                                        key_code,
                    const DFBInputDeviceKeymapEntry           *entry
)
{
    DFBResult           ret;
    CoreInputDeviceSetKeymapEntry       *args = (CoreInputDeviceSetKeymapEntry*) alloca( sizeof(CoreInputDeviceSetKeymapEntry) );
    CoreInputDeviceSetKeymapEntryReturn *return_args = (CoreInputDeviceSetKeymapEntryReturn*) alloca( sizeof(CoreInputDeviceSetKeymapEntryReturn) );

    D_DEBUG_AT( DirectFB_CoreInputDevice, "IInputDevice_Requestor::%s()\n", __FUNCTION__ );

    D_ASSERT( entry != NULL );

    args->key_code = key_code;
    args->entry = *entry;

    ret = (DFBResult) CoreInputDevice_Call( obj, FCEF_NONE, _CoreInputDevice_SetKeymapEntry, args, sizeof(CoreInputDeviceSetKeymapEntry), return_args, sizeof(CoreInputDeviceSetKeymapEntryReturn), NULL );
    if (ret) {
        D_DERROR( ret, "%s: CoreInputDevice_Call( CoreInputDevice_SetKeymapEntry ) failed!\n", __FUNCTION__ );
        return ret;
    }

    if (return_args->result) {
         /*D_DERROR( return_args->result, "%s: CoreInputDevice_SetKeymapEntry failed!\n", __FUNCTION__ );*/
         return return_args->result;
    }


    return DFB_OK;
}
Beispiel #21
0
static DirectResult
RUN_create( int index )
{
    DirectResult      ret;
    ComaTestInstance *instance;
    char              buf[20];

    snprintf( buf, sizeof(buf), "Tuner_%02d", index );

    instance = D_CALLOC( 1, sizeof(ComaTestInstance) );
    if (!instance)
        return D_OOM();

    ret = coma->CreateComponent( coma, buf, ComaTestMethodFunc,
                                 0,
                                 instance, &instance->component );
    if (ret) {
        D_DERROR( ret, "IComa::CreateComponent( '%s' ) failed!\n", buf );
        return ret;
    }

    instance->component->Activate( instance->component );

    return DR_OK;
}
Beispiel #22
0
static void
set_color()
{
     DFBResult  ret;
     char      *error;
     u32        argb;
     DFBColor   color;

     if (*filename == '#')
          filename++;

     argb = strtoul( filename, &error, 16 );

     if (*error) {
          fprintf( stderr, "Invalid characters in color string: '%s'\n", error );
          return;
     }

     color.a = (argb & 0xFF000000) >> 24;
     color.r = (argb & 0xFF0000) >> 16;
     color.g = (argb & 0xFF00) >> 8;
     color.b = (argb & 0xFF);

     ret = prophecy_context_set_color( context, &color );
     if (ret)
          D_DERROR( ret, "Prophecy/Test: prophecy_context_set_color() failed!\n" );
}
Beispiel #23
0
DirectFB::Util::FusionObjectWrapper<CoreSurfaceBuffer> &
SurfacePeer::getBuffer( int offset )
{
     D_DEBUG_AT( DirectFB_Graphics, "Graphics::SurfacePeer::%s( %p, offset %d ) <- surface %p\n", __FUNCTION__, this, offset, surface );

     u32 index;

     if (surface_config.caps & DSCAPS_STEREO) {
          D_ASSERT( buffer_num > 1 );

          index = ((flips + offset) % (buffer_num/2)) * 2;
     }
     else {
          D_ASSERT( buffer_num > 0 );

          index = (flips + offset) % buffer_num;
     }

     if (!buffer_objects[index]) {
          DFBResult          ret;
          CoreSurfaceBuffer *buffer;

          ret = ::CoreDFB_GetSurfaceBuffer( core_dfb, buffer_ids[index], &buffer );
          if (ret)
               D_DERROR( ret, "DirectFB/SurfacePeer: CoreDFB_GetSurfaceBuffer( 0x%x ) failed!\n", buffer_ids[index] );
          else {
               buffer_objects[index] = buffer;

               dfb_surface_buffer_unref( buffer );
          }
     }

     return buffer_objects[index];
}
Beispiel #24
0
DFBResult
SurfacePeer::updateBuffers()
{
     D_DEBUG_AT( DirectFB_Graphics, "Graphics::SurfacePeer::%s( %p ) <- surface %p\n", __FUNCTION__, this, surface );

     if (direct_serial_update( &surface_serial, &surface->config_serial )) {
          DFBResult ret;

          surface_config = surface->config;

          ret = ::CoreSurface_GetBuffers( surface, &buffer_ids[0], D_ARRAY_SIZE(buffer_ids), &buffer_num );
          if (ret) {
               D_DERROR( ret, "Graphics/SurfacePeer: CoreSurface::GetBuffers() failed!\n" );
               return ret;
          }

          for (size_t i=0; i<buffer_num; i++)
               buffer_objects[i] = NULL;
     }

     if (surface_config.caps & DSCAPS_STEREO) {
          D_ASSERT( buffer_num > 1 );

          index = (flips % (buffer_num/2)) * 2;
     }
     else {
          D_ASSERT( buffer_num > 0 );

          index = flips % buffer_num;
     }

     return DFB_OK;
}
Beispiel #25
0
static DFBResult
unrealize_region( CoreLayerRegion *region )
{
     DFBResult                ret;
     int                      index;
     CoreLayer               *layer;
     CoreLayerShared         *shared;
     const DisplayLayerFuncs *funcs;

     D_ASSERT( region != NULL );
     D_ASSERT( region->context != NULL );
     D_ASSERT( D_FLAGS_IS_SET( region->state, CLRSF_REALIZED ) );

     layer = dfb_layer_at( region->context->layer_id );

     D_ASSERT( layer != NULL );
     D_ASSERT( layer->shared != NULL );
     D_ASSERT( layer->funcs != NULL );

     shared = layer->shared;
     funcs  = layer->funcs;

     D_ASSERT( fusion_vector_contains( &shared->added_regions, region ) );

     index = fusion_vector_index_of( &shared->added_regions, region );

     D_DEBUG_AT( Core_Layers, "Removing region (%d, %d - %dx%d) from '%s'.\n",
                 DFB_RECTANGLE_VALS( &region->config.dest ), shared->description.name );

     /* Remove the region from hardware and driver. */
     if (funcs->RemoveRegion) {
          ret = funcs->RemoveRegion( layer, layer->driver_data,
                                     layer->layer_data, region->region_data );
          if (ret) {
               D_DERROR( ret, "Core/Layers: Could not remove region!\n" );
               return ret;
          }
     }

     /* Remove the region from the 'added' list. */
     fusion_vector_remove( &shared->added_regions, index );

     /* Deallocate the driver's region data. */
     if (region->region_data) {
          SHFREE( shared->shmpool, region->region_data );
          region->region_data = NULL;
     }

     /* Update the region's state. */
     D_FLAGS_CLEAR( region->state, CLRSF_REALIZED );
     D_FLAGS_SET( region->state, CLRSF_FROZEN );

     if (region->surface && region->surface_lock.buffer) {
          dfb_surface_unlock_buffer( region->surface, &region->surface_lock );
          dfb_surface_destroy_buffers( region->surface );
     }

     return DFB_OK;
}
Beispiel #26
0
DFBResult
ILayerRegion_Requestor::FlipUpdateStereo(
                    const DFBRegion                           *left,
                    const DFBRegion                           *right,
                    DFBSurfaceFlipFlags                        flags
)
{
    DFBResult           ret = DFB_OK;
    char        args_static[FLUXED_ARGS_BYTES];
    char        return_args_static[FLUXED_ARGS_BYTES];
    CoreLayerRegionFlipUpdateStereo       *args = (CoreLayerRegionFlipUpdateStereo*) args_alloc( args_static, sizeof(CoreLayerRegionFlipUpdateStereo) );
    CoreLayerRegionFlipUpdateStereoReturn *return_args;

    if (!args)
        return (DFBResult) D_OOM();

    return_args = (CoreLayerRegionFlipUpdateStereoReturn*) args_alloc( return_args_static, sizeof(CoreLayerRegionFlipUpdateStereoReturn) );

    if (!return_args) {
        args_free( args_static, args );
        return (DFBResult) D_OOM();
    }

    D_DEBUG_AT( DirectFB_CoreLayerRegion, "ILayerRegion_Requestor::%s()\n", __FUNCTION__ );


  if (left) {
    args->left = *left;
    args->left_set = true;
  }
  else
    args->left_set = false;
  if (right) {
    args->right = *right;
    args->right_set = true;
  }
  else
    args->right_set = false;
    args->flags = flags;

    ret = (DFBResult) CoreLayerRegion_Call( obj, FCEF_NONE, CoreLayerRegion_FlipUpdateStereo, args, sizeof(CoreLayerRegionFlipUpdateStereo), return_args, sizeof(CoreLayerRegionFlipUpdateStereoReturn), NULL );
    if (ret) {
        D_DERROR( ret, "%s: CoreLayerRegion_Call( CoreLayerRegion_FlipUpdateStereo ) failed!\n", __FUNCTION__ );
        goto out;
    }

    if (return_args->result) {
        /*D_DERROR( return_args->result, "%s: CoreLayerRegion_FlipUpdateStereo failed!\n", __FUNCTION__ );*/
        ret = return_args->result;
        goto out;
    }



out:
    args_free( return_args_static, return_args );
    args_free( args_static, args );
    return ret;
}
static DFBResult
init_bridge( CoreDFB                      *core,
             CoreSurfacePoolBridge        *bridge,
             const SurfacePoolBridgeFuncs *funcs,
             void                         *context )
{
     DFBResult ret;

     D_MAGIC_ASSERT( bridge, CoreSurfacePoolBridge );
     D_ASSERT( funcs != NULL );
     D_ASSERT( funcs->InitPoolBridge != NULL );

     D_DEBUG_AT( Core_SurfPoolBridge, "%s( %p, %p )\n", __FUNCTION__, bridge, funcs );

     if (funcs->PoolBridgeDataSize)
          bridge->bridge_data_size = funcs->PoolBridgeDataSize();

     if (funcs->PoolBridgeLocalDataSize)
          bridge->bridge_local_data_size = funcs->PoolBridgeLocalDataSize();

     if (funcs->PoolTransferDataSize)
          bridge->transfer_data_size = funcs->PoolTransferDataSize();

     /* Allocate shared bridge data. */
     if (bridge->bridge_data_size) {
          bridge->data = SHCALLOC( bridge->shmpool, 1, bridge->bridge_data_size );
          if (!bridge->data)
               return D_OOSHM();
     }

     /* Allocate local bridge data. */
     if (bridge->bridge_local_data_size &&
         !(bridge_locals[bridge->bridge_id] = D_CALLOC( 1, bridge->bridge_local_data_size )))
     {
          SHFREE( bridge->shmpool, bridge->data );
          return D_OOM();
     }

     ret = funcs->InitPoolBridge( core, bridge, bridge->data, get_local(bridge), context, &bridge->desc );
     if (ret) {
          D_DERROR( ret, "Core/SurfacePoolBridge: Initializing '%s' failed!\n", bridge->desc.name );

          if (bridge_locals[bridge->bridge_id]) {
               D_FREE( bridge_locals[bridge->bridge_id] );
               bridge_locals[bridge->bridge_id] = NULL;
          }
          if (bridge->data) {
               SHFREE( bridge->shmpool, bridge->data );
               bridge->data = NULL;
          }
          return ret;
     }

     fusion_skirmish_init2( &bridge->lock, bridge->desc.name, dfb_core_world(core), fusion_config->secure_fusion );

     return DFB_OK;
}
Beispiel #28
0
static DirectResult
RUN_call( int index )
{
    DirectResult    ret;
    int             result;
    IComaComponent *instance;
    char            buf[20];
    void           *ptr;
    int             seed = 0;

    snprintf( buf, sizeof(buf), "Tuner_%02d", index );

    ret = coma->GetComponent( coma, buf, 99999, &instance );
    if (ret) {
        D_DERROR( ret, "IComa::GetComponent( '%s' ) failed!\n", buf );
        return ret;
    }

    while (true) {
        ret = coma->GetLocal( coma, sizeof(DataCall1), &ptr );
        if (ret) {
            D_DERROR( ret, "IComa::GetLocal( %zu ) failed!\n", sizeof(DataCall1) );
        }
        else {
            int        i;
            DataCall1 *data = ptr;

            for (i=0; i<20; i++)
                data->bytes[i] = seed + i;

            ret = instance->Call( instance, COMA_TEST_CALL1, data, &result );
            if (ret)
                D_DERROR( ret, "IComaComponent::Call( COMA_TEST_CALL1 ) failed!\n" );

            for (i=0; i<20; i++) {
                if (data->bytes[i] != (seed + i) * 3)
                    D_BUG( "byte %d being %d does not match %d", i, data->bytes[i], (seed + i) * 3 );
            }
        }
    }

    return DR_OK;
}
int
main( int argc, char *argv[] )
{
     DFBResult  ret;
     int        i;
     IDirectFB *dfb;

     /* Initialize DirectFB. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          D_DERROR( ret, "DFBTest/Blit: DirectFBInit() failed!\n" );
          return ret;
     }

     /* Parse arguments. */
     for (i=1; i<argc; i++) {
          const char *arg = argv[i];

          if (strcmp( arg, "-h" ) == 0 || strcmp (arg, "--help") == 0)
               return print_usage( argv[0] );
          else if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
               fprintf (stderr, "dfbtest_blit version %s\n", DIRECTFB_VERSION);
               return false;
          }
          else
               return print_usage( argv[0] );
     }

     /* Create super interface. */
     ret = DirectFBCreate( &dfb );
     if (ret) {
          D_DERROR( ret, "DFBTest/Blit: DirectFBCreate() failed!\n" );
          return ret;
     }

     Test_Clipboard_Set( dfb, "text/plain", "This is a test string for clipboard" );
     Test_Clipboard_Get( dfb );

     /* Shutdown DirectFB. */
     dfb->Release( dfb );

     return ret;
}
Beispiel #30
0
static DFBResult
region_buffer_lock( CoreLayerRegion       *region,
                    CoreSurface           *surface,
                    CoreSurfaceBufferRole  role )
{
     DFBResult              ret;
     CoreSurfaceBuffer     *buffer;
     CoreSurfaceAllocation *allocation;
     CoreLayerContext      *context;

     D_ASSERT( region != NULL );
     D_MAGIC_ASSERT( surface, CoreSurface );

     context = region->context;
     D_MAGIC_ASSERT( context, CoreLayerContext );

     /* First unlock any previously locked buffer. */
     if (region->surface_lock.buffer) {
          D_MAGIC_ASSERT( region->surface_lock.buffer, CoreSurfaceBuffer );

          dfb_surface_unlock_buffer( region->surface_lock.buffer->surface, &region->surface_lock );
     }

     if (dfb_surface_lock( surface ))
          return DFB_FUSION;

     buffer = dfb_surface_get_buffer( surface, role );
     D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer );

     /* Lock the surface buffer. */
     ret = dfb_surface_buffer_lock( buffer, CSAID_LAYER0 + context->layer_id, CSAF_READ, &region->surface_lock );
     if (ret) {
          D_DERROR( ret, "Core/LayerRegion: Could not lock region surface for SetRegion()!\n" );
          dfb_surface_unlock( surface );
          return ret;
     }

     allocation = region->surface_lock.allocation;
     D_ASSERT( allocation != NULL );

     /* If hardware has written or is writing... */
     if (allocation->accessed[CSAID_GPU] & CSAF_WRITE) {
          D_DEBUG_AT( Core_Layers, "  -> Waiting for pending writes...\n" );

          /* ...wait for the operation to finish. */
          dfb_gfxcard_sync(); /* TODO: wait for serial instead */

          allocation->accessed[CSAID_GPU] &= ~CSAF_WRITE;
     }

     /* surface is unlocked by caller */

     return DFB_OK;
}