Remove duplicate triangulating stroker implementation.
[profile/ivi/qtbase.git] / src / gui / opengl / qopenglpaintengine.cpp
index 9c5e4d2..2f84a0f 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 QtGui module of the Qt Toolkit.
 **
@@ -35,6 +34,7 @@
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
@@ -85,7 +85,6 @@
 
 #include "qopenglengineshadermanager_p.h"
 #include "qopengl2pexvertexarray_p.h"
-#include "qopengltriangulatingstroker_p.h"
 #include "qopengltextureglyphcache_p.h"
 
 #include <QDebug>
@@ -124,14 +123,14 @@ void QOpenGL2PaintEngineExPrivate::updateTextureFilter(GLenum target, GLenum wra
     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);
 }
 
 
@@ -673,8 +672,8 @@ void QOpenGL2PaintEngineExPrivate::cleanupVectorPath(QPaintEngineEx *engine, voi
         d->unusedIBOSToClean << c->ibo;
 #else
     Q_UNUSED(engine);
-    qFree(c->vertices);
-    qFree(c->indices);
+    free(c->vertices);
+    free(c->indices);
 #endif
     delete c;
 }
@@ -719,7 +718,7 @@ void QOpenGL2PaintEngineExPrivate::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;
@@ -747,7 +746,7 @@ void QOpenGL2PaintEngineExPrivate::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
@@ -799,8 +798,8 @@ void QOpenGL2PaintEngineExPrivate::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;
                     }
@@ -835,12 +834,12 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path)
                     vertices[i] = float(inverseScale * polys.vertices.at(i));
                 funcs.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)
@@ -1405,8 +1404,7 @@ void QOpenGL2PaintEngineEx::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;
@@ -1460,8 +1458,7 @@ void QOpenGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &text
     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
@@ -1536,12 +1533,13 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
 
     void *cacheKey = ctx->shareGroup();
     bool recreateVertexArrays = false;
+    QFontEngine *fe = staticTextItem->fontEngine();
 
     QOpenGLTextureGlyphCache *cache =
-            (QOpenGLTextureGlyphCache *) staticTextItem->fontEngine()->glyphCache(cacheKey, glyphType, QTransform());
+            (QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, QTransform());
     if (!cache || cache->cacheType() != glyphType || cache->contextGroup() == 0) {
         cache = new QOpenGLTextureGlyphCache(glyphType, QTransform());
-        staticTextItem->fontEngine()->setGlyphCache(cacheKey, cache);
+        fe->setGlyphCache(cacheKey, cache);
         recreateVertexArrays = true;
     }
 
@@ -1565,11 +1563,11 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
     // 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();
@@ -1580,7 +1578,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
 
     transferMode(TextDrawingMode);
 
-    int margin = cache->glyphMargin();
+    int margin = fe->glyphMargin(glyphType);
 
     GLfloat dx = 1.0 / cache->width();
     GLfloat dy = 1.0 / cache->height();
@@ -1620,11 +1618,11 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
         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 = cache->subPixelPositionForX(staticTextItem->glyphPositions[i].x);
+                subPixelPosition = fe->subPixelPositionForX(staticTextItem->glyphPositions[i].x);
 
             QTextureGlyphCache::GlyphAndSubPixelPosition glyph(staticTextItem->glyphs[i], subPixelPosition);
 
@@ -1776,11 +1774,11 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
 
         if (cache->filterMode() != filterMode) {
             if (filterMode == QOpenGLTextureGlyphCache::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);
         }
@@ -1925,7 +1923,7 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev)
     d->ctx = QOpenGLContext::currentContext();
     d->ctx->d_func()->active_engine = this;
 
-    d->funcs.initializeGLFunctions();
+    d->funcs.initializeOpenGLFunctions();
 
     for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
         d->vertexAttributeArraysEnabledState[i] = false;