> // create surface
> dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
> dsc.width = width;
> dsc.height = height;
> dsc.pixelformat = pixelformat;
> dfb->CreateSurface( dfb, &dsc, &world );
> // size of pixel in byte
> row_bytes = (pixelformat >> 20) & 0x07;
>
> // hexdump
> world->Lock( world, DSLF_READ , &data, &pitch );
> __u8* ptr = data;
> size_t i, j, k;
> for( i = 0; i < height; i++ ){
> printf( "%p\t", ptr );
> for( j = 0; j < width; j++ ){
> for( k = 0; k < row_bytes; k++ )
> printf( "%02x", *ptr++ );
> putchar( ' ' );
> }
> putchar( '\n' );
> ptr += pitch - width * row_bytes;
> }
> world->Unlock( world );
>
I had to find out what most of you already know:
Locking and unlocking a surface in the way described above is much
slower than using preallocated memory. But why?
Does some (more detailed) information about the principles of DirectFB
exist besides DirectFB_overview_V0.2.pdf ?
-----
const int row_bytes = (pixelformat >> 20) & 0x07;
const int pitch = width * row_bytes;
void *const data = calloc( width * height, row_bytes );
dsc.flags = DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT |
DSDESC_PIXELFORMAT | DSDESC_PREALLOCATED;
dsc.caps = DSCCAPS_SYSTEMONLY;
dsc.width = width;
dsc.height = height;
dsc.pixelformat = pixelformat;
dsc.preallocated[0].data = data;
dsc.preallocated[0].pitch = pitch;
dsc.preallocated[1].data = NULL;
dsc.preallocated[1].pitch = 0;
dfb->CreateSurface( dfb, &dsc, &world );
// hexdump
__u8 *ptr = data;
size_t i, j, k;
for( i = 0; i < height; i++ ){
printf( "%p\t", ptr );
for( j = 0; j < width; j++ ){
for( k = 0; k < row_bytes; k++ )
printf( "%02x", *ptr++ );
putchar( ' ' );
}
putchar( '\n' );
ptr += pitch - width * row_bytes;
}
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev