diff options
author | Gunnar Sletta <gunnar@trolltech.com> | 2009-10-22 04:38:32 (GMT) |
---|---|---|
committer | Gunnar Sletta <gunnar@trolltech.com> | 2009-10-22 04:38:32 (GMT) |
commit | 414a6134ba2c578a17cf62971a410d74e75178c9 (patch) | |
tree | 459768cb175536e549b9e11582fd6db0756a3beb /src | |
parent | 0bf8f2cbc596280b86d53e19b2bde316c2cafe3f (diff) | |
parent | cdb98c137db4d051e4b41c9fa4626c4c369cc0b1 (diff) | |
download | Qt-414a6134ba2c578a17cf62971a410d74e75178c9.zip Qt-414a6134ba2c578a17cf62971a410d74e75178c9.tar.gz Qt-414a6134ba2c578a17cf62971a410d74e75178c9.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt-graphics-team into 4.6
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qapplication_mac.mm | 11 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 6 | ||||
-rw-r--r-- | src/gui/painting/qtextureglyphcache.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase_x11.cpp | 2 | ||||
-rw-r--r-- | src/opengl/opengl.pro | 7 | ||||
-rw-r--r-- | src/opengl/qgl.cpp | 35 | ||||
-rw-r--r-- | src/opengl/qgl_x11egl.cpp | 8 | ||||
-rw-r--r-- | src/opengl/qgraphicssystem_gl.cpp | 10 | ||||
-rw-r--r-- | src/opengl/qpaintengine_opengl.cpp | 40 | ||||
-rw-r--r-- | src/opengl/qpixmapdata_x11gl_p.h | 2 | ||||
-rw-r--r-- | src/opengl/qwindowsurface_gl.cpp | 1 | ||||
-rw-r--r-- | src/opengl/qwindowsurface_x11gl.cpp | 144 | ||||
-rw-r--r-- | src/opengl/qwindowsurface_x11gl_p.h | 81 | ||||
-rw-r--r-- | src/svg/qsvggenerator.cpp | 1 |
14 files changed, 306 insertions, 46 deletions
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index f9c8aa3..771cddc 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -203,6 +203,8 @@ static EventHandlerRef tablet_proximity_handler = 0; static EventHandlerUPP tablet_proximity_UPP = 0; bool QApplicationPrivate::native_modal_dialog_active; +Q_GUI_EXPORT bool qt_applefontsmoothing_enabled; + /***************************************************************************** External functions *****************************************************************************/ @@ -222,6 +224,12 @@ extern bool qt_sendSpontaneousEvent(QObject *obj, QEvent *event); // qapplicatio void onApplicationWindowChangedActivation( QWidget*widget, bool activated ); void onApplicationChangedActivation( bool activated ); +static void qt_mac_read_fontsmoothing_settings() +{ + NSInteger appleFontSmoothing = [[NSUserDefaults standardUserDefaults] integerForKey:@"AppleFontSmoothing"]; + qt_applefontsmoothing_enabled = (appleFontSmoothing > 0); +} + Q_GUI_EXPORT bool qt_mac_execute_apple_script(const char *script, long script_len, AEDesc *ret) { OSStatus err; AEDesc scriptTextDesc; @@ -1203,6 +1211,9 @@ void qt_init(QApplicationPrivate *priv, int) } if (QApplication::desktopSettingsAware()) QApplicationPrivate::qt_mac_apply_settings(); + + qt_mac_read_fontsmoothing_settings(); + // Cocoa application delegate #ifdef QT_MAC_USE_COCOA NSApplication *cocoaApp = [NSApplication sharedApplication]; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index fab2d8d..fd0e810 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -132,6 +132,10 @@ static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; extern bool qt_cleartype_enabled; #endif +#ifdef Q_WS_MAC +extern bool qt_applefontsmoothing_enabled; +#endif + /******************************************************************************** * Span functions @@ -508,7 +512,7 @@ bool QRasterPaintEngine::begin(QPaintDevice *device) #if defined(Q_WS_WIN) else if (qt_cleartype_enabled) #elif defined (Q_WS_MAC) - else if (true) + else if (qt_applefontsmoothing_enabled) #else else if (false) #endif diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 25b6aba..a192e87 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -229,8 +229,8 @@ void QImageTextureGlyphCache::createTextureData(int width, int height) int QImageTextureGlyphCache::glyphMargin() const { -#ifdef Q_WS_MAC - return 2; +#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) + return 0; #else return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0; #endif diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index 382c4fe..27ff003 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -752,7 +752,7 @@ QFontDef qt_FcPatternToQFontDef(FcPattern *pattern, const QFontDef &request) if (X11->display) dpi = QX11Info::appDpiY(); else - dpi = 96; // #### + dpi = qt_defaultDpiY(); } double size; diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 961c781..a212675 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -83,11 +83,12 @@ x11 { SOURCES += qgl_x11egl.cpp \ qglpixelbuffer_egl.cpp \ qgl_egl.cpp \ - qpixmapdata_x11gl_egl.cpp + qpixmapdata_x11gl_egl.cpp \ + qwindowsurface_x11gl.cpp HEADERS += qgl_egl_p.h \ - qpixmapdata_x11gl_p.h - + qpixmapdata_x11gl_p.h \ + qwindowsurface_x11gl_p.h } else { SOURCES += qgl_x11.cpp \ diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 97e3dad..6720ae7 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -151,22 +151,6 @@ class QGLEngineSelector public: QGLEngineSelector() : engineType(QPaintEngine::MaxUser) { -#ifdef Q_WS_MAC - // The ATI X1600 driver for Mac OS X does not support return - // values from functions in GLSL. Since working around this in - // the GL2 engine would require a big, ugly rewrite, we're - // falling back to the GL 1 engine.. - QGLWidget *tmp = 0; - if (!QGLContext::currentContext()) { - tmp = new QGLWidget(); - tmp->makeCurrent(); - } - if (strstr((char *) glGetString(GL_RENDERER), "X1600")) - setPreferredPaintEngine(QPaintEngine::OpenGL); - if (tmp) - delete tmp; -#endif - } void setPreferredPaintEngine(QPaintEngine::Type type) { @@ -175,6 +159,25 @@ public: } QPaintEngine::Type preferredPaintEngine() { +#ifdef Q_WS_MAC + // The ATI X1600 driver for Mac OS X does not support return + // values from functions in GLSL. Since working around this in + // the GL2 engine would require a big, ugly rewrite, we're + // falling back to the GL 1 engine.. + static bool mac_x1600_check_done = false; + if (!mac_x1600_check_done) { + QGLWidget *tmp = 0; + if (!QGLContext::currentContext()) { + tmp = new QGLWidget(); + tmp->makeCurrent(); + } + if (strstr((char *) glGetString(GL_RENDERER), "X1600")) + engineType = QPaintEngine::OpenGL; + if (tmp) + delete tmp; + mac_x1600_check_done = true; + } +#endif if (engineType == QPaintEngine::MaxUser) { // No user-set engine - use the defaults #if defined(QT_OPENGL_ES_2) diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index fb08741..3894ed1 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -521,6 +521,14 @@ bool Q_OPENGL_EXPORT qt_createEGLSurfaceForPixmap(QPixmapData* pmd, bool readOnl return false; } + static bool doneOnce = false; + if (!doneOnce) { + // Make sure QGLTextureCache is instanciated so it can install cleanup hooks + // which cleanup the EGL surface. + QGLTextureCache::instance(); + doneOnce = true; + } + Q_ASSERT(sizeof(Qt::HANDLE) >= sizeof(EGLSurface)); // Just to make totally sure! pixmapData->gl_surface = (Qt::HANDLE)pixmapSurface; pixmapData->is_cached = true; // Make sure the cleanup hook gets called diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp index 60d58a7..c0d9233 100644 --- a/src/opengl/qgraphicssystem_gl.cpp +++ b/src/opengl/qgraphicssystem_gl.cpp @@ -47,8 +47,9 @@ #include "private/qgl_p.h" #include <private/qwindowsurface_raster_p.h> -#ifdef Q_WS_X11 +#if defined(Q_WS_X11) && defined(QT_OPENGL_ES) #include "private/qpixmapdata_x11gl_p.h" +#include "private/qwindowsurface_x11gl_p.h" #endif QT_BEGIN_NAMESPACE @@ -57,7 +58,7 @@ extern QGLWidget *qt_gl_getShareWidget(); QPixmapData *QGLGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const { -#ifdef Q_WS_X11 +#if defined(Q_WS_X11) && defined(QT_OPENGL_ES) if (type == QPixmapData::PixmapType && QX11GLPixmapData::hasX11GLPixmaps()) return new QX11GLPixmapData(); #endif @@ -75,6 +76,11 @@ QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const return new QRasterWindowSurface(widget); #endif +#if defined(Q_WS_X11) && defined(QT_OPENGL_ES) + if (QX11GLPixmapData::hasX11GLPixmaps()) + return new QX11GLWindowSurface(widget); +#endif + return new QGLWindowSurface(widget); } diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 80628a2..aa6b6c9 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -746,7 +746,6 @@ public: uint has_brush : 1; uint has_fast_pen : 1; uint use_stencil_method : 1; - uint dirty_stencil : 1; uint dirty_drawable_texture : 1; uint has_stencil_face_ext : 1; uint use_fragment_programs : 1; @@ -757,6 +756,8 @@ public: uint use_system_clip : 1; uint use_emulation : 1; + QRegion dirty_stencil; + void updateUseEmulation(); QTransform matrix; @@ -1259,7 +1260,9 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) d->matrix = QTransform(); d->has_antialiasing = false; d->high_quality_antialiasing = false; - d->dirty_stencil = true; + + QSize sz(d->device->size()); + d->dirty_stencil = QRect(0, 0, sz.width(), sz.height()); d->use_emulation = false; @@ -1347,7 +1350,6 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) d->offscreen.begin(); - QSize sz(d->device->size()); glViewport(0, 0, sz.width(), sz.height()); // XXX (Embedded): We need a solution for GLWidgets that draw in a part or a bigger surface... glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -1949,34 +1951,34 @@ void QOpenGLPaintEnginePrivate::fillVertexArray(Qt::FillRule fillRule) { Q_Q(QOpenGLPaintEngine); - if (dirty_stencil) { - disableClipping(); + QRect rect = dirty_stencil.boundingRect(); - if (use_system_clip) { - glEnable(GL_SCISSOR_TEST); + if (use_system_clip) + rect = q->systemClip().intersected(dirty_stencil).boundingRect(); - QRect rect = q->systemClip().boundingRect(); + glStencilMask(~0); - const int left = rect.left(); - const int width = rect.width(); - const int bottom = device->size().height() - (rect.bottom() + 1); - const int height = rect.height(); + if (!rect.isEmpty()) { + disableClipping(); - glScissor(left, bottom, width, height); - } + glEnable(GL_SCISSOR_TEST); + + const int left = rect.left(); + const int width = rect.width(); + const int bottom = device->size().height() - (rect.bottom() + 1); + const int height = rect.height(); + + glScissor(left, bottom, width, height); glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); - dirty_stencil = false; + dirty_stencil -= rect; - if (use_system_clip) - glDisable(GL_SCISSOR_TEST); + glDisable(GL_SCISSOR_TEST); enableClipping(); } - glStencilMask(~0); - // Enable stencil. glEnable(GL_STENCIL_TEST); diff --git a/src/opengl/qpixmapdata_x11gl_p.h b/src/opengl/qpixmapdata_x11gl_p.h index 3e09ba9..bba9bb3 100644 --- a/src/opengl/qpixmapdata_x11gl_p.h +++ b/src/opengl/qpixmapdata_x11gl_p.h @@ -74,11 +74,9 @@ public: QGLContext* context() const; QSize size() const; - static bool hasX11GLPixmaps(); static QGLFormat glFormat(); private: - static void createPixmapSharedContext(EGLConfig config); mutable QGLContext* ctx; }; diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 2816eca..4547416 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -364,6 +364,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) if (ctxpriv->eglSurface == EGL_NO_SURFACE) { qWarning() << "hijackWindow() could not create EGL surface"; } + qDebug("QGLWindowSurface - using EGLConfig %d", ctxpriv->eglContext->config()); #endif widgetPrivate->extraData()->glContext = ctx; diff --git a/src/opengl/qwindowsurface_x11gl.cpp b/src/opengl/qwindowsurface_x11gl.cpp new file mode 100644 index 0000000..8ef239d --- /dev/null +++ b/src/opengl/qwindowsurface_x11gl.cpp @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** 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. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QTime> +#include <QDebug> + +#include <private/qt_x11_p.h> +#include <private/qimagepixmapcleanuphooks_p.h> + +#include "qwindowsurface_x11gl_p.h" +#include "qpixmapdata_x11gl_p.h" + +QT_BEGIN_NAMESPACE + +QX11GLWindowSurface::QX11GLWindowSurface(QWidget* window) + : QWindowSurface(window), m_GC(0), m_window(window) +{ +} + +QX11GLWindowSurface::~QX11GLWindowSurface() +{ + if (m_GC) + XFree(m_GC); +} + +QPaintDevice *QX11GLWindowSurface::paintDevice() +{ + return &m_backBuffer; +} + +extern void *qt_getClipRects(const QRegion &r, int &num); // in qpaintengine_x11.cpp + +void QX11GLWindowSurface::flush(QWidget *widget, const QRegion &widgetRegion, const QPoint &offset) +{ +// qDebug("QX11GLWindowSurface::flush()"); + QTime startTime = QTime::currentTime(); + if (m_backBuffer.isNull()) { + qDebug("QHarmattanWindowSurface::flush() - backBuffer is null, not flushing anything"); + return; + } + + QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft(); + QRegion windowRegion(widgetRegion); + QRect boundingRect = widgetRegion.boundingRect(); + if (!widgetOffset.isNull()) + windowRegion.translate(-widgetOffset); + QRect windowBoundingRect = windowRegion.boundingRect(); + + int rectCount; + XRectangle *rects = (XRectangle *)qt_getClipRects(windowRegion, rectCount); + if (rectCount <= 0) + return; +// qDebug() << "XSetClipRectangles"; +// for (int i = 0; i < num; ++i) +// qDebug() << ' ' << i << rects[i].x << rects[i].x << rects[i].y << rects[i].width << rects[i].height; + + if (m_GC == 0) { + m_GC = XCreateGC(X11->display, m_window->handle(), 0, 0); + XSetGraphicsExposures(X11->display, m_GC, False); + } + + XSetClipRectangles(X11->display, m_GC, 0, 0, rects, rectCount, YXBanded); + XCopyArea(X11->display, m_backBuffer.handle(), m_window->handle(), m_GC, + boundingRect.x() + offset.x(), boundingRect.y() + offset.y(), + boundingRect.width(), boundingRect.height(), + windowBoundingRect.x(), windowBoundingRect.y()); +} + +void QX11GLWindowSurface::setGeometry(const QRect &rect) +{ + if (rect.width() > m_backBuffer.size().width() || rect.height() > m_backBuffer.size().height()) { + QSize newSize = rect.size(); +// QSize newSize(1024,512); + qDebug() << "QX11GLWindowSurface::setGeometry() - creating a pixmap of size" << newSize; + QX11GLPixmapData *pd = new QX11GLPixmapData; + pd->resize(newSize.width(), newSize.height()); + m_backBuffer = QPixmap(pd); + } + +// if (gc) +// XFreeGC(X11->display, gc); +// gc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0); +// XSetGraphicsExposures(X11->display, gc, False); + QWindowSurface::setGeometry(rect); +} + +bool QX11GLWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return false; +} + +/* +void QX11GLWindowSurface::beginPaint(const QRegion ®ion) +{ +} + +void QX11GLWindowSurface::endPaint(const QRegion ®ion) +{ +} + +QImage *QX11GLWindowSurface::buffer(const QWidget *widget) +{ +} +*/ + +QT_END_NAMESPACE diff --git a/src/opengl/qwindowsurface_x11gl_p.h b/src/opengl/qwindowsurface_x11gl_p.h new file mode 100644 index 0000000..5ba4dc5 --- /dev/null +++ b/src/opengl/qwindowsurface_x11gl_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** 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. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_X11GL_P_H +#define QWINDOWSURFACE_X11GL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qwindowsurface_p.h> + +QT_BEGIN_NAMESPACE + +class QX11GLWindowSurface : public QWindowSurface +{ +public: + QX11GLWindowSurface(QWidget* window); + virtual ~QX11GLWindowSurface(); + + // Inherreted from QWindowSurface + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + +private: + GC m_GC; + QPixmap m_backBuffer; + QWidget *m_window; +}; + + +QT_END_NAMESPACE + +#endif // QWINDOWSURFACE_X11GL_P_H diff --git a/src/svg/qsvggenerator.cpp b/src/svg/qsvggenerator.cpp index da3123f..2f80a92 100644 --- a/src/svg/qsvggenerator.cpp +++ b/src/svg/qsvggenerator.cpp @@ -1063,6 +1063,7 @@ void QSvgPaintEngine::drawTextItem(const QPointF &pt, const QTextItem &textItem) "fill=\"" << d->attributes.stroke << "\" " "fill-opacity=\"" << d->attributes.strokeOpacity << "\" " "stroke=\"none\" " + "xml:space=\"preserve\" " "x=\"" << pt.x() << "\" y=\"" << pt.y() << "\" "; qfontToSvg(textItem.font()); *d->stream << " >" |