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

#include <qwaylandreadbackglxcontext.h>

Inheritance diagram for QWaylandReadbackGlxContext:
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...
 
 QWaylandReadbackGlxContext (QWaylandReadbackGlxIntegration *glxIntegration, QWaylandReadbackGlxWindow *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...
 

Properties

QWaylandShmBuffermBuffer
 
GLXFBConfig mConfig
 
GLXContext mContext
 
QWaylandReadbackGlxIntegrationmGlxIntegration
 
GLXPixmap mGlxPixmap
 
Pixmap mPixmap
 
QWaylandReadbackGlxWindowmWindow
 

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 qwaylandreadbackglxcontext.h.

Constructors and Destructors

◆ QWaylandReadbackGlxContext()

QWaylandReadbackGlxContext::QWaylandReadbackGlxContext ( QWaylandReadbackGlxIntegration glxIntegration,
QWaylandReadbackGlxWindow window 
)

Definition at line 71 of file qwaylandreadbackglxcontext.cpp.

73  , mGlxIntegration(glxIntegration)
74  , mWindow(window)
75  , mBuffer(0)
76  , mPixmap(0)
77  , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat(),GLX_PIXMAP_BIT))
78  , mGlxPixmap(0)
79 {
80  XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig);
81  mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE);
82 
84 }
QWaylandReadbackGlxIntegration * mGlxIntegration
GLXFBConfig qglx_findConfig(Display *display, int screen, const QPlatformWindowFormat &format, int drawableBit)
#define TRUE
Synonym for true.
Definition: qglobal.h:1018
QWaylandReadbackGlxWindow * mWindow
QPlatformGLContext()
All subclasses needs to specify the platformWindow.
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

Functions

◆ doneCurrent()

void QWaylandReadbackGlxContext::doneCurrent ( )
virtual

Reimplement in subclass to release current context.

Typically this is calling makeCurrent with 0 "surface"

Reimplemented from QPlatformGLContext.

Definition at line 93 of file qwaylandreadbackglxcontext.cpp.

94 {
96 }
virtual void doneCurrent()
Reimplement in subclass to release current context.

◆ geometryChanged()

void QWaylandReadbackGlxContext::geometryChanged ( )

Definition at line 136 of file qwaylandreadbackglxcontext.cpp.

Referenced by QWaylandReadbackGlxContext(), and QWaylandReadbackGlxWindow::setGeometry().

137 {
138  QSize size(mWindow->geometry().size());
139  if (size.isEmpty()) {
140  //QGLWidget wants a context for a window without geometry
141  size = QSize(1,1);
142  }
143 
145 
146  delete mBuffer;
147  //XFreePixmap deletes the glxPixmap as well
148  if (mPixmap) {
149  XFreePixmap(mGlxIntegration->xDisplay(),mPixmap);
150  }
151 
153  mWindow->attach(mBuffer);
154  int depth = XDefaultDepth(mGlxIntegration->xDisplay(),mGlxIntegration->screen());
155  mPixmap = XCreatePixmap(mGlxIntegration->xDisplay(),mGlxIntegration->rootWindow(),size.width(),size.height(),depth);
156  XSync(mGlxIntegration->xDisplay(),False);
157 
158  mGlxPixmap = glXCreatePixmap(mGlxIntegration->xDisplay(),mConfig,mPixmap,0);
159 
160  if (!mGlxPixmap) {
161  qDebug() << "Could not make egl surface out of pixmap :(";
162  }
163 }
virtual QRect geometry() const
Returnes the current geometry of a window.
Q_CORE_EXPORT void qDebug(const char *,...)
QWaylandReadbackGlxIntegration * mGlxIntegration
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
void attach(QWaylandBuffer *buffer)
QWaylandReadbackGlxWindow * mWindow
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ getProcAddress()

void * QWaylandReadbackGlxContext::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 126 of file qwaylandreadbackglxcontext.cpp.

127 {
128  return (void *) glXGetProcAddress(reinterpret_cast<GLubyte *>(procName.toLatin1().data()));
129 }
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 QWaylandReadbackGlxContext::makeCurrent ( )
virtual

Reimplement in subclass to do makeCurrent on native GL context.

Reimplemented from QPlatformGLContext.

Definition at line 86 of file qwaylandreadbackglxcontext.cpp.

Referenced by swapBuffers().

87 {
89 
90  glXMakeCurrent(mGlxIntegration->xDisplay(),mGlxPixmap,mContext);
91 }
QWaylandReadbackGlxIntegration * mGlxIntegration
virtual void makeCurrent()
Reimplement in subclass to do makeCurrent on native GL context.

◆ platformWindowFormat()

QPlatformWindowFormat QWaylandReadbackGlxContext::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 131 of file qwaylandreadbackglxcontext.cpp.

132 {
134 }
QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx)
QWaylandReadbackGlxIntegration * mGlxIntegration

◆ swapBuffers()

void QWaylandReadbackGlxContext::swapBuffers ( )
virtual

Reimplement in subclass to native swap buffers calls.

Implements QPlatformGLContext.

Definition at line 98 of file qwaylandreadbackglxcontext.cpp.

99 {
100  if (QPlatformGLContext::currentContext() != this) {
101  makeCurrent();
102  }
103 
104  QSize size = mWindow->geometry().size();
105 
106  QImage img(size,QImage::Format_ARGB32);
107  const uchar *constBits = img.bits();
108  void *pixels = const_cast<uchar *>(constBits);
109 
110  glReadPixels(0,0, size.width(), size.height(), GL_RGBA,GL_UNSIGNED_BYTE, pixels);
111 
112  img = img.mirrored();
114  constBits = img.bits();
115 
116  const uchar *constDstBits = mBuffer->image()->bits();
117  uchar *dstBits = const_cast<uchar *>(constDstBits);
118  memcpy(dstBits,constBits,(img.width()*4) * img.height());
119 
120 
121  mWindow->damage(QRegion(QRect(QPoint(0,0),size)));
123 
124 }
static const QPlatformGLContext * currentContext()
Returns the last context which called makeCurrent.
virtual QRect geometry() const
Returnes the current geometry of a window.
#define GL_UNSIGNED_INT_8_8_8_8_REV
unsigned char uchar
Definition: qglobal.h:994
int width() const
Returns the width.
Definition: qsize.h:126
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void makeCurrent()
Reimplement in subclass to do makeCurrent on native GL context.
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
#define GL_UNSIGNED_BYTE
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
#define GL_RGBA
QWaylandReadbackGlxWindow * mWindow
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void damage(const QRect &rect)
static void qgl_byteSwapImage(QImage &img, GLenum pixel_type)

Properties

◆ mBuffer

QWaylandShmBuffer* QWaylandReadbackGlxContext::mBuffer
private

Definition at line 71 of file qwaylandreadbackglxcontext.h.

Referenced by geometryChanged(), and swapBuffers().

◆ mConfig

GLXFBConfig QWaylandReadbackGlxContext::mConfig
private

◆ mContext

GLXContext QWaylandReadbackGlxContext::mContext
private

◆ mGlxIntegration

QWaylandReadbackGlxIntegration* QWaylandReadbackGlxContext::mGlxIntegration
private

Definition at line 69 of file qwaylandreadbackglxcontext.h.

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

◆ mGlxPixmap

GLXPixmap QWaylandReadbackGlxContext::mGlxPixmap
private

Definition at line 76 of file qwaylandreadbackglxcontext.h.

Referenced by geometryChanged(), and makeCurrent().

◆ mPixmap

Pixmap QWaylandReadbackGlxContext::mPixmap
private

Definition at line 73 of file qwaylandreadbackglxcontext.h.

Referenced by geometryChanged().

◆ mWindow

QWaylandReadbackGlxWindow* QWaylandReadbackGlxContext::mWindow
private

Definition at line 70 of file qwaylandreadbackglxcontext.h.

Referenced by geometryChanged(), and swapBuffers().


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