コード例 #1
0
ファイル: directfb.c プロジェクト: jameshilliard/20-4-4
static DFBResult
CreateRemote( const char *host, int session, IDirectFB **ret_interface )
{
     DFBResult             ret;
     DirectInterfaceFuncs *funcs;
     void                 *interface;

     D_ASSERT( host != NULL );
     D_ASSERT( ret_interface != NULL );

     ret = DirectGetInterface( &funcs, "IDirectFB", "Requestor", NULL, NULL );
     if (ret)
          return ret;

     ret = funcs->Allocate( &interface );
     if (ret)
          return ret;

     ret = funcs->Construct( interface, host, session );
     if (ret)
          return ret;

     *ret_interface = idirectfb_singleton = interface;

     return DFB_OK;
}
コード例 #2
0
static DirectResult
ConstructDispatcher( VoodooServer     *server,
                     VoodooManager    *manager,
                     const char       *name,
                     void             *ctx,
                     VoodooInstanceID *ret_instance )
{
    DirectResult          ret;
    DirectInterfaceFuncs *funcs;
    void                 *interface;
    VoodooInstanceID      instance;

    D_ASSERT( server != NULL );
    D_ASSERT( manager != NULL );
    D_ASSERT( name != NULL );
    D_ASSERT( ret_instance != NULL );

    ret = DirectGetInterface( &funcs, name, "Dispatcher", NULL, NULL );
    if (ret)
        return ret;

    ret = funcs->Allocate( &interface );
    if (ret)
        return ret;

    ret = funcs->Construct( interface, manager, &instance );
    if (ret)
        return ret;

    *ret_instance = instance;

    return DFB_OK;
}
コード例 #3
0
DFBResult
IDirectFBImageProvider_CreateFromBuffer( IDirectFBDataBuffer     *buffer,
        IDirectFBImageProvider **interface )
{
    DFBResult                            ret;
    DirectInterfaceFuncs                *funcs = NULL;
    IDirectFBDataBuffer_data            *buffer_data;
    IDirectFBImageProvider              *imageprovider;
    IDirectFBImageProvider_ProbeContext  ctx;

    /* Get the private information of the data buffer. */
    buffer_data = (IDirectFBDataBuffer_data*) buffer->priv;
    if (!buffer_data)
        return DFB_DEAD;

    /* Provide a fallback for image providers without data buffer support. */
    ctx.filename = buffer_data->filename;

    /* Wait until 32 bytes are available. */
    ret = buffer->WaitForData( buffer, 32 );
    if (ret)
        return ret;

    /* Read the first 32 bytes. */
    ret = buffer->PeekData( buffer, 32, 0, ctx.header, NULL );
    if (ret)
        return ret;

    /* Find a suitable implementation. */
    ret = DirectGetInterface( &funcs, "IDirectFBImageProvider", NULL, DirectProbeInterface, &ctx );
    if (ret)
        return ret;

    DIRECT_ALLOCATE_INTERFACE( imageprovider, IDirectFBImageProvider );

    /* Construct the interface. */
    ret = funcs->Construct( imageprovider, buffer );
    if (ret)
        return ret;

    *interface = imageprovider;

    return DFB_OK;
}
コード例 #4
0
ファイル: idirectfbfont.c プロジェクト: canalplus/r7oss
DFBResult
IDirectFBFont_CreateFromBuffer( IDirectFBDataBuffer       *buffer,
                                CoreDFB                   *core,
                                const DFBFontDescription  *desc,
                                IDirectFBFont            **interface )
{
     DFBResult                   ret;
     DirectInterfaceFuncs       *funcs = NULL;
     IDirectFBDataBuffer_data   *buffer_data;
     IDirectFBFont              *ifont;
     IDirectFBFont_ProbeContext  ctx = {0};

     /* Get the private information of the data buffer. */
     buffer_data = (IDirectFBDataBuffer_data*) buffer->priv;
     if (!buffer_data)
          return DFB_DEAD;

     /* Provide a fallback for image providers without data buffer support. */
     ctx.filename = buffer_data->filename;

     /* try to map the "file" content first */
     if (try_map_file( buffer_data, &ctx ) != DFB_OK) {
          /* try to load the "file" content from the buffer */

          /* we need to be able to seek (this implies non-streamed,
             so we also know the size) so we can reuse the buffer */
          if (buffer->SeekTo( buffer, 0 ) == DFB_OK) {
               unsigned int size, got;

               /* get the "file" length */
               buffer->GetLength( buffer, &size );

               ctx.content = D_MALLOC( size );
               if (!ctx.content)
                    return DR_NOLOCALMEMORY;

               ctx.content_size = 0;

               while (ctx.content_size < size) {
                    unsigned int get = size - ctx.content_size;

                    if (get > 8192)
                         get = 8192;

                    ret = buffer->WaitForData( buffer, get );
                    if (ret) {
                         D_DERROR( ret, "%s: WaitForData failed!\n", __FUNCTION__ );
                         break;
                    }

                    ret = buffer->GetData( buffer, get, ctx.content + ctx.content_size, &got );
                    if (ret) {
                         D_DERROR( ret, "%s: GetData failed!\n", __FUNCTION__ );
                         break;
                    }

                    if (!got)
                         break;

                    ctx.content_size += got;
               }

               if (ctx.content_size != size) {
                    D_ERROR( "%s: Got size %u differs from supposed %u!\n", __FUNCTION__, ctx.content_size, size );
                    D_FREE( ctx.content );
                    return DFB_FAILURE;
               }
          }
     }

     /* Find a suitable implementation. */
     ret = DirectGetInterface( &funcs, "IDirectFBFont", NULL, DirectProbeInterface, &ctx );
     if (ret) {
          unmap_or_free( &ctx );
          return ret;
     }

     DIRECT_ALLOCATE_INTERFACE( ifont, IDirectFBFont );

     /* Construct the interface. */
     ret = funcs->Construct( ifont, core, &ctx, desc );
     if (ret) {
          unmap_or_free( &ctx );
          return ret;
     }

     /* store pointer for deletion at destroy */
     {
          IDirectFBFont_data *data = (IDirectFBFont_data*)(ifont->priv);
          data->content = ctx.content;
          data->content_size = ctx.content_size;
          data->content_mapped = ctx.content_mapped;
     }

     *interface = ifont;

     return DFB_OK;
}