[cairo] Directfb Backend

Jefferson Ferreira jeffersonfr at gmail.com
Thu Mar 22 07:22:40 PDT 2012


Hello,

Anybody can help me with directfb backend ? In cairo-1.11.2 directfb
backend works, but in the git version don't. I would like to know what i
have to do. See the code below ... in this example a IDirectFBWindow was
created and painted with directfb and cairo, but this last one doesn't work..


// g++ simple.cpp `pkg-config --cflags --libs directfb cairo`
// ----------------------------------------- simple.cpp
---------------------------------------------
#include <stdio.h>
#include <unistd.h>

#include <directfb.h>
#include <cairo-directfb.h>

static int screen_width  = 0;
static int screen_height = 0;

int main (int argc, char **argv)
{
    // init dfb
    IDirectFB *dfb = NULL;
    IDirectFBDisplayLayer  *layer = NULL;
    DFBSurfaceDescription dsc;
    DFBDisplayLayerConfig  layer_dsc;

    DirectFBInit (&argc, &argv);
  DirectFBCreate (&dfb);

    dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer);
    layer->SetCooperativeLevel (layer, DLSCL_ADMINISTRATIVE);

    layer_dsc.flags = DLCONF_BUFFERMODE;
    layer_dsc.buffermode = DLBM_BACKSYSTEM;
    layer->SetConfiguration (layer, &layer_dsc);

    // create window
    IDirectFBWindow *window = NULL;
    IDirectFBSurface *surface = NULL;
    DFBWindowDescription desc;

    desc.flags  = (DFBWindowDescriptionFlags)(DWDESC_POSX | DWDESC_POSY |
DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS | DWDESC_PIXELFORMAT);
    desc.caps = (DFBWindowCapabilities)(DSCAPS_NONE | DWCAPS_ALPHACHANNEL);
    desc.pixelformat = DSPF_ARGB;
    desc.posx = 0;
    desc.posy = 0;
    desc.width  = 720;
    desc.height = 480;

    layer->CreateWindow (layer, &desc, &window);
    window->SetOpacity (window, 0xFF);
    window->GetSurface (window, &surface);

    // drawing
  surface->SetColor (surface, 0x40, 0x60, 0x80, 0xff);
  surface->FillRectangle (surface, 0, 0, screen_width, screen_height);
  surface->SetColor (surface, 0x80, 0x80, 0xff, 0xff);
  surface->DrawLine (surface, 0, screen_height / 2, screen_width - 1,
screen_height / 2);
  surface->SetColor (surface, 0x00, 0x00, 0xff, 0xa0);
  surface->FillRectangle (surface, 100, 100, 300, 300);
  surface->SetColor (surface, 0x80, 0x00, 0x00, 0xa0);
  surface->FillRectangle (surface, 200, 200, 300, 300);

    surface->Flip (surface, NULL, (DFBSurfaceFlipFlags)0);

    cairo_surface_t *cairo_surface;
    cairo_t *cairo_context;

    cairo_surface = cairo_directfb_surface_create(dfb, surface);
    cairo_context = cairo_create(cairo_surface);

    cairo_set_source_rgba(cairo_context, 0x80/255.0, 0x80/255.0,
0x80/255.0, 0xff/255.0);
    cairo_rectangle(cairo_context, 150, 150, 300, 300);
  cairo_fill(cairo_context);

    cairo_destroy(cairo_context);
    cairo_surface_destroy(cairo_surface);

  sleep (5);

    // release
  surface->Release( surface );
  dfb->Release( dfb );

  return 23;
}
// ---------------------------------------- end
----------------------------------------------------------

-- 
Jefferson Ferreira
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120322/65a89769/attachment.html>


More information about the cairo mailing list