Mercurial > MadButterfly
comparison src/graph_engine_openvg.c @ 1110:851a062368bd
Change signature of mbe_win_surface_create() by using format argument
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 08 Dec 2010 18:31:39 +0800 |
parents | 7f4dd130a78e |
children | 7451af5d63ec |
comparison
equal
deleted
inserted
replaced
1109:77596f3d8d0c | 1110:851a062368bd |
---|---|
538 | 538 |
539 return 0; | 539 return 0; |
540 } | 540 } |
541 | 541 |
542 #ifdef EGL_GLX | 542 #ifdef EGL_GLX |
543 #include <X11/Xlib.h> | |
544 #include <X11/Xutil.h> | |
545 | |
546 static int | |
547 _get_img_fmt_from_xvisual(Display *display, Visual *visual) { | |
548 VisualID visual_id; | |
549 XVisualInfo temp; | |
550 XVisualInfo *infos; | |
551 int n; | |
552 int fmt = -1; | |
553 | |
554 visual_id = XVisualIDFromVisual(visual); | |
555 temp.visualid = visual_id; | |
556 infos = XGetVisualInfo(display, VisualIDMask, &temp, &n); | |
557 if(n != 1) | |
558 return -1; | |
559 | |
560 switch(infos->depth) { | |
561 case 32: | |
562 fmt = MB_IFMT_ARGB32; | |
563 break; | |
564 | |
565 case 24: | |
566 fmt = MB_IFMT_RGB24; | |
567 break; | |
568 | |
569 case 16: | |
570 fmt = MB_IFMT_RGB16_565; | |
571 break; | |
572 | |
573 case 8: | |
574 fmt = MB_IFMT_A8; | |
575 break; | |
576 | |
577 case 1: | |
578 fmt = MB_IFMT_A1; | |
579 break; | |
580 } | |
581 | |
582 return fmt; | |
583 } | |
584 | |
585 /*! \brief Create an EGL window surface for X11. | 543 /*! \brief Create an EGL window surface for X11. |
586 * | 544 * |
587 * This function is compiled only for GLX enabled. | 545 * This function is compiled only for GLX enabled. |
588 */ | 546 */ |
589 mbe_surface_t * | 547 mbe_surface_t * |
590 mbe_win_surface_create(Display *display, Drawable drawable, | 548 mbe_win_surface_create(void *display, void *drawable, |
591 Visual *visual, int width, int height) { | 549 int fmt, int width, int height) { |
592 EGLDisplay egl_disp; | 550 EGLDisplay egl_disp; |
593 EGLSurface egl_surface; | 551 EGLSurface egl_surface; |
594 mbe_surface_t *surface; | 552 mbe_surface_t *surface; |
595 EGLConfig config; | 553 EGLConfig config; |
596 EGLint attrib_list[2] = {EGL_NONE}; | 554 EGLint attrib_list[2] = {EGL_NONE}; |
597 int fmt; | |
598 int r; | 555 int r; |
599 | 556 |
600 fmt = _get_img_fmt_from_xvisual(display, visual); | |
601 if(fmt == -1) | |
602 return NULL; | |
603 | |
604 r = _openvg_find_config(fmt, width, height, &config); | 557 r = _openvg_find_config(fmt, width, height, &config); |
605 if(r != 0) | 558 if(r != 0) |
606 return NULL; | 559 return NULL; |
607 | 560 |
608 egl_disp = eglGetDisplay(display); | 561 egl_disp = eglGetDisplay((Display *)display); |
609 if(egl_disp == EGL_NO_DISPLAY || egl_disp != _VG_DISPLAY()) | 562 if(egl_disp == EGL_NO_DISPLAY || egl_disp != _VG_DISPLAY()) |
610 return NULL; | 563 return NULL; |
611 | 564 |
612 egl_surface = eglCreateWindowSurface(egl_disp, config, drawable, | 565 egl_surface = eglCreateWindowSurface(egl_disp, config, |
566 (Drawable)drawable, | |
613 attrib_list); | 567 attrib_list); |
614 | 568 |
615 surface = O_ALLOC(mbe_surface_t); | 569 surface = O_ALLOC(mbe_surface_t); |
616 if(surface == NULL) { | 570 if(surface == NULL) { |
617 eglDestroySurface(egl_disp, egl_surface); | 571 eglDestroySurface(egl_disp, egl_surface); |