Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QEglFSScreen Class Reference

#include <qeglfsscreen.h>

Inheritance diagram for QEglFSScreen:
QPlatformScreen QObject

Public Functions

int depth () const
 Reimplement in subclass to return current depth of the screen. More...
 
QImage::Format format () const
 Reimplement in subclass to return the image format which corresponds to the screen format. More...
 
QRect geometry () const
 Reimplement in subclass to return the pixel geometry of the screen. More...
 
QPlatformGLContextplatformContext () const
 
 QEglFSScreen (EGLNativeDisplayType display)
 
 ~QEglFSScreen ()
 
- Public Functions inherited from QPlatformScreen
virtual QRect availableGeometry () const
 Reimplement in subclass to return the pixel geometry of the available space This normally is the desktop screen minus the task manager, global menubar etc. More...
 
virtual QSize physicalSize () const
 Reimplement this function in subclass to return the physical size of the screen. More...
 
virtual void setDirty (const QRect &)
 
virtual QWidgettopLevelAt (const QPoint &point) const
 Return the given top level widget for a given position. More...
 
virtual ~QPlatformScreen ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Functions

void createAndSetPlatformContext () const
 
void createAndSetPlatformContext ()
 

Properties

int m_depth
 
EGLDisplay m_dpy
 
QImage::Format m_format
 
QRect m_geometry
 
QPlatformGLContextm_platformContext
 
EGLSurface m_surface
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QPlatformScreen
static QPlatformScreenplatformScreenForWidget (const QWidget *widget)
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 55 of file qeglfsscreen.h.

Constructors and Destructors

◆ QEglFSScreen()

QEglFSScreen::QEglFSScreen ( EGLNativeDisplayType  display)

Definition at line 89 of file qeglfsscreen.cpp.

90  : m_depth(32)
93  , m_surface(0)
94 {
95 #ifdef QEGL_EXTRA_DEBUG
96  qWarning("QEglScreen %p\n", this);
97 #endif
98 
99  EGLint major, minor;
100 #ifdef QEGL_EXTRA_DEBUG
101  EGLint index;
102 #endif
103  if (!eglBindAPI(EGL_OPENGL_ES_API)) {
104  qWarning("Could not bind GL_ES API\n");
105  qFatal("EGL error");
106  }
107 
108  m_dpy = eglGetDisplay(display);
109  if (m_dpy == EGL_NO_DISPLAY) {
110  qWarning("Could not open egl display\n");
111  qFatal("EGL error");
112  }
113  qWarning("Opened display %p\n", m_dpy);
114 
115  if (!eglInitialize(m_dpy, &major, &minor)) {
116  qWarning("Could not initialize egl display\n");
117  qFatal("EGL error");
118  }
119 
120  qWarning("Initialized display %d %d\n", major, minor);
121 
122  int swapInterval = 1;
123  QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL");
124  if (!swapIntervalString.isEmpty()) {
125  bool ok;
126  swapInterval = swapIntervalString.toInt(&ok);
127  if (!ok)
128  swapInterval = 1;
129  }
130  eglSwapInterval(m_dpy, swapInterval);
131 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QImage::Format m_format
Definition: qeglfsscreen.h:73
QPlatformGLContext * m_platformContext
Definition: qeglfsscreen.h:74
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
Q_CORE_EXPORT void qWarning(const char *,...)
EGLDisplay m_dpy
Definition: qeglfsscreen.h:75
EGLSurface m_surface
Definition: qeglfsscreen.h:76
Q_CORE_EXPORT void qFatal(const char *,...)
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
quint16 index
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421

◆ ~QEglFSScreen()

QEglFSScreen::~QEglFSScreen ( )
inline

Definition at line 59 of file qeglfsscreen.h.

59 {}

Functions

◆ createAndSetPlatformContext() [1/2]

void QEglFSScreen::createAndSetPlatformContext ( ) const
private

Definition at line 133 of file qeglfsscreen.cpp.

Referenced by format(), geometry(), platformContext(), and ~QEglFSScreen().

133  {
134  const_cast<QEglFSScreen *>(this)->createAndSetPlatformContext();
135 }
void createAndSetPlatformContext() const

◆ createAndSetPlatformContext() [2/2]

void QEglFSScreen::createAndSetPlatformContext ( )
private

Definition at line 137 of file qeglfsscreen.cpp.

138 {
140 
142 
143  QByteArray depthString = qgetenv("QT_QPA_EGLFS_DEPTH");
144  if (depthString.toInt() == 16) {
145  platformFormat.setDepth(16);
146  platformFormat.setRedBufferSize(5);
147  platformFormat.setGreenBufferSize(6);
148  platformFormat.setBlueBufferSize(5);
149  m_depth = 16;
151  } else {
152  platformFormat.setDepth(32);
153  platformFormat.setRedBufferSize(8);
154  platformFormat.setGreenBufferSize(8);
155  platformFormat.setBlueBufferSize(8);
156  m_depth = 32;
158  }
159  if (!qgetenv("QT_QPA_EGLFS_MULTISAMPLE").isEmpty()) {
160  platformFormat.setSampleBuffers(true);
161  }
162 
163 
164  EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat);
165 
166  EGLNativeWindowType eglWindow = 0;
167 #ifdef Q_OPENKODE
168  if (kdInitializeNV() == KD_ENOTINITIALIZED) {
169  qFatal("Did not manage to initialize openkode");
170  }
171  KDWindow *window = kdCreateWindow(m_dpy,config,0);
172 
173  kdRealizeWindow(window,&eglWindow);
174 #endif
175 
176  m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL);
177  if (m_surface == EGL_NO_SURFACE) {
178  qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError());
179  eglTerminate(m_dpy);
180  qFatal("EGL error");
181  }
182  // qWarning("Created surface %dx%d\n", w, h);
183 
184 #ifdef QEGL_EXTRA_DEBUG
185  qWarning("Configuration %d matches requirements\n", (int)config);
186 
187  for (index = 0; attrs[index].attr != -1; ++index) {
188  EGLint value;
189  if (eglGetConfigAttrib(m_dpy, config, attrs[index].attr, &value)) {
190  qWarning("\t%s: %d\n", attrs[index].name, (int)value);
191  }
192  }
193  qWarning("\n");
194 #endif
195 
196  EGLint temp;
197  EGLint attribList[32];
198 
199  temp = 0;
200 
201  attribList[temp++] = EGL_CONTEXT_CLIENT_VERSION;
202  attribList[temp++] = 2; // GLES version 2
203  attribList[temp++] = EGL_NONE;
204 
205  QEGLPlatformContext *platformContext = new QEGLPlatformContext(m_dpy,config,attribList,m_surface,EGL_OPENGL_ES_API);
207 
208  EGLint w,h; // screen size detection
209  eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w);
210  eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h);
211 
212  m_geometry = QRect(0,0,w,h);
213 
214 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static QPlatformWindowFormat defaultFormat()
Returns the default QPlatformWindowFormat for the application.
The QPlatformWindowFormat class specifies the display format of an OpenGL rendering context and if po...
void setBlueBufferSize(int size)
Set the preferred blue buffer size to size.
QImage::Format m_format
Definition: qeglfsscreen.h:73
QPlatformGLContext * m_platformContext
Definition: qeglfsscreen.h:74
NativeWindowType EGLNativeWindowType
Definition: qegl_p.h:116
NSWindow * window
static bool isEmpty(const char *str)
const char * name
Q_CORE_EXPORT void qWarning(const char *,...)
QRect m_geometry
Definition: qeglfsscreen.h:71
EGLDisplay m_dpy
Definition: qeglfsscreen.h:75
EGLSurface m_surface
Definition: qeglfsscreen.h:76
Q_CORE_EXPORT void qFatal(const char *,...)
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
void setSampleBuffers(bool enable)
If enable is true, a GL context with multisample buffer support is picked; otherwise ignored...
void setWindowApi(QPlatformWindowFormat::WindowApi api)
QPlatformGLContext * platformContext() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void setRedBufferSize(int size)
Set the preferred red buffer size to size.
quint16 index
void setGreenBufferSize(int size)
Set the preferred green buffer size to size.
void setDepth(bool enable)
If enable is true enables the depth buffer; otherwise disables the depth buffer.

◆ depth()

int QEglFSScreen::depth ( ) const
virtual

Reimplement in subclass to return current depth of the screen.

Implements QPlatformScreen.

Definition at line 224 of file qeglfsscreen.cpp.

Referenced by ~QEglFSScreen().

225 {
226  return m_depth;
227 }

◆ format()

QImage::Format QEglFSScreen::format ( ) const
virtual

Reimplement in subclass to return the image format which corresponds to the screen format.

Implements QPlatformScreen.

Definition at line 229 of file qeglfsscreen.cpp.

Referenced by ~QEglFSScreen().

230 {
233  return m_format;
234 }
QImage::Format m_format
Definition: qeglfsscreen.h:73
void createAndSetPlatformContext() const

◆ geometry()

QRect QEglFSScreen::geometry ( ) const
virtual

Reimplement in subclass to return the pixel geometry of the screen.

Implements QPlatformScreen.

Definition at line 216 of file qeglfsscreen.cpp.

Referenced by QEglFSPaintDevice::size(), and ~QEglFSScreen().

217 {
218  if (m_geometry.isNull()) {
220  }
221  return m_geometry;
222 }
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
QRect m_geometry
Definition: qeglfsscreen.h:71
void createAndSetPlatformContext() const

◆ platformContext()

QPlatformGLContext * QEglFSScreen::platformContext ( ) const

Definition at line 235 of file qeglfsscreen.cpp.

Referenced by QEglFSPaintDevice::context(), createAndSetPlatformContext(), QEglFSWindow::glContext(), and ~QEglFSScreen().

236 {
237  if (!m_platformContext) {
238  QEglFSScreen *that = const_cast<QEglFSScreen *>(this);
240  }
241  return m_platformContext;
242 }
QPlatformGLContext * m_platformContext
Definition: qeglfsscreen.h:74
void createAndSetPlatformContext() const

Properties

◆ m_depth

int QEglFSScreen::m_depth
private

Definition at line 72 of file qeglfsscreen.h.

Referenced by createAndSetPlatformContext(), and depth().

◆ m_dpy

EGLDisplay QEglFSScreen::m_dpy
private

Definition at line 75 of file qeglfsscreen.h.

Referenced by createAndSetPlatformContext(), and QEglFSScreen().

◆ m_format

QImage::Format QEglFSScreen::m_format
private

Definition at line 73 of file qeglfsscreen.h.

Referenced by createAndSetPlatformContext(), and format().

◆ m_geometry

QRect QEglFSScreen::m_geometry
private

Definition at line 71 of file qeglfsscreen.h.

Referenced by createAndSetPlatformContext(), and geometry().

◆ m_platformContext

QPlatformGLContext* QEglFSScreen::m_platformContext
private

Definition at line 74 of file qeglfsscreen.h.

Referenced by createAndSetPlatformContext(), and platformContext().

◆ m_surface

EGLSurface QEglFSScreen::m_surface
private

Definition at line 76 of file qeglfsscreen.h.

Referenced by createAndSetPlatformContext().


The documentation for this class was generated from the following files: