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

#include <qwaylandxcompositeeglcontext.h>

Inheritance diagram for QWaylandXCompositeEGLContext:
QPlatformGLContext

Public Functions

void doneCurrent ()
 Reimplement in subclass to release current context. More...
 
void geometryChanged ()
 
void * getProcAddress (const QString &procName)
 Reimplement in subclass to native getProcAddr calls. More...
 
void makeCurrent ()
 Reimplement in subclass to do makeCurrent on native GL context. More...
 
QPlatformWindowFormat platformWindowFormat () const
 QWidget has the function qplatformWindowFormat(). More...
 
 QWaylandXCompositeEGLContext (QWaylandXCompositeEGLIntegration *glxIntegration, QWaylandXCompositeEGLWindow *window)
 
void swapBuffers ()
 Reimplement in subclass to native swap buffers calls. More...
 
- Public Functions inherited from QPlatformGLContext
 QPlatformGLContext ()
 All subclasses needs to specify the platformWindow. More...
 
virtual ~QPlatformGLContext ()
 If this is the current context for the thread, doneCurrent is called. More...
 

Static Private Functions

static void sync_function (void *data)
 

Properties

QWaylandBuffermBuffer
 
EGLConfig mConfig
 
EGLContext mContext
 
QWaylandXCompositeEGLIntegrationmEglIntegration
 
EGLSurface mEglWindowSurface
 
bool mWaitingForSync
 
QWaylandXCompositeEGLWindowmWindow
 
Window mXWindow
 

Additional Inherited Members

- Static Public Functions inherited from QPlatformGLContext
static const QPlatformGLContextcurrentContext ()
 Returns the last context which called makeCurrent. More...
 
- Protected Variables inherited from QPlatformGLContext
QScopedPointer< QPlatformGLContextPrivated_ptr
 

Detailed Description

Definition at line 54 of file qwaylandxcompositeeglcontext.h.

Constructors and Destructors

◆ QWaylandXCompositeEGLContext()

QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext ( QWaylandXCompositeEGLIntegration glxIntegration,
QWaylandXCompositeEGLWindow window 
)

Definition at line 55 of file qwaylandxcompositeeglcontext.cpp.

57  , mEglIntegration(glxIntegration)
58  , mWindow(window)
59  , mBuffer(0)
60  , mXWindow(0)
61  , mConfig(q_configFromQPlatformWindowFormat(glxIntegration->eglDisplay(),window->widget()->platformWindowFormat(),true,EGL_WINDOW_BIT))
62  , mWaitingForSync(false)
63 {
64  QVector<EGLint> eglContextAttrs;
65  eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); eglContextAttrs.append(2);
66  eglContextAttrs.append(EGL_NONE);
67 
68  mContext = eglCreateContext(glxIntegration->eglDisplay(),mConfig,EGL_NO_CONTEXT,eglContextAttrs.constData());
69  if (mContext == EGL_NO_CONTEXT) {
70  qFatal("failed to find context");
71  }
72 
74 }
QWaylandXCompositeEGLWindow * mWindow
EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType)
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
Q_CORE_EXPORT void qFatal(const char *,...)
QPlatformGLContext()
All subclasses needs to specify the platformWindow.
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
QWaylandXCompositeEGLIntegration * mEglIntegration
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

Functions

◆ doneCurrent()

void QWaylandXCompositeEGLContext::doneCurrent ( )
virtual

Reimplement in subclass to release current context.

Typically this is calling makeCurrent with 0 "surface"

Reimplemented from QPlatformGLContext.

Definition at line 83 of file qwaylandxcompositeeglcontext.cpp.

84 {
86  eglMakeCurrent(mEglIntegration->eglDisplay(),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT);
87 }
virtual void doneCurrent()
Reimplement in subclass to release current context.
QWaylandXCompositeEGLIntegration * mEglIntegration

◆ geometryChanged()

void QWaylandXCompositeEGLContext::geometryChanged ( )

Definition at line 114 of file qwaylandxcompositeeglcontext.cpp.

Referenced by QWaylandXCompositeEGLContext(), and QWaylandXCompositeEGLWindow::setGeometry().

115 {
116  QSize size(mWindow->geometry().size());
117  if (size.isEmpty()) {
118  //QGLWidget wants a context for a window without geometry
119  size = QSize(1,1);
120  }
121 
122  delete mBuffer;
123  //XFreePixmap deletes the glxPixmap as well
124  if (mXWindow) {
125  XDestroyWindow(mEglIntegration->xDisplay(),mXWindow);
126  }
127 
129 
130  XVisualInfo visualInfoTemplate;
131  memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
132  visualInfoTemplate.visualid = visualId;
133 
134  int matchingCount = 0;
135  XVisualInfo *visualInfo = XGetVisualInfo(mEglIntegration->xDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount);
136 
137  Colormap cmap = XCreateColormap(mEglIntegration->xDisplay(),mEglIntegration->rootWindow(),visualInfo->visual,AllocNone);
138 
139  XSetWindowAttributes a;
140  a.colormap = cmap;
141  mXWindow = XCreateWindow(mEglIntegration->xDisplay(), mEglIntegration->rootWindow(),0, 0, size.width(), size.height(),
142  0, visualInfo->depth, InputOutput, visualInfo->visual,
143  CWColormap, &a);
144 
145  XCompositeRedirectWindow(mEglIntegration->xDisplay(), mXWindow, CompositeRedirectManual);
146  XMapWindow(mEglIntegration->xDisplay(), mXWindow);
147 
148  mEglWindowSurface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mConfig,mXWindow,0);
149  if (mEglWindowSurface == EGL_NO_SURFACE) {
150  qFatal("Could not make eglsurface");
151  }
152 
153  XSync(mEglIntegration->xDisplay(),False);
155  (uint32_t)mXWindow,
156  size,
158  mWindow->attach(mBuffer);
159  wl_display_sync_callback(mEglIntegration->waylandDisplay()->wl_display(),
161  this);
162 
163  mWaitingForSync = true;
164  wl_display_sync(mEglIntegration->waylandDisplay()->wl_display(),0);
166  while (mWaitingForSync) {
168  }
169 }
virtual QRect geometry() const
Returnes the current geometry of a window.
QWaylandXCompositeEGLWindow * mWindow
struct wl_visual * argbVisual()
static QColor cmap[256]
Definition: qgl_mac.mm:760
long ASN1_INTEGER_get ASN1_INTEGER * a
static VisualID getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config)
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
void attach(QWaylandBuffer *buffer)
Q_CORE_EXPORT void qFatal(const char *,...)
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QWaylandXCompositeEGLIntegration * mEglIntegration
struct wl_display * wl_display() const

◆ getProcAddress()

void * QWaylandXCompositeEGLContext::getProcAddress ( const QString procName)
virtual

Reimplement in subclass to native getProcAddr calls.

Note: its convenient to use qPrintable(const QString &str) to get the const char * pointer

Implements QPlatformGLContext.

Definition at line 98 of file qwaylandxcompositeeglcontext.cpp.

99 {
100  return (void *)eglGetProcAddress(qPrintable(procName));
101 }
#define qPrintable(string)
Definition: qglobal.h:1750

◆ makeCurrent()

void QWaylandXCompositeEGLContext::makeCurrent ( )
virtual

Reimplement in subclass to do makeCurrent on native GL context.

Reimplemented from QPlatformGLContext.

Definition at line 76 of file qwaylandxcompositeeglcontext.cpp.

77 {
79 
81 }
virtual void makeCurrent()
Reimplement in subclass to do makeCurrent on native GL context.
QWaylandXCompositeEGLIntegration * mEglIntegration

◆ platformWindowFormat()

QPlatformWindowFormat QWaylandXCompositeEGLContext::platformWindowFormat ( ) const
virtual

QWidget has the function qplatformWindowFormat().

That function is for the application programmer to request the format of the window and the context that he wants.

Reimplement this function in a subclass to indicate what format the glContext actually has.

Implements QPlatformGLContext.

Definition at line 103 of file qwaylandxcompositeeglcontext.cpp.

104 {
106 }
QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config)
QWaylandXCompositeEGLIntegration * mEglIntegration

◆ swapBuffers()

void QWaylandXCompositeEGLContext::swapBuffers ( )
virtual

Reimplement in subclass to native swap buffers calls.

Implements QPlatformGLContext.

Definition at line 89 of file qwaylandxcompositeeglcontext.cpp.

90 {
91  QSize size = mWindow->geometry().size();
92 
93  eglSwapBuffers(mEglIntegration->eglDisplay(),mEglWindowSurface);
94  mWindow->damage(QRect(QPoint(0,0),size));
96 }
virtual QRect geometry() const
Returnes the current geometry of a window.
QWaylandXCompositeEGLWindow * mWindow
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void damage(const QRect &rect)
QWaylandXCompositeEGLIntegration * mEglIntegration

◆ sync_function()

void QWaylandXCompositeEGLContext::sync_function ( void *  data)
staticprivate

Definition at line 108 of file qwaylandxcompositeeglcontext.cpp.

Referenced by geometryChanged().

109 {
111  that->mWaitingForSync = false;
112 }
static const char * data(const QByteArray &arr)

Properties

◆ mBuffer

QWaylandBuffer* QWaylandXCompositeEGLContext::mBuffer
private

Definition at line 71 of file qwaylandxcompositeeglcontext.h.

Referenced by geometryChanged().

◆ mConfig

EGLConfig QWaylandXCompositeEGLContext::mConfig
private

◆ mContext

EGLContext QWaylandXCompositeEGLContext::mContext
private

Definition at line 75 of file qwaylandxcompositeeglcontext.h.

Referenced by makeCurrent(), and QWaylandXCompositeEGLContext().

◆ mEglIntegration

QWaylandXCompositeEGLIntegration* QWaylandXCompositeEGLContext::mEglIntegration
private

◆ mEglWindowSurface

EGLSurface QWaylandXCompositeEGLContext::mEglWindowSurface
private

Definition at line 76 of file qwaylandxcompositeeglcontext.h.

Referenced by geometryChanged(), makeCurrent(), and swapBuffers().

◆ mWaitingForSync

bool QWaylandXCompositeEGLContext::mWaitingForSync
private

Definition at line 79 of file qwaylandxcompositeeglcontext.h.

Referenced by geometryChanged(), and sync_function().

◆ mWindow

QWaylandXCompositeEGLWindow* QWaylandXCompositeEGLContext::mWindow
private

Definition at line 70 of file qwaylandxcompositeeglcontext.h.

Referenced by geometryChanged(), and swapBuffers().

◆ mXWindow

Window QWaylandXCompositeEGLContext::mXWindow
private

Definition at line 73 of file qwaylandxcompositeeglcontext.h.

Referenced by geometryChanged().


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