summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r--src/opengl/qgl.cpp40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index f4bf8fd68b..f033b51edd 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1719,7 +1719,7 @@ QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alp
int w = size.width();
int h = size.height();
#ifndef QT_OPENGL_ES
- if (!QOpenGLContext::currentContext()->isES()) {
+ if (!QOpenGLContext::currentContext()->isOpenGLES()) {
qgl1_functions()->glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
}
@@ -2305,7 +2305,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
funcs->glTexParameteri(target, GL_TEXTURE_MAG_FILTER, filtering);
QOpenGLContext *ctx = QOpenGLContext::currentContext();
- bool genMipmap = !ctx->isES();
+ bool genMipmap = !ctx->isOpenGLES();
if (glFormat.directRendering()
&& (qgl_extensions()->hasOpenGLExtension(QOpenGLExtensions::GenerateMipmap))
&& target == GL_TEXTURE_2D
@@ -2447,7 +2447,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
printf(" - did byte swapping (%d ms)\n", time.elapsed());
#endif
}
- if (ctx->isES()) {
+ if (ctx->isOpenGLES()) {
// OpenGL/ES requires that the internal and external formats be
// identical.
internalFormat = externalFormat;
@@ -2460,7 +2460,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
const QImage &constRef = img; // to avoid detach in bits()...
funcs->glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat,
pixel_type, constRef.bits());
- if (genMipmap && ctx->isES())
+ if (genMipmap && ctx->isOpenGLES())
q->functions()->glGenerateMipmap(target);
#ifndef QT_NO_DEBUG
GLenum error = funcs->glGetError();
@@ -2517,7 +2517,19 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target,
}
if (!texture) {
- QImage image = pixmap.toImage();
+ QImage image;
+ QPaintEngine* paintEngine = pixmap.paintEngine();
+ if (!paintEngine || paintEngine->type() != QPaintEngine::Raster)
+ image = pixmap.toImage();
+ else {
+ // QRasterPixmapData::toImage() will deep-copy the backing QImage if there's an active QPainter on it.
+ // For performance reasons, we don't want that here, so we temporarily redirect the paint engine.
+ QPaintDevice* currentPaintDevice = paintEngine->paintDevice();
+ paintEngine->setPaintDevice(0);
+ image = pixmap.toImage();
+ paintEngine->setPaintDevice(currentPaintDevice);
+ }
+
// If the system depth is 16 and the pixmap doesn't have an alpha channel
// then we convert it to RGB16 in the hope that it gets uploaded as a 16
// bit texture which is much faster to access than a 32-bit one.
@@ -2545,7 +2557,7 @@ int QGLContextPrivate::maxTextureSize()
#ifndef QT_OPENGL_ES
Q_Q(QGLContext);
- if (!q->contextHandle()->isES()) {
+ if (!q->contextHandle()->isOpenGLES()) {
GLenum proxy = GL_PROXY_TEXTURE_2D;
GLint size;
@@ -2725,7 +2737,7 @@ static void qDrawTextureRect(const QRectF &target, GLint textureWidth, GLint tex
Q_UNUSED(textureHeight);
Q_UNUSED(textureTarget);
#else
- if (textureTarget != GL_TEXTURE_2D && !QOpenGLContext::currentContext()->isES()) {
+ if (textureTarget != GL_TEXTURE_2D && !QOpenGLContext::currentContext()->isOpenGLES()) {
if (textureWidth == -1 || textureHeight == -1) {
QOpenGLFunctions_1_1 *gl1funcs = qgl1_functions();
gl1funcs->glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth);
@@ -2795,7 +2807,7 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text
#ifndef QT_OPENGL_ES_2
QOpenGLFunctions *funcs = qgl_functions();
- if (!contextHandle()->isES()) {
+ if (!contextHandle()->isOpenGLES()) {
#ifdef QT_OPENGL_ES
if (textureTarget != GL_TEXTURE_2D) {
qWarning("QGLContext::drawTexture(): texture target must be GL_TEXTURE_2D on OpenGL ES");
@@ -2857,7 +2869,7 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text
Q_UNUSED(textureId);
Q_UNUSED(textureTarget);
#else
- if (!contextHandle()->isES()) {
+ if (!contextHandle()->isOpenGLES()) {
QOpenGLFunctions *funcs = qgl_functions();
const bool wasEnabled = funcs->glIsEnabled(GL_TEXTURE_2D);
GLint oldTexture;
@@ -4163,7 +4175,7 @@ void QGLWidget::glDraw()
return;
makeCurrent();
#ifndef QT_OPENGL_ES
- if (d->glcx->deviceIsPixmap() && !d->glcx->contextHandle()->isES())
+ if (d->glcx->deviceIsPixmap() && !d->glcx->contextHandle()->isOpenGLES())
qgl1_functions()->glDrawBuffer(GL_FRONT);
#endif
QSize readback_target_size = d->glcx->d_ptr->readback_target_size;
@@ -4208,7 +4220,7 @@ void QGLWidget::qglColor(const QColor& c) const
#else
Q_D(const QGLWidget);
const QGLContext *ctx = QGLContext::currentContext();
- if (ctx && !ctx->contextHandle()->isES()) {
+ if (ctx && !ctx->contextHandle()->isOpenGLES()) {
if (ctx->format().rgba())
qgl1_functions()->glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF());
else if (!d->cmap.isEmpty()) { // QGLColormap in use?
@@ -4240,7 +4252,7 @@ void QGLWidget::qglClearColor(const QColor& c) const
#else
Q_D(const QGLWidget);
const QGLContext *ctx = QGLContext::currentContext();
- if (ctx && !ctx->contextHandle()->isES()) {
+ if (ctx && !ctx->contextHandle()->isOpenGLES()) {
if (ctx->format().rgba())
qgl_functions()->glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
else if (!d->cmap.isEmpty()) { // QGLColormap in use?
@@ -4420,7 +4432,7 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font)
{
#ifndef QT_OPENGL_ES
Q_D(QGLWidget);
- if (!d->glcx->contextHandle()->isES()) {
+ if (!d->glcx->contextHandle()->isOpenGLES()) {
Q_D(QGLWidget);
if (str.isEmpty() || !isValid())
return;
@@ -4511,7 +4523,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con
{
#ifndef QT_OPENGL_ES
Q_D(QGLWidget);
- if (!d->glcx->contextHandle()->isES()) {
+ if (!d->glcx->contextHandle()->isOpenGLES()) {
Q_D(QGLWidget);
if (str.isEmpty() || !isValid())
return;