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

#include <qwaylandreadbackeglcontext.h>

Inheritance diagram for QWaylandReadbackEglContext:
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...
 
virtual QPlatformWindowFormat platformWindowFormat () const
 QWidget has the function qplatformWindowFormat(). More...
 
 QWaylandReadbackEglContext (QWaylandReadbackEglIntegration *eglIntegration, QWaylandReadbackEglWindow *window)
 
void swapBuffers ()
 Reimplement in subclass to native swap buffers calls. More...
 
 ~QWaylandReadbackEglContext ()
 
- 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
 
EGLConfig mConfig
 
EGLContext mContext
 
QWaylandReadbackEglIntegrationmEglIntegration
 
Pixmap mPixmap
 
EGLSurface mPixmapSurface
 
QWaylandReadbackEglWindowmWindow
 

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 53 of file qwaylandreadbackeglcontext.h.

Constructors and Destructors

◆ QWaylandReadbackEglContext()

QWaylandReadbackEglContext::QWaylandReadbackEglContext ( QWaylandReadbackEglIntegration eglIntegration,
QWaylandReadbackEglWindow window 
)

Definition at line 75 of file qwaylandreadbackeglcontext.cpp.

76  : mEglIntegration(eglIntegration)
77  , mWindow(window)
78  , mBuffer(0)
79  , mPixmap(0)
80  , mConfig(q_configFromQPlatformWindowFormat(eglIntegration->eglDisplay(),window->widget()->platformWindowFormat(),true,EGL_PIXMAP_BIT))
81  , mPixmapSurface(EGL_NO_SURFACE)
82 {
83  QVector<EGLint> eglContextAttrs;
84  eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
85  eglContextAttrs.append(2);
86  eglContextAttrs.append(EGL_NONE);
87 
88  mContext = eglCreateContext(eglIntegration->eglDisplay(),mConfig,0,eglContextAttrs.constData());
89 
91 }
EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType)
QWaylandReadbackEglIntegration * mEglIntegration
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
QWaylandReadbackEglWindow * mWindow
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

◆ ~QWaylandReadbackEglContext()

QWaylandReadbackEglContext::~QWaylandReadbackEglContext ( )

Definition at line 93 of file qwaylandreadbackeglcontext.cpp.

94 {
95  eglDestroyContext(mEglIntegration->eglDisplay(),mContext);
96 }
QWaylandReadbackEglIntegration * mEglIntegration

Functions

◆ doneCurrent()

void QWaylandReadbackEglContext::doneCurrent ( )
virtual

Reimplement in subclass to release current context.

Typically this is calling makeCurrent with 0 "surface"

Reimplemented from QPlatformGLContext.

Definition at line 107 of file qwaylandreadbackeglcontext.cpp.

108 {
110  eglMakeCurrent(mEglIntegration->eglDisplay(),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT);
111 }
virtual void doneCurrent()
Reimplement in subclass to release current context.
QWaylandReadbackEglIntegration * mEglIntegration

◆ geometryChanged()

void QWaylandReadbackEglContext::geometryChanged ( )

Definition at line 151 of file qwaylandreadbackeglcontext.cpp.

Referenced by QWaylandReadbackEglContext(), and QWaylandReadbackEglWindow::setGeometry().

152 {
153  QSize size(mWindow->geometry().size());
154  if (size.isEmpty()) {
155  //QGLWidget wants a context for a window without geometry
156  size = QSize(1,1);
157  }
158 
160 
161  delete mBuffer;
162  if (mPixmap)
163  XFreePixmap(mEglIntegration->xDisplay(),mPixmap);
164 
166  mWindow->attach(mBuffer);
167  mPixmap = XCreatePixmap(mEglIntegration->xDisplay(),mEglIntegration->rootWindow(),size.width(),size.height(),mEglIntegration->depth());
168  XSync(mEglIntegration->xDisplay(),False);
169 
170  mPixmapSurface = eglCreatePixmapSurface(mEglIntegration->eglDisplay(),mConfig,mPixmap,0);
171  if (mPixmapSurface == EGL_NO_SURFACE) {
172  qDebug() << "Could not make egl surface out of pixmap :(";
173  }
174 }
virtual QRect geometry() const
Returnes the current geometry of a window.
QWaylandReadbackEglIntegration * mEglIntegration
Q_CORE_EXPORT void qDebug(const char *,...)
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
void attach(QWaylandBuffer *buffer)
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QWaylandReadbackEglWindow * mWindow

◆ getProcAddress()

void * QWaylandReadbackEglContext::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 141 of file qwaylandreadbackeglcontext.cpp.

142 {
143  return (void *) eglGetProcAddress(procName.toLatin1().data());
144 }
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 QWaylandReadbackEglContext::makeCurrent ( )
virtual

Reimplement in subclass to do makeCurrent on native GL context.

Reimplemented from QPlatformGLContext.

Definition at line 98 of file qwaylandreadbackeglcontext.cpp.

Referenced by swapBuffers().

99 {
101 
103 
105 }
QWaylandReadbackEglIntegration * mEglIntegration
virtual void makeCurrent()
Reimplement in subclass to do makeCurrent on native GL context.
QWaylandReadbackEglWindow * mWindow

◆ platformWindowFormat()

QPlatformWindowFormat QWaylandReadbackEglContext::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 146 of file qwaylandreadbackeglcontext.cpp.

147 {
149 }
QWaylandReadbackEglIntegration * mEglIntegration
QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config)

◆ swapBuffers()

void QWaylandReadbackEglContext::swapBuffers ( )
virtual

Reimplement in subclass to native swap buffers calls.

Implements QPlatformGLContext.

Definition at line 113 of file qwaylandreadbackeglcontext.cpp.

114 {
115  eglSwapBuffers(mEglIntegration->eglDisplay(),mPixmapSurface);
116 
117  if (QPlatformGLContext::currentContext() != this) {
118  makeCurrent();
119  }
120 
121  QSize size = mWindow->geometry().size();
122 
123  QImage img(size,QImage::Format_ARGB32);
124  const uchar *constBits = img.bits();
125  void *pixels = const_cast<uchar *>(constBits);
126 
127  glReadPixels(0,0, size.width(), size.height(), GL_RGBA,GL_UNSIGNED_BYTE, pixels);
128 
129  img = img.mirrored();
131  constBits = img.bits();
132 
133  const uchar *constDstBits = mBuffer->image()->bits();
134  uchar *dstBits = const_cast<uchar *>(constDstBits);
135  memcpy(dstBits,constBits,(img.width()*4) * img.height());
136 
137 
138  mWindow->damage(QRegion(QRect(QPoint(0,0),size)));
139 }
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
QWaylandReadbackEglIntegration * mEglIntegration
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
void makeCurrent()
Reimplement in subclass to do makeCurrent on native GL context.
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
static void qgl_byteSwapImage(QImage &img, GLenum pixel_type)
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
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void damage(const QRect &rect)
QWaylandReadbackEglWindow * mWindow

Properties

◆ mBuffer

QWaylandShmBuffer* QWaylandReadbackEglContext::mBuffer
private

Definition at line 71 of file qwaylandreadbackeglcontext.h.

Referenced by geometryChanged(), and swapBuffers().

◆ mConfig

EGLConfig QWaylandReadbackEglContext::mConfig
private

◆ mContext

EGLContext QWaylandReadbackEglContext::mContext
private

◆ mEglIntegration

QWaylandReadbackEglIntegration* QWaylandReadbackEglContext::mEglIntegration
private

◆ mPixmap

Pixmap QWaylandReadbackEglContext::mPixmap
private

Definition at line 73 of file qwaylandreadbackeglcontext.h.

Referenced by geometryChanged().

◆ mPixmapSurface

EGLSurface QWaylandReadbackEglContext::mPixmapSurface
private

Definition at line 77 of file qwaylandreadbackeglcontext.h.

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

◆ mWindow

QWaylandReadbackEglWindow* QWaylandReadbackEglContext::mWindow
private

Definition at line 70 of file qwaylandreadbackeglcontext.h.

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


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