head 1.2; access; symbols; locks; strict; comment @ * @; 1.2 date 2005.07.29.05.48.07; author behdad; state Exp; branches; next 1.1; commitid 7e5c42e9c3074567; 1.1 date 2004.09.30.20.02.16; author sxpert; state Exp; branches; next ; desc @@ 1.2 log @2005-07-29 Behdad Esfahbod * Updated to cairo 0.6.0 API. @ text @/************************************************************************* * Cairo Frame Buffer demo * (c) 2004 Amaury Jacquot * This program is licensed under the GNU GPL version 2 or later license ************************************************************************/ #include #include #include #include #include #include int main(){ int fbfd = 0; struct fb_var_screeninfo vinfo; struct fb_fix_screeninfo finfo; long int screensize = 0; char* fbp = 0; cairo_t* cr; cairo_surface_t *surface; // open the frame buffer file for reading & writing fbfd = open ( "/dev/fb0", O_RDWR ); if (!fbfd) { printf ("Error: can't open framebuffer device.\n"); exit (1); } printf ("The framebuffer device was opened successfully\n"); if (ioctl (fbfd, FBIOGET_FSCREENINFO, &finfo)) { printf ("Error reading fixed information\n"); close (fbfd); exit (2); } if (ioctl (fbfd, FBIOGET_VSCREENINFO, &vinfo)) { printf ("Error reading variable information\n"); close (fbfd); exit (3); } // print info about the buffer printf ("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel); // calculates size screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; // map the device to memory fbp = (char*) mmap (0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); if ((int)fbp == -1) { printf ("Error: failed to map framebuffer device to memory\n"); close (fbfd); exit (4); } printf ("The framebuffer device was successfully mapped to memory\n"); surface = cairo_image_surface_create_for_data (fbp, CAIRO_FORMAT_ARGB32, vinfo.xres, vinfo.yres, finfo.line_length); cr = cairo_create (surface); cairo_move_to (cr, 100, 100); cairo_line_to (cr, 300, 300); cairo_stroke (cr); munmap (fbp, screensize); close (fbfd); return 0; } @ 1.1 log @ first version of the frame buffer demo @ text @d21 1 d60 1 a60 2 cr = cairo_create (); cairo_set_target_image (cr, fbp, CAIRO_FORMAT_ARGB32, d62 1 @