Hello all,

I'm writing an application that starts a thread that uses DirectFB to show
video, and my code shows some graphic information over this video, my
application cannot access the DirectFB context of this thread and I'm using
Fusion to create other DirectFB context to draw my DFB graphics, my code are
initialized after the video thread and my graphic are shown OK over the
video but in some situations the video thread needs reinitialize/reconfigure
DFB context and my own DFB context don't know that this ocurred and cannot
be reinitialized, there's some way to force my DFB context be always shown
over the video even the first Directfb context was reinitializated ?

My DirectFB initialization code snippet are bellow :

int
BackendDFB::initialize()
{
    int result = 0;
    bckType = BACKEND_TYPE_DIRECTFB;
    dfbPicDescriptor = 0;
    dfbFontDescriptor = 0;
    fprintf(stderr, "Initializing DirectFB...\n");
    if( DirectFBInit(NULL, NULL) != DFB_OK ) {
        fprintf(stderr, "Error initializing DirectFB.\n");
        result = -1;
    } else {
        fprintf(stderr, "DirectFB initializing OK, creating DFB
superinterface...\n");
        if( DirectFBCreate( &dfb ) != DFB_OK ) {
          fprintf(stderr, "Error creating DFB super interface.\n");
          result = -2;
        } else {
            dfb->EnumDisplayLayers(dfb, dfbDisplayLayerCallback, this);

            pictMap = new PictureMap();
            createDFBmainSurface(false); /*false - create surface without
create window and layer*/
        }
    }

    return result;
}

int
BackendDFB::createDFBmainSurface(bool fromMainWindow)
{
    int result = 0;

    if ( ! dfb )
        return -1;

    if (wsurface) {
        wsurface->Release(wsurface);
        wsurface = NULL;
    }

    if (fromMainWindow) {
        if (window)
            window->GetSurface(window, &wsurface);
        else
            result = -1;
    } else {
              memset(&dsc, 0, sizeof(DFBSurfaceDescription));
              dsc.flags = DFBSurfaceDescriptionFlags(DSDESC_CAPS |
DSDESC_PIXELFORMAT);
              dsc.caps  = DFBSurfaceCapabilities(DSCAPS_PRIMARY |
                                                 DSCAPS_VIDEOONLY |
                                                 DSCAPS_PREMULTIPLIED |
                                                 DSCAPS_FLIPPING);
              dsc.pixelformat = DSPF_ARGB;

              dfb->CreateSurface( dfb, &dsc, &wsurface );

              if (wsurface) {
                  int w, h;
                  wsurface->GetSize (wsurface,    &w, &h);
                  setWindowDimensions(0, 0, w, h);
              }
      }

    if (wsurface) {
        wsurface->SetBlittingFlags( wsurface,
DFBSurfaceBlittingFlags(DSBLIT_BLEND_ALPHACHANNEL));
        wsurface->SetPorterDuff( wsurface, DSPD_SRC_OVER );
        wsurface->SetDstBlendFunction(wsurface, DSBF_INVSRCALPHA);
        wsurface->SetDrawingFlags(wsurface, DSDRAW_BLEND);
        wsurface->Clear(wsurface, 0x00, 0x00, 0x00, 0x00);
   } else
       result = -2;

    return result;
}

And I will update the screen I use this function :
void
BackendDFB::update_screen()
{
    if (wsurface)
        wsurface->Flip(wsurface, NULL, DSFLIP_ONSYNC);
}

Thanks for all help
Flávio Alberto Lopes Soares
_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users

Reply via email to