X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fopengl%2Fgl2paintengineex%2Fqpaintengineex_opengl2.cpp;h=1972035e4aea23350ac8ad2936b292ffea18e991;hb=16f8afa5b1c906ae60f98619d17c34b40c21804e;hp=673f614c0d1cb80e9eddb490f06cb5ab277e6f8b;hpb=72395bc540c60d9966788817c08cd3e126a40f97;p=profile%2Fivi%2Fqtbase.git diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 673f614..1972035 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1,34 +1,34 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ ** ** This file is part of the QtOpenGL module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** ** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. ** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. ** ** ** @@ -76,31 +76,19 @@ #include #include #include -#include #include #include -#include +#include #include "qglengineshadermanager_p.h" #include "qgl2pexvertexarray_p.h" -#include "qtriangulatingstroker_p.h" #include "qtextureglyphcache_gl_p.h" #include QT_BEGIN_NAMESPACE -#if defined(Q_WS_WIN) -extern Q_GUI_EXPORT bool qt_cleartype_enabled; -#endif -#ifdef Q_WS_MAC -extern bool qt_applefontsmoothing_enabled; -#endif - -#if !defined(QT_MAX_CACHED_GLYPH_SIZE) -# define QT_MAX_CACHED_GLYPH_SIZE 64 -#endif Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert); @@ -132,14 +120,14 @@ void QGL2PaintEngineExPrivate::updateTextureFilter(GLenum target, GLenum wrapMod lastTextureUsed = id; if (smoothPixmapTransform) { - glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } else { - glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } - glTexParameterf(target, GL_TEXTURE_WRAP_S, wrapMode); - glTexParameterf(target, GL_TEXTURE_WRAP_T, wrapMode); + glTexParameteri(target, GL_TEXTURE_WRAP_S, wrapMode); + glTexParameteri(target, GL_TEXTURE_WRAP_T, wrapMode); } @@ -301,7 +289,7 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms() const QRadialGradient *g = static_cast(currentBrush.gradient()); QPointF realCenter = g->center(); QPointF realFocal = g->focalPoint(); - qreal realRadius = g->radius(); + qreal realRadius = g->centerRadius() - g->focalRadius(); translationPoint = realFocal; QPointF fmp = realCenter - realFocal; @@ -311,6 +299,12 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms() shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Fmp2MRadius2), fmp2_m_radius2); shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Inverse2Fmp2MRadius2), GLfloat(1.0 / (2.0*fmp2_m_radius2))); + shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::SqrFr), + GLfloat(g->focalRadius() * g->focalRadius())); + shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BRadius), + GLfloat(2 * (g->centerRadius() - g->focalRadius()) * g->focalRadius()), + g->focalRadius(), + g->centerRadius() - g->focalRadius()); QVector2D halfViewportSize(width*0.5, height*0.5); shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize); @@ -666,6 +660,7 @@ struct QGL2PEVectorPathCache int indexCount; GLenum primitiveType; qreal iscale; + QVertexIndexVector::Type indexType; }; void QGL2PaintEngineExPrivate::cleanupVectorPath(QPaintEngineEx *engine, void *data) @@ -678,8 +673,8 @@ void QGL2PaintEngineExPrivate::cleanupVectorPath(QPaintEngineEx *engine, void *d d->unusedIBOSToClean << c->ibo; #else Q_UNUSED(engine); - qFree(c->vertices); - qFree(c->indices); + free(c->vertices); + free(c->indices); #endif delete c; } @@ -724,7 +719,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) cache->vbo = 0; Q_ASSERT(cache->ibo == 0); #else - qFree(cache->vertices); + free(cache->vertices); Q_ASSERT(cache->indices == 0); #endif updateCache = true; @@ -752,7 +747,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) glBufferData(GL_ARRAY_BUFFER, floatSizeInBytes, vertexCoordinateArray.data(), GL_STATIC_DRAW); cache->ibo = 0; #else - cache->vertices = (float *) qMalloc(floatSizeInBytes); + cache->vertices = (float *) malloc(floatSizeInBytes); memcpy(cache->vertices, vertexCoordinateArray.data(), floatSizeInBytes); cache->indices = 0; #endif @@ -804,8 +799,8 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) glDeleteBuffers(1, &cache->vbo); glDeleteBuffers(1, &cache->ibo); #else - qFree(cache->vertices); - qFree(cache->indices); + free(cache->vertices); + free(cache->indices); #endif updateCache = true; } @@ -823,13 +818,14 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) cache->indexCount = polys.indices.size(); cache->primitiveType = GL_TRIANGLES; cache->iscale = inverseScale; + cache->indexType = polys.indices.type(); #ifdef QT_OPENGL_CACHE_AS_VBOS glGenBuffers(1, &cache->vbo); glGenBuffers(1, &cache->ibo); glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cache->ibo); - if (QGLExtensions::glExtensions() & QGLExtensions::ElementIndexUint) + if (polys.indices.type() == QVertexIndexVector::UnsignedInt) glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(quint32) * polys.indices.size(), polys.indices.data(), GL_STATIC_DRAW); else glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(quint16) * polys.indices.size(), polys.indices.data(), GL_STATIC_DRAW); @@ -839,12 +835,12 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) vertices[i] = float(inverseScale * polys.vertices.at(i)); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * vertices.size(), vertices.data(), GL_STATIC_DRAW); #else - cache->vertices = (float *) qMalloc(sizeof(float) * polys.vertices.size()); - if (QGLExtensions::glExtensions() & QGLExtensions::ElementIndexUint) { - cache->indices = (quint32 *) qMalloc(sizeof(quint32) * polys.indices.size()); + cache->vertices = (float *) malloc(sizeof(float) * polys.vertices.size()); + if (polys.indices.type() == QVertexIndexVector::UnsignedInt) { + cache->indices = (quint32 *) malloc(sizeof(quint32) * polys.indices.size()); memcpy(cache->indices, polys.indices.data(), sizeof(quint32) * polys.indices.size()); } else { - cache->indices = (quint16 *) qMalloc(sizeof(quint16) * polys.indices.size()); + cache->indices = (quint16 *) malloc(sizeof(quint16) * polys.indices.size()); memcpy(cache->indices, polys.indices.data(), sizeof(quint16) * polys.indices.size()); } for (int i = 0; i < polys.vertices.size(); ++i) @@ -857,7 +853,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cache->ibo); setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, 0); - if (QGLExtensions::glExtensions() & QGLExtensions::ElementIndexUint) + if (cache->indexType == QVertexIndexVector::UnsignedInt) glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_INT, 0); else glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_SHORT, 0); @@ -865,7 +861,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) glBindBuffer(GL_ARRAY_BUFFER, 0); #else setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices); - if (QGLExtensions::glExtensions() & QGLExtensions::ElementIndexUint) + if (cache->indexType == QVertexIndexVector::UnsignedInt) glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_INT, (qint32 *)cache->indices); else glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_SHORT, (qint16 *)cache->indices); @@ -894,7 +890,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) prepareForDraw(currentBrush.isOpaque()); setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, vertices.constData()); - if (QGLExtensions::glExtensions() & QGLExtensions::ElementIndexUint) + if (polys.indices.type() == QVertexIndexVector::UnsignedInt) glDrawElements(GL_TRIANGLES, polys.indices.size(), GL_UNSIGNED_INT, polys.indices.data()); else glDrawElements(GL_TRIANGLES, polys.indices.size(), GL_UNSIGNED_SHORT, polys.indices.data()); @@ -1430,19 +1426,29 @@ void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem) ensureActive(); - QFontEngineGlyphCache::Type glyphType = textItem->fontEngine()->glyphFormat >= 0 - ? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat) - : d->glyphCacheType; - if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { - if (d->device->alphaRequested() || state()->matrix.type() > QTransform::TxTranslate - || (state()->composition_mode != QPainter::CompositionMode_Source - && state()->composition_mode != QPainter::CompositionMode_SourceOver)) - { - glyphType = QFontEngineGlyphCache::Raster_A8; + QPainterState *s = state(); + float det = s->matrix.determinant(); + + // don't try to cache huge fonts or vastly transformed fonts + QFontEngine *fontEngine = textItem->fontEngine(); + if (shouldDrawCachedGlyphs(fontEngine, s->matrix) || det < 0.25f || det > 4.f) { + QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0 + ? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat) + : d->glyphCacheType; + if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { + if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() + || d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate + || (s->composition_mode != QPainter::CompositionMode_Source + && s->composition_mode != QPainter::CompositionMode_SourceOver)) + { + glyphType = QFontEngineGlyphCache::Raster_A8; + } } - } - d->drawCachedGlyphs(glyphType, textItem); + d->drawCachedGlyphs(glyphType, textItem); + } else { + QPaintEngineEx::drawStaticTextItem(textItem); + } } bool QGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const QSize &size, const QRectF &src) @@ -1483,9 +1489,7 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem bool drawCached = txtype < QTransform::TxProject; // don't try to cache huge fonts or vastly transformed fonts - const qreal pixelSize = ti.fontEngine->fontDef.pixelSize; - if (pixelSize * pixelSize * qAbs(det) >= QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE || - det < 0.25f || det > 4.f) + if (shouldDrawCachedGlyphs(ti.fontEngine, s->matrix) || det < 0.25f || det > 4.f) drawCached = false; QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 @@ -1494,7 +1498,8 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { - if (d->device->alphaRequested() || txtype > QTransform::TxTranslate + if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() + || d->device->alphaRequested() || txtype > QTransform::TxTranslate || (state()->composition_mode != QPainter::CompositionMode_Source && state()->composition_mode != QPainter::CompositionMode_SourceOver)) { @@ -1548,13 +1553,6 @@ namespace { } -#if defined(Q_WS_WIN) -static bool fontSmoothingApproximately(qreal target) -{ - extern Q_GUI_EXPORT qreal qt_fontsmoothing_gamma; // qapplication_win.cpp - return (qAbs(qt_fontsmoothing_gamma - target) < 0.2); -} -#endif // #define QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO @@ -1568,12 +1566,12 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp void *cacheKey = const_cast(QGLContextPrivate::contextGroup(ctx)->context()); bool recreateVertexArrays = false; + QFontEngine *fe = staticTextItem->fontEngine(); QGLTextureGlyphCache *cache = - (QGLTextureGlyphCache *) staticTextItem->fontEngine()->glyphCache(cacheKey, glyphType, QTransform()); - if (!cache || cache->cacheType() != glyphType || cache->context() == 0) { - cache = new QGLTextureGlyphCache(ctx, glyphType, QTransform()); - staticTextItem->fontEngine()->setGlyphCache(cacheKey, cache); - cache->insert(ctx, cache); + (QGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, QTransform()); + if (!cache || cache->cacheType() != glyphType || cache->contextGroup() == 0) { + cache = new QGLTextureGlyphCache(glyphType, QTransform()); + fe->setGlyphCache(cacheKey, cache); recreateVertexArrays = true; } @@ -1597,11 +1595,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp // cache so this text is performed before we test if the cache size has changed. if (recreateVertexArrays) { cache->setPaintEnginePrivate(this); - if (!cache->populate(staticTextItem->fontEngine(), staticTextItem->numGlyphs, + if (!cache->populate(fe, staticTextItem->numGlyphs, staticTextItem->glyphs, staticTextItem->glyphPositions)) { // No space for glyphs in cache. We need to reset it and try again. cache->clear(); - cache->populate(staticTextItem->fontEngine(), staticTextItem->numGlyphs, + cache->populate(fe, staticTextItem->numGlyphs, staticTextItem->glyphs, staticTextItem->glyphPositions); } cache->fillInPendingGlyphs(); @@ -1612,7 +1610,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp transferMode(TextDrawingMode); - int margin = cache->glyphMargin(); + int margin = fe->glyphMargin(glyphType); GLfloat dx = 1.0 / cache->width(); GLfloat dy = 1.0 / cache->height(); @@ -1652,11 +1650,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp vertexCoordinates->clear(); textureCoordinates->clear(); - bool supportsSubPixelPositions = staticTextItem->fontEngine()->supportsSubPixelPositions(); + bool supportsSubPixelPositions = fe->supportsSubPixelPositions(); for (int i=0; inumGlyphs; ++i) { QFixed subPixelPosition; if (supportsSubPixelPositions) - subPixelPosition = cache->subPixelPositionForX(staticTextItem->glyphPositions[i].x); + subPixelPosition = fe->subPixelPositionForX(staticTextItem->glyphPositions[i].x); QTextureGlyphCache::GlyphAndSubPixelPosition glyph(staticTextItem->glyphs[i], subPixelPosition); @@ -1675,6 +1673,8 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp } int numGlyphs = vertexCoordinates->vertexCount() / 4; + if (numGlyphs == 0) + return; if (elementIndices.size() < numGlyphs*6) { Q_ASSERT(elementIndices.size() % 6 == 0); @@ -1806,30 +1806,17 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp if (cache->filterMode() != filterMode) { if (filterMode == QGLTextureGlyphCache::Linear) { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } else { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } cache->setFilterMode(filterMode); } } bool srgbFrameBufferEnabled = false; - if (ctx->d_ptr->extension_flags & QGLExtensions::SRGBFrameBuffer) { -#if defined(Q_WS_MAC) - if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) -#elif defined(Q_WS_WIN) - if (glyphType != QFontEngineGlyphCache::Raster_RGBMask || fontSmoothingApproximately(2.1)) -#else - if (false) -#endif - { - glEnable(FRAMEBUFFER_SRGB_EXT); - srgbFrameBufferEnabled = true; - } - } #if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0); @@ -1993,7 +1980,9 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) #if !defined(QT_OPENGL_ES_2) bool success = qt_resolve_version_2_0_functions(d->ctx) - && qt_resolve_buffer_extensions(d->ctx); + && qt_resolve_buffer_extensions(d->ctx) + && (!QGLFramebufferObject::hasOpenGLFramebufferObjects() + || qt_resolve_framebufferobject_extensions(d->ctx)); Q_ASSERT(success); Q_UNUSED(success); #endif @@ -2011,13 +2000,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->glyphCacheType = QFontEngineGlyphCache::Raster_A8; #if !defined(QT_OPENGL_ES_2) -#if defined(Q_WS_WIN) - if (qt_cleartype_enabled - && (fontSmoothingApproximately(1.0) || fontSmoothingApproximately(2.1))) -#endif -#if defined(Q_WS_MAC) - if (qt_applefontsmoothing_enabled) -#endif d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask; #endif @@ -2035,21 +2017,13 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) bool QGL2PaintEngineEx::end() { Q_D(QGL2PaintEngineEx); - QGLContext *ctx = d->ctx; + QGLContext *ctx = d->ctx; glUseProgram(0); d->transferMode(BrushDrawingMode); d->device->endPaint(); -#if defined(Q_WS_X11) - // On some (probably all) drivers, deleting an X pixmap which has been bound to a texture - // before calling glFinish/swapBuffers renders garbage. Presumably this is because X deletes - // the pixmap behind the driver's back before it's had a chance to use it. To fix this, we - // reference all QPixmaps which have been bound to stop them being deleted and only deref - // them here, after swapBuffers, where they can be safely deleted. - ctx->d_func()->boundPixmaps.clear(); -#endif - d->ctx->d_ptr->active_engine = 0; + ctx->d_ptr->active_engine = 0; d->resetGLState(); @@ -2302,41 +2276,6 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) state()->currentClip = d->maxClip; state()->clipTestEnabled = true; break; - case Qt::UniteClip: { - d->resetClipIfNeeded(); - ++d->maxClip; - if (state()->rectangleClip.isValid()) { - QPainterPath path; - path.addRect(state()->rectangleClip); - - // flush the existing clip rectangle to the depth buffer - d->writeClip(qtVectorPathForPath(state()->matrix.inverted().map(path)), d->maxClip); - } - - state()->clipTestEnabled = false; -#ifndef QT_GL_NO_SCISSOR_TEST - QRect oldRectangleClip = state()->rectangleClip; - - state()->rectangleClip = state()->rectangleClip.united(pathRect); - d->updateClipScissorTest(); - - QRegion extendRegion = QRegion(state()->rectangleClip) - oldRectangleClip; - - if (!extendRegion.isEmpty()) { - QPainterPath extendPath; - extendPath.addRegion(extendRegion); - - // first clear the depth buffer in the extended region - d->writeClip(qtVectorPathForPath(state()->matrix.inverted().map(extendPath)), 0); - } -#endif - // now write the clip path - d->writeClip(path, d->maxClip); - state()->canRestoreClip = false; - state()->currentClip = d->maxClip; - state()->clipTestEnabled = true; - break; - } default: break; } @@ -2357,8 +2296,8 @@ void QGL2PaintEngineExPrivate::systemStateChanged() if (systemClip.isEmpty()) { useSystemClip = false; } else { - if (q->paintDevice()->devType() == QInternal::Widget && currentClipWidget) { - QWidgetPrivate *widgetPrivate = qt_widget_private(currentClipWidget->window()); + if (q->paintDevice()->devType() == QInternal::Widget && currentClipDevice) { + QWidgetPrivate *widgetPrivate = qt_widget_private(static_cast(currentClipDevice)->window()); useSystemClip = widgetPrivate->extra && widgetPrivate->extra->inRenderWithPainter; } else { useSystemClip = true;