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

#include <qwaylandxcompositeglxcontext.h>

Inheritance diagram for QWaylandXCompositeGLXContext:
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...
 
 QWaylandXCompositeGLXContext (QWaylandXCompositeGLXIntegration *glxIntegration, QWaylandXCompositeGLXWindow *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...
 

Private Functions

void waitForSync ()
 

Static Private Functions

static void sync_function (void *data)
 

Properties

QWaylandBuffermBuffer
 
GLXFBConfig mConfig
 
GLXContext mContext
 
QWaylandXCompositeGLXIntegrationmGlxIntegration
 
bool mWaitingForSyncCallback
 
QWaylandXCompositeGLXWindowmWindow
 
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 57 of file qwaylandxcompositeglxcontext.h.

Constructors and Destructors

◆ QWaylandXCompositeGLXContext()

QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext ( QWaylandXCompositeGLXIntegration glxIntegration,
QWaylandXCompositeGLXWindow window 
)

Definition at line 52 of file qwaylandxcompositeglxcontext.cpp.

54  , mGlxIntegration(glxIntegration)
55  , mWindow(window)
56  , mBuffer(0)
57  , mXWindow(0)
58  , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat()))
60 {
61  XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig);
62  mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE);
63 
65 }
QWaylandXCompositeGLXWindow * mWindow
GLXFBConfig qglx_findConfig(Display *display, int screen, const QPlatformWindowFormat &format, int drawableBit)
#define TRUE
Synonym for true.
Definition: qglobal.h:1018
QWaylandXCompositeGLXIntegration * mGlxIntegration
QPlatformGLContext()
All subclasses needs to specify the platformWindow.
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

Functions

◆ doneCurrent()

void QWaylandXCompositeGLXContext::doneCurrent ( )
virtual

Reimplement in subclass to release current context.

Typically this is calling makeCurrent with 0 "surface"

Reimplemented from QPlatformGLContext.

Definition at line 73 of file qwaylandxcompositeglxcontext.cpp.

74 {
75  glXMakeCurrent(mGlxIntegration->xDisplay(),0,0);
77 }
virtual void doneCurrent()
Reimplement in subclass to release current context.
QWaylandXCompositeGLXIntegration * mGlxIntegration

◆ geometryChanged()

void QWaylandXCompositeGLXContext::geometryChanged ( )

Definition at line 117 of file qwaylandxcompositeglxcontext.cpp.

Referenced by QWaylandXCompositeGLXContext(), and QWaylandXCompositeGLXWindow::setGeometry().

118 {
119  QSize size(mWindow->geometry().size());
120  if (size.isEmpty()) {
121  //QGLWidget wants a context for a window without geometry
122  size = QSize(1,1);
123  }
124 
125  delete mBuffer;
126  //XFreePixmap deletes the glxPixmap as well
127  if (mXWindow) {
128  XDestroyWindow(mGlxIntegration->xDisplay(),mXWindow);
129  }
130 
131  XVisualInfo *visualInfo = glXGetVisualFromFBConfig(mGlxIntegration->xDisplay(),mConfig);
132  Colormap cmap = XCreateColormap(mGlxIntegration->xDisplay(),mGlxIntegration->rootWindow(),visualInfo->visual,AllocNone);
133 
134  XSetWindowAttributes a;
135  a.background_pixel = WhitePixel(mGlxIntegration->xDisplay(), mGlxIntegration->screen());
136  a.border_pixel = BlackPixel(mGlxIntegration->xDisplay(), mGlxIntegration->screen());
137  a.colormap = cmap;
138  mXWindow = XCreateWindow(mGlxIntegration->xDisplay(), mGlxIntegration->rootWindow(),0, 0, size.width(), size.height(),
139  0, visualInfo->depth, InputOutput, visualInfo->visual,
140  CWBackPixel|CWBorderPixel|CWColormap, &a);
141 
142  XCompositeRedirectWindow(mGlxIntegration->xDisplay(), mXWindow, CompositeRedirectManual);
143  XMapWindow(mGlxIntegration->xDisplay(), mXWindow);
144 
145  XSync(mGlxIntegration->xDisplay(),False);
147  (uint32_t)mXWindow,
148  size,
150  mWindow->attach(mBuffer);
151  waitForSync();
152 }
virtual QRect geometry() const
Returnes the current geometry of a window.
struct wl_visual * argbVisual()
static QColor cmap[256]
Definition: qgl_mac.mm:760
long ASN1_INTEGER_get ASN1_INTEGER * a
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
struct wl_xcomposite * waylandXComposite() const
void attach(QWaylandBuffer *buffer)
QWaylandXCompositeGLXWindow * mWindow
QWaylandXCompositeGLXIntegration * mGlxIntegration
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ getProcAddress()

void * QWaylandXCompositeGLXContext::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 88 of file qwaylandxcompositeglxcontext.cpp.

89 {
90  return (void *) glXGetProcAddress(reinterpret_cast<GLubyte *>(procName.toLatin1().data()));
91 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993

◆ makeCurrent()

void QWaylandXCompositeGLXContext::makeCurrent ( )
virtual

Reimplement in subclass to do makeCurrent on native GL context.

Reimplemented from QPlatformGLContext.

Definition at line 67 of file qwaylandxcompositeglxcontext.cpp.

68 {
70  glXMakeCurrent(mGlxIntegration->xDisplay(),mXWindow,mContext);
71 }
virtual void makeCurrent()
Reimplement in subclass to do makeCurrent on native GL context.
QWaylandXCompositeGLXIntegration * mGlxIntegration

◆ platformWindowFormat()

QPlatformWindowFormat QWaylandXCompositeGLXContext::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 93 of file qwaylandxcompositeglxcontext.cpp.

94 {
96 }
QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx)
QWaylandXCompositeGLXIntegration * mGlxIntegration

◆ swapBuffers()

void QWaylandXCompositeGLXContext::swapBuffers ( )
virtual

Reimplement in subclass to native swap buffers calls.

Implements QPlatformGLContext.

Definition at line 79 of file qwaylandxcompositeglxcontext.cpp.

80 {
81  QSize size = mWindow->geometry().size();
82 
83  glXSwapBuffers(mGlxIntegration->xDisplay(),mXWindow);
84  mWindow->damage(QRect(QPoint(0,0),size));
86 }
virtual QRect geometry() const
Returnes the current geometry of a window.
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
QWaylandXCompositeGLXWindow * mWindow
QWaylandXCompositeGLXIntegration * mGlxIntegration
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)

◆ sync_function()

void QWaylandXCompositeGLXContext::sync_function ( void *  data)
staticprivate

Definition at line 98 of file qwaylandxcompositeglxcontext.cpp.

Referenced by waitForSync().

99 {
101  that->mWaitingForSyncCallback = false;
102 }
static const char * data(const QByteArray &arr)

◆ waitForSync()

void QWaylandXCompositeGLXContext::waitForSync ( )
private

Definition at line 104 of file qwaylandxcompositeglxcontext.cpp.

Referenced by geometryChanged().

105 {
106  wl_display_sync_callback(mGlxIntegration->waylandDisplay()->wl_display(),
108  this);
110  wl_display_sync(mGlxIntegration->waylandDisplay()->wl_display(),0);
112  while (mWaitingForSyncCallback) {
114  }
115 }
QWaylandXCompositeGLXIntegration * mGlxIntegration
struct wl_display * wl_display() const

Properties

◆ mBuffer

QWaylandBuffer* QWaylandXCompositeGLXContext::mBuffer
private

Definition at line 74 of file qwaylandxcompositeglxcontext.h.

Referenced by geometryChanged().

◆ mConfig

GLXFBConfig QWaylandXCompositeGLXContext::mConfig
private

◆ mContext

GLXContext QWaylandXCompositeGLXContext::mContext
private

◆ mGlxIntegration

QWaylandXCompositeGLXIntegration* QWaylandXCompositeGLXContext::mGlxIntegration
private

◆ mWaitingForSyncCallback

bool QWaylandXCompositeGLXContext::mWaitingForSyncCallback
private

Definition at line 82 of file qwaylandxcompositeglxcontext.h.

Referenced by sync_function(), and waitForSync().

◆ mWindow

QWaylandXCompositeGLXWindow* QWaylandXCompositeGLXContext::mWindow
private

Definition at line 73 of file qwaylandxcompositeglxcontext.h.

Referenced by geometryChanged(), and swapBuffers().

◆ mXWindow

Window QWaylandXCompositeGLXContext::mXWindow
private

Definition at line 76 of file qwaylandxcompositeglxcontext.h.

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


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