src/gui/egl/qegl_wince.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
    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 <windows.h>
    49 #include <windows.h>
    48 
    50 
    49 
    51 
    50 QT_BEGIN_NAMESPACE
    52 QT_BEGIN_NAMESPACE
    51 
    53 
    52 EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties *properties)
    54 EGLNativeDisplayType QEgl::nativeDisplay()
    53 {
       
    54     // Create the native drawable for the paint device.
       
    55     int devType = device->devType();
       
    56     EGLNativePixmapType pixmapDrawable = 0;
       
    57     EGLNativeWindowType windowDrawable = 0;
       
    58     bool ok;
       
    59     if (devType == QInternal::Pixmap) {
       
    60         pixmapDrawable = 0;
       
    61         ok = (pixmapDrawable != 0);
       
    62     } else if (devType == QInternal::Widget) {
       
    63         windowDrawable = (EGLNativeWindowType)(static_cast<QWidget *>(device))->winId();
       
    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 
       
    73     // Create the EGL surface to draw into, based on the native drawable.
       
    74     const int *props;
       
    75     if (properties)
       
    76         props = properties->properties();
       
    77     else
       
    78         props = 0;
       
    79     EGLSurface surf;
       
    80     if (devType == QInternal::Widget)
       
    81         surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, props);
       
    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     }
       
    87     return surf;
       
    88 }
       
    89 
       
    90 EGLNativeDisplayType QEglContext::nativeDisplay()
       
    91 {
    55 {
    92     HDC myDc = GetDC(0);
    56     HDC myDc = GetDC(0);
    93 
       
    94     if (!myDc) {
    57     if (!myDc) {
    95         qWarning("QEglContext::nativeDisplay(): WinCE display is not open");
    58         qWarning("QEglContext::nativeDisplay(): WinCE display is not open");
    96         return EGL_DEFAULT_DISPLAY;
    59         return EGL_DEFAULT_DISPLAY;
    97     }
    60     }
    98     return EGLNativeDisplayType(myDc);
    61     return EGLNativeDisplayType(myDc);
       
    62 }
       
    63 
       
    64 EGLNativeWindowType QEgl::nativeWindow(QWidget* widget)
       
    65 {
       
    66     return (EGLNativeWindowType)(widget->winId());
       
    67 }
       
    68 
       
    69 EGLNativePixmapType QEgl::nativePixmap(QPixmap*)
       
    70 {
       
    71     qWarning("QEgl: EGL pixmap surfaces not supported on WinCE");
       
    72     return (EGLNativePixmapType)0;
    99 }
    73 }
   100 
    74 
   101 // Set pixel format and other properties based on a paint device.
    75 // Set pixel format and other properties based on a paint device.
   102 void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev)
    76 void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev)
   103 {
    77 {