40 ****************************************************************************/ |
40 ****************************************************************************/ |
41 |
41 |
42 #include <QtGui/qpaintdevice.h> |
42 #include <QtGui/qpaintdevice.h> |
43 #include <QtGui/qpixmap.h> |
43 #include <QtGui/qpixmap.h> |
44 #include <QtGui/qwidget.h> |
44 #include <QtGui/qwidget.h> |
|
45 |
45 #include "qegl_p.h" |
46 #include "qegl_p.h" |
|
47 #include "qeglcontext_p.h" |
46 |
48 |
47 #include <coecntrl.h> |
49 #include <coecntrl.h> |
48 |
50 |
49 QT_BEGIN_NAMESPACE |
51 QT_BEGIN_NAMESPACE |
50 |
52 |
51 EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties *properties) |
53 EGLNativeDisplayType QEgl::nativeDisplay() |
52 { |
54 { |
53 // Create the native drawable for the paint device. |
55 return EGL_DEFAULT_DISPLAY; |
54 int devType = device->devType(); |
56 } |
55 EGLNativePixmapType pixmapDrawable = 0; |
|
56 EGLNativeWindowType windowDrawable = 0; |
|
57 bool ok; |
|
58 if (devType == QInternal::Pixmap) { |
|
59 pixmapDrawable = 0; |
|
60 ok = (pixmapDrawable != 0); |
|
61 } else if (devType == QInternal::Widget) { |
|
62 QWidget *w = static_cast<QWidget *>(device); |
|
63 windowDrawable = (EGLNativeWindowType)(w->winId()->DrawableWindow()); |
|
64 ok = (windowDrawable != 0); |
|
65 } else { |
|
66 ok = false; |
|
67 } |
|
68 if (!ok) { |
|
69 qWarning("QEglContext::createSurface(): Cannot create the native EGL drawable"); |
|
70 return EGL_NO_SURFACE; |
|
71 } |
|
72 |
57 |
73 // Create the EGL surface to draw into, based on the native drawable. |
58 EGLNativeWindowType QEgl::nativeWindow(QWidget* widget) |
74 const int *props; |
59 { |
75 if (properties) |
60 return (EGLNativeWindowType)(widget->winId()->DrawableWindow()); |
76 props = properties->properties(); |
61 } |
77 else |
62 |
78 props = 0; |
63 EGLNativePixmapType QEgl::nativePixmap(QPixmap*) |
79 EGLSurface surf; |
64 { |
80 if (devType == QInternal::Widget) |
65 qWarning("QEgl: EGL pixmap surfaces not implemented yet on Symbian"); |
81 surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, props); |
66 return (EGLNativePixmapType)0; |
82 else |
|
83 surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, props); |
|
84 if (surf == EGL_NO_SURFACE) |
|
85 qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError()); |
|
86 return surf; |
|
87 } |
67 } |
88 |
68 |
89 // Set pixel format and other properties based on a paint device. |
69 // Set pixel format and other properties based on a paint device. |
90 void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev) |
70 void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev) |
91 { |
71 { |