Changeset 3680
- Timestamp:
- 30/11/08 20:36:42 (6 weeks ago)
- Location:
- trunk/display
- Files:
-
- 3 removed
- 9 modified
-
README (modified) (1 diff)
-
TODO (modified) (1 diff)
-
setup.py (modified) (8 diffs)
-
src/__init__.py (modified) (2 diffs)
-
src/common.h (modified) (1 diff)
-
src/dfb.c (deleted)
-
src/dfb.py (deleted)
-
src/fb.c (modified) (4 diffs)
-
src/fb.py (modified) (2 diffs)
-
src/x11.c (modified) (4 diffs)
-
src/x11.py (modified) (1 diff)
-
test/evas.py (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/display/README
r1151 r3680 2 2 framebuffer. Provides X11Display and X11Window classes for managing 3 3 X11 windows, with optional support for Imlib2 (render Imlib2 images to 4 X11 windows), Evas (both software and OpenGL canvases), and pygame 5 (render Imlib2 images to pygame surfaces). 4 X11 windows), and pygame (render Imlib2 images to pygame surfaces). 6 5 7 6 See http://www.freevo.org/kaa for more information -
trunk/display/TODO
r1152 r3680 3 3 inside. 4 4 5 Better opengl check. If EvasGL is used but the device is broken or the6 user has no permission, the code will use the GL software renderer7 which is _much_ slower than the evas x11 software render.8 9 5 Maybe remove that bad pygame hack 10 11 Add more (evas based) displays like streaming the display as mpeg12 stream. This could be done by using a buffer output and convert it to13 mpeg2. This display can also be used to make it work with a DXR3 or14 other mpeg decoder based cards.15 16 Fix DirectFB Evas display. Please check if there is still a bug in17 evas and help fixing it.18 6 19 7 Create a REAME -
trunk/display/setup.py
r3678 r3680 7 7 # ----------------------------------------------------------------------------- 8 8 # kaa.display - Display module 9 # Copyright (C) 2005, 2006 Dirk Meyer, Jason Tackaberry9 # Copyright (C) 2005, 2006, 2008 Dirk Meyer, Jason Tackaberry 10 10 # 11 11 # First Edition: Dirk Meyer <dmeyer@tzi.de> … … 55 55 check_library('X11', ['<X11/Xlib.h>'], '') 56 56 check_library('imlib2', '1.1.1') 57 evas = check_library('evas', '0.9.9.010')58 check_library('directfb', '0.9.20')59 57 60 58 print 'checking for pygame', '...', … … 69 67 if not os.path.isdir(inc): 70 68 raise ImportError 71 72 69 print 'ok' 73 70 check_library('sdl', '1.2.5') … … 82 79 if get_library('imlib2'): 83 80 config.define('USE_IMLIB2') 84 if get_library('evas'):85 config.define('USE_EVAS')86 81 87 82 if get_library('X11'): … … 99 94 x11.add_library('XComposite') 100 95 101 features = { 'with': [], 'without': [] }102 96 imlib2 = get_library('imlib2') 103 97 if 'imlib2-x11' in disable or 'imlib2' in disable: 104 features['without'].append('imlib2')98 print '+ X11 (no imlib2)' 105 99 elif imlib2 and imlib2.compile(['<Imlib2.h>'], 'imlib_context_set_display(NULL);'): 106 100 config.define('USE_IMLIB2_X11') 107 101 x11.add_library('imlib2') 108 features['with'].append('imlib2')102 print '+ X11 (imlib2)' 109 103 elif imlib2: 110 104 print … … 121 115 print 122 116 sys.exit(1) 123 if evas and evas.compile(['<Evas.h>', '<Evas_Engine_Software_X11.h>']):124 features['with'].append('evas')125 x11.add_library('evas')126 config.define('ENABLE_ENGINE_SOFTWARE_X11')127 else:128 features['without'].append('evas')129 130 if evas and evas.compile(['<Evas.h>', '<Evas_Engine_GL_X11.h>']):131 features['with'].append('evasGL')132 x11.add_library('evas')133 x11.libraries.append("GL")134 config.define('ENABLE_ENGINE_GL_X11')135 else:136 features['without'].append('evasGL')137 138 features = ', '.join(features['with'] + [ 'no %s' % x for x in features['without'] ])139 print '+ X11 (%s)' % features140 117 modules.append(x11) 141 118 else: … … 147 124 fb = Extension('kaa.display._FBmodule', [ 'src/fb.c', 'src/common.c']) 148 125 fb.add_library('imlib2') 149 if evas and evas.compile(['<Evas.h>', '<Evas_Engine_FB.h>']): 150 fb.add_library('evas') 151 config.define('ENABLE_ENGINE_FB') 152 print "+ Framebuffer (imlib2, evas)" 153 else: 154 print "+ Framebuffer (imlib2, no evas)" 126 print "+ Framebuffer (imlib2)" 155 127 modules.append(fb) 156 128 else: 157 129 print "- Framebuffer" 158 159 160 if get_library('directfb'):161 162 # the dfb so module163 dfb = Extension('kaa.display._DFBmodule', [ 'src/dfb.c', 'src/common.c'] )164 dfb.add_library('directfb')165 if evas and evas.compile(['<Evas.h>', '<Evas_Engine_DirectFB.h>'], extra_libraries = ['directfb']):166 print "+ DirectFB (evas)"167 dfb.add_library('evas')168 config.define('ENABLE_ENGINE_DIRECTFB')169 else:170 print "+ DirectFB"171 modules.append(dfb)172 else:173 print "- DirectFB"174 130 175 131 … … 188 144 189 145 requires_common = 'python-kaa-base >= 0.1.2, pygame >= 1.6.0, python-kaa-imlib2 >= 0.2.0,' \ 190 'imlib2 >= 1.2.1 , python-kaa-evas >= 0.1.0, evas >= 0.9.9.032'146 'imlib2 >= 1.2.1' 191 147 build_requires_common = 'python-kaa-base >= 0.1.2, pygame-devel >= 1.6.0, python-kaa-imlib2 >= 0.2.0,' \ 192 'imlib2-devel >= 1.2.1 , python-kaa-evas >= 0.1.0, evas-devel >= 0.9.9.032'148 'imlib2-devel >= 1.2.1' 193 149 194 150 setup(module = 'display', -
trunk/display/src/__init__.py
r2600 r3680 43 43 # import X11 support 44 44 try: 45 from x11 import X11Display, X11Window , EvasX11Window45 from x11 import X11Display, X11Window 46 46 displays.append('x11') 47 47 except ImportError, e: 48 X11Display = X11Window = EvasX11Window =ImportErrorWrapper('X11')48 X11Display = X11Window = ImportErrorWrapper('X11') 49 49 50 50 # import GTK support … … 57 57 # import Framebuffer support 58 58 try: 59 from fb import Framebuffer, EvasFramebuffer,PAL_768x576, PAL_800x600, \59 from fb import Framebuffer, PAL_768x576, PAL_800x600, \ 60 60 NTSC_640x480, NTSC_768x576, NTSC_800x600 61 61 displays.append('framebuffer') 62 62 except ImportError, e: 63 Framebuffer = EvasFramebuffer = ImportErrorWrapper('framebuffer') 64 65 # import DirectFB support 66 try: 67 from dfb import DirectFB, EvasDirectFB 68 displays.append('directfb') 69 except ImportError, e: 70 DirectFB = EvasDirectFB = ImportErrorWrapper('directfb') 63 Framebuffer = ImportErrorWrapper('framebuffer') 71 64 72 65 # import SDL support -
trunk/display/src/common.h
r2217 r3680 32 32 void **get_module_api(char *module); 33 33 34 #define CHECK_EVAS_PYOBJECT \35 if (!Evas_PyObject_Type) { \36 PyErr_Format(PyExc_SystemError, "kaa.evas is required but is not available."); \37 return NULL; \38 }39 40 41 34 #define CHECK_IMAGE_PYOBJECT \ 42 35 if (!Image_PyObject_Type) { \ -
trunk/display/src/fb.c
r2217 r3680 54 54 55 55 56 #ifdef ENABLE_ENGINE_FB57 #include <Evas.h>58 #include <Evas_Engine_FB.h>59 PyTypeObject *Evas_PyObject_Type = NULL;60 Evas *(*evas_object_from_pyobject)(PyObject *pyevas);61 #endif62 63 56 int fb_fd = 0; 64 57 int *fb_mem = 0; … … 246 239 } 247 240 248 #ifdef ENABLE_ENGINE_FB249 PyObject *250 new_evas_fb(PyObject *self, PyObject *args, PyObject *kwargs)251 {252 Evas_Engine_Info_FB *einfo;253 PyObject *evas_pyobject;254 Evas *evas;255 256 CHECK_EVAS_PYOBJECT257 258 if (!PyArg_ParseTuple(args, "O!", Evas_PyObject_Type, &evas_pyobject))259 return NULL;260 261 evas = evas_object_from_pyobject(evas_pyobject);262 263 evas_output_method_set(evas, evas_render_method_lookup("fb"));264 einfo = (Evas_Engine_Info_FB *)evas_engine_info_get(evas);265 if (!einfo) {266 PyErr_Format(PyExc_SystemError, "Evas is not built with FB support.");267 return NULL;268 }269 270 /* the following is specific to the engine */271 einfo->info.virtual_terminal = 0;272 einfo->info.device_number = 0;273 einfo->info.refresh = 0;274 einfo->info.rotation = 0;275 276 evas_output_size_set(evas, fb_var.xres, fb_var.yres);277 evas_output_viewport_set(evas, 0, 0, fb_var.xres, fb_var.yres);278 279 evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);280 Py_INCREF(Py_None);281 return Py_None;282 }283 #endif // ENABLE_ENGINE_FB284 241 285 242 PyMethodDef fb_methods[] = { … … 290 247 { "depth", (PyCFunction) fb_depth, METH_VARARGS }, 291 248 { "info", (PyCFunction) fb_info, METH_VARARGS }, 292 #ifdef ENABLE_ENGINE_FB293 { "new_evas_fb", (PyCFunction) new_evas_fb, METH_VARARGS | METH_KEYWORDS },294 #endif295 249 { NULL } 296 250 }; … … 308 262 } else 309 263 PyErr_Clear(); 310 311 #ifdef ENABLE_ENGINE_FB 312 { 313 // Import kaa-evas's C api 314 void **evas_api_ptrs = get_module_api("kaa.evas._evas"); 315 if (evas_api_ptrs != NULL) { 316 evas_object_from_pyobject = evas_api_ptrs[0]; 317 Evas_PyObject_Type = evas_api_ptrs[1]; 318 } else 319 PyErr_Clear(); 320 } 321 322 #endif 323 324 } 264 } -
trunk/display/src/fb.py
r1958 r3680 31 31 32 32 __all__ = [ 'PAL_768x576', 'PAL_800x600', 'NTSC_640x480', 'NTSC_768x576', 33 'NTSC_800x600', 'Framebuffer' , 'EvasFramebuffer']33 'NTSC_800x600', 'Framebuffer' ] 34 34 35 35 import _FBmodule as fb … … 138 138 """ 139 139 fb.update(self.image._image) 140 141 142 class EvasFramebuffer(_Framebuffer):143 """144 Frambuffer using evas for drawing145 The 'mode' argument can either be a size (width, height) matching one of146 the specified framebuffer resolutions, a list for fbset or None. If set to147 None, the current framebuffer size will be used.148 """149 def __init__(self, mode=None):150 _Framebuffer.__init__(self, mode)151 import kaa.evas152 self._evas = kaa.evas.Evas()153 fb.new_evas_fb(self._evas._evas)154 155 156 def get_evas(self):157 """158 Return evas object.159 """160 return self._evas -
trunk/display/src/x11.c
r3408 r3680 38 38 39 39 40 #if defined(ENABLE_ENGINE_SOFTWARE_X11) || defined(ENABLE_ENGINE_GL_X11)41 #include <Evas.h>42 Evas *(*evas_object_from_pyobject)(PyObject *pyevas);43 PyTypeObject *Evas_PyObject_Type = NULL;44 #endif45 46 #ifdef ENABLE_ENGINE_SOFTWARE_X1147 #include <Evas_Engine_Software_X11.h>48 #endif49 50 #ifdef ENABLE_ENGINE_GL_X1151 #include <Evas_Engine_GL_X11.h>52 #include <GL/gl.h>53 #include <GL/glx.h>54 #endif55 56 40 #if defined(USE_IMLIB2_X11) && !defined(X_DISPLAY_MISSING) 57 41 #include <X11/Xlib.h> … … 60 44 PyTypeObject *Image_PyObject_Type = NULL; 61 45 #endif 62 63 64 65 #if defined(ENABLE_ENGINE_SOFTWARE_X11) || defined(ENABLE_ENGINE_GL_X11)66 X11Window_PyObject *67 engine_common_x11_setup(Evas *evas, PyObject *kwargs,68 X11Display_PyObject *disp,69 Visual *(*best_visual_get)(Display *, int),70 Colormap (*best_colormap_get)(Display *, int),71 int (*best_depth_get)(Display *, int),72 Display **ei_display, Drawable *ei_drawable, Visual **ei_visual,73 Colormap *ei_colormap, int *ei_depth)74 {75 X11Window_PyObject *win_object, *py_parent;76 Window win, parent;77 XSetWindowAttributes attr;78 int screen, w, h;79 char *title = NULL;80 81 if (!PyArg_ParseTuple(PyDict_GetItemString(kwargs, "size"), "ii", &w, &h))82 return NULL;83 py_parent = (X11Window_PyObject *)PyDict_GetItemString(kwargs, "parent");84 if (PyMapping_HasKeyString(kwargs, "title"))85 title = PyString_AsString(PyDict_GetItemString(kwargs, "title"));86 87 if (py_parent) {88 parent = py_parent->window;89 }90 else91 parent = DefaultRootWindow(disp->display);92 93 attr.backing_store = NotUseful;94 attr.border_pixel = 0;95 attr.background_pixmap = None;96 attr.event_mask = ExposureMask | ButtonPressMask | ButtonReleaseMask |97 StructureNotifyMask | PointerMotionMask | KeyPressMask | FocusChangeMask;98 attr.bit_gravity = ForgetGravity;99 100 *ei_display = disp->display;101 XLockDisplay(*ei_display);102 screen = DefaultScreen(*ei_display);103 104 *ei_visual = best_visual_get(*ei_display, screen);105 *ei_colormap = attr.colormap = best_colormap_get(*ei_display, screen);106 *ei_depth = best_depth_get(*ei_display, screen);107 108 win = XCreateWindow(*ei_display, parent, 0, 0,109 w, h, 0, *ei_depth, InputOutput, *ei_visual,110 CWBackingStore | CWColormap | CWBackPixmap |111 CWBitGravity | CWEventMask, &attr);112 113 *ei_drawable = win;114 if (title)115 XStoreName(*ei_display, win, title);116 XUnlockDisplay(*ei_display);117 118 win_object = X11Window_PyObject__wrap((PyObject *)disp, win);119 return win_object;120 }121 122 #define ENGINE_COMMON_X11_SETUP(evas, kwargs, display, func, info) \123 engine_common_x11_setup(evas, kwargs, display, \124 func.best_visual_get, func.best_colormap_get, func.best_depth_get, \125 &info.display, &info.drawable, &info.visual, &info.colormap, \126 &info.depth);127 128 129 #ifdef ENABLE_ENGINE_SOFTWARE_X11130 X11Window_PyObject *131 new_evas_software_x11(PyObject *self, PyObject *args, PyObject *kwargs)132 {133 Evas_Engine_Info_Software_X11 *einfo;134 X11Window_PyObject *x11;135 X11Display_PyObject *display;136 PyObject *evas_pyobject;137 Evas *evas;138 139 CHECK_EVAS_PYOBJECT140 141 if (!PyArg_ParseTuple(args, "O!O!", Evas_PyObject_Type, &evas_pyobject,142 &X11Display_PyObject_Type, &display))143 return NULL;144 145 evas = evas_object_from_pyobject(evas_pyobject);146 evas_output_method_set(evas, evas_render_method_lookup("software_x11"));147 einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(evas);148 if (!einfo) {149 PyErr_Format(PyExc_SystemError, "Evas is not built with Software X11 support.");150 return NULL;151 }152 153 x11 = ENGINE_COMMON_X11_SETUP(evas, kwargs, display, einfo->func,154 einfo->info);155 156 einfo->info.rotation = 0;157 einfo->info.debug = 0;158 159 evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);160 return x11;161 }162 #endif163 164 #ifdef ENABLE_ENGINE_GL_X11165 X11Window_PyObject *166 new_evas_gl_x11(PyObject *self, PyObject *args, PyObject *kwargs)167 {168 Evas_Engine_Info_GL_X11 *einfo;169 X11Window_PyObject *x11;170 X11Display_PyObject *display;171 PyObject *evas_pyobject;172 Evas *evas;173 174 CHECK_EVAS_PYOBJECT175 176 if (!PyArg_ParseTuple(args, "O!O!", Evas_PyObject_Type, &evas_pyobject,177 &X11Display_PyObject_Type, &display))178 return NULL;179 180 evas = evas_object_from_pyobject(evas_pyobject);181 182 evas_output_method_set(evas, evas_render_method_lookup("gl_x11"));183 einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(evas);184 if (!einfo) {185 PyErr_Format(PyExc_SystemError, "Evas is not built with GLX support.");186 return NULL;187 }188 189 x11 = ENGINE_COMMON_X11_SETUP(evas, kwargs, display, einfo->func, einfo->info);190 evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);191 return x11;192 }193 #endif194 195 #endif /* defined(ENABLE_ENGINE_GL_X11) ||196 defined (ENABLE_ENGINE_SOFTWARE_X11) */197 46 198 47 … … 293 142 { "render_imlib2_image", (PyCFunction) render_imlib2_image, METH_VARARGS }, 294 143 { "set_shape_mask_from_imlib2_image", (PyCFunction) set_shape_mask_from_imlib2_image, METH_VARARGS }, 295 #ifdef ENABLE_ENGINE_SOFTWARE_X11296 { "new_evas_software_x11", (PyCFunction) new_evas_software_x11, METH_VARARGS | METH_KEYWORDS },297 #endif298 #ifdef ENABLE_ENGINE_GL_X11299 { "new_evas_gl_x11", (PyCFunction) new_evas_gl_x11, METH_VARARGS | METH_KEYWORDS },300 #endif301 144 { NULL } 302 145 }; … … 339 182 #endif 340 183 341 #if defined(ENABLE_ENGINE_SOFTWARE_X11) || defined(ENABLE_ENGINE_GL_X11)342 {343 // Import kaa-evas's C api344 void **evas_api_ptrs = get_module_api("kaa.evas._evas");345 if (evas_api_ptrs != NULL) {346 evas_object_from_pyobject = evas_api_ptrs[0];347 Evas_PyObject_Type = evas_api_ptrs[1];348 } else349 PyErr_Clear();350 }351 #endif352 353 184 if (!XInitThreads()) 354 185 PyErr_Format(PyExc_SystemError, "Unable to initialize X11 threads."); -
trunk/display/src/x11.py
r3379 r3680 523 523 """ 524 524 self._window.set_decorated(setting) 525 526 527 class EvasX11Window(X11Window):528 def __init__(self, gl = False, display = None, size = (640, 480),529 title = "Evas", **kwargs):530 import kaa.evas531 532 if not gl:533 f = _X11.new_evas_software_x11534 else:535 f = _X11.new_evas_gl_x11536 537 if "parent" in kwargs:538 assert(isinstance(kwargs["parent"], X11Window))539 kwargs["parent"] = kwargs["parent"]._window540 541 assert(type(size) in (list, tuple))542 display = _get_display(display)543 self._evas = kaa.evas.Evas()544 window = f(self._evas._evas, display._display, size = size,545 title = title, **kwargs)546 self._evas.output_size_set(size)547 self._evas.viewport_set((0, 0), size)548 549 # Ensures the display remains alive until after Evas gets deallocated550 # during garbage collection.551 self._evas._dependencies.append(display._display)552 self._evas._dependencies.append(window)553 if "parent" in kwargs:554 self._evas._dependencies.append(kwargs["parent"])555 super(EvasX11Window, self).__init__(display, window)556 557 558 def handle_events(self, events):559 needs_render = False560 for event, data in events:561 if event == X11Display.XEVENT_EXPOSE:562 self._evas.damage_rectangle_add((data["pos"], data["size"]))563 needs_render = True564 #elif event == X11Display.XEVENT_CONFIGURE_NOTIFY:565 # if data["size"] != self._evas.output_size_get():566 # # This doesn't act right for gl.567 # self._evas.output_size_set(data["size"])568 # #self._evas.viewport_set((0, 0), data["size"])569 # needs_render = True570 571 super(EvasX11Window, self).handle_events(events)572 573 if needs_render:574 self._evas.render()575 self._display.handle_events()576 577 578 def get_evas(self):579 return self._evas
