96 #include <QtCore/qglobal.h> 98 #if !defined(QT_OPENGL_ES_1) 99 #include <private/qpaintengineex_opengl2_p.h> 103 #include <private/qglpixelbuffer_p.h> 104 #include <private/qfont_p.h> 107 #ifndef QT_OPENGL_ES_2 108 #include <private/qpaintengine_opengl_p.h> 113 #if !defined(QT_OPENGL_ES_2) 124 return pbuf->d_func()->qctx;
140 if(
init(size, format, shareWidget)) {
143 req_shareWidget = shareWidget;
146 qctx->d_func()->sharing = (shareWidget != 0);
147 if (shareWidget != 0 && shareWidget->d_func()->glcx) {
149 shareWidget->d_func()->glcx->d_func()->sharing =
true;
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;
188 d->common_init(size, format, shareWidget);
213 d->common_init(
QSize(width, height), format, shareWidget);
230 if (current !=
d->qctx)
235 if (current && current !=
d->qctx)
255 d->qctx->makeCurrent();
273 d->qctx->doneCurrent();
286 #if (defined(Q_WS_X11) || defined(Q_WS_WIN)) && defined(QT_NO_EGL) 291 glGenTextures(1, &texture);
373 glCopyTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0,
d->req_size.width(),
d->req_size.height(), 0);
379 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS 428 #if !defined(QT_OPENGL_ES_1) 432 #ifndef QT_OPENGL_ES_2 439 #if defined(QT_OPENGL_ES_1) 440 return qt_buffer_engine()->engine();
441 #elif defined(QT_OPENGL_ES_2) 442 return qt_buffer_2_engine()->engine();
445 return qt_buffer_2_engine()->engine();
447 return qt_buffer_engine()->engine();
458 int w =
d->req_size.width();
459 int h =
d->req_size.height();
468 return qRound(w * 1000 / dpmx);
471 return qRound(h * 1000 / dpmy);
480 return qRound(dpmx * 0.0254);
483 return qRound(dpmy * 0.0254);
486 return qRound(dpmx * 0.0254);
489 return qRound(dpmy * 0.0254);
492 qWarning(
"QGLPixelBuffer::metric(), Unhandled metric type: %d\n", metric);
513 return d->qctx->bindTexture(image, target,
GLint(GL_RGBA8));
515 return d->qctx->bindTexture(image, target,
GL_RGBA);
519 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS 524 return d->qctx->bindTexture(image, target, QMacCompatGLint(GL_RGBA8));
543 return d->qctx->bindTexture(pixmap, target,
GLint(GL_RGBA8));
545 return d->qctx->bindTexture(pixmap, target,
GL_RGBA);
549 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS 554 return d->qctx->bindTexture(pixmap, target, QMacCompatGLint(GL_RGBA8));
573 return d->qctx->bindTexture(fileName);
584 d->qctx->deleteTexture(texture_id);
587 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS 592 d->qctx->deleteTexture(texture_id);
611 d->qctx->drawTexture(target, textureId, textureTarget);
614 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS 619 d->qctx->drawTexture(target, textureId, textureTarget);
637 d->qctx->drawTexture(point, textureId, textureTarget);
640 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS 645 d->qctx->drawTexture(point, textureId, textureTarget);
virtual QGLFormat format() const
QGLFormat format() const
Returns the format of the pbuffer.
virtual ~QGLPixelBuffer()
Destroys the pbuffer and frees any allocated resources.
virtual QSize size() const
static void addShare(const QGLContext *context, const QGLContext *share)
void setPBuffer(QGLPixelBuffer *pb)
#define GL_TEXTURE_MIN_FILTER
QGLPixelBuffer(const QSize &size, const QGLFormat &format=QGLFormat::defaultFormat(), QGLWidget *shareWidget=0)
Constructs an OpenGL pbuffer of the given size.
#define QT_END_NAMESPACE
This macro expands to.
virtual QGLContext * context() const
bool doneCurrent()
Makes no context the current OpenGL context.
Q_GUI_EXPORT int qt_defaultDpiY()
Q_GUI_EXPORT int qt_defaultDpiX()
The QPointF class defines a point in the plane using floating point precision.
The QString class provides a Unicode character string.
void updateDynamicTexture(GLuint texture_id) const
Copies the pbuffer contents into the texture specified with texture_id.
GLuint bindTexture(const QImage &image, GLenum target=GL_TEXTURE_2D)
Generates and binds a 2D GL texture to the current context, based on image.
bool makeCurrent()
Makes this pbuffer the current OpenGL rendering context.
QSize size() const
Returns the size of the pbuffer.
static const QGLContext * currentContext()
Returns the current context, i.e.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
void common_init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget)
The QGLContext class encapsulates an OpenGL rendering context.
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
QImage toImage() const
Returns the contents of the pbuffer as a QImage.
bool isValid() const
Returns true if this pbuffer is valid; otherwise returns false.
The QGLPixelBuffer class encapsulates an OpenGL pbuffer.
void qgl_cleanup_glyph_cache(QGLContext *)
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
QImage qt_gl_read_framebuffer(const QSize &, bool, bool)
bool qt_gl_preferGL2Engine()
QScopedPointer< QGLPixelBufferPrivate > d_ptr
void deleteTexture(GLuint texture_id)
Removes the texture identified by texture_id from the texture cache.
int metric(PaintDeviceMetric metric) const
Reimplemented Function
virtual void makeCurrent()
Makes this context the current OpenGL rendering context.
The QPixmap class is an off-screen image representation that can be used as a paint device...
QScopedPointer< QObjectData > d_ptr
GLuint generateDynamicTexture() const
The QSize class defines the size of a two-dimensional object using integer point precision.
#define GL_TEXTURE_MAG_FILTER
Qt::HANDLE handle() const
Returns the native pbuffer handle.
static QString fileName(const QString &fileUrl)
void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget=GL_TEXTURE_2D)
Draws the given texture, textureId, to the given target rectangle, target, in OpenGL model space...
Q_DECL_CONSTEXPR int qRound(qreal d)
QPaintEngine * paintEngine() const
Reimplemented Function