diff options
Diffstat (limited to 'src/opengl/qpaintengine_opengl.cpp')
-rw-r--r-- | src/opengl/qpaintengine_opengl.cpp | 74 |
1 files changed, 60 insertions, 14 deletions
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index f1169fd..ff00f29 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -2116,7 +2116,7 @@ void QOpenGLPaintEngine::updatePen(const QPen &pen) Qt::PenStyle pen_style = pen.style(); d->pen_brush_style = pen.brush().style(); d->cpen = pen; - d->has_pen = (pen_style != Qt::NoPen); + d->has_pen = (pen_style != Qt::NoPen) && (d->pen_brush_style != Qt::NoBrush); d->updateUseEmulation(); if (pen.isCosmetic()) { @@ -4300,8 +4300,10 @@ void QOpenGLPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QR else { GLenum target = qt_gl_preferredTextureTarget(); d->flushDrawQueue(); - d->device->context()->bindTexture(pm, target); - drawTextureRect(pm.width(), pm.height(), r, sr, target); + QGLTexture *tex = + d->device->context()->d_func()->bindTexture(pm, target, GL_RGBA, + QGLContext::InternalBindOption); + drawTextureRect(pm.width(), pm.height(), r, sr, target, tex); } } @@ -4333,10 +4335,13 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con } else { d->flushDrawQueue(); + QGLTexture *tex; if (scaled.isNull()) - d->device->context()->bindTexture(pm); + tex = d->device->context()->d_func()->bindTexture(pm, GL_TEXTURE_2D, GL_RGBA, + QGLContext::InternalBindOption); else - d->device->context()->bindTexture(scaled); + tex = d->device->context()->d_func()->bindTexture(scaled, GL_TEXTURE_2D, GL_RGBA, + QGLContext::InternalBindOption); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, d->use_smooth_pixmap_transform); #ifndef QT_OPENGL_ES @@ -4349,6 +4354,15 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con GLdouble tc_w = r.width()/pm.width(); GLdouble tc_h = r.height()/pm.height(); + // Rotate the texture so that it is aligned correctly and the + // wrapping is done correctly + if (tex->options & QGLContext::InvertedYBindOption) { + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glRotatef(180.0, 0.0, 1.0, 0.0); + glRotatef(180.0, 0.0, 0.0, 1.0); + } + q_vertexType vertexArray[4*2]; q_vertexType texCoordArray[4*2]; @@ -4367,6 +4381,8 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); + if (tex->options & QGLContext::InvertedYBindOption) + glPopMatrix(); glDisable(GL_TEXTURE_2D); #ifndef QT_OPENGL_ES @@ -4402,13 +4418,15 @@ void QOpenGLPaintEngine::drawImage(const QRectF &r, const QImage &image, const Q else { GLenum target = qt_gl_preferredTextureTarget(); d->flushDrawQueue(); - d->device->context()->bindTexture(image, target); - drawTextureRect(image.width(), image.height(), r, sr, target); + QGLTexture *tex = + d->device->context()->d_func()->bindTexture(image, target, GL_RGBA, + QGLContext::InternalBindOption); + drawTextureRect(image.width(), image.height(), r, sr, target, tex); } } void QOpenGLPaintEngine::drawTextureRect(int tx_width, int tx_height, const QRectF &r, - const QRectF &sr, GLenum target) + const QRectF &sr, GLenum target, QGLTexture *tex) { Q_D(QOpenGLPaintEngine); #ifndef QT_OPENGL_ES @@ -4423,8 +4441,13 @@ void QOpenGLPaintEngine::drawTextureRect(int tx_width, int tx_height, const QRec if (target == GL_TEXTURE_2D) { x1 = sr.x() / tx_width; x2 = x1 + sr.width() / tx_width; - y1 = 1 - (sr.bottom() / tx_height); - y2 = 1 - (sr.y() / tx_height); + if (tex->options & QGLContext::InvertedYBindOption) { + y1 = 1 - (sr.bottom() / tx_height); + y2 = 1 - (sr.y() / tx_height); + } else { + y1 = sr.bottom() / tx_height; + y2 = sr.y() / tx_height; + } } else { x1 = sr.x(); x2 = sr.right(); @@ -4767,7 +4790,24 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, const QTextItemInt &ti, } } - QImage glyph_im(ti.fontEngine->alphaMapForGlyph(glyphs[i]).convertToFormat(QImage::Format_Indexed8)); + QImage glyph_im(ti.fontEngine->alphaMapForGlyph(glyphs[i])); + + // The QPF implementation of alphaMapForGlyph() uses the color + // RGBA = (value, value, value, 255) instead of the color + // RGBA = (0, 0, 0, value) that the other font engines use. + // We modify the image colors to rectify this situation. + QFontEngine::Type type = ti.fontEngine->type(); + if (type == QFontEngine::QPF1 || type == QFontEngine::QPF2) { + if (glyph_im.format() == QImage::Format_Indexed8) { + for (int i = 0; i < 256; ++i) + glyph_im.setColor(i, qRgba(0, 0, 0, i)); + } else if (glyph_im.format() == QImage::Format_Mono) { + glyph_im.setColor(0, qRgba(0, 0, 0, 0)); + glyph_im.setColor(1, qRgba(0, 0, 0, 255)); + } + } + + glyph_im = glyph_im.convertToFormat(QImage::Format_Indexed8); glyph_width = glyph_im.width(); Q_ASSERT(glyph_width >= 0); // pad the glyph width to an even number @@ -5179,9 +5219,12 @@ void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType * glActiveTexture(GL_TEXTURE0 + brush_texture_location); if (current_style == Qt::TexturePattern) - device->context()->bindTexture(cbrush.textureImage()); + device->context()->d_func()->bindTexture(cbrush.textureImage(), GL_TEXTURE_2D, GL_RGBA, + QGLContext::InternalBindOption); else - device->context()->bindTexture(qt_imageForBrush(current_style, true)); + device->context()->d_func()->bindTexture(qt_imageForBrush(current_style, true), + GL_TEXTURE_2D, GL_RGBA, + QGLContext::InternalBindOption); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, use_smooth_pixmap_transform); } @@ -5588,8 +5631,11 @@ QPixmapFilter *QOpenGLPaintEngine::createPixmapFilter(int type) const if (QGLContext::currentContext()) return QGLContext::currentContext()->d_func()->createPixmapFilter(type); else -#endif return 0; +#else + Q_UNUSED(type); + return 0; +#endif } |