Qt 4.8
Public Functions | Public Variables | List of all members
QGLPixelBufferPrivate Class Reference

#include <qglpixelbuffer_p.h>

Public Functions

bool cleanup ()
 
void common_init (const QSize &size, const QGLFormat &f, QGLWidget *shareWidget)
 
bool init (const QSize &size, const QGLFormat &f, QGLWidget *shareWidget)
 
 QGLPixelBufferPrivate (QGLPixelBuffer *q)
 

Public Variables

HGLRC ctx
 
QEglContextctx
 
HDC dc
 
QGLFormat format
 
QGLPBufferGLPaintDevice glDevice
 
bool has_render_texture:1
 
bool invalid
 
HPBUFFERARB pbuf
 
EGLSurface pbuf
 
QGLPixelBufferq_ptr
 
QGLContextqctx
 
QGLFormat req_format
 
QPointer< QGLWidgetreq_shareWidget
 
QSize req_size
 
int textureFormat
 

Detailed Description

Definition at line 150 of file qglpixelbuffer_p.h.

Constructors and Destructors

◆ QGLPixelBufferPrivate()

QGLPixelBufferPrivate::QGLPixelBufferPrivate ( QGLPixelBuffer q)
inline

Definition at line 153 of file qglpixelbuffer_p.h.

153  : q_ptr(q), invalid(true), qctx(0), pbuf(0), ctx(0)
154  {
155 #ifdef Q_WS_WIN
156  dc = 0;
157 #elif defined(Q_WS_MACX)
158  share_ctx = 0;
159 #endif
160  }
QGLPixelBuffer * q_ptr

Functions

◆ cleanup()

bool QGLPixelBufferPrivate::cleanup ( )

Definition at line 154 of file qglpixelbuffer_egl.cpp.

Referenced by nearest_gl_texture_size(), and qt_format_to_attrib_list().

155 {
156  // No need to destroy "pbuf" here - it is done in QGLContext::reset().
157  return true;
158 }

◆ common_init()

void QGLPixelBufferPrivate::common_init ( const QSize size,
const QGLFormat f,
QGLWidget shareWidget 
)

Definition at line 137 of file qglpixelbuffer.cpp.

138 {
140  if(init(size, format, shareWidget)) {
141  req_size = size;
142  req_format = format;
143  req_shareWidget = shareWidget;
144  invalid = false;
145  qctx = new QGLContext(format);
146  qctx->d_func()->sharing = (shareWidget != 0);
147  if (shareWidget != 0 && shareWidget->d_func()->glcx) {
148  QGLContextGroup::addShare(qctx, shareWidget->d_func()->glcx);
149  shareWidget->d_func()->glcx->d_func()->sharing = true;
150  }
151 
152  glDevice.setPBuffer(q);
153  qctx->d_func()->paintDevice = q;
154  qctx->d_func()->valid = true;
155 #if defined(Q_WS_WIN) && !defined(QT_OPENGL_ES)
156  qctx->d_func()->dc = dc;
157  qctx->d_func()->rc = ctx;
158 #elif (defined(Q_WS_X11) && defined(QT_NO_EGL))
159  qctx->d_func()->cx = ctx;
160  qctx->d_func()->pbuf = (void *) pbuf;
161  qctx->d_func()->vi = 0;
162 #elif defined(Q_WS_MAC)
163  qctx->d_func()->cx = ctx;
164  qctx->d_func()->vi = 0;
165 #elif !defined(QT_NO_EGL)
166  qctx->d_func()->eglContext = ctx;
167  qctx->d_func()->eglSurface = pbuf;
168 #endif
169  }
170 }
static void addShare(const QGLContext *context, const QGLContext *share)
Definition: qgl.cpp:5846
void setPBuffer(QGLPixelBuffer *pb)
QPointer< QGLWidget > req_shareWidget
#define Q_Q(Class)
Definition: qglobal.h:2483
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
The QGLPixelBuffer class encapsulates an OpenGL pbuffer.
bool init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget)
QGLPBufferGLPaintDevice glDevice

◆ init()

bool QGLPixelBufferPrivate::init ( const QSize size,
const QGLFormat f,
QGLWidget shareWidget 
)

Definition at line 58 of file qglpixelbuffer_egl.cpp.

Referenced by nearest_gl_texture_size(), and qt_format_to_attrib_list().

59 {
60  // Create the EGL context.
61  ctx = new QEglContext();
62  ctx->setApi(QEgl::OpenGL);
63 
64  // Find the shared context.
65  QEglContext *shareContext = 0;
66  if (shareWidget && shareWidget->d_func()->glcx)
67  shareContext = shareWidget->d_func()->glcx->d_func()->eglContext;
68 
69  // Choose an appropriate configuration. We use the best format
70  // we can find, even if it is greater than the requested format.
71  // We try for a pbuffer that is capable of texture rendering if possible.
72  textureFormat = EGL_NONE;
73  if (shareContext) {
74  // Use the same configuration as the widget we are sharing with.
75  ctx->setConfig(shareContext->config());
76 #if QGL_RENDER_TEXTURE
77  if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGBA) == EGL_TRUE)
78  textureFormat = EGL_TEXTURE_RGBA;
79  else if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGB) == EGL_TRUE)
80  textureFormat = EGL_TEXTURE_RGB;
81 #endif
82  } else {
83  QEglProperties configProps;
84  qt_eglproperties_set_glformat(configProps, f);
85  configProps.setDeviceType(QInternal::Pbuffer);
86  configProps.setRenderableType(ctx->api());
87  bool ok = false;
88 #if QGL_RENDER_TEXTURE
89  textureFormat = EGL_TEXTURE_RGBA;
90  configProps.setValue(EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE);
91  ok = ctx->chooseConfig(configProps, QEgl::BestPixelFormat);
92  if (!ok) {
93  // Try again with RGB texture rendering.
94  textureFormat = EGL_TEXTURE_RGB;
95  configProps.removeValue(EGL_BIND_TO_TEXTURE_RGBA);
96  configProps.setValue(EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE);
97  ok = ctx->chooseConfig(configProps, QEgl::BestPixelFormat);
98  if (!ok) {
99  // One last try for a pbuffer with no texture rendering.
100  configProps.removeValue(EGL_BIND_TO_TEXTURE_RGB);
101  textureFormat = EGL_NONE;
102  }
103  }
104 #endif
105  if (!ok) {
106  if (!ctx->chooseConfig(configProps, QEgl::BestPixelFormat)) {
107  delete ctx;
108  ctx = 0;
109  return false;
110  }
111  }
112  }
113 
114  // Retrieve the actual format properties.
116 
117  // Create the attributes needed for the pbuffer.
118  QEglProperties attribs;
119  attribs.setValue(EGL_WIDTH, size.width());
120  attribs.setValue(EGL_HEIGHT, size.height());
121 #if QGL_RENDER_TEXTURE
122  if (textureFormat != EGL_NONE) {
123  attribs.setValue(EGL_TEXTURE_FORMAT, textureFormat);
124  attribs.setValue(EGL_TEXTURE_TARGET, EGL_TEXTURE_2D);
125  }
126 #endif
127 
128  // Create the pbuffer surface.
129  pbuf = eglCreatePbufferSurface(ctx->display(), ctx->config(), attribs.properties());
130 #if QGL_RENDER_TEXTURE
131  if (pbuf == EGL_NO_SURFACE && textureFormat != EGL_NONE) {
132  // Try again with texture rendering disabled.
133  textureFormat = EGL_NONE;
134  attribs.removeValue(EGL_TEXTURE_FORMAT);
135  attribs.removeValue(EGL_TEXTURE_TARGET);
136  pbuf = eglCreatePbufferSurface(ctx->display(), ctx->config(), attribs.properties());
137  }
138 #endif
139  if (pbuf == EGL_NO_SURFACE) {
140  qWarning() << "QGLPixelBufferPrivate::init(): Unable to create EGL pbuffer surface:" << QEgl::errorString();
141  return false;
142  }
143 
144  // Create a new context for the configuration.
145  if (!ctx->createContext(shareContext)) {
146  delete ctx;
147  ctx = 0;
148  return false;
149  }
150 
151  return true;
152 }
void qt_glformat_from_eglconfig(QGLFormat &format, const EGLConfig config)
Definition: qgl_egl.cpp:145
bool removeValue(int name)
void setValue(int name, int value)
EGLConfig config() const
Definition: qeglcontext_p.h:96
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
Definition: qegl.cpp:743
int width() const
Returns the width.
Definition: qsize.h:126
void setRenderableType(QEgl::API api)
Q_CORE_EXPORT void qWarning(const char *,...)
int height() const
Returns the height.
Definition: qsize.h:129
void setDeviceType(int devType)
void qt_eglproperties_set_glformat(QEglProperties &eglProperties, const QGLFormat &glFormat)
Definition: qgl_egl.cpp:61

Properties

◆ ctx [1/2]

HGLRC QGLPixelBufferPrivate::ctx

Definition at line 183 of file qglpixelbuffer_p.h.

Referenced by init(), nearest_gl_texture_size(), and qt_format_to_attrib_list().

◆ ctx [2/2]

QEglContext* QGLPixelBufferPrivate::ctx

Definition at line 198 of file qglpixelbuffer_p.h.

◆ dc

HDC QGLPixelBufferPrivate::dc

Definition at line 179 of file qglpixelbuffer_p.h.

Referenced by qt_format_to_attrib_list().

◆ format

QGLFormat QGLPixelBufferPrivate::format

Definition at line 169 of file qglpixelbuffer_p.h.

◆ glDevice

QGLPBufferGLPaintDevice QGLPixelBufferPrivate::glDevice

Definition at line 168 of file qglpixelbuffer_p.h.

◆ has_render_texture

bool QGLPixelBufferPrivate::has_render_texture

Definition at line 180 of file qglpixelbuffer_p.h.

Referenced by qt_format_to_attrib_list().

◆ invalid

bool QGLPixelBufferPrivate::invalid

Definition at line 166 of file qglpixelbuffer_p.h.

Referenced by qt_format_to_attrib_list().

◆ pbuf [1/2]

HPBUFFERARB QGLPixelBufferPrivate::pbuf

Definition at line 182 of file qglpixelbuffer_p.h.

Referenced by init(), nearest_gl_texture_size(), and qt_format_to_attrib_list().

◆ pbuf [2/2]

EGLSurface QGLPixelBufferPrivate::pbuf

Definition at line 197 of file qglpixelbuffer_p.h.

◆ q_ptr

QGLPixelBuffer* QGLPixelBufferPrivate::q_ptr

Definition at line 165 of file qglpixelbuffer_p.h.

◆ qctx

QGLContext* QGLPixelBufferPrivate::qctx

Definition at line 167 of file qglpixelbuffer_p.h.

Referenced by QGLWindowSurface::updateGeometry().

◆ req_format

QGLFormat QGLPixelBufferPrivate::req_format

Definition at line 171 of file qglpixelbuffer_p.h.

◆ req_shareWidget

QPointer<QGLWidget> QGLPixelBufferPrivate::req_shareWidget

Definition at line 172 of file qglpixelbuffer_p.h.

◆ req_size

QSize QGLPixelBufferPrivate::req_size

Definition at line 173 of file qglpixelbuffer_p.h.

◆ textureFormat

int QGLPixelBufferPrivate::textureFormat

Definition at line 199 of file qglpixelbuffer_p.h.

Referenced by init().


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