Update DirectFB Backend

Jefferson Ferreira <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <CAF7VXs8bRWH8vZVGrKeDUUJguaq7i=ddxMX3DxieFn=z27550g@mail.gmail.com>
Please,

Someone knows how I can put this examples to work with the current cairo
with directfb ?

- change the backend in Makefile to "directfb"
https://github.com/msteinert/cairo-demo

- the other example is attached to this email

thanks in advance.

-- 
Jefferson Ferreira

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
teste.cpp (text/x-c++src, 2.4 KB)
// 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  = 720;
static int screen_height = 480;

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  = screen_width;
	desc.height = screen_height;

	layer->CreateWindow (layer, &desc, &window);
	window->SetOpacity (window, 0x80);
	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);
	
	surface->Flip(surface, NULL, (DFBSurfaceFlipFlags)0);

	cairo_destroy(cairo_context);
	cairo_surface_destroy(cairo_surface);

	sleep (5);

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

	return 23;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.