Qt 4.8
Classes | Functions
qgl_qws.cpp File Reference
#include "qgl.h"
#include "qgl_egl_p.h"
#include "qglpixelbuffer.h"
#include <qglscreen_qws.h>
#include <qscreenproxy_qws.h>
#include <private/qglwindowsurface_qws_p.h>
#include <private/qbackingstore_p.h>
#include <private/qfont_p.h>
#include <private/qfontengine_p.h>
#include <private/qgl_p.h>
#include <private/qpaintengine_opengl_p.h>
#include <qpixmap.h>
#include <qtimer.h>
#include <qapplication.h>
#include <qstack.h>
#include <qdesktopwidget.h>
#include <qdebug.h>
#include <qvarlengtharray.h>

Go to the source code of this file.

Classes

class  QGLTemporaryContextPrivate
 

Functions

static QGLScreenglScreenForDevice (QPaintDevice *device)
 
static EGLSurface qt_egl_create_surface (QEglContext *context, QPaintDevice *device, const QEglProperties *properties=0)
 

Function Documentation

◆ glScreenForDevice()

static QGLScreen* glScreenForDevice ( QPaintDevice device)
static

Definition at line 65 of file qgl_qws.cpp.

Referenced by qt_egl_create_surface().

66 {
67  QScreen *screen = qt_screen;
68  if (screen->classId() == QScreen::MultiClass) {
69  int screenNumber;
70  if (device && device->devType() == QInternal::Widget)
71  screenNumber = qApp->desktop()->screenNumber(static_cast<QWidget *>(device));
72  else
73  screenNumber = 0;
74  screen = screen->subScreens()[screenNumber];
75  }
76  while (screen->classId() == QScreen::ProxyClass ||
77  screen->classId() == QScreen::TransformedClass) {
78  screen = static_cast<QProxyScreen *>(screen)->screen();
79  }
80  if (screen->classId() == QScreen::GLClass)
81  return static_cast<QGLScreen *>(screen);
82  else
83  return 0;
84 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
The QProxyScreen class provides a generic interface to QScreen implementations.
virtual int devType() const
Definition: qpaintdevice.h:167
#define qApp
virtual QList< QScreen * > subScreens() const
Definition: qscreen_qws.h:283
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
ClassId classId() const
Returns the class identifier for the screen object.

◆ qt_egl_create_surface()

static EGLSurface qt_egl_create_surface ( QEglContext context,
QPaintDevice device,
const QEglProperties properties = 0 
)
static

Definition at line 123 of file qgl_qws.cpp.

125 {
126  // Get the screen surface functions, which are used to create native ids.
127  QGLScreen *glScreen = glScreenForDevice(device);
128  if (!glScreen)
129  return EGL_NO_SURFACE;
130  QGLScreenSurfaceFunctions *funcs = glScreen->surfaceFunctions();
131  if (!funcs)
132  return EGL_NO_SURFACE;
133 
134  // Create the native drawable for the paint device.
135  int devType = device->devType();
136  EGLNativePixmapType pixmapDrawable = 0;
137  EGLNativeWindowType windowDrawable = 0;
138  bool ok;
139  if (devType == QInternal::Pixmap) {
140  ok = funcs->createNativePixmap(static_cast<QPixmap *>(device), &pixmapDrawable);
141  } else if (devType == QInternal::Image) {
142  ok = funcs->createNativeImage(static_cast<QImage *>(device), &pixmapDrawable);
143  } else {
144  ok = funcs->createNativeWindow(static_cast<QWidget *>(device), &windowDrawable);
145  }
146  if (!ok) {
147  qWarning("QEglContext::createSurface(): Cannot create the native EGL drawable");
148  return EGL_NO_SURFACE;
149  }
150 
151  // Create the EGL surface to draw into, based on the native drawable.
152  const EGLint *props;
153  if (properties)
154  props = properties->properties();
155  else
156  props = 0;
157  EGLSurface surf;
158  if (devType == QInternal::Widget) {
159  surf = eglCreateWindowSurface
160  (context->display(), context->config(), windowDrawable, props);
161  } else {
162  surf = eglCreatePixmapSurface
163  (context->display(), context->config(), pixmapDrawable, props);
164  }
165  if (surf == EGL_NO_SURFACE)
166  qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
167  return surf;
168 }
virtual bool createNativeImage(QImage *image, EGLNativePixmapType *native)
Creates a native OpenGLES drawable for directly rendering into image and returns it in native...
NativePixmapType EGLNativePixmapType
Definition: qegl_p.h:117
const EGLint * properties() const
static QGLScreen * glScreenForDevice(QPaintDevice *device)
Definition: qgl_qws.cpp:65
NativeWindowType EGLNativeWindowType
Definition: qegl_p.h:116
virtual int devType() const
Definition: qpaintdevice.h:167
EGLConfig config() const
Definition: qeglcontext_p.h:96
virtual bool createNativeWindow(QWidget *widget, EGLNativeWindowType *native)
Creates a native OpenGLES drawable for the surface of widget and returns it in native.
Q_CORE_EXPORT void qWarning(const char *,...)
virtual bool createNativePixmap(QPixmap *pixmap, EGLNativePixmapType *native)
Creates a native OpenGLES drawable for directly rendering into pixmap and returns it in native...
QGLScreenSurfaceFunctions * surfaceFunctions() const
Returns the surface functions object for this QGLScreen.
EGLDisplay display()
Definition: qeglcontext_p.h:94
The QGLScreenSurfaceFunctions class encapsulates the functions for creating native windows and pixmap...
Definition: qglscreen_qws.h:81
This class encapsulates an OpenGL screen driver.
Definition: qglscreen_qws.h:89