diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-08-01 09:48:40 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-08-01 09:48:40 (GMT) |
commit | 0f10e3603fc5f24ebd3773cb2976d0bb24fcbd17 (patch) | |
tree | 4bfa9c57e62b023730ec5fc7dafbd45cfc33c086 /src/opengl | |
parent | c9fb043d9fa38dd8eec6976e7a338dc89ddc5b0e (diff) | |
parent | bf8f39329c05a92c3da2b73b4e555dc9980e6008 (diff) | |
download | Qt-0f10e3603fc5f24ebd3773cb2976d0bb24fcbd17.zip Qt-0f10e3603fc5f24ebd3773cb2976d0bb24fcbd17.tar.gz Qt-0f10e3603fc5f24ebd3773cb2976d0bb24fcbd17.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging:
Make macdeployqt more robust against usage of symbolic links.
Document support for Linguist on Mac.
Make mac(deploy|change)qt handle dylibs that use Qt inside an app bundle.
Guard macdeployqt against @rpath and @loader_path too.
Fix typo.
OpenVG cleanup.
Include trailing space width in RTL text line width
Fix the compilation error when QT_NO_PLUGIN_CHECK was set.
Fixed holes in border image drawing by introducing new API.
Properly resolve and use glMapBuffer / glUnmapBuffer on GLES2.
Revert "fix QFileInfo::isSymLink() for NTFS mount points"
Remove debug output.
Add some sound support to the uikit platform.
Add flickrdemo uikit example project.
Fix uikit simulator build.
Get subpixel antialiasing again w/combo of raster and affine transform
Add initial support for bitmap version 4/5 headers.
optimize QRawFont::supportsCharacter()
Switch to use floating point pixelSize in QRawFont completely
Add a way to check if we have a matching family in the database.
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 128 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 10 | ||||
-rw-r--r-- | src/opengl/qglbuffer.cpp | 4 | ||||
-rw-r--r-- | src/opengl/qglextensions.cpp | 33 | ||||
-rw-r--r-- | src/opengl/qglextensions_p.h | 4 |
5 files changed, 151 insertions, 28 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 0d2f2a2..a961366 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -651,7 +651,7 @@ void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) if (newMode == mode) return; - if (mode == TextDrawingMode || mode == ImageDrawingMode || mode == ImageArrayDrawingMode) { + if (mode == TextDrawingMode || imageDrawingMode) { lastTextureUsed = GLuint(-1); } @@ -661,14 +661,21 @@ void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) shaderManager->setHasComplexGeometry(false); } + imageDrawingMode = false; + if (newMode == ImageDrawingMode) { setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, staticVertexCoordinateArray); setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, staticTextureCoordinateArray); + imageDrawingMode = true; } - if (newMode == ImageArrayDrawingMode) { + if (newMode == ImageArrayDrawingMode || newMode == ImageArrayWithOpacityDrawingMode) { setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinateArray.data()); setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinateArray.data()); + imageDrawingMode = true; + } + + if (newMode == ImageArrayWithOpacityDrawingMode) { setVertexAttributePointer(QT_OPACITY_ATTR, (GLfloat*)opacityArray.data()); } @@ -1096,7 +1103,7 @@ void QGL2PaintEngineExPrivate::resetClipIfNeeded() bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) { - if (brushTextureDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode) + if (brushTextureDirty && !imageDrawingMode) updateBrushTexture(); if (compositionModeDirty) @@ -1116,12 +1123,12 @@ bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) } QGLEngineShaderManager::OpacityMode opacityMode; - if (mode == ImageArrayDrawingMode) { + if (mode == ImageArrayWithOpacityDrawingMode) { opacityMode = QGLEngineShaderManager::AttributeOpacity; } else { opacityMode = stateHasOpacity ? QGLEngineShaderManager::UniformOpacity : QGLEngineShaderManager::NoOpacity; - if (stateHasOpacity && (mode != ImageDrawingMode)) { + if (stateHasOpacity && !imageDrawingMode) { // Using a brush bool brushIsPattern = (currentBrush.style() >= Qt::Dense1Pattern) && (currentBrush.style() <= Qt::DiagCrossPattern); @@ -1141,7 +1148,7 @@ bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) matrixUniformDirty = true; } - if (brushUniformsDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode) + if (brushUniformsDirty && !imageDrawingMode) updateBrushUniforms(); if (opacityMode == QGLEngineShaderManager::UniformOpacity && opacityUniformDirty) { @@ -1881,23 +1888,46 @@ void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *frag return; } + QSize size = pixmap.size(); + ensureActive(); int max_texture_size = d->ctx->d_func()->maxTextureSize(); - if (pixmap.width() > max_texture_size || pixmap.height() > max_texture_size) { + if (size.width() > max_texture_size || size.height() > max_texture_size) { QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); - d->drawPixmapFragments(fragments, fragmentCount, scaled, hints); + d->drawPixmapFragments(fragments, fragmentCount, scaled, size, hints); } else { - d->drawPixmapFragments(fragments, fragmentCount, pixmap, hints); + d->drawPixmapFragments(fragments, fragmentCount, pixmap, size, hints); } } +void QGL2PaintEngineEx::drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, const QPixmap &pixmap, + QPainter::PixmapFragmentHints hints) +{ + Q_D(QGL2PaintEngineEx); + // Use fallback for extended composition modes. + if (state()->composition_mode > QPainter::CompositionMode_Plus) { + QPaintEngineEx::drawPixmapFragments(targetRects, sourceRects, fragmentCount, pixmap, hints); + return; + } + + QSize size = pixmap.size(); + + ensureActive(); + int max_texture_size = d->ctx->d_func()->maxTextureSize(); + if (size.width() > max_texture_size || size.height() > max_texture_size) { + QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); + d->drawPixmapFragments(targetRects, sourceRects, fragmentCount, scaled, size, hints); + } else { + d->drawPixmapFragments(targetRects, sourceRects, fragmentCount, pixmap, size, hints); + } +} void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, - QPainter::PixmapFragmentHints hints) + const QSize &size, QPainter::PixmapFragmentHints hints) { - GLfloat dx = 1.0f / pixmap.size().width(); - GLfloat dy = 1.0f / pixmap.size().height(); + GLfloat dx = 1.0f / size.width(); + GLfloat dy = 1.0f / size.height(); vertexCoordinateArray.clear(); textureCoordinateArray.clear(); @@ -1958,7 +1988,7 @@ void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFragmen data[i].y = 1 - data[i].y; } - transferMode(ImageArrayDrawingMode); + transferMode(allOpaque ? ImageArrayDrawingMode : ImageArrayWithOpacityDrawingMode); bool isBitmap = pixmap.isQBitmap(); bool isOpaque = !isBitmap && (!pixmap.hasAlpha() || (hints & QPainter::OpaqueHint)) && allOpaque; @@ -1981,6 +2011,77 @@ void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFragmen glDrawArrays(GL_TRIANGLES, 0, 6 * fragmentCount); } +void QGL2PaintEngineExPrivate::drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, + const QPixmap &pixmap, const QSize &size, + QPainter::PixmapFragmentHints hints) +{ + GLfloat dx = 1.0f / size.width(); + GLfloat dy = 1.0f / size.height(); + + vertexCoordinateArray.clear(); + textureCoordinateArray.clear(); + + if (snapToPixelGrid) { + snapToPixelGrid = false; + matrixDirty = true; + } + + for (int i = 0; i < fragmentCount; ++i) { + vertexCoordinateArray.addVertex(targetRects[i].right(), targetRects[i].bottom()); + vertexCoordinateArray.addVertex(targetRects[i].right(), targetRects[i].top()); + vertexCoordinateArray.addVertex(targetRects[i].left(), targetRects[i].top()); + vertexCoordinateArray.addVertex(targetRects[i].left(), targetRects[i].top()); + vertexCoordinateArray.addVertex(targetRects[i].left(), targetRects[i].bottom()); + vertexCoordinateArray.addVertex(targetRects[i].right(), targetRects[i].bottom()); + + QRectF sourceRect = sourceRects ? sourceRects[i] : QRectF(0, 0, size.width(), size.height()); + + QGLRect src(sourceRect.left() * dx, sourceRect.top() * dy, + sourceRect.right() * dx, sourceRect.bottom() * dy); + + textureCoordinateArray.addVertex(src.right, src.bottom); + textureCoordinateArray.addVertex(src.right, src.top); + textureCoordinateArray.addVertex(src.left, src.top); + textureCoordinateArray.addVertex(src.left, src.top); + textureCoordinateArray.addVertex(src.left, src.bottom); + textureCoordinateArray.addVertex(src.right, src.bottom); + } + + glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); + QGLTexture *texture = ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, + QGLContext::InternalBindOption + | QGLContext::CanFlipNativePixmapBindOption); + + if (texture->options & QGLContext::InvertedYBindOption) { + // Flip texture y-coordinate. + QGLPoint *data = textureCoordinateArray.data(); + for (int i = 0; i < 6 * fragmentCount; ++i) + data[i].y = 1 - data[i].y; + } + + transferMode(ImageArrayDrawingMode); + + bool isBitmap = pixmap.isQBitmap(); + bool isOpaque = !isBitmap && (!pixmap.hasAlpha() || (hints & QPainter::OpaqueHint)); + + updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, + q->state()->renderHints & QPainter::SmoothPixmapTransform, texture->id); + + // Setup for texture drawing + currentBrush = noBrush; + shaderManager->setSrcPixelType(isBitmap ? QGLEngineShaderManager::PatternSrc + : QGLEngineShaderManager::ImageSrc); + if (prepareForDraw(isOpaque)) + shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT); + + if (isBitmap) { + QColor col = qt_premultiplyColor(q->state()->pen.color(), (GLfloat)q->state()->opacity); + shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col); + } + + glDrawArrays(GL_TRIANGLES, 0, 6 * fragmentCount); +} + bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) { Q_D(QGL2PaintEngineEx); @@ -2001,6 +2102,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->width = sz.width(); d->height = sz.height(); d->mode = BrushDrawingMode; + d->imageDrawingMode = false; d->brushTextureDirty = true; d->brushUniformsDirty = true; d->matrixUniformDirty = true; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 2895d5a..80daf63 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -68,7 +68,8 @@ enum EngineMode { ImageDrawingMode, TextDrawingMode, BrushDrawingMode, - ImageArrayDrawingMode + ImageArrayDrawingMode, + ImageArrayWithOpacityDrawingMode }; QT_BEGIN_NAMESPACE @@ -126,6 +127,8 @@ public: virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints); + virtual void drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, const QPixmap &pixmap, + QPainter::PixmapFragmentHints hints); virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags = Qt::AutoColor); virtual void drawTextItem(const QPointF &p, const QTextItem &textItem); @@ -202,7 +205,9 @@ public: void fill(const QVectorPath &path); void stroke(const QVectorPath &path, const QPen &pen); void drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern = false); - void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, + void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, const QSize &size, + QPainter::PixmapFragmentHints hints); + void drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, const QPixmap &pixmap, const QSize &size, QPainter::PixmapFragmentHints hints); void drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType, QStaticTextItem *staticTextItem); @@ -255,6 +260,7 @@ public: int width, height; QGLContext *ctx; EngineMode mode; + bool imageDrawingMode; QFontEngineGlyphCache::Type glyphCacheType; // Dirty flags diff --git a/src/opengl/qglbuffer.cpp b/src/opengl/qglbuffer.cpp index a1ec3ef..b5c6b83 100644 --- a/src/opengl/qglbuffer.cpp +++ b/src/opengl/qglbuffer.cpp @@ -543,6 +543,10 @@ void *QGLBuffer::map(QGLBuffer::Access access) return 0; if (!glMapBufferARB) return 0; +#ifdef QT_OPENGL_ES_2 + if (access != QGLBuffer::WriteOnly) + return 0; +#endif return glMapBufferARB(d->type, access); } diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp index 98d2960..64f7526 100644 --- a/src/opengl/qglextensions.cpp +++ b/src/opengl/qglextensions.cpp @@ -191,23 +191,30 @@ bool qt_resolve_frag_program_extensions(QGLContext *ctx) bool qt_resolve_buffer_extensions(QGLContext *ctx) { + if (!QGLContextPrivate::extensionFuncs(ctx).qt_bufferFuncsResolved) { #if defined(QGL_RESOLVE_BUFFER_FUNCS) - if (glBindBuffer && glDeleteBuffers && glGenBuffers && glBufferData - && glBufferSubData && glGetBufferParameteriv) - return true; + glBindBuffer = (_glBindBuffer) qt_gl_getProcAddressARB(ctx, "glBindBuffer"); + glDeleteBuffers = (_glDeleteBuffers) qt_gl_getProcAddressARB(ctx, "glDeleteBuffers"); + glGenBuffers = (_glGenBuffers) qt_gl_getProcAddressARB(ctx, "glGenBuffers"); + glBufferData = (_glBufferData) qt_gl_getProcAddressARB(ctx, "glBufferData"); + glBufferSubData = (_glBufferSubData) qt_gl_getProcAddressARB(ctx, "glBufferSubData"); + glGetBufferSubData = (_glGetBufferSubData) qt_gl_getProcAddressARB(ctx, "glGetBufferSubData"); + glGetBufferParameteriv = (_glGetBufferParameteriv) qt_gl_getProcAddressARB(ctx, "glGetBufferParameteriv"); #endif -#if defined(QGL_RESOLVE_BUFFER_FUNCS) - glBindBuffer = (_glBindBuffer) qt_gl_getProcAddressARB(ctx, "glBindBuffer"); - glDeleteBuffers = (_glDeleteBuffers) qt_gl_getProcAddressARB(ctx, "glDeleteBuffers"); - glGenBuffers = (_glGenBuffers) qt_gl_getProcAddressARB(ctx, "glGenBuffers"); - glBufferData = (_glBufferData) qt_gl_getProcAddressARB(ctx, "glBufferData"); - glBufferSubData = (_glBufferSubData) qt_gl_getProcAddressARB(ctx, "glBufferSubData"); - glGetBufferSubData = (_glGetBufferSubData) qt_gl_getProcAddressARB(ctx, "glGetBufferSubData"); - glGetBufferParameteriv = (_glGetBufferParameteriv) qt_gl_getProcAddressARB(ctx, "glGetBufferParameteriv"); +#ifdef QT_OPENGL_ES_2 + QGLExtensionMatcher extensions; + if (extensions.match("GL_OES_mapbuffer")) { + glMapBufferARB = (_glMapBufferARB) qt_gl_getProcAddressARB(ctx, "glMapBufferOES"); + glUnmapBufferARB = (_glUnmapBufferARB) qt_gl_getProcAddressARB(ctx, "glUnmapBufferOES"); + } +#else + glMapBufferARB = (_glMapBufferARB) qt_gl_getProcAddressARB(ctx, "glMapBuffer"); + glUnmapBufferARB = (_glUnmapBufferARB) qt_gl_getProcAddressARB(ctx, "glUnmapBuffer"); #endif - glMapBufferARB = (_glMapBufferARB) qt_gl_getProcAddressARB(ctx, "glMapBuffer"); - glUnmapBufferARB = (_glUnmapBufferARB) qt_gl_getProcAddressARB(ctx, "glUnmapBuffer"); + + QGLContextPrivate::extensionFuncs(ctx).qt_bufferFuncsResolved = true; + } #if defined(QGL_RESOLVE_BUFFER_FUNCS) return glBindBuffer diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h index 98433c3..f85c89b 100644 --- a/src/opengl/qglextensions_p.h +++ b/src/opengl/qglextensions_p.h @@ -332,6 +332,8 @@ struct QGLExtensionFuncs qt_glMapBufferARB = 0; qt_glUnmapBufferARB = 0; + qt_bufferFuncsResolved = false; + qt_glProgramParameteriEXT = 0; qt_glFramebufferTextureEXT = 0; qt_glFramebufferTextureLayerEXT = 0; @@ -457,6 +459,8 @@ struct QGLExtensionFuncs _glMapBufferARB qt_glMapBufferARB; _glUnmapBufferARB qt_glUnmapBufferARB; + bool qt_bufferFuncsResolved; + // Geometry shaders... _glProgramParameteriEXT qt_glProgramParameteriEXT; _glFramebufferTextureEXT qt_glFramebufferTextureEXT; |