Remove duplicate triangulating stroker implementation.
[profile/ivi/qtbase.git] / src / opengl / gl2paintengineex / qpaintengineex_opengl2.cpp
index 45ac639..1972035 100644 (file)
@@ -1,8 +1,7 @@
 /****************************************************************************
 **
-** 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.
 **
@@ -35,6 +34,7 @@
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
@@ -82,7 +82,6 @@
 
 #include "qglengineshadermanager_p.h"
 #include "qgl2pexvertexarray_p.h"
-#include "qtriangulatingstroker_p.h"
 #include "qtextureglyphcache_gl_p.h"
 
 #include <QDebug>
@@ -674,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;
 }
@@ -720,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;
@@ -748,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
@@ -800,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;
                     }
@@ -836,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());
+                cache->vertices = (float *) malloc(sizeof(float) * polys.vertices.size());
                 if (polys.indices.type() == QVertexIndexVector::UnsignedInt) {
-                    cache->indices = (quint32 *) qMalloc(sizeof(quint32) * polys.indices.size());
+                    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)
@@ -1432,13 +1431,13 @@ void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem)
 
     // don't try to cache huge fonts or vastly transformed fonts
     QFontEngine *fontEngine = textItem->fontEngine();
-    const qreal pixelSize = fontEngine->fontDef.pixelSize;
-    if (shouldDrawCachedGlyphs(pixelSize, s->matrix) || det < 0.25f || det > 4.f) {
+    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 (d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate
+            if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()
+                || d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate
                 || (s->composition_mode != QPainter::CompositionMode_Source
                 && s->composition_mode != QPainter::CompositionMode_SourceOver))
             {
@@ -1490,8 +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 (shouldDrawCachedGlyphs(pixelSize, s->matrix) || 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
@@ -1500,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))
         {
@@ -1567,11 +1566,12 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
     void *cacheKey = const_cast<QGLContext *>(QGLContextPrivate::contextGroup(ctx)->context());
     bool recreateVertexArrays = false;
 
+    QFontEngine *fe = staticTextItem->fontEngine();
     QGLTextureGlyphCache *cache =
-            (QGLTextureGlyphCache *) staticTextItem->fontEngine()->glyphCache(cacheKey, glyphType, QTransform());
+            (QGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, QTransform());
     if (!cache || cache->cacheType() != glyphType || cache->contextGroup() == 0) {
         cache = new QGLTextureGlyphCache(glyphType, QTransform());
-        staticTextItem->fontEngine()->setGlyphCache(cacheKey, cache);
+        fe->setGlyphCache(cacheKey, cache);
         recreateVertexArrays = true;
     }
 
@@ -1595,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();
@@ -1610,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();
@@ -1650,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; i<staticTextItem->numGlyphs; ++i) {
             QFixed subPixelPosition;
             if (supportsSubPixelPositions)
-                subPixelPosition = staticTextItem->fontEngine()->subPixelPositionForX(staticTextItem->glyphPositions[i].x);
+                subPixelPosition = fe->subPixelPositionForX(staticTextItem->glyphPositions[i].x);
 
             QTextureGlyphCache::GlyphAndSubPixelPosition glyph(staticTextItem->glyphs[i], subPixelPosition);
 
@@ -1980,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