diff options
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 88 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 9 | ||||
-rw-r--r-- | src/opengl/qgl.cpp | 25 |
3 files changed, 13 insertions, 109 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 90b7214..0f8e945 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -227,11 +227,6 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) pex->transferMode(BrushDrawingMode); -#ifndef QT_OPENGL_ES_2 - if (pex->inRenderText) - glPushAttrib(GL_ENABLE_BIT | GL_VIEWPORT_BIT | GL_SCISSOR_BIT); -#endif - glDisable(GL_STENCIL_TEST); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); @@ -276,11 +271,6 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glViewport(0, 0, pex->width, pex->height); pex->updateClipScissorTest(); - -#ifndef QT_OPENGL_ES_2 - if (pex->inRenderText) - glPopAttrib(); -#endif } void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) @@ -965,20 +955,11 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) // Pass when high bit is set, replace stencil value with 0 glStencilFunc(GL_NOTEQUAL, 0, GL_STENCIL_HIGH_BIT); } - prepareForDraw(currentBrush.isOpaque()); - if (inRenderText) - prepareDepthRangeForRenderText(); - // Stencil the brush onto the dest buffer composite(vertexCoordinateArray.boundingRect()); - - if (inRenderText) - restoreDepthRangeForRenderText(); - glStencilMask(0); - updateClipScissorTest(); } } @@ -1017,13 +998,6 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, useSimpleShader(); glEnable(GL_STENCIL_TEST); // For some reason, this has to happen _after_ the simple shader is use()'d -#ifndef QT_OPENGL_ES_2 - if (inRenderText) { - glPushAttrib(GL_ENABLE_BIT); - glDisable(GL_DEPTH_TEST); - } -#endif - if (mode == WindingFillMode) { Q_ASSERT(stops && !count); if (q->state()->clipTestEnabled) { @@ -1082,12 +1056,6 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, // Enable color writes & disable stencil writes glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - -#ifndef QT_OPENGL_ES_2 - if (inRenderText) - glPopAttrib(); -#endif - } /* @@ -1227,30 +1195,6 @@ void QGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stops, i } } -void QGL2PaintEngineExPrivate::prepareDepthRangeForRenderText() -{ -#ifndef QT_OPENGL_ES_2 - // Get the z translation value from the model view matrix and - // transform it using the ortogonal projection with z-near = 0, - // and z-far = 1, which is used in QGLWidget::renderText() - GLdouble model[4][4]; - glGetDoublev(GL_MODELVIEW_MATRIX, &model[0][0]); - float deviceZ = -2 * model[3][2] - 1; - - glGetFloatv(GL_DEPTH_RANGE, depthRange); - float windowZ = depthRange[0] + (deviceZ + 1) * 0.5 * (depthRange[1] - depthRange[0]); - - glDepthRange(windowZ, windowZ); -#endif -} - -void QGL2PaintEngineExPrivate::restoreDepthRangeForRenderText() -{ -#ifndef QT_OPENGL_ES_2 - glDepthRange(depthRange[0], depthRange[1]); -#endif -} - /////////////////////////////////// Public Methods ////////////////////////////////////////// QGL2PaintEngineEx::QGL2PaintEngineEx() @@ -1268,10 +1212,7 @@ void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush) if (qbrush_style(brush) == Qt::NoBrush) return; - - if (!d->inRenderText) - ensureActive(); - + ensureActive(); d->setBrush(brush); d->fill(path); } @@ -1486,8 +1427,7 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem { Q_D(QGL2PaintEngineEx); - if (!d->inRenderText) - ensureActive(); + ensureActive(); QOpenGL2PaintEngineState *s = state(); const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); @@ -1506,7 +1446,7 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) : d->glyphCacheType; - if (d->inRenderText || txtype > QTransform::TxTranslate) + if (txtype > QTransform::TxTranslate) glyphType = QFontEngineGlyphCache::Raster_A8; if (glyphType == QFontEngineGlyphCache::Raster_RGBMask @@ -1548,8 +1488,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly if (cache->width() == 0 || cache->height() == 0) return; - if (inRenderText) - transferMode(BrushDrawingMode); transferMode(TextDrawingMode); int margin = cache->glyphMargin(); @@ -1585,9 +1523,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly QBrush pensBrush = q->state()->pen.brush(); setBrush(pensBrush); - if (inRenderText) - prepareDepthRangeForRenderText(); - if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { // Subpixel antialiasing without gamma correction @@ -1672,9 +1607,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::MaskTexture), QT_MASK_TEXTURE_UNIT); glDrawArrays(GL_TRIANGLES, 0, 6 * glyphs.size()); - - if (inRenderText) - restoreDepthRangeForRenderText(); } void QGL2PaintEngineEx::drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints) @@ -1822,11 +1754,9 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->shaderManager = new QGLEngineShaderManager(d->ctx); - if (!d->inRenderText) { - glDisable(GL_STENCIL_TEST); - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - } + glDisable(GL_STENCIL_TEST); + glDisable(GL_DEPTH_TEST); + glDisable(GL_SCISSOR_TEST); #if !defined(QT_OPENGL_ES_2) glDisable(GL_MULTISAMPLE); @@ -2267,12 +2197,6 @@ QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const return s; } -void QGL2PaintEngineEx::setRenderTextActive(bool active) -{ - Q_D(QGL2PaintEngineEx); - d->inRenderText = active; -} - QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState &other) : QPainterState(other) { diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index c94c4f4..9a5c447 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -168,8 +168,7 @@ public: ctx(0), useSystemClip(true), addOffset(false), - inverseScale(1), - inRenderText(false) + inverseScale(1) { } ~QGL2PaintEngineExPrivate(); @@ -215,10 +214,6 @@ public: return shaderManager->getUniformLocation(uniform); } - - void prepareDepthRangeForRenderText(); - void restoreDepthRangeForRenderText(); - void clearClip(uint value); void writeClip(const QVectorPath &path, uint value); void resetClipIfNeeded(); @@ -228,7 +223,6 @@ public: void regenerateClip(); void systemStateChanged(); - static QGLEngineShaderManager* shaderManagerForEngine(QGL2PaintEngineEx *engine) { return engine->d_func()->shaderManager; } static QGL2PaintEngineExPrivate *getData(QGL2PaintEngineEx *engine) { return engine->d_func(); } static void cleanupVectorPath(QPaintEngineEx *engine, void *data); @@ -273,7 +267,6 @@ public: GLuint lastTextureUsed; bool needsSync; - bool inRenderText; bool multisamplingAlwaysEnabled; GLfloat depthRange[2]; diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 5bb62f7..f5e46de 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4409,9 +4409,9 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, int height = d->glcx->device()->height(); bool auto_swap = autoBufferSwap(); + QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); + qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); QPaintEngine *engine = paintEngine(); - if (engine->type() == QPaintEngine::OpenGL2) - static_cast<QGL2PaintEngineEx *>(engine)->setRenderTextActive(true); QPainter *p; bool reuse_painter = false; if (engine->isActive()) { @@ -4431,11 +4431,6 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, setAutoBufferSwap(false); // disable glClear() as a result of QPainter::begin() d->disable_clear_on_painter_begin = true; - if (engine->type() == QPaintEngine::OpenGL2) { - qt_save_gl_state(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - } p = new QPainter(this); } @@ -4459,11 +4454,8 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, delete p; setAutoBufferSwap(auto_swap); d->disable_clear_on_painter_begin = false; - if (engine->type() == QPaintEngine::OpenGL2) - qt_restore_gl_state(); } - if (engine->type() == QPaintEngine::OpenGL2) - static_cast<QGL2PaintEngineEx *>(engine)->setRenderTextActive(false); + qgl_engine_selector()->setPreferredPaintEngine(oldEngineType); #else // QT_OPENGL_ES Q_UNUSED(x); Q_UNUSED(y); @@ -4511,9 +4503,9 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con &win_x, &win_y, &win_z); win_y = height - win_y; // y is inverted + QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); + qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); QPaintEngine *engine = paintEngine(); - if (engine->type() == QPaintEngine::OpenGL2) - static_cast<QGL2PaintEngineEx *>(engine)->setRenderTextActive(true); QPainter *p; bool reuse_painter = false; bool use_depth_testing = glIsEnabled(GL_DEPTH_TEST); @@ -4527,8 +4519,6 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con setAutoBufferSwap(false); // disable glClear() as a result of QPainter::begin() d->disable_clear_on_painter_begin = true; - if (engine->type() == QPaintEngine::OpenGL2) - qt_save_gl_state(); p = new QPainter(this); } @@ -4557,13 +4547,10 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con } else { p->end(); delete p; - if (engine->type() == QPaintEngine::OpenGL2) - qt_restore_gl_state(); setAutoBufferSwap(auto_swap); d->disable_clear_on_painter_begin = false; } - if (engine->type() == QPaintEngine::OpenGL2) - static_cast<QGL2PaintEngineEx *>(engine)->setRenderTextActive(false); + qgl_engine_selector()->setPreferredPaintEngine(oldEngineType); #else // QT_OPENGL_ES Q_UNUSED(x); Q_UNUSED(y); |