summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessible.cpp24
-rw-r--r--src/gui/accessible/qaccessible.h4
-rw-r--r--src/gui/accessible/qaccessible2.h8
-rw-r--r--src/gui/accessible/qaccessiblebridge.h4
-rw-r--r--src/gui/accessible/qaccessibleobject.cpp33
-rw-r--r--src/gui/accessible/qaccessibleobject.h4
-rw-r--r--src/gui/accessible/qaccessibleplugin.h4
-rw-r--r--src/gui/accessible/qplatformaccessibility.h4
-rw-r--r--src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp43
-rw-r--r--src/gui/image/qbitmap.h4
-rw-r--r--src/gui/image/qicon.cpp6
-rw-r--r--src/gui/image/qicon.h4
-rw-r--r--src/gui/image/qiconengine.h4
-rw-r--r--src/gui/image/qiconengineplugin.h4
-rw-r--r--src/gui/image/qimage.h4
-rw-r--r--src/gui/image/qimageiohandler.h4
-rw-r--r--src/gui/image/qimagereader.cpp75
-rw-r--r--src/gui/image/qimagereader.h5
-rw-r--r--src/gui/image/qimagewriter.cpp85
-rw-r--r--src/gui/image/qimagewriter.h5
-rw-r--r--src/gui/image/qmovie.h4
-rw-r--r--src/gui/image/qpicture.h4
-rw-r--r--src/gui/image/qpictureformatplugin.h4
-rw-r--r--src/gui/image/qpixmap.cpp3
-rw-r--r--src/gui/image/qpixmap.h4
-rw-r--r--src/gui/image/qpixmap_raster.cpp2
-rw-r--r--src/gui/image/qpixmapcache.h4
-rw-r--r--src/gui/image/qplatformpixmap.cpp5
-rw-r--r--src/gui/image/qplatformpixmap.h5
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.h4
-rw-r--r--src/gui/kernel/kernel.pri4
-rw-r--r--src/gui/kernel/qclipboard.h4
-rw-r--r--src/gui/kernel/qcursor.h4
-rw-r--r--src/gui/kernel/qdrag.h4
-rw-r--r--src/gui/kernel/qevent.h4
-rw-r--r--src/gui/kernel/qgenericplugin.h4
-rw-r--r--src/gui/kernel/qgenericpluginfactory.h4
-rw-r--r--src/gui/kernel/qguiapplication.cpp127
-rw-r--r--src/gui/kernel/qguiapplication.h4
-rw-r--r--src/gui/kernel/qguiapplication_p.h4
-rw-r--r--src/gui/kernel/qinputmethod.h4
-rw-r--r--src/gui/kernel/qinputmethod_p.h4
-rw-r--r--src/gui/kernel/qkeysequence.h4
-rw-r--r--src/gui/kernel/qoffscreensurface.cpp345
-rw-r--r--src/gui/kernel/qoffscreensurface.h (renamed from src/gui/text/qrawfont_ft.cpp)117
-rw-r--r--src/gui/kernel/qopenglcontext.h4
-rw-r--r--src/gui/kernel/qopenglcontext_p.h4
-rw-r--r--src/gui/kernel/qpalette.h4
-rw-r--r--src/gui/kernel/qplatformclipboard.h4
-rw-r--r--src/gui/kernel/qplatformcursor.cpp4
-rw-r--r--src/gui/kernel/qplatformcursor.h4
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h4
-rw-r--r--src/gui/kernel/qplatformdrag.h4
-rw-r--r--src/gui/kernel/qplatforminputcontext.h4
-rw-r--r--src/gui/kernel/qplatforminputcontext_p.h4
-rw-r--r--src/gui/kernel/qplatforminputcontextfactory_p.h4
-rw-r--r--src/gui/kernel/qplatforminputcontextplugin_p.h4
-rw-r--r--src/gui/kernel/qplatformintegration.cpp11
-rw-r--r--src/gui/kernel/qplatformintegration.h8
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_p.h4
-rw-r--r--src/gui/kernel/qplatformintegrationplugin.h4
-rw-r--r--src/gui/kernel/qplatformmenu.h16
-rw-r--r--src/gui/kernel/qplatformnativeinterface.h4
-rw-r--r--src/gui/kernel/qplatformoffscreensurface.cpp93
-rw-r--r--src/gui/kernel/qplatformoffscreensurface.h (renamed from src/gui/text/qabstractfontengine_p.h)67
-rw-r--r--src/gui/kernel/qplatformopenglcontext.h4
-rw-r--r--src/gui/kernel/qplatformscreen.h4
-rw-r--r--src/gui/kernel/qplatformscreen_p.h4
-rw-r--r--src/gui/kernel/qplatformscreenpageflipper.h4
-rw-r--r--src/gui/kernel/qplatformservices.h3
-rw-r--r--src/gui/kernel/qplatformsharedgraphicscache.h4
-rw-r--r--src/gui/kernel/qplatformsurface.h5
-rw-r--r--src/gui/kernel/qplatformtheme.cpp16
-rw-r--r--src/gui/kernel/qplatformtheme.h7
-rw-r--r--src/gui/kernel/qplatformthemefactory_p.h4
-rw-r--r--src/gui/kernel/qplatformthemeplugin.h4
-rw-r--r--src/gui/kernel/qplatformwindow.cpp16
-rw-r--r--src/gui/kernel/qplatformwindow.h3
-rw-r--r--src/gui/kernel/qplatformwindow_p.h4
-rw-r--r--src/gui/kernel/qscreen.h4
-rw-r--r--src/gui/kernel/qscreen_p.h4
-rw-r--r--src/gui/kernel/qsessionmanager.h4
-rw-r--r--src/gui/kernel/qstylehints.h4
-rw-r--r--src/gui/kernel/qsurface.cpp1
-rw-r--r--src/gui/kernel/qsurface.h7
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp24
-rw-r--r--src/gui/kernel/qsurfaceformat.h8
-rw-r--r--src/gui/kernel/qtouchdevice.h4
-rw-r--r--src/gui/kernel/qtouchdevice_p.h4
-rw-r--r--src/gui/kernel/qwindow.cpp189
-rw-r--r--src/gui/kernel/qwindow.h24
-rw-r--r--src/gui/kernel/qwindow_p.h11
-rw-r--r--src/gui/kernel/qwindowdefs.h4
-rw-r--r--src/gui/kernel/qwindowdefs_win.h4
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp13
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h9
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h10
-rw-r--r--src/gui/math3d/qgenericmatrix.h4
-rw-r--r--src/gui/math3d/qmatrix4x4.h4
-rw-r--r--src/gui/math3d/qquaternion.cpp5
-rw-r--r--src/gui/math3d/qquaternion.h4
-rw-r--r--src/gui/math3d/qvector2d.h4
-rw-r--r--src/gui/math3d/qvector3d.h4
-rw-r--r--src/gui/math3d/qvector4d.h4
-rw-r--r--src/gui/opengl/qopengl.h4
-rw-r--r--src/gui/opengl/qopengl_p.h6
-rw-r--r--src/gui/opengl/qopenglbuffer.h4
-rw-r--r--src/gui/opengl/qopenglcustomshaderstage_p.h4
-rw-r--r--src/gui/opengl/qopenglengineshadermanager_p.h4
-rw-r--r--src/gui/opengl/qopenglengineshadersource_p.h4
-rw-r--r--src/gui/opengl/qopenglextensions_p.h4
-rw-r--r--src/gui/opengl/qopenglframebufferobject.h4
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp11
-rw-r--r--src/gui/opengl/qopenglfunctions.h4
-rw-r--r--src/gui/opengl/qopenglpaintdevice.h4
-rw-r--r--src/gui/opengl/qopenglpaintengine.cpp99
-rw-r--r--src/gui/opengl/qopenglpaintengine_p.h7
-rw-r--r--src/gui/opengl/qopenglshadercache_meego_p.h4
-rw-r--r--src/gui/opengl/qopenglshadercache_p.h4
-rw-r--r--src/gui/opengl/qopenglshaderprogram.h4
-rw-r--r--src/gui/opengl/qopengltexturecache.cpp7
-rw-r--r--src/gui/opengl/qopengltexturecache_p.h3
-rw-r--r--src/gui/opengl/qopengltextureglyphcache.cpp44
-rw-r--r--src/gui/painting/qbackingstore.h4
-rw-r--r--src/gui/painting/qbrush.h13
-rw-r--r--src/gui/painting/qcolor.h4
-rw-r--r--src/gui/painting/qcosmeticstroker_p.h4
-rw-r--r--src/gui/painting/qdrawhelper.cpp2
-rw-r--r--src/gui/painting/qdrawhelper_p.h38
-rw-r--r--src/gui/painting/qemulationpaintengine_p.h4
-rw-r--r--src/gui/painting/qgrayraster.c10
-rw-r--r--src/gui/painting/qmatrix.h4
-rw-r--r--src/gui/painting/qoutlinemapper.cpp2
-rw-r--r--src/gui/painting/qpagedpaintdevice.h4
-rw-r--r--src/gui/painting/qpaintbuffer.cpp2
-rw-r--r--src/gui/painting/qpaintdevice.h4
-rw-r--r--src/gui/painting/qpaintengine.h4
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp48
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h4
-rw-r--r--src/gui/painting/qpaintengineex.cpp12
-rw-r--r--src/gui/painting/qpaintengineex_p.h6
-rw-r--r--src/gui/painting/qpainter.cpp36
-rw-r--r--src/gui/painting/qpainter.h4
-rw-r--r--src/gui/painting/qpainterpath.h4
-rw-r--r--src/gui/painting/qpathclipper_p.h4
-rw-r--r--src/gui/painting/qpdfwriter.h4
-rw-r--r--src/gui/painting/qpen.h4
-rw-r--r--src/gui/painting/qplatformbackingstore.h4
-rw-r--r--src/gui/painting/qpolygon.h4
-rw-r--r--src/gui/painting/qregion.h4
-rw-r--r--src/gui/painting/qrgb.h7
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp7
-rw-r--r--src/gui/painting/qtextureglyphcache_p.h4
-rw-r--r--src/gui/painting/qtransform.h8
-rw-r--r--src/gui/painting/qvectorpath_p.h4
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.h4
-rw-r--r--src/gui/text/qfont.cpp35
-rw-r--r--src/gui/text/qfont.h4
-rw-r--r--src/gui/text/qfont_p.h3
-rw-r--r--src/gui/text/qfont_qpa.cpp2
-rw-r--r--src/gui/text/qfontdatabase.cpp87
-rw-r--r--src/gui/text/qfontdatabase.h4
-rw-r--r--src/gui/text/qfontdatabase_qpa.cpp12
-rw-r--r--src/gui/text/qfontengine.cpp11
-rw-r--r--src/gui/text/qfontengine_ft.cpp7
-rw-r--r--src/gui/text/qfontengine_p.h6
-rw-r--r--src/gui/text/qfontengine_qpa.cpp4
-rw-r--r--src/gui/text/qfontengine_qpa_p.h4
-rw-r--r--src/gui/text/qfontengine_qpf.cpp4
-rw-r--r--src/gui/text/qfontengineglyphcache_p.h1
-rw-r--r--src/gui/text/qfontinfo.h4
-rw-r--r--src/gui/text/qfontmetrics.cpp96
-rw-r--r--src/gui/text/qfontmetrics.h4
-rw-r--r--src/gui/text/qglyphrun.h4
-rw-r--r--src/gui/text/qglyphrun_p.h4
-rw-r--r--src/gui/text/qplatformfontdatabase.cpp7
-rw-r--r--src/gui/text/qplatformfontdatabase.h10
-rw-r--r--src/gui/text/qrawfont.h4
-rw-r--r--src/gui/text/qstatictext.h4
-rw-r--r--src/gui/text/qsyntaxhighlighter.h4
-rw-r--r--src/gui/text/qtextcursor.h4
-rw-r--r--src/gui/text/qtextdocument.h4
-rw-r--r--src/gui/text/qtextdocumentfragment.h4
-rw-r--r--src/gui/text/qtextdocumentwriter.h4
-rw-r--r--src/gui/text/qtextengine.cpp31
-rw-r--r--src/gui/text/qtextformat.h4
-rw-r--r--src/gui/text/qtextlayout.h4
-rw-r--r--src/gui/text/qtextlist.h4
-rw-r--r--src/gui/text/qtextobject.h4
-rw-r--r--src/gui/text/qtextoption.h4
-rw-r--r--src/gui/text/qtexttable.h4
-rw-r--r--src/gui/util/qdesktopservices.h4
-rw-r--r--src/gui/util/qvalidator.cpp159
-rw-r--r--src/gui/util/qvalidator.h37
194 files changed, 1616 insertions, 1174 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 9b8e44f003..1d1b64117e 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -51,6 +51,7 @@
#include <QtCore/qdebug.h>
#include <QtCore/qmetaobject.h>
+#include <QtCore/qhash.h>
#include <private/qfactoryloader_p.h>
QT_BEGIN_NAMESPACE
@@ -430,6 +431,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
#endif
Q_GLOBAL_STATIC(QList<QAccessible::InterfaceFactory>, qAccessibleFactories)
+typedef QHash<QString, QAccessiblePlugin*> QAccessiblePluginsHash;
+Q_GLOBAL_STATIC(QAccessiblePluginsHash, qAccessiblePlugins);
QAccessible::UpdateHandler QAccessible::updateHandler = 0;
QAccessible::RootObjectHandler QAccessible::rootObjectHandler = 0;
@@ -580,9 +583,13 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
if (!object)
return 0;
+ // Create a QAccessibleInterface for the object class. Start by the most
+ // derived class and walk up the class hierarchy.
const QMetaObject *mo = object->metaObject();
while (mo) {
const QString cn = QLatin1String(mo->className());
+
+ // Check if the class has a InterfaceFactory installed.
for (int i = qAccessibleFactories()->count(); i > 0; --i) {
InterfaceFactory factory = qAccessibleFactories()->at(i - 1);
if (QAccessibleInterface *iface = factory(cn, object))
@@ -590,8 +597,21 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
}
#ifndef QT_NO_ACCESSIBILITY
#ifndef QT_NO_LIBRARY
- if (QAccessibleInterface * iface = qLoadPlugin1<QAccessibleInterface, QAccessiblePlugin>(loader(), cn, object))
- return iface;
+ // Find a QAccessiblePlugin (factory) for the class name. If there's
+ // no entry in the cache try to create it using the plugin loader.
+ if (!qAccessiblePlugins()->contains(cn)) {
+ QAccessiblePlugin *factory = 0; // 0 means "no plugin found". This is cached as well.
+ const int index = loader()->indexOf(cn);
+ if (index != -1)
+ factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+ qAccessiblePlugins()->insert(cn, factory);
+ }
+
+ // At this point the cache should contain a valid factory pointer or 0:
+ Q_ASSERT(qAccessiblePlugins()->contains(cn));
+ QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+ if (factory)
+ return factory->create(cn, object);
#endif
#endif
mo = mo->superClass();
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h
index 5988e6c346..96fc7c031b 100644
--- a/src/gui/accessible/qaccessible.h
+++ b/src/gui/accessible/qaccessible.h
@@ -54,8 +54,6 @@
#include <stdlib.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -679,7 +677,5 @@ inline void QAccessible::updateAccessibility(QObject *object, int child, Event r
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QACCESSIBLE_H
#endif //!QT_NO_ACCESSIBILITY
diff --git a/src/gui/accessible/qaccessible2.h b/src/gui/accessible/qaccessible2.h
index 2f95094584..169ca2b5e5 100644
--- a/src/gui/accessible/qaccessible2.h
+++ b/src/gui/accessible/qaccessible2.h
@@ -45,8 +45,6 @@
#include <QtGui/qaccessible.h>
#include <QtCore/qcoreapplication.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -186,9 +184,9 @@ public:
virtual bool isColumnSelected(int column) const = 0;
// Returns a boolean value indicating whether the specified row is completely selected.
virtual bool isRowSelected(int row) const = 0;
- // Selects a row and unselects all previously selected rows.
+ // Selects a row and it might unselect all previously selected rows.
virtual bool selectRow(int row) = 0;
- // Selects a column and unselects all previously selected columns.
+ // Selects a column it might unselect all previously selected columns.
virtual bool selectColumn(int column) = 0;
// Unselects one row, leaving other selected rows selected (if any).
virtual bool unselectRow(int row) = 0;
@@ -234,6 +232,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/accessible/qaccessiblebridge.h b/src/gui/accessible/qaccessiblebridge.h
index 077996900b..0a0002af2c 100644
--- a/src/gui/accessible/qaccessiblebridge.h
+++ b/src/gui/accessible/qaccessiblebridge.h
@@ -45,8 +45,6 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -79,6 +77,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QACCESSIBLEBRIDGE_H
diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp
index af8787ae80..c1ef71e1fa 100644
--- a/src/gui/accessible/qaccessibleobject.cpp
+++ b/src/gui/accessible/qaccessibleobject.cpp
@@ -55,39 +55,8 @@ class QAccessibleObjectPrivate
{
public:
QPointer<QObject> object;
-
- QList<QByteArray> actionList() const;
};
-QList<QByteArray> QAccessibleObjectPrivate::actionList() const
-{
- QList<QByteArray> actionList;
-
- if (!object)
- return actionList;
-
- const QMetaObject *mo = object->metaObject();
- Q_ASSERT(mo);
-
- QByteArray defaultAction = QMetaObject::normalizedSignature(
- mo->classInfo(mo->indexOfClassInfo("DefaultSlot")).value());
-
- for (int i = 0; i < mo->methodCount(); ++i) {
- const QMetaMethod member = mo->method(i);
- if (member.methodType() != QMetaMethod::Slot && member.access() != QMetaMethod::Public)
- continue;
-
- if (!qstrcmp(member.tag(), "QACCESSIBLE_SLOT")) {
- if (member.methodSignature() == defaultAction)
- actionList.prepend(defaultAction);
- else
- actionList << member.methodSignature();
- }
- }
-
- return actionList;
-}
-
/*!
\class QAccessibleObject
\brief The QAccessibleObject class implements parts of the
@@ -224,6 +193,8 @@ int QAccessibleApplication::childCount() const
/*! \reimp */
int QAccessibleApplication::indexOfChild(const QAccessibleInterface *child) const
{
+ if (!child)
+ return -1;
const QObjectList tlw(topLevelObjects());
return tlw.indexOf(child->object());
}
diff --git a/src/gui/accessible/qaccessibleobject.h b/src/gui/accessible/qaccessibleobject.h
index abe55f38c6..fcbaa59dc9 100644
--- a/src/gui/accessible/qaccessibleobject.h
+++ b/src/gui/accessible/qaccessibleobject.h
@@ -45,8 +45,6 @@
#include <QtGui/qaccessible.h>
#include <QtGui/qaccessible2.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -101,6 +99,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QACCESSIBLEOBJECT_H
diff --git a/src/gui/accessible/qaccessibleplugin.h b/src/gui/accessible/qaccessibleplugin.h
index 6f7915d025..ac56c83f98 100644
--- a/src/gui/accessible/qaccessibleplugin.h
+++ b/src/gui/accessible/qaccessibleplugin.h
@@ -45,8 +45,6 @@
#include <QtGui/qaccessible.h>
#include <QtCore/qfactoryinterface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -73,6 +71,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QACCESSIBLEPLUGIN_H
diff --git a/src/gui/accessible/qplatformaccessibility.h b/src/gui/accessible/qplatformaccessibility.h
index f10e8a7f12..26a22e492d 100644
--- a/src/gui/accessible/qplatformaccessibility.h
+++ b/src/gui/accessible/qplatformaccessibility.h
@@ -55,8 +55,6 @@
#include <QtGui/qaccessible.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -75,8 +73,6 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_ACCESSIBILITY
#endif // QPLATFORMACCESSIBILITY_H
diff --git a/src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp b/src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp
index fbf58a8c09..f9a4ee4ad1 100644
--- a/src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp
+++ b/src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp
@@ -133,3 +133,46 @@ s = "README.1ST"; v.validate(s, pos); // Returns Acceptable
s = "read me.txt"; v.validate(s, pos); // Returns Invalid
s = "readm"; v.validate(s, pos); // Returns Intermediate
//! [4]
+
+//! [5]
+// regexp: optional '-' followed by between 1 and 3 digits
+QRegularExpression rx("-?\\d{1,3}");
+QValidator *validator = new QRegularExpressionValidator(rx, this);
+
+QLineEdit *edit = new QLineEdit(this);
+edit->setValidator(validator);
+//! [5]
+
+//! [6]
+// integers 1 to 9999
+QRegularExpression re("[1-9]\\d{0,3}");
+// the validator treats the regexp as "^[1-9]\\d{0,3}$"
+QRegularExpressionValidator v(re, 0);
+QString s;
+int pos = 0;
+
+s = "0"; v.validate(s, pos); // returns Invalid
+s = "12345"; v.validate(s, pos); // returns Invalid
+s = "1"; v.validate(s, pos); // returns Acceptable
+
+re.setPattern("\\S+"); // one or more non-whitespace characters
+v.setRegularExpression(re);
+s = "myfile.txt"; v.validate(s, pos); // Returns Acceptable
+s = "my file.txt"; v.validate(s, pos); // Returns Invalid
+
+// A, B or C followed by exactly five digits followed by W, X, Y or Z
+re.setPattern("[A-C]\\d{5}[W-Z]");
+v.setRegularExpression(re);
+s = "a12345Z"; v.validate(s, pos); // Returns Invalid
+s = "A12345Z"; v.validate(s, pos); // Returns Acceptable
+s = "B12"; v.validate(s, pos); // Returns Intermediate
+
+// match most 'readme' files
+re.setPattern("read\\S?me(\.(txt|asc|1st))?");
+re.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
+v.setRegularExpression(re);
+s = "readme"; v.validate(s, pos); // Returns Acceptable
+s = "README.1ST"; v.validate(s, pos); // Returns Acceptable
+s = "read me.txt"; v.validate(s, pos); // Returns Invalid
+s = "readm"; v.validate(s, pos); // Returns Intermediate
+//! [6]
diff --git a/src/gui/image/qbitmap.h b/src/gui/image/qbitmap.h
index 1f062a0758..f8bd2feed7 100644
--- a/src/gui/image/qbitmap.h
+++ b/src/gui/image/qbitmap.h
@@ -44,8 +44,6 @@
#include <QtGui/qpixmap.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -80,6 +78,4 @@ Q_DECLARE_SHARED(QBitmap)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QBITMAP_H
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index dce902301c..6b91ead666 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -60,6 +60,7 @@
#include "private/qhexstring_p.h"
#include "private/qguiapplication_p.h"
+#include "qpa/qplatformtheme.h"
#ifndef QT_NO_ICON
QT_BEGIN_NAMESPACE
@@ -986,7 +987,10 @@ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
if (qtIconCache()->contains(name)) {
icon = *qtIconCache()->object(name);
} else {
- QIcon *cachedIcon = new QIcon(new QIconLoaderEngine(name));
+ QPlatformTheme * const platformTheme = QGuiApplicationPrivate::platformTheme();
+ QIconEngine * const engine = platformTheme ? platformTheme->createIconEngine(name)
+ : new QIconLoaderEngine(name);
+ QIcon *cachedIcon = new QIcon(engine);
qtIconCache()->insert(name, cachedIcon);
icon = *cachedIcon;
}
diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h
index ad459005f5..cda2360bed 100644
--- a/src/gui/image/qicon.h
+++ b/src/gui/image/qicon.h
@@ -47,8 +47,6 @@
#include <QtCore/qlist.h>
#include <QtGui/qpixmap.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -140,6 +138,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QIcon &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QICON_H
diff --git a/src/gui/image/qiconengine.h b/src/gui/image/qiconengine.h
index 1d296b9f66..9fb21adf97 100644
--- a/src/gui/image/qiconengine.h
+++ b/src/gui/image/qiconengine.h
@@ -46,8 +46,6 @@
#include <QtCore/qlist.h>
#include <QtGui/qicon.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -90,6 +88,4 @@ typedef QIconEngine QIconEngineV2;
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QICONENGINE_H
diff --git a/src/gui/image/qiconengineplugin.h b/src/gui/image/qiconengineplugin.h
index 58bade1d09..a62659f8cb 100644
--- a/src/gui/image/qiconengineplugin.h
+++ b/src/gui/image/qiconengineplugin.h
@@ -45,8 +45,6 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -66,6 +64,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QICONENGINEPLUGIN_H
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index bce25c49ea..50d4bc7666 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -53,8 +53,6 @@
#include <QtCore/qstringlist.h>
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -430,6 +428,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QImage &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QIMAGE_H
diff --git a/src/gui/image/qimageiohandler.h b/src/gui/image/qimageiohandler.h
index f6d905bc6b..2ba99beab3 100644
--- a/src/gui/image/qimageiohandler.h
+++ b/src/gui/image/qimageiohandler.h
@@ -46,8 +46,6 @@
#include <QtCore/qfactoryinterface.h>
#include <QtCore/qscopedpointer.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -142,6 +140,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QImageIOPlugin::Capabilities)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QIMAGEIOHANDLER_H
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index 5eaf7bb8f2..89930f3b20 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -189,34 +189,35 @@ struct _qt_BuiltInFormatStruct
{
_qt_BuiltInFormatType type;
const char *extension;
+ const char *mimeType;
};
static const _qt_BuiltInFormatStruct _qt_BuiltInFormats[] = {
#ifndef QT_NO_IMAGEFORMAT_PNG
- {_qt_PngFormat, "png"},
+ {_qt_PngFormat, "png", "image/png"},
#endif
#ifndef QT_NO_IMAGEFORMAT_JPEG
- {_qt_JpgFormat, "jpg"},
+ {_qt_JpgFormat, "jpg", "image/jpeg"},
{_qt_JpegFormat, "jpeg"},
#endif
#ifdef QT_BUILTIN_GIF_READER
- {_qt_GifFormat, "gif"},
+ {_qt_GifFormat, "gif", "image/gif"},
#endif
#ifndef QT_NO_IMAGEFORMAT_BMP
- {_qt_BmpFormat, "bmp"},
+ {_qt_BmpFormat, "bmp", "image/bmp"},
#endif
#ifndef QT_NO_IMAGEFORMAT_PPM
- {_qt_PpmFormat, "ppm"},
- {_qt_PgmFormat, "pgm"},
- {_qt_PbmFormat, "pbm"},
+ {_qt_PpmFormat, "ppm", "image/x-portable-pixmap"},
+ {_qt_PgmFormat, "pgm", "image/x-portable-graymap"},
+ {_qt_PbmFormat, "pbm", "image/x-portable-bitmap"},
#endif
#ifndef QT_NO_IMAGEFORMAT_XBM
- {_qt_XbmFormat, "xbm"},
+ {_qt_XbmFormat, "xbm", "image/x-xbitmap"},
#endif
#ifndef QT_NO_IMAGEFORMAT_XPM
- {_qt_XpmFormat, "xpm"},
+ {_qt_XpmFormat, "xpm", "image/x-xpixmap"},
#endif
- {_qt_NoFormat, ""}
+ {_qt_NoFormat, "", ""}
};
static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
@@ -1441,6 +1442,10 @@ QByteArray QImageReader::imageFormat(QIODevice *device)
void supportedImageHandlerFormats(QFactoryLoader *loader,
QImageIOPlugin::Capability cap,
QSet<QByteArray> *result);
+
+void supportedImageHandlerMimeTypes(QFactoryLoader *loader,
+ QImageIOPlugin::Capability cap,
+ QSet<QByteArray> *result);
#endif
/*!
@@ -1449,18 +1454,17 @@ void supportedImageHandlerFormats(QFactoryLoader *loader,
By default, Qt can read the following formats:
\table
- \header \li Format \li Description
- \row \li BMP \li Windows Bitmap
- \row \li GIF \li Graphic Interchange Format (optional)
- \row \li JPG \li Joint Photographic Experts Group
- \row \li JPEG \li Joint Photographic Experts Group
- \row \li PNG \li Portable Network Graphics
- \row \li PBM \li Portable Bitmap
- \row \li PGM \li Portable Graymap
- \row \li PPM \li Portable Pixmap
- \row \li XBM \li X11 Bitmap
- \row \li XPM \li X11 Pixmap
- \row \li SVG \li Scalable Vector Graphics
+ \header \li Format \li MIME type \li Description
+ \row \li BMP \li image/bmp \li Windows Bitmap
+ \row \li GIF \li image/gif \li Graphic Interchange Format (optional)
+ \row \li JPG \li image/jpeg \li Joint Photographic Experts Group
+ \row \li PNG \li image/png \li Portable Network Graphics
+ \row \li PBM \li image/x-portable-bitmap \li Portable Bitmap
+ \row \li PGM \li image/x-portable-graymap \li Portable Graymap
+ \row \li PPM \li image/x-portable-pixmap \li Portable Pixmap
+ \row \li XBM \li image/x-xbitmap \li X11 Bitmap
+ \row \li XPM \li image/x-xpixmap \li X11 Pixmap
+ \row \li SVG \li image/svg+xml \li Scalable Vector Graphics
\endtable
Reading and writing SVG files is supported through the \l{Qt SVG} module.
@@ -1490,4 +1494,31 @@ QList<QByteArray> QImageReader::supportedImageFormats()
return sortedFormats;
}
+/*!
+ Returns the list of MIME types supported by QImageReader.
+
+ Note that the QApplication instance must be created before this function is
+ called.
+
+ \sa supportedImageFormats(), QImageWriter::supportedMimeTypes()
+*/
+
+QList<QByteArray> QImageReader::supportedMimeTypes()
+{
+ QSet<QByteArray> mimeTypes;
+ for (int i = 0; i < _qt_NumFormats; ++i)
+ mimeTypes << _qt_BuiltInFormats[i].mimeType;
+
+#ifndef QT_NO_LIBRARY
+ supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanRead, &mimeTypes);
+#endif // QT_NO_LIBRARY
+
+ QList<QByteArray> sortedMimeTypes;
+ for (QSet<QByteArray>::ConstIterator it = mimeTypes.constBegin(); it != mimeTypes.constEnd(); ++it)
+ sortedMimeTypes << *it;
+
+ qSort(sortedMimeTypes);
+ return sortedMimeTypes;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qimagereader.h b/src/gui/image/qimagereader.h
index 11c925b142..4f3c93af7d 100644
--- a/src/gui/image/qimagereader.h
+++ b/src/gui/image/qimagereader.h
@@ -46,8 +46,6 @@
#include <QtGui/qimage.h>
#include <QtGui/qimageiohandler.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -133,6 +131,7 @@ public:
static QByteArray imageFormat(const QString &fileName);
static QByteArray imageFormat(QIODevice *device);
static QList<QByteArray> supportedImageFormats();
+ static QList<QByteArray> supportedMimeTypes();
private:
Q_DISABLE_COPY(QImageReader)
@@ -141,6 +140,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QIMAGEREADER_H
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
index 20e601be03..8823f9293d 100644
--- a/src/gui/image/qimagewriter.cpp
+++ b/src/gui/image/qimagewriter.cpp
@@ -100,6 +100,7 @@
#include <qfile.h>
#include <qfileinfo.h>
#include <qimageiohandler.h>
+#include <qjsonarray.h>
#include <qset.h>
#include <qvariant.h>
@@ -677,6 +678,26 @@ void supportedImageHandlerFormats(QFactoryLoader *loader,
result->insert(key);
}
}
+
+void supportedImageHandlerMimeTypes(QFactoryLoader *loader,
+ QImageIOPlugin::Capability cap,
+ QSet<QByteArray> *result)
+{
+ QList<QJsonObject> metaDataList = loader->metaData();
+
+ const int pluginCount = metaDataList.size();
+ for (int i = 0; i < pluginCount; ++i) {
+ const QJsonObject metaData = metaDataList.at(i).value(QStringLiteral("MetaData")).toObject();
+ const QJsonArray keys = metaData.value(QStringLiteral("Keys")).toArray();
+ const QJsonArray mimeTypes = metaData.value(QStringLiteral("MimeTypes")).toArray();
+ QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(loader->instance(i));
+ const int keyCount = keys.size();
+ for (int k = 0; k < keyCount; ++k) {
+ if (plugin && (plugin->capabilities(0, keys.at(k).toString().toLatin1()) & cap) != 0)
+ result->insert(mimeTypes.at(k).toString().toLatin1());
+ }
+ }
+}
#endif // QT_NO_IMAGEFORMATPLUGIN
/*!
@@ -685,16 +706,15 @@ void supportedImageHandlerFormats(QFactoryLoader *loader,
By default, Qt can write the following formats:
\table
- \header \li Format \li Description
- \row \li BMP \li Windows Bitmap
- \row \li JPG \li Joint Photographic Experts Group
- \row \li JPEG \li Joint Photographic Experts Group
- \row \li PNG \li Portable Network Graphics
- \row \li PBM \li Portable Bitmap
- \row \li PGM \li Portable Graymap
- \row \li PPM \li Portable Pixmap
- \row \li XBM \li X11 Bitmap
- \row \li XPM \li X11 Pixmap
+ \header \li Format \li MIME type \li Description
+ \row \li BMP \li image/bmp \li Windows Bitmap
+ \row \li JPG \li image/jpeg \li Joint Photographic Experts Group
+ \row \li PNG \li image/png \li Portable Network Graphics
+ \row \li PBM \li image/x-portable-bitmap \li Portable Bitmap
+ \row \li PGM \li image/x-portable-graymap \li Portable Graymap
+ \row \li PPM \li image/x-portable-pixmap \li Portable Pixmap
+ \row \li XBM \li image/x-xbitmap \li X11 Bitmap
+ \row \li XPM \li image/x-xpixmap \li X11 Pixmap
\endtable
Reading and writing SVG files is supported through the \l{Qt SVG} module.
@@ -726,9 +746,6 @@ QList<QByteArray> QImageWriter::supportedImageFormats()
#ifndef QT_NO_IMAGEFORMAT_JPEG
formats << "jpg" << "jpeg";
#endif
-#ifdef QT_BUILTIN_GIF_READER
- formats << "gif";
-#endif
#ifndef QT_NO_IMAGEFORMATPLUGIN
supportedImageHandlerFormats(loader(), QImageIOPlugin::CanWrite, &formats);
@@ -742,4 +759,46 @@ QList<QByteArray> QImageWriter::supportedImageFormats()
return sortedFormats;
}
+/*!
+ Returns the list of MIME types supported by QImageWriter.
+
+ Note that the QApplication instance must be created before this function is
+ called.
+
+ \sa supportedImageFormats(), QImageReader::supportedMimeTypes()
+*/
+QList<QByteArray> QImageWriter::supportedMimeTypes()
+{
+ QSet<QByteArray> mimeTypes;
+ mimeTypes << "image/bmp";
+#ifndef QT_NO_IMAGEFORMAT_PPM
+ mimeTypes << "image/x-portable-bitmap";
+ mimeTypes << "image/x-portable-graymap";
+ mimeTypes << "image/x-portable-pixmap";
+#endif
+#ifndef QT_NO_IMAGEFORMAT_XBM
+ mimeTypes << "image/x-xbitmap";
+#endif
+#ifndef QT_NO_IMAGEFORMAT_XPM
+ mimeTypes << "image/x-xpixmap";
+#endif
+#ifndef QT_NO_IMAGEFORMAT_PNG
+ mimeTypes << "image/png";
+#endif
+#ifndef QT_NO_IMAGEFORMAT_JPEG
+ mimeTypes << "image/jpeg";
+#endif
+
+#ifndef QT_NO_LIBRARY
+ supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanWrite, &mimeTypes);
+#endif // QT_NO_LIBRARY
+
+ QList<QByteArray> sortedMimeTypes;
+ for (QSet<QByteArray>::ConstIterator it = mimeTypes.constBegin(); it != mimeTypes.constEnd(); ++it)
+ sortedMimeTypes << *it;
+
+ qSort(sortedMimeTypes);
+ return sortedMimeTypes;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qimagewriter.h b/src/gui/image/qimagewriter.h
index 7d05cd5236..3f5cf9c454 100644
--- a/src/gui/image/qimagewriter.h
+++ b/src/gui/image/qimagewriter.h
@@ -46,8 +46,6 @@
#include <QtCore/qlist.h>
#include <QtGui/qimageiohandler.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -102,6 +100,7 @@ public:
bool supportsOption(QImageIOHandler::ImageOption option) const;
static QList<QByteArray> supportedImageFormats();
+ static QList<QByteArray> supportedMimeTypes();
private:
Q_DISABLE_COPY(QImageWriter)
@@ -110,6 +109,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QIMAGEWRITER_H
diff --git a/src/gui/image/qmovie.h b/src/gui/image/qmovie.h
index 60df9199c4..94d7c79e7b 100644
--- a/src/gui/image/qmovie.h
+++ b/src/gui/image/qmovie.h
@@ -50,8 +50,6 @@
#include <QtCore/qlist.h>
#include <QtGui/qimagereader.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -146,8 +144,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_MOVIE
#endif // QMOVIE_H
diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h
index f0abb50764..08445a3143 100644
--- a/src/gui/image/qpicture.h
+++ b/src/gui/image/qpicture.h
@@ -46,8 +46,6 @@
#include <QtCore/qsharedpointer.h>
#include <QtGui/qpaintdevice.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -193,6 +191,4 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPicture &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPICTURE_H
diff --git a/src/gui/image/qpictureformatplugin.h b/src/gui/image/qpictureformatplugin.h
index 16e7feaffe..30989c084c 100644
--- a/src/gui/image/qpictureformatplugin.h
+++ b/src/gui/image/qpictureformatplugin.h
@@ -45,8 +45,6 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -76,6 +74,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPICTUREFORMATPLUGIN_H
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index b6a21f588e..85f0dc2d92 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -678,6 +678,9 @@ qreal QPixmap::devicePixelRatio() const
*/
void QPixmap::setDevicePixelRatio(qreal scaleFactor)
{
+ if (isNull())
+ return;
+
detach();
data->setDevicePixelRatio(scaleFactor);
}
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h
index a25ecb21e4..f1fce03c80 100644
--- a/src/gui/image/qpixmap.h
+++ b/src/gui/image/qpixmap.h
@@ -50,8 +50,6 @@
#include <QtGui/qimage.h>
#include <QtGui/qtransform.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -245,6 +243,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QPixmap &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPIXMAP_H
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index f0cb69f3ec..554b31debf 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -353,7 +353,9 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC
is_null = (w <= 0 || h <= 0);
image.d->devicePixelRatio = sourceImage.devicePixelRatio();
+ //ensure the pixmap and the image resulting from toImage() have the same cacheKey();
setSerialNumber(image.cacheKey() >> 32);
+ setDetachNumber(image.d->detach_no);
}
QImage* QRasterPlatformPixmap::buffer()
diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h
index 7f7db7dc35..83e6610f2a 100644
--- a/src/gui/image/qpixmapcache.h
+++ b/src/gui/image/qpixmapcache.h
@@ -48,8 +48,6 @@
#include <QtCore/qpair.h>
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -96,6 +94,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPIXMAPCACHE_H
diff --git a/src/gui/image/qplatformpixmap.cpp b/src/gui/image/qplatformpixmap.cpp
index ce66972dc3..54f0087bc2 100644
--- a/src/gui/image/qplatformpixmap.cpp
+++ b/src/gui/image/qplatformpixmap.cpp
@@ -173,6 +173,11 @@ void QPlatformPixmap::setSerialNumber(int serNo)
ser_no = serNo;
}
+void QPlatformPixmap::setDetachNumber(int detNo)
+{
+ detach_no = detNo;
+}
+
QImage QPlatformPixmap::toImage(const QRect &rect) const
{
if (rect.contains(QRect(0, 0, w, h)))
diff --git a/src/gui/image/qplatformpixmap.h b/src/gui/image/qplatformpixmap.h
index ded4bd30a9..08e03f10bd 100644
--- a/src/gui/image/qplatformpixmap.h
+++ b/src/gui/image/qplatformpixmap.h
@@ -54,8 +54,6 @@
#include <QtGui/qpixmap.h>
#include <QtCore/qatomic.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -132,6 +130,7 @@ public:
protected:
void setSerialNumber(int serNo);
+ void setDetachNumber(int detNo);
int w;
int h;
int d;
@@ -158,6 +157,4 @@ extern bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, int, int,
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMPIXMAP_H
diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h
index b4f03008fd..ef19a03125 100644
--- a/src/gui/itemmodels/qstandarditemmodel.h
+++ b/src/gui/itemmodels/qstandarditemmodel.h
@@ -50,8 +50,6 @@
#include <QtCore/qdatastream.h>
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -453,6 +451,4 @@ Q_GUI_EXPORT QDataStream &operator<<(QDataStream &out, const QStandardItem &item
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif //QSTANDARDITEMMODEL_H
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index f766b5fbaf..eb87a8c31b 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -24,6 +24,7 @@ HEADERS += \
kernel/qplatformthemefactory_p.h \
kernel/qplatformthemeplugin.h \
kernel/qplatformwindow.h \
+ kernel/qplatformoffscreensurface.h \
kernel/qplatformwindow_p.h \
kernel/qplatformcursor.h \
kernel/qplatformclipboard.h \
@@ -34,6 +35,7 @@ HEADERS += \
kernel/qguiapplication_p.h \
kernel/qwindow_p.h \
kernel/qwindow.h \
+ kernel/qoffscreensurface.h \
kernel/qplatformsurface.h \
kernel/qsurface.h \
kernel/qclipboard.h \
@@ -81,6 +83,7 @@ SOURCES += \
kernel/qplatformthemefactory.cpp \
kernel/qplatformthemeplugin.cpp \
kernel/qplatformwindow.cpp \
+ kernel/qplatformoffscreensurface.cpp \
kernel/qplatformcursor.cpp \
kernel/qplatformclipboard.cpp \
kernel/qplatformnativeinterface.cpp \
@@ -88,6 +91,7 @@ SOURCES += \
kernel/qsurfaceformat.cpp \
kernel/qguiapplication.cpp \
kernel/qwindow.cpp \
+ kernel/qoffscreensurface.cpp \
kernel/qplatformsurface.cpp \
kernel/qsurface.cpp \
kernel/qclipboard.cpp \
diff --git a/src/gui/kernel/qclipboard.h b/src/gui/kernel/qclipboard.h
index 520d731717..7235a03b6b 100644
--- a/src/gui/kernel/qclipboard.h
+++ b/src/gui/kernel/qclipboard.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -112,6 +110,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QCLIPBOARD_H
diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h
index d4ca15ff93..016a0ef798 100644
--- a/src/gui/kernel/qcursor.h
+++ b/src/gui/kernel/qcursor.h
@@ -45,8 +45,6 @@
#include <QtCore/qpoint.h>
#include <QtGui/qwindowdefs.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -130,6 +128,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QCursor &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QCURSOR_H
diff --git a/src/gui/kernel/qdrag.h b/src/gui/kernel/qdrag.h
index abbb382400..553b0e1922 100644
--- a/src/gui/kernel/qdrag.h
+++ b/src/gui/kernel/qdrag.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -100,6 +98,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QDRAG_H
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index e84765cae6..0b4e708bdb 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -58,8 +58,6 @@
#include <QtGui/qvector2d.h>
#include <QtGui/qtouchdevice.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -909,6 +907,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QEVENT_H
diff --git a/src/gui/kernel/qgenericplugin.h b/src/gui/kernel/qgenericplugin.h
index 10bde146bd..f00a532283 100644
--- a/src/gui/kernel/qgenericplugin.h
+++ b/src/gui/kernel/qgenericplugin.h
@@ -45,8 +45,6 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -68,6 +66,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QGENERICPLUGIN_H
diff --git a/src/gui/kernel/qgenericpluginfactory.h b/src/gui/kernel/qgenericpluginfactory.h
index 03d688a5c5..2443e670cc 100644
--- a/src/gui/kernel/qgenericpluginfactory.h
+++ b/src/gui/kernel/qgenericpluginfactory.h
@@ -44,8 +44,6 @@
#include <QtCore/qstringlist.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -61,6 +59,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QGENERICPLUGINFACTORY_H
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index c155ecfe0c..89b3b9ab89 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1063,6 +1063,8 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate()
delete platform_integration;
platform_integration = 0;
delete m_gammaTables.load();
+
+ window_list.clear();
}
#if 0
@@ -1665,10 +1667,10 @@ void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::Cl
void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e)
{
- if (e->fileName.isEmpty())
+ if (e->url.isEmpty())
return;
- QFileOpenEvent event(e->fileName);
+ QFileOpenEvent event(e->url);
QGuiApplication::sendSpontaneousEvent(qApp, &event);
}
@@ -2622,6 +2624,13 @@ static inline void applyCursor(QWindow *w, QCursor c)
cursor->changeCursor(&c, w);
}
+static inline void unsetCursor(QWindow *w)
+{
+ if (const QScreen *screen = w->screen())
+ if (QPlatformCursor *cursor = screen->handle()->cursor())
+ cursor->changeCursor(0, w);
+}
+
static inline void applyCursor(const QList<QWindow *> &l, const QCursor &c)
{
for (int i = 0; i < l.size(); ++i) {
@@ -2635,8 +2644,13 @@ static inline void applyWindowCursor(const QList<QWindow *> &l)
{
for (int i = 0; i < l.size(); ++i) {
QWindow *w = l.at(i);
- if (w->handle() && w->type() != Qt::Desktop)
- applyCursor(w, w->cursor());
+ if (w->handle() && w->type() != Qt::Desktop) {
+ if (qt_window_private(w)->hasCursor) {
+ applyCursor(w, w->cursor());
+ } else {
+ unsetCursor(w);
+ }
+ }
}
}
@@ -2768,111 +2782,6 @@ QInputMethod *QGuiApplication::inputMethod()
QFontDatabase::removeApplicationFont()
*/
-// These pixmaps approximate the images in the Windows User Interface Guidelines.
-
-// XPM
-
-static const char * const move_xpm[] = {
-"11 20 3 1",
-". c None",
-"a c #FFFFFF",
-"X c #000000", // X11 cursor is traditionally black
-"aa.........",
-"aXa........",
-"aXXa.......",
-"aXXXa......",
-"aXXXXa.....",
-"aXXXXXa....",
-"aXXXXXXa...",
-"aXXXXXXXa..",
-"aXXXXXXXXa.",
-"aXXXXXXXXXa",
-"aXXXXXXaaaa",
-"aXXXaXXa...",
-"aXXaaXXa...",
-"aXa..aXXa..",
-"aa...aXXa..",
-"a.....aXXa.",
-"......aXXa.",
-".......aXXa",
-".......aXXa",
-"........aa."};
-
-
-/* XPM */
-static const char * const copy_xpm[] = {
-"24 30 3 1",
-". c None",
-"a c #000000",
-"X c #FFFFFF",
-"XX......................",
-"XaX.....................",
-"XaaX....................",
-"XaaaX...................",
-"XaaaaX..................",
-"XaaaaaX.................",
-"XaaaaaaX................",
-"XaaaaaaaX...............",
-"XaaaaaaaaX..............",
-"XaaaaaaaaaX.............",
-"XaaaaaaXXXX.............",
-"XaaaXaaX................",
-"XaaXXaaX................",
-"XaX..XaaX...............",
-"XX...XaaX...............",
-"X.....XaaX..............",
-"......XaaX..............",
-".......XaaX.............",
-".......XaaX.............",
-"........XX...aaaaaaaaaaa",
-".............aXXXXXXXXXa",
-".............aXXXXXXXXXa",
-".............aXXXXaXXXXa",
-".............aXXXXaXXXXa",
-".............aXXaaaaaXXa",
-".............aXXXXaXXXXa",
-".............aXXXXaXXXXa",
-".............aXXXXXXXXXa",
-".............aXXXXXXXXXa",
-".............aaaaaaaaaaa"};
-
-/* XPM */
-static const char * const link_xpm[] = {
-"24 30 3 1",
-". c None",
-"a c #000000",
-"X c #FFFFFF",
-"XX......................",
-"XaX.....................",
-"XaaX....................",
-"XaaaX...................",
-"XaaaaX..................",
-"XaaaaaX.................",
-"XaaaaaaX................",
-"XaaaaaaaX...............",
-"XaaaaaaaaX..............",
-"XaaaaaaaaaX.............",
-"XaaaaaaXXXX.............",
-"XaaaXaaX................",
-"XaaXXaaX................",
-"XaX..XaaX...............",
-"XX...XaaX...............",
-"X.....XaaX..............",
-"......XaaX..............",
-".......XaaX.............",
-".......XaaX.............",
-"........XX...aaaaaaaaaaa",
-".............aXXXXXXXXXa",
-".............aXXXaaaaXXa",
-".............aXXXXaaaXXa",
-".............aXXXaaaaXXa",
-".............aXXaaaXaXXa",
-".............aXXaaXXXXXa",
-".............aXXaXXXXXXa",
-".............aXXXaXXXXXa",
-".............aXXXXXXXXXa",
-".............aaaaaaaaaaa"};
-
QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
{
Q_UNUSED(cshape);
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index f90321f396..0e9d6f2336 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -49,8 +49,6 @@
#include <QtCore/qpoint.h>
#include <QtCore/qsize.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -187,6 +185,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QGUIAPPLICATION_H
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 0946591887..e5f08934c1 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -65,8 +65,6 @@
#include "private/qshortcutmap_p.h"
#include <qicon.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QPlatformIntegration;
@@ -293,6 +291,4 @@ Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QGUIAPPLICATION_P_H
diff --git a/src/gui/kernel/qinputmethod.h b/src/gui/kernel/qinputmethod.h
index 35e29e9cb5..eceebb1c0f 100644
--- a/src/gui/kernel/qinputmethod.h
+++ b/src/gui/kernel/qinputmethod.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QInputMethodPrivate;
@@ -116,6 +114,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/kernel/qinputmethod_p.h b/src/gui/kernel/qinputmethod_p.h
index ab91660e3f..6cfc5e2f88 100644
--- a/src/gui/kernel/qinputmethod_p.h
+++ b/src/gui/kernel/qinputmethod_p.h
@@ -61,8 +61,6 @@
#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QInputMethodPrivate : public QObjectPrivate
@@ -91,6 +89,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h
index dd26efda8e..6324e203f0 100644
--- a/src/gui/kernel/qkeysequence.h
+++ b/src/gui/kernel/qkeysequence.h
@@ -45,8 +45,6 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qstring.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -231,6 +229,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QKEYSEQUENCE_H
diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp
new file mode 100644
index 0000000000..e2306050dd
--- /dev/null
+++ b/src/gui/kernel/qoffscreensurface.cpp
@@ -0,0 +1,345 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qoffscreensurface.h"
+
+#include "qguiapplication_p.h"
+#include "qscreen.h"
+#include "qplatformintegration.h"
+#include "qplatformoffscreensurface.h"
+#include "qwindow.h"
+#include "qplatformwindow.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QOffscreenSurface
+ \inmodule QtGui
+ \since 5.1
+ \brief The QOffscreenSurface class represents an offscreen surface in the underlying platform.
+
+ QOffscreenSurface is intended to be used with QOpenGLContext to allow rendering with OpenGL in
+ an arbitrary thread without the need to create a QWindow.
+
+ Even though the surface is renderable, the surface's pixels are not accessible.
+ QOffscreenSurface should only be used to create OpenGL resources such as textures
+ or framebuffer objects.
+
+ An application will typically use QOffscreenSurface to perform some time-consuming tasks in a
+ separate thread in order to avoid stalling the main rendering thread. Resources created in the
+ QOffscreenSurface's context can be shared with the main OpenGL context. Some common use cases
+ are asynchronous texture uploads or rendering into a QOpenGLFramebufferObject.
+
+ How the offscreen surface is implemented depends on the underlying platform, but it will
+ typically use a pixel buffer (pbuffer). If the platform doesn't implement or support
+ offscreen surfaces, QOffscreenSurface will use an invisible QWindow internally.
+*/
+class Q_GUI_EXPORT QOffscreenSurfacePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QOffscreenSurface)
+
+public:
+ QOffscreenSurfacePrivate()
+ : QObjectPrivate()
+ , surfaceType(QSurface::OpenGLSurface)
+ , platformOffscreenSurface(0)
+ , offscreenWindow(0)
+ , screen(0)
+ , size(1, 1)
+ {
+ }
+
+ ~QOffscreenSurfacePrivate()
+ {
+ }
+
+ QSurface::SurfaceType surfaceType;
+ QPlatformOffscreenSurface *platformOffscreenSurface;
+ QWindow *offscreenWindow;
+ QSurfaceFormat requestedFormat;
+ QScreen *screen;
+ QSize size;
+};
+
+
+/*!
+ Creates an offscreen surface for the \a targetScreen.
+
+ The underlying platform surface is not created until create() is called.
+
+ \sa setScreen(), create()
+*/
+QOffscreenSurface::QOffscreenSurface(QScreen *targetScreen)
+ : QObject(*new QOffscreenSurfacePrivate(), 0)
+ , QSurface(Offscreen)
+{
+ Q_D(QOffscreenSurface);
+ d->screen = targetScreen;
+ if (!d->screen)
+ d->screen = QGuiApplication::primaryScreen();
+
+ //if your applications aborts here, then chances are your creating a QOffscreenSurface before
+ //the screen list is populated.
+ Q_ASSERT(d->screen);
+
+ connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*)));
+}
+
+
+/*!
+ Destroys the offscreen surface.
+*/
+QOffscreenSurface::~QOffscreenSurface()
+{
+ destroy();
+}
+
+/*!
+ Returns the surface type of the offscreen surface.
+
+ The surface type of an offscreen surface is always QSurface::OpenGLSurface.
+*/
+QOffscreenSurface::SurfaceType QOffscreenSurface::surfaceType() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->surfaceType;
+}
+
+/*!
+ Allocates the platform resources associated with the offscreen surface.
+
+ It is at this point that the surface format set using setFormat() gets resolved
+ into an actual native surface.
+
+ Call destroy() to free the platform resources if necessary.
+
+ \sa destroy()
+*/
+void QOffscreenSurface::create()
+{
+ Q_D(QOffscreenSurface);
+ if (!d->platformOffscreenSurface && !d->offscreenWindow) {
+ d->platformOffscreenSurface = QGuiApplicationPrivate::platformIntegration()->createPlatformOffscreenSurface(this);
+ // No platform offscreen surface, fallback to an invisible window
+ if (!d->platformOffscreenSurface) {
+ d->offscreenWindow = new QWindow(d->screen);
+ d->offscreenWindow->setSurfaceType(QWindow::OpenGLSurface);
+ d->offscreenWindow->setFormat(d->requestedFormat);
+ d->offscreenWindow->setGeometry(0, 0, d->size.width(), d->size.height());
+ d->offscreenWindow->create();
+ }
+ }
+}
+
+/*!
+ Releases the native platform resources associated with this offscreen surface.
+
+ \sa create()
+*/
+void QOffscreenSurface::destroy()
+{
+ Q_D(QOffscreenSurface);
+ delete d->platformOffscreenSurface;
+ d->platformOffscreenSurface = 0;
+ if (d->offscreenWindow) {
+ d->offscreenWindow->destroy();
+ delete d->offscreenWindow;
+ d->offscreenWindow = 0;
+ }
+}
+
+/*!
+ Returns \c true if this offscreen surface is valid; otherwise returns \c false.
+
+ The offscreen surface is valid if the platform resources have been successfuly allocated.
+
+ \sa create()
+*/
+bool QOffscreenSurface::isValid() const
+{
+ Q_D(const QOffscreenSurface);
+ return (d->platformOffscreenSurface && d->platformOffscreenSurface->isValid())
+ || (d->offscreenWindow && d->offscreenWindow->handle());
+}
+
+/*!
+ Sets the offscreen surface \a format.
+
+ The surface format will be resolved in the create() function. Calling
+ this function after create() will not re-resolve the surface format of the native surface.
+
+ \sa create(), destroy()
+*/
+void QOffscreenSurface::setFormat(const QSurfaceFormat &format)
+{
+ Q_D(QOffscreenSurface);
+ d->requestedFormat = format;
+}
+
+/*!
+ Returns the requested surfaceformat of this offscreen surface.
+
+ If the requested format was not supported by the platform implementation,
+ the requestedFormat will differ from the actual offscreen surface format.
+
+ This is the value set with setFormat().
+
+ \sa setFormat(), format()
+ */
+QSurfaceFormat QOffscreenSurface::requestedFormat() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->requestedFormat;
+}
+
+/*!
+ Returns the actual format of this offscreen surface.
+
+ After the offscreen surface has been created, this function will return the actual
+ surface format of the surface. It might differ from the requested format if the requested
+ format could not be fulfilled by the platform.
+
+ \sa create(), requestedFormat()
+*/
+QSurfaceFormat QOffscreenSurface::format() const
+{
+ Q_D(const QOffscreenSurface);
+ if (d->platformOffscreenSurface)
+ return d->platformOffscreenSurface->format();
+ if (d->offscreenWindow)
+ return d->offscreenWindow->format();
+ return d->requestedFormat;
+}
+
+/*!
+ Returns the size of the offscreen surface.
+*/
+QSize QOffscreenSurface::size() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->size;
+}
+
+/*!
+ Returns the screen to which the offscreen surface is connected.
+
+ \sa setScreen()
+*/
+QScreen *QOffscreenSurface::screen() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->screen;
+}
+
+/*!
+ Sets the screen to which the offscreen surface is connected.
+
+ If the offscreen surface has been created, it will be recreated on the \a newScreen.
+
+ \sa screen()
+*/
+void QOffscreenSurface::setScreen(QScreen *newScreen)
+{
+ Q_D(QOffscreenSurface);
+ if (!newScreen)
+ newScreen = QGuiApplication::primaryScreen();
+ if (newScreen != d->screen) {
+ const bool wasCreated = d->platformOffscreenSurface != 0 || d->offscreenWindow != 0;
+ if (wasCreated)
+ destroy();
+ if (d->screen)
+ disconnect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*)));
+ d->screen = newScreen;
+ if (newScreen) {
+ connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*)));
+ if (wasCreated)
+ create();
+ }
+ emit screenChanged(newScreen);
+ }
+}
+
+/*!
+ Called when the offscreen surface's screen is destroyed.
+
+ \internal
+*/
+void QOffscreenSurface::screenDestroyed(QObject *object)
+{
+ Q_D(QOffscreenSurface);
+ if (object == static_cast<QObject *>(d->screen))
+ setScreen(0);
+}
+
+/*!
+ \fn QOffscreenSurface::screenChanged(QScreen *screen)
+
+ This signal is emitted when an offscreen surface's \a screen changes, either
+ by being set explicitly with setScreen(), or automatically when
+ the window's screen is removed.
+*/
+
+/*!
+ Returns the platform offscreen surface corresponding to the offscreen surface.
+
+ \internal
+*/
+QPlatformOffscreenSurface *QOffscreenSurface::handle() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->platformOffscreenSurface;
+}
+
+/*!
+ Returns the platform surface corresponding to the offscreen surface.
+
+ \internal
+*/
+QPlatformSurface *QOffscreenSurface::surfaceHandle() const
+{
+ Q_D(const QOffscreenSurface);
+ if (d->offscreenWindow)
+ return d->offscreenWindow->handle();
+
+ return d->platformOffscreenSurface;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/text/qrawfont_ft.cpp b/src/gui/kernel/qoffscreensurface.h
index 5cac45b216..a1b46f9b88 100644
--- a/src/gui/text/qrawfont_ft.cpp
+++ b/src/gui/kernel/qoffscreensurface.h
@@ -39,91 +39,60 @@
**
****************************************************************************/
-#include <QtCore/qglobal.h>
-
-#if !defined(QT_NO_RAWFONT)
-
-#include "qrawfont_p.h"
-#include "qfontengine_ft_p.h"
-#include "quuid.h"
+#ifndef QOFFSCREENSURFACE_H
+#define QOFFSCREENSURFACE_H
+#include <QtCore/QObject>
+#include <QtGui/qsurface.h>
QT_BEGIN_NAMESPACE
-class QFontEngineFTRawFont
+class QOffscreenSurfacePrivate;
- : public QFontEngineFT
+class QScreen;
+class QPlatformOffscreenSurface;
+class Q_GUI_EXPORT QOffscreenSurface : public QObject, public QSurface
{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QOffscreenSurface)
+
public:
- QFontEngineFTRawFont(const QFontDef &fontDef)
- : QFontEngineFT(fontDef)
- {
- }
-
- void updateFamilyNameAndStyle()
- {
- fontDef.family = QString::fromUtf8(freetype->face->family_name);
-
- if (freetype->face->style_flags & FT_STYLE_FLAG_ITALIC)
- fontDef.style = QFont::StyleItalic;
-
- if (freetype->face->style_flags & FT_STYLE_FLAG_BOLD)
- fontDef.weight = QFont::Bold;
- }
-
- bool initFromData(const QByteArray &fontData)
- {
- FaceId faceId;
- faceId.filename = "";
- faceId.index = 0;
- faceId.uuid = QUuid::createUuid().toByteArray();
-
- return init(faceId, true, Format_None, fontData);
- }
-};
+ explicit QOffscreenSurface(QScreen *screen = 0);
+ virtual ~QOffscreenSurface();
-void QRawFontPrivate::platformCleanUp()
-{
- // Font engine handles all resources
-}
+ SurfaceType surfaceType() const;
-void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData, qreal pixelSize,
- QFont::HintingPreference hintingPreference)
-{
- Q_ASSERT(fontEngine == 0);
-
- QFontDef fontDef;
- fontDef.pixelSize = pixelSize;
-
- QFontEngineFTRawFont *fe = new QFontEngineFTRawFont(fontDef);
- if (!fe->initFromData(fontData)) {
- delete fe;
- return;
- }
-
- fe->updateFamilyNameAndStyle();
-
- switch (hintingPreference) {
- case QFont::PreferNoHinting:
- fe->setDefaultHintStyle(QFontEngineFT::HintNone);
- break;
- case QFont::PreferFullHinting:
- fe->setDefaultHintStyle(QFontEngineFT::HintFull);
- break;
- case QFont::PreferVerticalHinting:
- fe->setDefaultHintStyle(QFontEngineFT::HintLight);
- break;
- default:
- // Leave it as it is
- break;
- }
-
- fontEngine = fe;
- fontEngine->ref.ref();
-}
+ void create();
+ void destroy();
+
+ bool isValid() const;
+
+ void setFormat(const QSurfaceFormat &format);
+ QSurfaceFormat format() const;
+ QSurfaceFormat requestedFormat() const;
+
+ QSize size() const;
+
+ QScreen *screen() const;
+ void setScreen(QScreen *screen);
+
+ QPlatformOffscreenSurface *handle() const;
+
+Q_SIGNALS:
+ void screenChanged(QScreen *screen);
+
+private Q_SLOTS:
+ void screenDestroyed(QObject *screen);
+
+private:
+
+ QPlatformSurface *surfaceHandle() const;
+
+ Q_DISABLE_COPY(QOffscreenSurface)
+};
QT_END_NAMESPACE
-#endif // QT_NO_RAWFONT
+#endif // QOFFSCREENSURFACE_H
diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h
index d6d812a98d..e8d04d7446 100644
--- a/src/gui/kernel/qopenglcontext.h
+++ b/src/gui/kernel/qopenglcontext.h
@@ -59,8 +59,6 @@
#include <QtGui/qopengl.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QOpenGLContextPrivate;
@@ -159,8 +157,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_OPENGL
#endif // QGUIGLCONTEXT_H
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index fb81412b2b..ba5434e8ac 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -64,8 +64,6 @@
#include <QtCore/QHash>
#include <QtCore/QSet>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -259,7 +257,5 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_OPENGL
#endif // QOPENGLCONTEXT_P_H
diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h
index 9ea0830442..2248f6727e 100644
--- a/src/gui/kernel/qpalette.h
+++ b/src/gui/kernel/qpalette.h
@@ -46,8 +46,6 @@
#include <QtGui/qcolor.h>
#include <QtGui/qbrush.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -210,6 +208,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QPalette &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPALETTE_H
diff --git a/src/gui/kernel/qplatformclipboard.h b/src/gui/kernel/qplatformclipboard.h
index a925b16e9e..3ffc020e8d 100644
--- a/src/gui/kernel/qplatformclipboard.h
+++ b/src/gui/kernel/qplatformclipboard.h
@@ -57,8 +57,6 @@
#include <QtGui/QClipboard>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -76,8 +74,6 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_CLIPBOARD
#endif //QPLATFORMCLIPBOARD_H
diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp
index 16a59f5d07..c2f510b496 100644
--- a/src/gui/kernel/qplatformcursor.cpp
+++ b/src/gui/kernel/qplatformcursor.cpp
@@ -95,6 +95,10 @@ QList<QPlatformCursor *> QPlatformCursorPrivate::getInstances()
\a windowCursor is a pointer to the QCursor that should be displayed.
+ To unset the cursor of \a window, 0 is passed. This means \a window does not have
+ a cursor set and the cursor of a the first parent window which has a cursor explicitly
+ set or the system default cursor should take effect.
+
\a window is a pointer to the window currently displayed at QCursor::pos(). Note
that this may be 0 if the current position is not occupied by a displayed widget.
diff --git a/src/gui/kernel/qplatformcursor.h b/src/gui/kernel/qplatformcursor.h
index d624a068f1..011209aa3a 100644
--- a/src/gui/kernel/qplatformcursor.h
+++ b/src/gui/kernel/qplatformcursor.h
@@ -58,8 +58,6 @@
#include <qpa/qplatformscreen.h>
#include <QtGui/QCursor>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -106,6 +104,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMCURSOR_H
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index fe3c5d2b99..ecc00ed8c6 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -59,8 +59,6 @@
#include <QtCore/QDir>
#include <QtGui/QRgb>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -319,6 +317,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMDIALOGHELPER_H
diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h
index 61ff2dddf6..59f9899f23 100644
--- a/src/gui/kernel/qplatformdrag.h
+++ b/src/gui/kernel/qplatformdrag.h
@@ -54,8 +54,6 @@
#include <QtCore/qglobal.h>
#include <QtGui/QPixmap>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
#ifndef QT_NO_DRAGANDDROP
@@ -118,6 +116,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/kernel/qplatforminputcontext.h b/src/gui/kernel/qplatforminputcontext.h
index 2efe9486ca..0e4121eed4 100644
--- a/src/gui/kernel/qplatforminputcontext.h
+++ b/src/gui/kernel/qplatforminputcontext.h
@@ -53,8 +53,6 @@
#include <QtGui/qinputmethod.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QPlatformInputContextPrivate;
@@ -102,6 +100,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMINPUTCONTEXT_H
diff --git a/src/gui/kernel/qplatforminputcontext_p.h b/src/gui/kernel/qplatforminputcontext_p.h
index f55acbd79f..29d6e45269 100644
--- a/src/gui/kernel/qplatforminputcontext_p.h
+++ b/src/gui/kernel/qplatforminputcontext_p.h
@@ -55,8 +55,6 @@
#include <private/qobject_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QPlatformInputContextPrivate: public QObjectPrivate
@@ -73,6 +71,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/kernel/qplatforminputcontextfactory_p.h b/src/gui/kernel/qplatforminputcontextfactory_p.h
index 2e82f7c4d5..2177d7965d 100644
--- a/src/gui/kernel/qplatforminputcontextfactory_p.h
+++ b/src/gui/kernel/qplatforminputcontextfactory_p.h
@@ -55,8 +55,6 @@
#include <QtCore/qstringlist.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -72,7 +70,5 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMINPUTCONTEXTFACTORY_H
diff --git a/src/gui/kernel/qplatforminputcontextplugin_p.h b/src/gui/kernel/qplatforminputcontextplugin_p.h
index ac97df15a3..ff79bb94b9 100644
--- a/src/gui/kernel/qplatforminputcontextplugin_p.h
+++ b/src/gui/kernel/qplatforminputcontextplugin_p.h
@@ -56,8 +56,6 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -77,6 +75,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMINPUTCONTEXTPLUGIN_H
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index 980e45742e..027b9fc9f1 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -360,4 +360,15 @@ class QPlatformTheme *QPlatformIntegration::createPlatformTheme(const QString &n
return new QPlatformTheme;
}
+/*!
+ Factory function for QOffscreenSurface. An offscreen surface will typically be implemented with a
+ pixel buffer (pbuffer). If the platform doesn't support offscreen surfaces, an invisible window
+ will be used by QOffscreenSurface instead.
+*/
+QPlatformOffscreenSurface *QPlatformIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
+{
+ Q_UNUSED(surface)
+ return 0;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index ee796bf323..6e10df9495 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -55,8 +55,6 @@
#include <qpa/qplatformscreen.h>
#include <QtGui/qsurfaceformat.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -77,6 +75,8 @@ class QPlatformDialogHelper;
class QPlatformSharedGraphicsCache;
class QPlatformServices;
class QKeyEvent;
+class QPlatformOffscreenSurface;
+class QOffscreenSurface;
class Q_GUI_EXPORT QPlatformIntegration
{
@@ -148,12 +148,12 @@ public:
virtual QStringList themeNames() const;
virtual QPlatformTheme *createPlatformTheme(const QString &name) const;
+ virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const;
+
protected:
void screenAdded(QPlatformScreen *screen);
};
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMINTEGRATION_H
diff --git a/src/gui/kernel/qplatformintegrationfactory_p.h b/src/gui/kernel/qplatformintegrationfactory_p.h
index 859e6f9c4d..fb3ba55316 100644
--- a/src/gui/kernel/qplatformintegrationfactory_p.h
+++ b/src/gui/kernel/qplatformintegrationfactory_p.h
@@ -55,8 +55,6 @@
#include <QtCore/qstringlist.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -71,7 +69,5 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMINTEGRATIONFACTORY_H
diff --git a/src/gui/kernel/qplatformintegrationplugin.h b/src/gui/kernel/qplatformintegrationplugin.h
index 4de0d3edc0..434366f0b0 100644
--- a/src/gui/kernel/qplatformintegrationplugin.h
+++ b/src/gui/kernel/qplatformintegrationplugin.h
@@ -54,8 +54,6 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -75,6 +73,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMINTEGRATIONPLUGIN_H
diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h
index b02998940b..3485cc58dd 100644
--- a/src/gui/kernel/qplatformmenu.h
+++ b/src/gui/kernel/qplatformmenu.h
@@ -57,8 +57,6 @@
#include <QtGui/QKeySequence>
#include <QtGui/QIcon>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QPlatformMenu;
@@ -80,6 +78,7 @@ public:
virtual void setIsSeparator(bool isSeparator) = 0;
virtual void setFont(const QFont &font) = 0;
virtual void setRole(MenuRole role) = 0;
+ virtual void setCheckable(bool checkable) = 0;
virtual void setChecked(bool isChecked) = 0;
virtual void setShortcut(const QKeySequence& shortcut) = 0;
virtual void setEnabled(bool enabled) = 0;
@@ -101,8 +100,19 @@ public:
virtual quintptr tag()const = 0;
virtual void setText(const QString &text) = 0;
+ virtual void setIcon(const QIcon &icon) = 0;
virtual void setEnabled(bool enabled) = 0;
virtual void setVisible(bool visible) = 0;
+ virtual void setMinimumWidth(int width) { Q_UNUSED(width); }
+ virtual void setFont(const QFont &font) { Q_UNUSED(font); }
+
+ virtual void showPopup(const QWindow *parentWindow, QPoint pos, const QPlatformMenuItem *item)
+ {
+ Q_UNUSED(parentWindow);
+ Q_UNUSED(pos);
+ Q_UNUSED(item);
+ setVisible(true);
+ }
virtual QPlatformMenuItem *menuItemAt(int position) const = 0;
virtual QPlatformMenuItem *menuItemForTag(quintptr tag) const = 0;
@@ -125,7 +135,5 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/kernel/qplatformnativeinterface.h b/src/gui/kernel/qplatformnativeinterface.h
index fd892c1e75..eaa24a9e55 100644
--- a/src/gui/kernel/qplatformnativeinterface.h
+++ b/src/gui/kernel/qplatformnativeinterface.h
@@ -55,8 +55,6 @@
#include <QtCore/QObject>
#include <QtCore/QVariant>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -98,6 +96,4 @@ Q_SIGNALS:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMNATIVEINTERFACE_H
diff --git a/src/gui/kernel/qplatformoffscreensurface.cpp b/src/gui/kernel/qplatformoffscreensurface.cpp
new file mode 100644
index 0000000000..dd354f465e
--- /dev/null
+++ b/src/gui/kernel/qplatformoffscreensurface.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformoffscreensurface.h"
+
+#include "qoffscreensurface.h"
+#include "qscreen.h"
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformOffscreenSurfacePrivate
+{
+public:
+};
+
+QPlatformOffscreenSurface::QPlatformOffscreenSurface(QOffscreenSurface *offscreenSurface)
+ : QPlatformSurface(offscreenSurface)
+ , d_ptr(new QPlatformOffscreenSurfacePrivate)
+{
+}
+
+QPlatformOffscreenSurface::~QPlatformOffscreenSurface()
+{
+}
+
+QOffscreenSurface *QPlatformOffscreenSurface::offscreenSurface() const
+{
+ return static_cast<QOffscreenSurface*>(m_surface);
+}
+
+/*!
+ Returns the platform screen handle corresponding to this QPlatformOffscreenSurface.
+*/
+QPlatformScreen *QPlatformOffscreenSurface::screen() const
+{
+ return offscreenSurface()->screen()->handle();
+}
+
+/*!
+ Returns the actual surface format of the offscreen surface.
+*/
+QSurfaceFormat QPlatformOffscreenSurface::format() const
+{
+ return QSurfaceFormat();
+}
+
+/*!
+ Returns \c true if the platform offscreen surface has been allocated.
+*/
+bool QPlatformOffscreenSurface::isValid() const
+{
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/text/qabstractfontengine_p.h b/src/gui/kernel/qplatformoffscreensurface.h
index e122cc5b4f..099d8ee94a 100644
--- a/src/gui/text/qabstractfontengine_p.h
+++ b/src/gui/kernel/qplatformoffscreensurface.h
@@ -39,70 +39,47 @@
**
****************************************************************************/
-#ifndef QABSTRACTFONTENGINE_P_H
-#define QABSTRACTFONTENGINE_P_H
+#ifndef QPLATFORMOFFSCREENSURFACE_H
+#define QPLATFORMOFFSCREENSURFACE_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.
+// This file is part of the QPA API and is not meant to be used
+// in applications. Usage of this API may make your code
+// source and binary incompatible with future versions of Qt.
//
-#include "qfontengine_p.h"
-#include "qabstractfontengine_qws.h"
+#include "qplatformsurface.h"
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_NAMESPACE
-class QCustomFontEngine;
+class QOffscreenSurface;
+class QPlatformScreen;
+class QPlatformOffscreenSurfacePrivate;
-class QProxyFontEngine : public QFontEngine
+class Q_GUI_EXPORT QPlatformOffscreenSurface : public QPlatformSurface
{
- Q_OBJECT
+ Q_DECLARE_PRIVATE(QPlatformOffscreenSurface)
public:
- QProxyFontEngine(QAbstractFontEngine *engine, const QFontDef &def);
- virtual ~QProxyFontEngine();
-
- virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
- virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const;
- virtual QImage alphaMapForGlyph(glyph_t);
- virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags);
- virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
- virtual glyph_metrics_t boundingBox(glyph_t glyph);
-
- virtual QFixed ascent() const;
- virtual QFixed descent() const;
- virtual QFixed leading() const;
- virtual QFixed xHeight() const;
- virtual QFixed averageCharWidth() const;
- virtual QFixed lineThickness() const;
- virtual QFixed underlinePosition() const;
- virtual qreal maxCharWidth() const;
- virtual qreal minLeftBearing() const;
- virtual qreal minRightBearing() const;
- virtual int glyphCount() const;
-
- virtual bool canRender(const QChar *string, int len);
-
- virtual Type type() const { return Proxy; }
- virtual const char *name() const { return "proxy engine"; }
+ explicit QPlatformOffscreenSurface(QOffscreenSurface *offscreenSurface);
+ virtual ~QPlatformOffscreenSurface();
- virtual void draw(QPaintEngine *, qreal, qreal, const QTextItemInt &);
+ QOffscreenSurface *offscreenSurface() const;
- inline QAbstractFontEngine::Capabilities capabilities() const
- { return engineCapabilities; }
+ QPlatformScreen *screen() const;
- bool drawAsOutline() const;
+ virtual QSurfaceFormat format() const;
+ virtual bool isValid() const;
+protected:
+ QScopedPointer<QPlatformOffscreenSurfacePrivate> d_ptr;
private:
- QAbstractFontEngine *engine;
- QAbstractFontEngine::Capabilities engineCapabilities;
+ Q_DISABLE_COPY(QPlatformOffscreenSurface)
};
QT_END_NAMESPACE
-#endif
+#endif // QPLATFORMOFFSCREENSURFACE_H
diff --git a/src/gui/kernel/qplatformopenglcontext.h b/src/gui/kernel/qplatformopenglcontext.h
index 6a0c819752..9e13622283 100644
--- a/src/gui/kernel/qplatformopenglcontext.h
+++ b/src/gui/kernel/qplatformopenglcontext.h
@@ -58,8 +58,6 @@
#include <QtGui/qwindow.h>
#include <QtGui/qopengl.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -102,8 +100,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_OPENGL
#endif // QPLATFORMOPENGLCONTEXT_H
diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h
index eae9c5a739..085a147e8d 100644
--- a/src/gui/kernel/qplatformscreen.h
+++ b/src/gui/kernel/qplatformscreen.h
@@ -63,8 +63,6 @@
#include <QtGui/qwindowdefs.h>
#include <qpa/qplatformpixmap.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -133,6 +131,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMSCREEN_H
diff --git a/src/gui/kernel/qplatformscreen_p.h b/src/gui/kernel/qplatformscreen_p.h
index 6914a82a06..588496b494 100644
--- a/src/gui/kernel/qplatformscreen_p.h
+++ b/src/gui/kernel/qplatformscreen_p.h
@@ -53,8 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QScreen;
@@ -67,6 +65,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMSCREEN_P_H
diff --git a/src/gui/kernel/qplatformscreenpageflipper.h b/src/gui/kernel/qplatformscreenpageflipper.h
index c6eac28564..232e37d24a 100644
--- a/src/gui/kernel/qplatformscreenpageflipper.h
+++ b/src/gui/kernel/qplatformscreenpageflipper.h
@@ -53,8 +53,6 @@
#include <QtCore/QObject>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QPlatformScreenBuffer {
@@ -91,6 +89,4 @@ Q_SIGNALS:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMSCREENPAGEFLIPPER_H
diff --git a/src/gui/kernel/qplatformservices.h b/src/gui/kernel/qplatformservices.h
index 200298f2ba..609a4a04be 100644
--- a/src/gui/kernel/qplatformservices.h
+++ b/src/gui/kernel/qplatformservices.h
@@ -53,8 +53,6 @@
#include <QtCore/QtGlobal>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QUrl;
@@ -71,6 +69,5 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QPLATFORMSERVICES_H
diff --git a/src/gui/kernel/qplatformsharedgraphicscache.h b/src/gui/kernel/qplatformsharedgraphicscache.h
index 20a551688f..bb2dfe00e5 100644
--- a/src/gui/kernel/qplatformsharedgraphicscache.h
+++ b/src/gui/kernel/qplatformsharedgraphicscache.h
@@ -54,8 +54,6 @@
#include <QtCore/qobject.h>
#include <QtGui/qimage.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QPlatformSharedGraphicsCache: public QObject
@@ -103,6 +101,4 @@ Q_SIGNALS:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMSHAREDGRAPHICSCACHE_H
diff --git a/src/gui/kernel/qplatformsurface.h b/src/gui/kernel/qplatformsurface.h
index bffb3c5848..b96e494f74 100644
--- a/src/gui/kernel/qplatformsurface.h
+++ b/src/gui/kernel/qplatformsurface.h
@@ -55,8 +55,6 @@
#include <QtGui/qsurface.h>
#include <QtGui/qsurfaceformat.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -74,10 +72,9 @@ private:
QSurface *m_surface;
friend class QPlatformWindow;
+ friend class QPlatformOffscreenSurface;
};
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif //QPLATFORMSURFACE_H
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index ceb95c51e8..9f5c789a6e 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -46,6 +46,7 @@
#include <QtCore/qfileinfo.h>
#include <qpalette.h>
#include <qtextformat.h>
+#include <qiconloader_p.h>
QT_BEGIN_NAMESPACE
@@ -272,4 +273,19 @@ QPlatformSystemTrayIcon *QPlatformTheme::createPlatformSystemTrayIcon() const
}
#endif
+/*!
+ Factory function for the QIconEngine used by QIcon::fromTheme(). By default this
+ function returns a QIconLoaderEngine, but subclasses can reimplement it to
+ provide their own.
+
+ It is especially useful to benefit from some platform specific facilities or
+ optimizations like an inter-process cache in systems mostly built with Qt.
+
+ \since 5.1
+*/
+QIconEngine *QPlatformTheme::createIconEngine(const QString &iconName) const
+{
+ return new QIconLoaderEngine(iconName);
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h
index 3ac2b904d2..0e95321102 100644
--- a/src/gui/kernel/qplatformtheme.h
+++ b/src/gui/kernel/qplatformtheme.h
@@ -53,10 +53,9 @@
#include <QtCore/QtGlobal>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
+class QIconEngine;
class QMenu;
class QMenuBar;
class QPlatformMenuItem;
@@ -272,11 +271,11 @@ public:
virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const;
virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const;
+ virtual QIconEngine *createIconEngine(const QString &iconName) const;
+
static QVariant defaultThemeHint(ThemeHint hint);
};
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMTHEME_H
diff --git a/src/gui/kernel/qplatformthemefactory_p.h b/src/gui/kernel/qplatformthemefactory_p.h
index 632aae86ee..ad954f39b6 100644
--- a/src/gui/kernel/qplatformthemefactory_p.h
+++ b/src/gui/kernel/qplatformthemefactory_p.h
@@ -55,8 +55,6 @@
#include <QtCore/qstringlist.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -71,6 +69,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMTHEMEFACTORY_H
diff --git a/src/gui/kernel/qplatformthemeplugin.h b/src/gui/kernel/qplatformthemeplugin.h
index e3f106753a..cef5fb77b4 100644
--- a/src/gui/kernel/qplatformthemeplugin.h
+++ b/src/gui/kernel/qplatformthemeplugin.h
@@ -54,8 +54,6 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QPlatformTheme;
@@ -74,6 +72,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMTHEMEPLUGIN_H
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index b710701e7f..1eec6bfefc 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -197,7 +197,13 @@ bool QPlatformWindow::isEmbedded(const QPlatformWindow *parentWindow) const
*/
QPoint QPlatformWindow::mapToGlobal(const QPoint &pos) const
{
- return pos;
+ const QPlatformWindow *p = this;
+ QPoint result = pos;
+ while (p) {
+ result += p->geometry().topLeft();
+ p = p->parent();
+ }
+ return result;
}
/*!
@@ -209,7 +215,13 @@ QPoint QPlatformWindow::mapToGlobal(const QPoint &pos) const
*/
QPoint QPlatformWindow::mapFromGlobal(const QPoint &pos) const
{
- return pos;
+ const QPlatformWindow *p = this;
+ QPoint result = pos;
+ while (p) {
+ result -= p->geometry().topLeft();
+ p = p->parent();
+ }
+ return result;
}
/*!
diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h
index fe62d7b67b..e3e460b54c 100644
--- a/src/gui/kernel/qplatformwindow.h
+++ b/src/gui/kernel/qplatformwindow.h
@@ -59,8 +59,6 @@
#include <qpa/qplatformopenglcontext.h>
#include <qpa/qplatformsurface.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -140,5 +138,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
#endif //QPLATFORMWINDOW_H
diff --git a/src/gui/kernel/qplatformwindow_p.h b/src/gui/kernel/qplatformwindow_p.h
index 24e18ca379..ac47afb6f1 100644
--- a/src/gui/kernel/qplatformwindow_p.h
+++ b/src/gui/kernel/qplatformwindow_p.h
@@ -55,8 +55,6 @@
#include <QtCore/qrect.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QPlatformWindowPrivate
@@ -67,6 +65,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMWINDOW_P_H
diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h
index 557cd019a3..9fe4379646 100644
--- a/src/gui/kernel/qscreen.h
+++ b/src/gui/kernel/qscreen.h
@@ -52,8 +52,6 @@
#include <QtCore/qnamespace.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -160,7 +158,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSCREEN_H
diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h
index 7b26159c20..3e5feb2932 100644
--- a/src/gui/kernel/qscreen_p.h
+++ b/src/gui/kernel/qscreen_p.h
@@ -58,8 +58,6 @@
#include <QtCore/private/qobject_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QScreenPrivate : public QObjectPrivate
@@ -98,6 +96,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSCREEN_P_H
diff --git a/src/gui/kernel/qsessionmanager.h b/src/gui/kernel/qsessionmanager.h
index 4eac11e403..a1cd8741d2 100644
--- a/src/gui/kernel/qsessionmanager.h
+++ b/src/gui/kernel/qsessionmanager.h
@@ -49,8 +49,6 @@
#ifndef QT_NO_SESSIONMANAGER
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -101,8 +99,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_SESSIONMANAGER
#endif // QSESSIONMANAGER_H
diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h
index c9c8185b9a..7a447aae67 100644
--- a/src/gui/kernel/qstylehints.h
+++ b/src/gui/kernel/qstylehints.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -74,6 +72,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp
index 97b8220124..a943639d5f 100644
--- a/src/gui/kernel/qsurface.cpp
+++ b/src/gui/kernel/qsurface.cpp
@@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE
The SurfaceClass enum describes the actual subclass of the surface.
\value Window The surface is an instance of QWindow.
+ \value Offscreen The surface is an instance of QOffscreenSurface.
*/
diff --git a/src/gui/kernel/qsurface.h b/src/gui/kernel/qsurface.h
index 36d85342c5..8dbc230c10 100644
--- a/src/gui/kernel/qsurface.h
+++ b/src/gui/kernel/qsurface.h
@@ -47,8 +47,6 @@
#include <QtCore/qsize.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -60,7 +58,8 @@ class Q_GUI_EXPORT QSurface
{
public:
enum SurfaceClass {
- Window
+ Window,
+ Offscreen
};
enum SurfaceType {
@@ -89,6 +88,4 @@ protected:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif //QSURFACE_H
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index 2c26a172a4..25b603bb9c 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -583,6 +583,30 @@ int QSurfaceFormat::minorVersion() const
}
/*!
+ Returns a QPair<int, int> representing the OpenGL version.
+
+ Useful for version checks, for example format.version() >= qMakePair(3, 2)
+*/
+QPair<int, int> QSurfaceFormat::version() const
+{
+ return qMakePair(d->major, d->minor);
+}
+
+/*!
+ Sets the desired \a major and \a minor OpenGL versions.
+
+ The default version is 2.0.
+*/
+void QSurfaceFormat::setVersion(int major, int minor)
+{
+ if (d->minor != minor || d->major != major) {
+ detach();
+ d->minor = minor;
+ d->major = major;
+ }
+}
+
+/*!
Returns true if all the options of the two QSurfaceFormat objects
\a a and \a b are equal.
diff --git a/src/gui/kernel/qsurfaceformat.h b/src/gui/kernel/qsurfaceformat.h
index 8ab89225de..7c3c846df3 100644
--- a/src/gui/kernel/qsurfaceformat.h
+++ b/src/gui/kernel/qsurfaceformat.h
@@ -42,8 +42,7 @@
#define QSURFACEFORMAT_H
#include <QtCore/qglobal.h>
-
-QT_BEGIN_HEADER
+#include <QtCore/qpair.h>
QT_BEGIN_NAMESPACE
@@ -122,6 +121,9 @@ public:
void setMinorVersion(int minorVersion);
int minorVersion() const;
+ QPair<int, int> version() const;
+ void setVersion(int major, int minor);
+
bool stereo() const;
void setStereo(bool enable);
@@ -156,6 +158,4 @@ inline bool QSurfaceFormat::stereo() const
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif //QSURFACEFORMAT_H
diff --git a/src/gui/kernel/qtouchdevice.h b/src/gui/kernel/qtouchdevice.h
index d9892bfbd3..312bdce3e6 100644
--- a/src/gui/kernel/qtouchdevice.h
+++ b/src/gui/kernel/qtouchdevice.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -90,6 +88,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QTouchDevice::Capabilities)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTOUCHDEVICE_H
diff --git a/src/gui/kernel/qtouchdevice_p.h b/src/gui/kernel/qtouchdevice_p.h
index a358d77e92..435f8a5c37 100644
--- a/src/gui/kernel/qtouchdevice_p.h
+++ b/src/gui/kernel/qtouchdevice_p.h
@@ -56,8 +56,6 @@
#include <QtCore/qobject.h>
#include <QtGui/qtouchdevice.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -79,6 +77,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTOUCHDEVICE_P_H
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 2fcad5706f..69ae30389e 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -115,6 +115,9 @@ QT_BEGIN_NAMESPACE
windowing systems that do not make this information visible to the
application, isExposed() will simply return the same value as isVisible().
+ QWindow::Visibility queried through visibility() is a convenience API
+ combining the functions of visible() and windowState().
+
\section1 Rendering
There are two Qt APIs that can be used to render content into a window,
@@ -216,6 +219,120 @@ QWindow::~QWindow()
}
/*!
+ \enum QWindow::Visibility
+ \since 5.1
+
+ This enum describes what part of the screen the window occupies or should
+ occupy.
+
+ \value Windowed The window occupies part of the screen, but not necessarily
+ the entire screen. This state will occur only on windowing systems which
+ support showing multiple windows simultaneously. In this state it is
+ possible for the user to move and resize the window manually, if
+ WindowFlags permit it and if it is supported by the windowing system.
+
+ \value Minimized The window is reduced to an entry or icon on the task bar,
+ dock, task list or desktop, depending on how the windowing system handles
+ minimized windows.
+
+ \value Maximized The window occupies one entire screen, and the titlebar is
+ still visible. On most windowing systems this is the state achieved by
+ clicking the maximize button on the toolbar.
+
+ \value FullScreen The window occupies one entire screen, is not resizable,
+ and there is no titlebar. On some platforms which do not support showing
+ multiple simultaneous windows, this can be the usual visibility when the
+ window is not hidden.
+
+ \value AutomaticVisibility This means to give the window a default visible
+ state, which might be fullscreen or windowed depending on the platform.
+ It can be given as a parameter to setVisibility but will never be
+ read back from the visibility accessor.
+
+ \value Hidden The window is not visible in any way, however it may remember
+ a latent visibility which can be restored by setting AutomaticVisibility.
+*/
+
+/*!
+ \property QWindow::visibility
+ \brief the screen-occupation state of the window
+ \since 5.1
+
+ Visibility is whether the window should appear in the windowing system as
+ normal, minimized, maximized, fullscreen or hidden.
+
+ To set the visibility to AutomaticVisibility means to give the window
+ a default visible state, which might be fullscreen or windowed depending on
+ the platform.
+ When reading the visibility property you will always get the actual state,
+ never AutomaticVisibility.
+*/
+QWindow::Visibility QWindow::visibility() const
+{
+ Q_D(const QWindow);
+ return d->visibility;
+}
+
+void QWindow::setVisibility(Visibility v)
+{
+ switch (v) {
+ case Hidden:
+ hide();
+ break;
+ case AutomaticVisibility:
+ show();
+ break;
+ case Windowed:
+ showNormal();
+ break;
+ case Minimized:
+ showMinimized();
+ break;
+ case Maximized:
+ showMaximized();
+ break;
+ case FullScreen:
+ showFullScreen();
+ break;
+ default:
+ Q_ASSERT(false);
+ break;
+ }
+}
+
+void QWindowPrivate::updateVisibility()
+{
+ Q_Q(QWindow);
+
+ QWindow::Visibility old = visibility;
+
+ if (visible) {
+ switch (windowState) {
+ case Qt::WindowMinimized:
+ visibility = QWindow::Minimized;
+ break;
+ case Qt::WindowMaximized:
+ visibility = QWindow::Maximized;
+ break;
+ case Qt::WindowFullScreen:
+ visibility = QWindow::FullScreen;
+ break;
+ case Qt::WindowNoState:
+ visibility = QWindow::Windowed;
+ break;
+ default:
+ Q_ASSERT(false);
+ break;
+ }
+ } else {
+ visibility = QWindow::Hidden;
+ }
+
+ if (visibility != old)
+ emit q->visibilityChanged(visibility);
+}
+
+/*!
Sets the \a surfaceType of the window.
Specifies whether the window is meant for raster rendering with
@@ -264,6 +381,7 @@ void QWindow::setVisible(bool visible)
return;
d->visible = visible;
emit visibleChanged(visible);
+ d->updateVisibility();
if (!d->platformWindow)
create();
@@ -284,7 +402,7 @@ void QWindow::setVisible(bool visible)
}
#ifndef QT_NO_CURSOR
- if (visible)
+ if (visible && d->hasCursor)
d->applyCursor();
#endif
d->platformWindow->setVisible(visible);
@@ -642,7 +760,8 @@ void QWindow::lower()
}
/*!
- Sets the window's opacity in the windowing system to \a level.
+ \property QWindow::opacity
+ \brief The opacity of the window in the windowing system.
If the windowing system supports window opacity, this can be used to fade the
window in and out, or to make it semitransparent.
@@ -650,15 +769,25 @@ void QWindow::lower()
A value of 1.0 or above is treated as fully opaque, whereas a value of 0.0 or below
is treated as fully transparent. Values inbetween represent varying levels of
translucency between the two extremes.
+
+ The default value is 1.0.
*/
void QWindow::setOpacity(qreal level)
{
Q_D(QWindow);
- if (level == d->opacity) // #fixme: Add property for 5.1
+ if (level == d->opacity)
return;
d->opacity = level;
- if (d->platformWindow)
+ if (d->platformWindow) {
d->platformWindow->setOpacity(level);
+ emit opacityChanged(level);
+ }
+}
+
+qreal QWindow::opacity() const
+{
+ Q_D(const QWindow);
+ return d->opacity;
}
/*!
@@ -797,6 +926,7 @@ void QWindow::setWindowState(Qt::WindowState state)
d->platformWindow->setWindowState(state);
d->windowState = state;
emit windowStateChanged(d->windowState);
+ d->updateVisibility();
}
/*!
@@ -1436,13 +1566,15 @@ QObject *QWindow::focusObject() const
Shows the window.
This equivalent to calling showFullScreen() or showNormal(), depending
- on whether the platform defaults to windows being fullscreen or not.
+ on whether the platform defaults to windows being fullscreen or not, and
+ whether the window is a popup.
- \sa showFullScreen(), showNormal(), hide(), QStyleHints::showIsFullScreen()
+ \sa showFullScreen(), showNormal(), hide(), QStyleHints::showIsFullScreen(), flags()
*/
void QWindow::show()
{
- if (qApp->styleHints()->showIsFullScreen())
+ bool isPopup = d_func()->windowFlags & Qt::Popup & ~Qt::Window;
+ if (!isPopup && qApp->styleHints()->showIsFullScreen())
showFullScreen();
else
showNormal();
@@ -1711,6 +1843,7 @@ bool QWindow::event(QEvent *ev)
case QEvent::WindowStateChange: {
Q_D(QWindow);
emit windowStateChanged(d->windowState);
+ d->updateVisibility();
break;
}
@@ -1946,13 +2079,7 @@ void QWindowPrivate::maybeQuitOnLastWindowClosed()
void QWindow::setCursor(const QCursor &cursor)
{
Q_D(QWindow);
- d->cursor = cursor;
- // Only attempt to set cursor and emit signal if there is an actual platform cursor
- if (d->screen->handle()->cursor()) {
- d->applyCursor();
- QEvent event(QEvent::CursorChange);
- QGuiApplication::sendEvent(this, &event);
- }
+ d->setCursor(&cursor);
}
/*!
@@ -1960,7 +2087,8 @@ void QWindow::setCursor(const QCursor &cursor)
*/
void QWindow::unsetCursor()
{
- setCursor(Qt::ArrowCursor);
+ Q_D(QWindow);
+ d->setCursor(0);
}
/*!
@@ -1974,14 +2102,39 @@ QCursor QWindow::cursor() const
return d->cursor;
}
+void QWindowPrivate::setCursor(const QCursor *newCursor)
+{
+
+ Q_Q(QWindow);
+ if (newCursor) {
+ const Qt::CursorShape newShape = newCursor->shape();
+ if (newShape <= Qt::LastCursor && hasCursor && newShape == cursor.shape())
+ return; // Unchanged and no bitmap/custom cursor.
+ cursor = *newCursor;
+ hasCursor = true;
+ } else {
+ if (!hasCursor)
+ return;
+ cursor = QCursor(Qt::ArrowCursor);
+ hasCursor = false;
+ }
+ // Only attempt to set cursor and emit signal if there is an actual platform cursor
+ if (screen->handle()->cursor()) {
+ applyCursor();
+ QEvent event(QEvent::CursorChange);
+ QGuiApplication::sendEvent(q, &event);
+ }
+}
+
void QWindowPrivate::applyCursor()
{
Q_Q(QWindow);
if (platformWindow) {
if (QPlatformCursor *platformCursor = screen->handle()->cursor()) {
- QCursor *oc = QGuiApplication::overrideCursor();
- QCursor c = oc ? *oc : cursor;
- platformCursor->changeCursor(&c, q);
+ QCursor *c = QGuiApplication::overrideCursor();
+ if (!c && hasCursor)
+ c = &cursor;
+ platformCursor->changeCursor(c, q);
}
}
}
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 2e2f12a8ab..4b8f0ca3e7 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -59,8 +59,6 @@
#include <QtGui/qcursor.h>
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -93,6 +91,8 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface
Q_OBJECT
Q_DECLARE_PRIVATE(QWindow)
+ Q_ENUMS(Visibility)
+
// All properties which are declared here are inherited by QQuickWindow and therefore available in QML.
// So please think carefully about what it does to the QML namespace if you add any new ones,
// particularly the possible meanings these names might have in any specializations of Window.
@@ -111,9 +111,19 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface
Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged)
Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
+ Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged)
Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged)
+ Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
public:
+ enum Visibility {
+ Hidden = 0,
+ AutomaticVisibility,
+ Windowed,
+ Minimized,
+ Maximized,
+ FullScreen
+ };
explicit QWindow(QScreen *screen = 0);
explicit QWindow(QWindow *parent);
@@ -124,6 +134,9 @@ public:
bool isVisible() const;
+ Visibility visibility() const;
+ void setVisibility(Visibility v);
+
void create();
WId winId() const;
@@ -148,6 +161,8 @@ public:
QString title() const;
void setOpacity(qreal level);
+ qreal opacity() const;
+
void requestActivate();
bool isActive() const;
@@ -283,10 +298,13 @@ Q_SIGNALS:
void maximumHeightChanged(int arg);
void visibleChanged(bool arg);
+ void visibilityChanged(QWindow::Visibility visibility);
void contentOrientationChanged(Qt::ScreenOrientation orientation);
void focusObjectChanged(QObject *object);
+ void opacityChanged(qreal opacity);
+
private Q_SLOTS:
void screenDestroyed(QObject *screen);
@@ -330,6 +348,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QWINDOW_H
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index 6933c892a0..bcbface370 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -59,8 +59,6 @@
#include <QtCore/private/qobject_p.h>
#include <QtGui/QIcon>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
#define QWINDOWSIZE_MAX ((1<<24)-1)
@@ -85,6 +83,7 @@ public:
, visible(false)
, exposed(false)
, windowState(Qt::WindowNoState)
+ , visibility(QWindow::Hidden)
, resizeEventPending(true)
, receivedExpose(false)
, positionPolicy(WindowFrameExclusive)
@@ -98,6 +97,7 @@ public:
, screen(0)
#ifndef QT_NO_CURSOR
, cursor(Qt::ArrowCursor)
+ , hasCursor(false)
#endif
{
isWindow = true;
@@ -109,6 +109,7 @@ public:
void maybeQuitOnLastWindowClosed();
#ifndef QT_NO_CURSOR
+ void setCursor(const QCursor *c = 0);
void applyCursor();
#endif
@@ -122,6 +123,8 @@ public:
virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; }
+ void updateVisibility();
+
QWindow::SurfaceType surfaceType;
Qt::WindowFlags windowFlags;
QWindow *parentWindow;
@@ -134,6 +137,7 @@ public:
QIcon windowIcon;
QRect geometry;
Qt::WindowState windowState;
+ QWindow::Visibility visibility;
bool resizeEventPending;
bool receivedExpose;
PositionPolicy positionPolicy;
@@ -153,12 +157,11 @@ public:
#ifndef QT_NO_CURSOR
QCursor cursor;
+ bool hasCursor;
#endif
};
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QWINDOW_P_H
diff --git a/src/gui/kernel/qwindowdefs.h b/src/gui/kernel/qwindowdefs.h
index 9aaca3ff60..42f4bc7c9b 100644
--- a/src/gui/kernel/qwindowdefs.h
+++ b/src/gui/kernel/qwindowdefs.h
@@ -46,7 +46,6 @@
#include <QtCore/qobjectdefs.h>
#include <QtCore/qnamespace.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -88,7 +87,6 @@ typedef QList<QWidget *> QWidgetList;
typedef QList<QWindow *> QWindowList;
QT_END_NAMESPACE
-QT_END_HEADER
// Window system dependent definitions
@@ -104,7 +102,6 @@ typedef QT_PREPEND_NAMESPACE(quintptr) WId;
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
template<class K, class V> class QHash;
@@ -114,7 +111,6 @@ template<class V> class QSet;
typedef QSet<QWidget *> QWidgetSet;
QT_END_NAMESPACE
-QT_END_HEADER
#if defined(QT_NEEDS_QMAIN)
#define main qMain
diff --git a/src/gui/kernel/qwindowdefs_win.h b/src/gui/kernel/qwindowdefs_win.h
index 8f551900ae..fea995a0f5 100644
--- a/src/gui/kernel/qwindowdefs_win.h
+++ b/src/gui/kernel/qwindowdefs_win.h
@@ -44,8 +44,6 @@
#include <QtCore/qglobal.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -124,6 +122,4 @@ Q_WIDGETS_EXPORT HDC qt_win_display_dc();
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QWINDOWDEFS_WIN_H
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 27bb4bae00..5483dc49d0 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -575,6 +575,12 @@ void QWindowSystemInterface::handleFileOpenEvent(const QString& fileName)
QGuiApplicationPrivate::processWindowSystemEvent(&e);
}
+void QWindowSystemInterface::handleFileOpenEvent(const QUrl &url)
+{
+ QWindowSystemInterfacePrivate::FileOpenEvent e(url);
+ QGuiApplicationPrivate::processWindowSystemEvent(&e);
+}
+
void QWindowSystemInterface::handleTabletEvent(QWindow *w, ulong timestamp, bool down, const QPointF &local, const QPointF &global,
int device, int pointerType, qreal pressure, int xTilt, int yTilt,
qreal tangentialPressure, qreal rotation, int z, qint64 uid,
@@ -641,6 +647,13 @@ void QWindowSystemInterface::handleContextMenuEvent(QWindow *w, bool mouseTrigge
}
#endif
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPoint &p) {
+ dbg.nospace() << "TouchPoint(" << p.id << " @" << p.normalPosition << " press " << p.pressure << " vel " << p.velocity << " state " << (int)p.state;
+ return dbg.space();
+}
+#endif
+
Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier) {
QWindowSystemInterface::handleMouseEvent(w, local, global, b, mods);
}
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index 5715b69ee5..687c72bbef 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -62,8 +62,6 @@
#include <QtCore/QEventLoop>
#include <QtGui/QVector2D>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QMimeData;
@@ -160,6 +158,7 @@ public:
static void handleThemeChange(QWindow *tlw);
static void handleFileOpenEvent(const QString& fileName);
+ static void handleFileOpenEvent(const QUrl &url);
static void handleTabletEvent(QWindow *w, ulong timestamp, bool down, const QPointF &local, const QPointF &global,
int device, int pointerType, qreal pressure, int xTilt, int yTilt,
@@ -191,6 +190,10 @@ private:
static bool sendWindowSystemEventsImplementation(QEventLoop::ProcessEventsFlags flags);
};
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPoint &p);
+#endif
+
QT_END_NAMESPACE
-QT_END_HEADER
+
#endif // QWINDOWSYSTEMINTERFACE_H
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index 4131568461..d0b728ec4d 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -59,8 +59,6 @@
#include <QMutex>
#include <QList>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QWindowSystemInterfacePrivate {
@@ -287,9 +285,12 @@ public:
class FileOpenEvent : public WindowSystemEvent {
public:
FileOpenEvent(const QString& fileName)
- : WindowSystemEvent(FileOpen), fileName(fileName)
+ : WindowSystemEvent(FileOpen), url(QUrl::fromLocalFile(fileName))
+ { }
+ FileOpenEvent(const QUrl &url)
+ : WindowSystemEvent(FileOpen), url(url)
{ }
- QString fileName;
+ QUrl url;
};
class TabletEvent : public InputEvent {
@@ -424,7 +425,6 @@ public:
static QList<QTouchEvent::TouchPoint> convertTouchPoints(const QList<QWindowSystemInterface::TouchPoint> &points, QEvent::Type *type);
};
-QT_END_HEADER
QT_END_NAMESPACE
#endif // QWINDOWSYSTEMINTERFACE_P_H
diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h
index 911e7f036c..c243647d33 100644
--- a/src/gui/math3d/qgenericmatrix.h
+++ b/src/gui/math3d/qgenericmatrix.h
@@ -46,8 +46,6 @@
#include <QtCore/qdebug.h>
#include <QtCore/qdatastream.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -401,6 +399,4 @@ Q_DECLARE_METATYPE(QMatrix3x4)
Q_DECLARE_METATYPE(QMatrix4x2)
Q_DECLARE_METATYPE(QMatrix4x3)
-QT_END_HEADER
-
#endif
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index d41602f0cb..d4ba7d64d8 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -48,8 +48,6 @@
#include <QtGui/qgenericmatrix.h>
#include <QtCore/qrect.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -1119,6 +1117,4 @@ QT_DEPRECATED QGenericMatrix<N, M, float> qGenericMatrixFromMatrix4x4(const QMat
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index b02715e390..d042d9812a 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -66,7 +66,8 @@ QT_BEGIN_NAMESPACE
/*!
\fn QQuaternion::QQuaternion()
- Constructs an identity quaternion, i.e. with coordinates (1, 0, 0, 0).
+ Constructs an identity quaternion (1, 0, 0, 0), i.e. with the vector (0, 0, 0)
+ and scalar 1.
*/
/*!
@@ -257,7 +258,7 @@ QQuaternion QQuaternion::normalized() const
}
/*!
- Normalizes the currect quaternion in place. Nothing happens if this
+ Normalizes the current quaternion in place. Nothing happens if this
is a null quaternion or the length of the quaternion is very close to 1.
\sa length(), normalized()
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index 13fbac8f4a..c12b0f4fec 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -45,8 +45,6 @@
#include <QtGui/qvector3d.h>
#include <QtGui/qvector4d.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -324,6 +322,4 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QQuaternion &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h
index 9ac738fa2d..647e5e36f2 100644
--- a/src/gui/math3d/qvector2d.h
+++ b/src/gui/math3d/qvector2d.h
@@ -45,8 +45,6 @@
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -252,6 +250,4 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QVector2D &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h
index 28700d7d97..879b2125ea 100644
--- a/src/gui/math3d/qvector3d.h
+++ b/src/gui/math3d/qvector3d.h
@@ -45,8 +45,6 @@
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -276,6 +274,4 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QVector3D &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h
index 5acd1d3f48..4bd3822133 100644
--- a/src/gui/math3d/qvector4d.h
+++ b/src/gui/math3d/qvector4d.h
@@ -45,8 +45,6 @@
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -281,6 +279,4 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QVector4D &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/opengl/qopengl.h b/src/gui/opengl/qopengl.h
index 9d29e07319..a4a626a0c4 100644
--- a/src/gui/opengl/qopengl.h
+++ b/src/gui/opengl/qopengl.h
@@ -46,8 +46,6 @@
#include <QtCore/qglobal.h>
-QT_BEGIN_HEADER
-
#if defined(QT_OPENGL_ES_2)
# if defined(Q_OS_MAC)
# include <OpenGLES/ES2/gl.h>
@@ -113,8 +111,6 @@ QT_BEGIN_NAMESPACE
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_OPENGL
#endif // QOPENGL_H
diff --git a/src/gui/opengl/qopengl_p.h b/src/gui/opengl/qopengl_p.h
index 84245fb670..3cf636751a 100644
--- a/src/gui/opengl/qopengl_p.h
+++ b/src/gui/opengl/qopengl_p.h
@@ -46,11 +46,9 @@
#include <private/qopenglcontext_p.h>
#include <QtCore/qset.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
-class QOpenGLExtensionMatcher
+class Q_GUI_EXPORT QOpenGLExtensionMatcher
{
public:
QOpenGLExtensionMatcher();
@@ -68,6 +66,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QOPENGL_H
diff --git a/src/gui/opengl/qopenglbuffer.h b/src/gui/opengl/qopenglbuffer.h
index 5ce8c3db49..014060086d 100644
--- a/src/gui/opengl/qopenglbuffer.h
+++ b/src/gui/opengl/qopenglbuffer.h
@@ -47,8 +47,6 @@
#include <QtCore/qscopedpointer.h>
#include <QtGui/qopengl.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -128,8 +126,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_OPENGL
#endif
diff --git a/src/gui/opengl/qopenglcustomshaderstage_p.h b/src/gui/opengl/qopenglcustomshaderstage_p.h
index 2accb03fa3..bb671b0d3b 100644
--- a/src/gui/opengl/qopenglcustomshaderstage_p.h
+++ b/src/gui/opengl/qopenglcustomshaderstage_p.h
@@ -55,8 +55,6 @@
#include <QOpenGLShaderProgram>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -87,7 +85,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/opengl/qopenglengineshadermanager_p.h b/src/gui/opengl/qopenglengineshadermanager_p.h
index 462ffbf703..49c03a7fee 100644
--- a/src/gui/opengl/qopenglengineshadermanager_p.h
+++ b/src/gui/opengl/qopenglengineshadermanager_p.h
@@ -228,8 +228,6 @@
#include <private/qopenglcontext_p.h>
#include <private/qopenglcustomshaderstage_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -508,6 +506,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif //QOPENGLENGINE_SHADER_MANAGER_H
diff --git a/src/gui/opengl/qopenglengineshadersource_p.h b/src/gui/opengl/qopenglengineshadersource_p.h
index f1b1dbe5a6..869bd057f2 100644
--- a/src/gui/opengl/qopenglengineshadersource_p.h
+++ b/src/gui/opengl/qopenglengineshadersource_p.h
@@ -56,8 +56,6 @@
#include "qopenglengineshadermanager_p.h"
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -523,6 +521,4 @@ static const char* const qopenglslRgbMaskFragmentShaderPass2 = "\n\
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // GLGC_SHADER_SOURCE_H
diff --git a/src/gui/opengl/qopenglextensions_p.h b/src/gui/opengl/qopenglextensions_p.h
index a4e473c049..265771ce1b 100644
--- a/src/gui/opengl/qopenglextensions_p.h
+++ b/src/gui/opengl/qopenglextensions_p.h
@@ -55,8 +55,6 @@
#include "qopenglfunctions.h"
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -193,6 +191,4 @@ inline void QOpenGLExtensions::glGetBufferSubData(GLenum target, qopengl_GLintpt
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QOPENGL_EXTENSIONS_P_H
diff --git a/src/gui/opengl/qopenglframebufferobject.h b/src/gui/opengl/qopenglframebufferobject.h
index 9dbef318f0..e4fd7c8e95 100644
--- a/src/gui/opengl/qopenglframebufferobject.h
+++ b/src/gui/opengl/qopenglframebufferobject.h
@@ -49,8 +49,6 @@
#include <QtCore/qscopedpointer.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -161,8 +159,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_OPENGL
#endif // QOPENGLFRAMEBUFFEROBJECT_H
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index ee5855d866..3737df7497 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -289,7 +289,7 @@ static int qt_gl_resolve_features()
return features;
#else
int features = 0;
- //QOpenGLFormat::OpenGLVersionFlags versions = QOpenGLFormat::openGLVersionFlags();
+ QSurfaceFormat format = QOpenGLContext::currentContext()->format();
QOpenGLExtensionMatcher extensions;
// Recognize features by extension name.
@@ -327,6 +327,10 @@ static int qt_gl_resolve_features()
QOpenGLFunctions::StencilSeparate |
QOpenGLFunctions::BlendEquationSeparate |
QOpenGLFunctions::NPOTTextures;
+
+ if (format.majorVersion() >= 3)
+ features |= QOpenGLFunctions::Framebuffers;
+
return features;
#endif
}
@@ -349,10 +353,13 @@ static int qt_gl_resolve_extensions()
extensions |= QOpenGLExtensions::BGRATextureFormat;
#else
+ QSurfaceFormat format = QOpenGLContext::currentContext()->format();
extensions |= QOpenGLExtensions::ElementIndexUint | QOpenGLExtensions::MapBuffer;
// Recognize features by extension name.
- if (extensionMatcher.match("GL_ARB_framebuffer_object")) {
+ if (format.majorVersion() >= 3
+ || extensionMatcher.match("GL_ARB_framebuffer_object"))
+ {
extensions |= QOpenGLExtensions::FramebufferMultisample |
QOpenGLExtensions::FramebufferBlit |
QOpenGLExtensions::PackedDepthStencil;
diff --git a/src/gui/opengl/qopenglfunctions.h b/src/gui/opengl/qopenglfunctions.h
index 5f3b63d0a0..100e3751be 100644
--- a/src/gui/opengl/qopenglfunctions.h
+++ b/src/gui/opengl/qopenglfunctions.h
@@ -71,8 +71,6 @@
#define Q_OPENGL_FUNCTIONS_DEBUG
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -1520,8 +1518,6 @@ inline void QOpenGLFunctions::glVertexAttribPointer(GLuint indx, GLint size, GLe
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_OPENGL
#endif
diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h
index 66850c73fc..731000f131 100644
--- a/src/gui/opengl/qopenglpaintdevice.h
+++ b/src/gui/opengl/qopenglpaintdevice.h
@@ -48,8 +48,6 @@
#include <QtGui/qopengl.h>
#include <QtGui/qopenglcontext.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -91,8 +89,6 @@ protected:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_OPENGL
#endif // QOPENGLPAINTDEVICE_H
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
index 9fd8a7ada7..555c47f265 100644
--- a/src/gui/opengl/qopenglpaintengine.cpp
+++ b/src/gui/opengl/qopenglpaintengine.cpp
@@ -624,7 +624,7 @@ void QOpenGL2PaintEngineExPrivate::transferMode(EngineMode newMode)
if (newMode == mode)
return;
- if (mode == TextDrawingMode || mode == ImageDrawingMode || mode == ImageArrayDrawingMode) {
+ if (mode != BrushDrawingMode) {
lastTextureUsed = GLuint(-1);
}
@@ -639,10 +639,12 @@ void QOpenGL2PaintEngineExPrivate::transferMode(EngineMode newMode)
setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, staticTextureCoordinateArray);
}
- if (newMode == ImageArrayDrawingMode) {
+ if (newMode == ImageArrayDrawingMode || newMode == ImageOpacityArrayDrawingMode) {
setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinateArray.data());
setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinateArray.data());
- setVertexAttributePointer(QT_OPACITY_ATTR, (GLfloat*)opacityArray.data());
+
+ if (newMode == ImageOpacityArrayDrawingMode)
+ setVertexAttributePointer(QT_OPACITY_ATTR, (GLfloat*)opacityArray.data());
}
// This needs to change when we implement high-quality anti-aliasing...
@@ -1069,9 +1071,23 @@ void QOpenGL2PaintEngineExPrivate::resetClipIfNeeded()
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
+bool QOpenGL2PaintEngineExPrivate::prepareForCachedGlyphDraw(const QFontEngineGlyphCache &cache)
+{
+ Q_Q(QOpenGL2PaintEngineEx);
+
+ Q_ASSERT(cache.transform().type() <= QTransform::TxScale);
+
+ QTransform &transform = q->state()->matrix;
+ transform.scale(1.0 / cache.transform().m11(), 1.0 / cache.transform().m22());
+ bool ret = prepareForDraw(false);
+ transform.scale(cache.transform().m11(), cache.transform().m22());
+
+ return ret;
+}
+
bool QOpenGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque)
{
- if (brushTextureDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode)
+ if (brushTextureDirty && (mode == TextDrawingMode || mode == BrushDrawingMode))
updateBrushTexture();
if (compositionModeDirty)
@@ -1091,12 +1107,12 @@ bool QOpenGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque)
}
QOpenGLEngineShaderManager::OpacityMode opacityMode;
- if (mode == ImageArrayDrawingMode) {
+ if (mode == ImageOpacityArrayDrawingMode) {
opacityMode = QOpenGLEngineShaderManager::AttributeOpacity;
} else {
opacityMode = stateHasOpacity ? QOpenGLEngineShaderManager::UniformOpacity
: QOpenGLEngineShaderManager::NoOpacity;
- if (stateHasOpacity && (mode != ImageDrawingMode)) {
+ if (stateHasOpacity && (mode != ImageDrawingMode && mode != ImageArrayDrawingMode)) {
// Using a brush
bool brushIsPattern = (currentBrush.style() >= Qt::Dense1Pattern) &&
(currentBrush.style() <= Qt::DiagCrossPattern);
@@ -1116,7 +1132,7 @@ bool QOpenGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque)
matrixUniformDirty = true;
}
- if (brushUniformsDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode)
+ if (brushUniformsDirty && (mode == TextDrawingMode || mode == BrushDrawingMode))
updateBrushUniforms();
if (opacityMode == QOpenGLEngineShaderManager::UniformOpacity && opacityUniformDirty) {
@@ -1407,11 +1423,9 @@ void QOpenGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem)
ensureActive();
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) {
+ if (shouldDrawCachedGlyphs(fontEngine, s->matrix)) {
QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0
? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat)
: d->glyphCacheType;
@@ -1461,13 +1475,6 @@ void QOpenGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &text
QTransform::TransformationType txtype = s->matrix.type();
- float det = s->matrix.determinant();
- bool drawCached = txtype < QTransform::TxProject;
-
- // don't try to cache huge fonts or vastly transformed fonts
- if (!shouldDrawCachedGlyphs(ti.fontEngine, s->matrix) || det < 0.25f || det > 4.f)
- drawCached = false;
-
QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0
? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat)
: d->glyphCacheType;
@@ -1482,7 +1489,7 @@ void QOpenGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &text
}
}
- if (drawCached) {
+ if (shouldDrawCachedGlyphs(ti.fontEngine, s->matrix)) {
QVarLengthArray<QFixedPoint> positions;
QVarLengthArray<glyph_t> glyphs;
QTransform matrix = QTransform::fromTranslate(p.x(), p.y());
@@ -1531,6 +1538,12 @@ namespace {
// #define QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO
+bool QOpenGL2PaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &t) const
+{
+ // Don't try to cache vastly transformed fonts
+ return t.type() < QTransform::TxProject && QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t);
+}
+
void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType,
QStaticTextItem *staticTextItem)
{
@@ -1542,10 +1555,18 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
bool recreateVertexArrays = false;
QFontEngine *fe = staticTextItem->fontEngine();
+ // We allow scaling, so that the glyph-cache will contain glyphs with the
+ // appropriate resolution in the case of displays with a device-pixel-ratio != 1.
+ QTransform transform = s->matrix.type() < QTransform::TxRotate ?
+ QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) :
+ QTransform::fromScale(
+ QVector2D(s->matrix.m11(), s->matrix.m12()).length(),
+ QVector2D(s->matrix.m21(), s->matrix.m22()).length());
+
QOpenGLTextureGlyphCache *cache =
- (QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, QTransform());
+ (QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, transform);
if (!cache || cache->cacheType() != glyphType || cache->contextGroup() == 0) {
- cache = new QOpenGLTextureGlyphCache(glyphType, QTransform());
+ cache = new QOpenGLTextureGlyphCache(glyphType, transform);
fe->setGlyphCache(cacheKey, cache);
recreateVertexArrays = true;
}
@@ -1583,7 +1604,10 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
if (cache->width() == 0 || cache->height() == 0)
return;
- transferMode(TextDrawingMode);
+ if (glyphType == QFontEngineGlyphCache::Raster_ARGB)
+ transferMode(ImageArrayDrawingMode);
+ else
+ transferMode(TextDrawingMode);
int margin = fe->glyphMargin(glyphType);
@@ -1637,8 +1661,8 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
if (c.isNull())
continue;
- int x = qFloor(staticTextItem->glyphPositions[i].x) + c.baseLineX - margin;
- int y = qRound(staticTextItem->glyphPositions[i].y) - c.baseLineY - margin;
+ int x = qFloor(staticTextItem->glyphPositions[i].x.toReal() * cache->transform().m11()) + c.baseLineX - margin;
+ int y = qRound(staticTextItem->glyphPositions[i].y.toReal() * cache->transform().m22()) - c.baseLineY - margin;
vertexCoordinates->addQuad(QRectF(x, y, c.w, c.h));
textureCoordinates->addQuad(QRectF(c.x*dx, c.y*dy, c.w * dx, c.h * dy));
@@ -1679,8 +1703,10 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
#endif
}
- setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinates->data());
- setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinates->data());
+ if (glyphType != QFontEngineGlyphCache::Raster_ARGB || recreateVertexArrays) {
+ setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinates->data());
+ setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinates->data());
+ }
if (!snapToPixelGrid) {
snapToPixelGrid = true;
@@ -1711,9 +1737,9 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
}
compositionModeDirty = false; // I can handle this myself, thank you very much
- prepareForDraw(false); // Text always causes src pixels to be transparent
+ prepareForCachedGlyphDraw(*cache);
- // prepareForDraw() have set the opacity on the current shader, so the opacity state can now be reset.
+ // prepareForCachedGlyphDraw() have set the opacity on the current shader, so the opacity state can now be reset.
if (compMode == QPainter::CompositionMode_Source) {
q->state()->opacity = oldOpacity;
opacityUniformDirty = true;
@@ -1734,7 +1760,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
}
compositionModeDirty = false; // I can handle this myself, thank you very much
- prepareForDraw(false); // Text always causes src pixels to be transparent
+ prepareForCachedGlyphDraw(*cache);
glEnable(GL_BLEND);
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
@@ -1758,22 +1784,31 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
}
compositionModeDirty = false;
- prepareForDraw(false); // Text always causes src pixels to be transparent
+ prepareForCachedGlyphDraw(*cache);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
}
compositionModeDirty = true;
+ } else if (glyphType == QFontEngineGlyphCache::Raster_ARGB) {
+ currentBrush = noBrush;
+ shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::ImageSrc);
+ if (prepareForCachedGlyphDraw(*cache))
+ shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT);
} else {
// Greyscale/mono glyphs
shaderManager->setMaskType(QOpenGLEngineShaderManager::PixelMask);
- prepareForDraw(false); // Text always causes src pixels to be transparent
+ prepareForCachedGlyphDraw(*cache);
}
QOpenGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate)?QOpenGLTextureGlyphCache::Linear:QOpenGLTextureGlyphCache::Nearest;
if (lastMaskTextureUsed != cache->texture() || cache->filterMode() != filterMode) {
- funcs.glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT);
+ if (glyphType == QFontEngineGlyphCache::Raster_ARGB)
+ funcs.glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
+ else
+ funcs.glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT);
+
if (lastMaskTextureUsed != cache->texture()) {
glBindTexture(GL_TEXTURE_2D, cache->texture());
lastMaskTextureUsed = cache->texture();
@@ -1889,7 +1924,7 @@ void QOpenGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFra
funcs.glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
GLuint id = QOpenGLTextureCache::cacheForContext(ctx)->bindTexture(ctx, pixmap);
- transferMode(ImageArrayDrawingMode);
+ transferMode(ImageOpacityArrayDrawingMode);
bool isBitmap = pixmap.isQBitmap();
bool isOpaque = !isBitmap && (!pixmap.hasAlpha() || (hints & QPainter::OpaqueHint)) && allOpaque;
diff --git a/src/gui/opengl/qopenglpaintengine_p.h b/src/gui/opengl/qopenglpaintengine_p.h
index 93e1b4232e..d51f0e5256 100644
--- a/src/gui/opengl/qopenglpaintengine_p.h
+++ b/src/gui/opengl/qopenglpaintengine_p.h
@@ -70,7 +70,8 @@ enum EngineMode {
ImageDrawingMode,
TextDrawingMode,
BrushDrawingMode,
- ImageArrayDrawingMode
+ ImageArrayDrawingMode,
+ ImageOpacityArrayDrawingMode
};
QT_BEGIN_NAMESPACE
@@ -157,7 +158,8 @@ public:
void setRenderTextActive(bool);
bool isNativePaintingActive() const;
- bool supportsTransformations(QFontEngine *, const QTransform &) const { return true; }
+ bool requiresPretransformedGlyphPositions(QFontEngine *, const QTransform &) const { return false; }
+ bool shouldDrawCachedGlyphs(QFontEngine *, const QTransform &) const;
private:
Q_DISABLE_COPY(QOpenGL2PaintEngineEx)
@@ -235,6 +237,7 @@ public:
void setBrush(const QBrush& brush);
void transferMode(EngineMode newMode);
bool prepareForDraw(bool srcPixelsAreOpaque); // returns true if the program has changed
+ bool prepareForCachedGlyphDraw(const QFontEngineGlyphCache &cache);
inline void useSimpleShader();
inline GLuint location(const QOpenGLEngineShaderManager::Uniform uniform) {
return shaderManager->getUniformLocation(uniform);
diff --git a/src/gui/opengl/qopenglshadercache_meego_p.h b/src/gui/opengl/qopenglshadercache_meego_p.h
index 3d62d79ee7..d1c14150d1 100644
--- a/src/gui/opengl/qopenglshadercache_meego_p.h
+++ b/src/gui/opengl/qopenglshadercache_meego_p.h
@@ -68,8 +68,6 @@
# include <syslog.h>
#endif
-QT_BEGIN_HEADER
-
/*
This cache stores internal Qt shader programs in shared memory.
@@ -450,7 +448,5 @@ QT_END_NAMESPACE
#endif
-QT_END_HEADER
-
#endif
#endif
diff --git a/src/gui/opengl/qopenglshadercache_p.h b/src/gui/opengl/qopenglshadercache_p.h
index 0e0b6c3735..17305539df 100644
--- a/src/gui/opengl/qopenglshadercache_p.h
+++ b/src/gui/opengl/qopenglshadercache_p.h
@@ -59,8 +59,6 @@
# include "qopenglshadercache_meego_p.h"
#else
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -91,7 +89,5 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
#endif
diff --git a/src/gui/opengl/qopenglshaderprogram.h b/src/gui/opengl/qopenglshaderprogram.h
index cd05d0f96b..f371326239 100644
--- a/src/gui/opengl/qopenglshaderprogram.h
+++ b/src/gui/opengl/qopenglshaderprogram.h
@@ -50,8 +50,6 @@
#include <QtGui/qvector4d.h>
#include <QtGui/qmatrix4x4.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -293,8 +291,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_OPENGL
#endif
diff --git a/src/gui/opengl/qopengltexturecache.cpp b/src/gui/opengl/qopengltexturecache.cpp
index fffc3688e3..94b82885ff 100644
--- a/src/gui/opengl/qopengltexturecache.cpp
+++ b/src/gui/opengl/qopengltexturecache.cpp
@@ -95,9 +95,10 @@ void QOpenGLTextureCacheWrapper::cleanupTexturesForPixmapData(QPlatformPixmap *p
cleanupTexturesForCacheKey(pmd->cacheKey());
}
-QOpenGLTextureCache::QOpenGLTextureCache(QOpenGLContext *ctx)
+QOpenGLTextureCache::QOpenGLTextureCache(QOpenGLContext *ctx, bool useByteSwapImage)
: QOpenGLSharedResource(ctx->shareGroup())
, m_cache(64 * 1024) // 64 MB cache
+ , m_useByteSwapImage(useByteSwapImage)
{
}
@@ -180,7 +181,9 @@ GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, qint64 key, con
QImage tx = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- qgl_byteSwapImage(tx);
+ // Performance could be improved by skipping qgl_byteSwapImage().
+ if (m_useByteSwapImage)
+ qgl_byteSwapImage(tx);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tx.width(), tx.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, const_cast<const QImage &>(tx).bits());
diff --git a/src/gui/opengl/qopengltexturecache_p.h b/src/gui/opengl/qopengltexturecache_p.h
index 2e82d5f373..d4d3f00069 100644
--- a/src/gui/opengl/qopengltexturecache_p.h
+++ b/src/gui/opengl/qopengltexturecache_p.h
@@ -78,7 +78,7 @@ class Q_GUI_EXPORT QOpenGLTextureCache : public QOpenGLSharedResource
public:
static QOpenGLTextureCache *cacheForContext(QOpenGLContext *context);
- QOpenGLTextureCache(QOpenGLContext *);
+ QOpenGLTextureCache(QOpenGLContext *, bool useByteSwapImage = true);
~QOpenGLTextureCache();
GLuint bindTexture(QOpenGLContext *context, const QPixmap &pixmap);
@@ -94,6 +94,7 @@ private:
QMutex m_mutex;
QCache<quint64, QOpenGLCachedTexture> m_cache;
+ bool m_useByteSwapImage;
};
QT_END_NAMESPACE
diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp
index b751629117..83f407575e 100644
--- a/src/gui/opengl/qopengltextureglyphcache.cpp
+++ b/src/gui/opengl/qopengltextureglyphcache.cpp
@@ -120,7 +120,7 @@ void QOpenGLTextureGlyphCache::createTextureData(int width, int height)
m_textureResource->m_width = width;
m_textureResource->m_height = height;
- if (m_type == QFontEngineGlyphCache::Raster_RGBMask) {
+ if (m_type == QFontEngineGlyphCache::Raster_RGBMask || m_type == QFontEngineGlyphCache::Raster_ARGB) {
QVarLengthArray<uchar> data(width * height * 4);
for (int i = 0; i < data.size(); ++i)
data[i] = 0;
@@ -314,30 +314,40 @@ void QOpenGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed
for (int x = 0; x < maskWidth; ++x)
src[x] = -src[x]; // convert 0 and 1 into 0 and 255
}
- } else if (mask.format() == QImage::Format_RGB32) {
- // Make the alpha component equal to the average of the RGB values.
- // This is needed when drawing sub-pixel antialiased text on translucent targets.
- for (int y = 0; y < maskHeight; ++y) {
- quint32 *src = (quint32 *) mask.scanLine(y);
- for (int x = 0; x < maskWidth; ++x) {
- uchar r = src[x] >> 16;
- uchar g = src[x] >> 8;
- uchar b = src[x];
- quint32 avg = (quint32(r) + quint32(g) + quint32(b) + 1) / 3; // "+1" for rounding.
+ } else if (mask.depth() == 32) {
+ if (mask.format() == QImage::Format_RGB32
+ // We need to make the alpha component equal to the average of the RGB values.
+ // This is needed when drawing sub-pixel antialiased text on translucent targets.
+#if defined(QT_OPENGL_ES_2)
+ || !hasBGRA // We need to reverse the bytes
+#endif
+ ) {
+ for (int y = 0; y < maskHeight; ++y) {
+ quint32 *src = (quint32 *) mask.scanLine(y);
+ for (int x = 0; x < maskWidth; ++x) {
+ uchar r = src[x] >> 16;
+ uchar g = src[x] >> 8;
+ uchar b = src[x];
+ quint32 avg;
+ if (mask.format() == QImage::Format_RGB32)
+ avg = (quint32(r) + quint32(g) + quint32(b) + 1) / 3; // "+1" for rounding.
+ else // Format_ARGB_Premultiplied
+ avg = src[x] >> 24;
#if defined(QT_OPENGL_ES_2)
- if (!hasBGRA) {
- // Reverse bytes to match GL_RGBA
- src[x] = (avg << 24) | (quint32(r) << 0) | (quint32(g) << 8) | (quint32(b) << 16);
- } else
+ if (!hasBGRA) {
+ // Reverse bytes to match GL_RGBA
+ src[x] = (avg << 24) | (quint32(r) << 0) | (quint32(g) << 8) | (quint32(b) << 16);
+ } else
#endif
- src[x] = (src[x] & 0x00ffffff) | (avg << 24);
+ src[x] = (src[x] & 0x00ffffff) | (avg << 24);
+ }
}
}
}
glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture);
- if (mask.format() == QImage::Format_RGB32) {
+ if (mask.depth() == 32) {
#if defined(QT_OPENGL_ES_2)
glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, hasBGRA ? GL_BGRA_EXT : GL_RGBA, GL_UNSIGNED_BYTE, mask.bits());
#else
diff --git a/src/gui/painting/qbackingstore.h b/src/gui/painting/qbackingstore.h
index 2a3f91246b..65efab2f48 100644
--- a/src/gui/painting/qbackingstore.h
+++ b/src/gui/painting/qbackingstore.h
@@ -47,8 +47,6 @@
#include <QtGui/qwindow.h>
#include <QtGui/qregion.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -93,6 +91,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QBACKINGSTORE_H
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index 294e0b7931..4d8c97e255 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -52,17 +52,6 @@
#include <QtGui/qimage.h>
#include <QtGui/qpixmap.h>
-#if defined(Q_OS_VXWORKS)
-# if defined(m_data)
-# undef m_data
-# endif
-# if defined(m_type)
-# undef m_type
-# endif
-#endif
-
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -326,6 +315,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QBRUSH_H
diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h
index cd65984f4e..5bd879ed63 100644
--- a/src/gui/painting/qcolor.h
+++ b/src/gui/painting/qcolor.h
@@ -46,8 +46,6 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qstringlist.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -276,6 +274,4 @@ inline QColor QColor::darker(int f) const
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QCOLOR_H
diff --git a/src/gui/painting/qcosmeticstroker_p.h b/src/gui/painting/qcosmeticstroker_p.h
index 136b014424..fb37b70ba5 100644
--- a/src/gui/painting/qcosmeticstroker_p.h
+++ b/src/gui/painting/qcosmeticstroker_p.h
@@ -47,8 +47,6 @@
#include <private/qpaintengine_raster_p.h>
#include <qpen.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -155,6 +153,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QCOSMETICLINE_H
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 0f77ae6d86..906ef128fa 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -5368,7 +5368,7 @@ void qBlendTexture(int count, const QSpan *spans, void *userData)
proc(count, spans, userData);
}
-template <class DST>
+template <class DST> Q_STATIC_TEMPLATE_FUNCTION
inline void qt_bitmapblit_template(QRasterBuffer *rasterBuffer,
int x, int y, DST color,
const uchar *map,
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index 258f130efc..f958538aa6 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -70,15 +70,19 @@ QT_BEGIN_NAMESPACE
#if defined(Q_CC_RVCT)
// RVCT doesn't like static template functions
# define Q_STATIC_TEMPLATE_FUNCTION
-# define Q_STATIC_INLINE_FUNCTION static __forceinline
+# define Q_ALWAYS_INLINE __forceinline
# define Q_DECL_RESTRICT
#elif defined(Q_CC_GNU)
-# define Q_STATIC_TEMPLATE_FUNCTION static __attribute__((always_inline))
-# define Q_STATIC_INLINE_FUNCTION static inline __attribute__((always_inline))
+# define Q_STATIC_TEMPLATE_FUNCTION static
+# define Q_ALWAYS_INLINE inline __attribute__((always_inline))
# define Q_DECL_RESTRICT __restrict__
+#elif defined(Q_CC_MSVC)
+# define Q_STATIC_TEMPLATE_FUNCTION static
+# define Q_ALWAYS_INLINE __forceinline
+# define Q_DECL_RESTRICT __restrict
#else
# define Q_STATIC_TEMPLATE_FUNCTION static
-# define Q_STATIC_INLINE_FUNCTION static inline
+# define Q_ALWAYS_INLINE inline
# define Q_DECL_RESTRICT
#endif
@@ -382,7 +386,7 @@ static inline qreal qRadialDeterminant(qreal a, qreal b, qreal c)
return (b * b) - (4 * a * c);
}
-template <class RadialFetchFunc>
+template <class RadialFetchFunc> Q_STATIC_TEMPLATE_FUNCTION
const uint * QT_FASTCALL qt_fetch_radial_gradient_template(uint *buffer, const Operator *op, const QSpanData *data,
int y, int x, int length)
{
@@ -562,7 +566,7 @@ public:
# pragma push
# pragma arm
#endif
-Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint b) {
+static Q_ALWAYS_INLINE uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint b) {
uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
t &= 0xff00ff;
@@ -579,7 +583,7 @@ Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint
#if QT_POINTER_SIZE == 8 // 64-bit versions
-Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
+static Q_ALWAYS_INLINE uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
t += (((quint64(y)) | ((quint64(y)) << 24)) & 0x00ff00ff00ff00ff) * b;
t >>= 8;
@@ -587,14 +591,14 @@ Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint
return (uint(t)) | (uint(t >> 24));
}
-Q_STATIC_INLINE_FUNCTION uint BYTE_MUL(uint x, uint a) {
+static Q_ALWAYS_INLINE uint BYTE_MUL(uint x, uint a) {
quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080) >> 8;
t &= 0x00ff00ff00ff00ff;
return (uint(t)) | (uint(t >> 24));
}
-Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x) {
+static Q_ALWAYS_INLINE uint PREMUL(uint x) {
uint a = x >> 24;
quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080) >> 8;
@@ -604,7 +608,7 @@ Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x) {
#else // 32-bit versions
-Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
+static Q_ALWAYS_INLINE uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
t >>= 8;
t &= 0xff00ff;
@@ -619,7 +623,7 @@ Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint
# pragma push
# pragma arm
#endif
-Q_STATIC_INLINE_FUNCTION uint BYTE_MUL(uint x, uint a) {
+static Q_ALWAYS_INLINE uint BYTE_MUL(uint x, uint a) {
uint t = (x & 0xff00ff) * a;
t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
t &= 0xff00ff;
@@ -634,7 +638,7 @@ Q_STATIC_INLINE_FUNCTION uint BYTE_MUL(uint x, uint a) {
# pragma pop
#endif
-Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x) {
+static Q_ALWAYS_INLINE uint PREMUL(uint x) {
uint a = x >> 24;
uint t = (x & 0xff00ff) * a;
t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
@@ -649,14 +653,14 @@ Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x) {
#endif
-Q_STATIC_INLINE_FUNCTION uint BYTE_MUL_RGB16(uint x, uint a) {
+static Q_ALWAYS_INLINE uint BYTE_MUL_RGB16(uint x, uint a) {
a += 1;
uint t = (((x & 0x07e0)*a) >> 8) & 0x07e0;
t |= (((x & 0xf81f)*(a>>2)) >> 6) & 0xf81f;
return t;
}
-Q_STATIC_INLINE_FUNCTION uint BYTE_MUL_RGB16_32(uint x, uint a) {
+static Q_ALWAYS_INLINE uint BYTE_MUL_RGB16_32(uint x, uint a) {
uint t = (((x & 0xf81f07e0) >> 5)*a) & 0xf81f07e0;
t |= (((x & 0x07e0f81f)*a) >> 5) & 0x07e0f81f;
return t;
@@ -687,7 +691,7 @@ inline quint24::operator uint() const
return data[2] | (data[1] << 8) | (data[0] << 16);
}
-template <class T>
+template <class T> Q_STATIC_TEMPLATE_FUNCTION
void qt_memfill(T *dest, T value, int count);
template<> inline void qt_memfill(quint32 *dest, quint32 color, int count)
@@ -728,7 +732,7 @@ inline void qt_memfill(T *dest, T value, int count)
}
}
-template <class T>
+template <class T> Q_STATIC_TEMPLATE_FUNCTION
inline void qt_rectfill(T *dest, T value,
int x, int y, int width, int height, int stride)
{
@@ -794,7 +798,7 @@ do { \
# pragma push
# pragma arm
#endif
-Q_STATIC_INLINE_FUNCTION int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; }
+static Q_ALWAYS_INLINE int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; }
#if defined(Q_CC_RVCT)
# pragma pop
#endif
diff --git a/src/gui/painting/qemulationpaintengine_p.h b/src/gui/painting/qemulationpaintengine_p.h
index f706ef3705..72093a3612 100644
--- a/src/gui/painting/qemulationpaintengine_p.h
+++ b/src/gui/painting/qemulationpaintengine_p.h
@@ -55,8 +55,6 @@
#include <private/qpaintengineex_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -107,6 +105,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c
index 8be462517c..7dfb743ae2 100644
--- a/src/gui/painting/qgrayraster.c
+++ b/src/gui/painting/qgrayraster.c
@@ -1736,9 +1736,9 @@
if ( raster->worker )
raster->worker->skip_spans = params->skip_spans;
- // If raster object and raster buffer are allocated, but
- // raster size isn't of the minimum size, indicate out of
- // memory.
+ /* If raster object and raster buffer are allocated, but */
+ /* raster size isn't of the minimum size, indicate out of */
+ /* memory. */
if (raster->buffer_allocated_size < MINIMUM_POOL_SIZE )
return ErrRaster_OutOfMemory;
@@ -1866,8 +1866,8 @@
( sizeof ( TCell ) * 8 ) );
}
else if ( pool_base)
- { // Case when there is a raster pool allocated, but it
- // doesn't have the minimum size (and so memory will be reallocated)
+ { /* Case when there is a raster pool allocated, but it */
+ /* doesn't have the minimum size (and so memory will be reallocated) */
rast->buffer = pool_base;
rast->worker = NULL;
rast->buffer_size = pool_size;
diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h
index 672bbdcfd1..d2c1ae3a3c 100644
--- a/src/gui/painting/qmatrix.h
+++ b/src/gui/painting/qmatrix.h
@@ -49,8 +49,6 @@
#include <QtCore/qpoint.h>
#include <QtCore/qrect.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -185,6 +183,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QMatrix &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QMATRIX_H
diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp
index 2f2fe44209..8b47dae5ff 100644
--- a/src/gui/painting/qoutlinemapper.cpp
+++ b/src/gui/painting/qoutlinemapper.cpp
@@ -48,8 +48,6 @@
QT_BEGIN_NAMESPACE
-static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
-
#define qreal_to_fixed_26_6(f) (int(f * 64))
diff --git a/src/gui/painting/qpagedpaintdevice.h b/src/gui/painting/qpagedpaintdevice.h
index b2b53d8038..d44a401184 100644
--- a/src/gui/painting/qpagedpaintdevice.h
+++ b/src/gui/painting/qpagedpaintdevice.h
@@ -44,8 +44,6 @@
#include <QtGui/qpaintdevice.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
#if defined(B0)
@@ -90,6 +88,4 @@ protected:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp
index 1a5a19a366..43bf1fd4ee 100644
--- a/src/gui/painting/qpaintbuffer.cpp
+++ b/src/gui/painting/qpaintbuffer.cpp
@@ -1752,7 +1752,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
QRawFont rawFont;
QRawFontPrivate *rawFontD = QRawFontPrivate::get(rawFont);
QFontPrivate *fontD = QFontPrivate::get(font);
- rawFontD->fontEngine = fontD->engineForScript(QUnicodeTables::Common);
+ rawFontD->fontEngine = fontD->engineForScript(QChar::Script_Common);
rawFontD->fontEngine->ref.ref();
QGlyphRun glyphs;
diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h
index 1a638ffeba..1529b701cf 100644
--- a/src/gui/painting/qpaintdevice.h
+++ b/src/gui/painting/qpaintdevice.h
@@ -45,8 +45,6 @@
#include <QtGui/qwindowdefs.h>
#include <QtCore/qrect.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -120,6 +118,4 @@ inline bool QPaintDevice::paintingActive() const
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPAINTDEVICE_H
diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h
index 85f4d2159e..b3e3762cc8 100644
--- a/src/gui/painting/qpaintengine.h
+++ b/src/gui/painting/qpaintengine.h
@@ -47,8 +47,6 @@
#include <QtCore/qscopedpointer.h>
#include <QtGui/qpainter.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -348,6 +346,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QPaintEngine::DirtyFlags)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPAINTENGINE_H
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index aaa0a4b87e..801a5689c1 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -2858,7 +2858,19 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
// x, y,
// positions[i].x.toInt(), positions[i].y.toInt());
- alphaPenBlt(bits + ((c.x << leftShift) >> rightShift) + c.y * bpl, bpl, depth, x, y, c.w, c.h);
+ const uchar *glyphBits = bits + ((c.x << leftShift) >> rightShift) + c.y * bpl;
+
+ if (glyphType == QFontEngineGlyphCache::Raster_ARGB) {
+ // The current state transform has already been applied to the positions,
+ // so we prevent drawImage() from re-applying the transform by clearing
+ // the state for the duration of the call.
+ QTransform originalTransform = s->matrix;
+ s->matrix = QTransform();
+ drawImage(QPoint(x, y), QImage(glyphBits, c.w, c.h, bpl, image.format()));
+ s->matrix = originalTransform;
+ } else {
+ alphaPenBlt(glyphBits, bpl, depth, x, y, c.w, c.h);
+ }
}
}
return true;
@@ -3011,13 +3023,15 @@ void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
ensurePen();
ensureRasterState();
+ QTransform matrix = state()->matrix;
+
QFontEngine *fontEngine = textItem->fontEngine();
- if (!supportsTransformations(fontEngine)) {
+ if (shouldDrawCachedGlyphs(fontEngine, matrix)) {
drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions,
fontEngine);
- } else if (state()->matrix.type() < QTransform::TxProject) {
+ } else if (matrix.type() < QTransform::TxProject) {
bool invertible;
- QTransform invMat = state()->matrix.inverted(&invertible);
+ QTransform invMat = matrix.inverted(&invertible);
if (!invertible)
return;
@@ -3056,7 +3070,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
QRasterPaintEngineState *s = state();
QTransform matrix = s->matrix;
- if (!supportsTransformations(ti.fontEngine)) {
+ if (shouldDrawCachedGlyphs(ti.fontEngine, matrix)) {
QVarLengthArray<QFixedPoint> positions;
QVarLengthArray<glyph_t> glyphs;
@@ -3300,21 +3314,25 @@ void QRasterPaintEngine::releaseDC(HDC) const
/*!
\internal
*/
-bool QRasterPaintEngine::supportsTransformations(QFontEngine *fontEngine) const
+bool QRasterPaintEngine::requiresPretransformedGlyphPositions(QFontEngine *fontEngine, const QTransform &m) const
{
- const QTransform &m = state()->matrix;
- return supportsTransformations(fontEngine, m);
+ // Cached glyphs always require pretransformed positions
+ if (shouldDrawCachedGlyphs(fontEngine, m))
+ return true;
+
+ // Otherwise let the base-class decide based on the transform
+ return QPaintEngineEx::requiresPretransformedGlyphPositions(fontEngine, m);
}
-/*!
- \internal
-*/
-bool QRasterPaintEngine::supportsTransformations(QFontEngine *fontEngine, const QTransform &m) const
+bool QRasterPaintEngine::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const
{
- if (fontEngine->supportsTransformations(m))
- return true;
+ // The font engine might not support filling the glyph cache
+ // with the given transform applied, in which case we need to
+ // fall back to the QPainterPath code-path.
+ if (!fontEngine->supportsTransformation(m))
+ return false;
- return !shouldDrawCachedGlyphs(fontEngine, m);
+ return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, m);
}
/*!
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index e90cad6d8a..e5bb0406ae 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -231,8 +231,8 @@ public:
QPoint coordinateOffset() const;
- bool supportsTransformations(QFontEngine *fontEngine) const;
- bool supportsTransformations(QFontEngine *fontEngine, const QTransform &m) const;
+ bool requiresPretransformedGlyphPositions(QFontEngine *fontEngine, const QTransform &m) const;
+ bool shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const;
protected:
QRasterPaintEngine(QRasterPaintEnginePrivate &d, QPaintDevice *);
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 83b684da1e..6e72b5db7f 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -1081,18 +1081,16 @@ void QPaintEngineEx::drawStaticTextItem(QStaticTextItem *staticTextItem)
}
}
-bool QPaintEngineEx::supportsTransformations(QFontEngine *fontEngine, const QTransform &m) const
+bool QPaintEngineEx::requiresPretransformedGlyphPositions(QFontEngine *, const QTransform &t) const
{
- Q_UNUSED(fontEngine);
-
- if (!m.isAffine())
- return true;
-
- return false;
+ return t.type() >= QTransform::TxProject;
}
bool QPaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const
{
+ if (fontEngine->glyphFormat == QFontEngineGlyphCache::Raster_ARGB)
+ return true;
+
qreal pixelSize = fontEngine->fontDef.pixelSize;
return (pixelSize * pixelSize * qAbs(m.determinant())) <
QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE;
diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h
index 399a6f63b0..5a9df72c76 100644
--- a/src/gui/painting/qpaintengineex_p.h
+++ b/src/gui/painting/qpaintengineex_p.h
@@ -61,8 +61,6 @@
#include <private/qvectorpath_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -164,7 +162,7 @@ public:
IsEmulationEngine = 0x02 // If set, this object is a QEmulationEngine.
};
virtual uint flags() const {return 0;}
- virtual bool supportsTransformations(QFontEngine *fontEngine, const QTransform &m) const;
+ virtual bool requiresPretransformedGlyphPositions(QFontEngine *fontEngine, const QTransform &m) const;
virtual bool shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const;
protected:
@@ -192,6 +190,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 786136d203..c483e93a5f 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -1155,9 +1155,6 @@ void QPainterPrivate::updateState(QPainterState *newState)
should antialias text if possible, and the \l
{RenderHint}{QPainter::SmoothPixmapTransform} indicates that the
engine should use a smooth pixmap transformation algorithm.
- \l {RenderHint}{HighQualityAntialiasing} is an OpenGL-specific rendering hint
- indicating that the engine should use fragment programs and offscreen
- rendering for antialiasing.
The renderHints() function returns a flag that specifies the
rendering hints that are set for this painter. Use the
@@ -1409,9 +1406,8 @@ void QPainterPrivate::updateState(QPainterState *newState)
a smooth pixmap transformation algorithm (such as bilinear) rather
than nearest neighbor.
- \value HighQualityAntialiasing An OpenGL-specific rendering hint
- indicating that the engine should use fragment programs and offscreen
- rendering for antialiasing.
+ \value HighQualityAntialiasing This value is obsolete and will be ignored,
+ use the Antialiasing render hint instead.
\value NonCosmeticDefaultPen This value is obsolete, the default for QPen
is now non-cosmetic.
@@ -5552,13 +5548,13 @@ void QPainter::drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun)
QVarLengthArray<QFixedPoint, 128> fixedPointPositions(count);
QRawFontPrivate *fontD = QRawFontPrivate::get(font);
- bool supportsTransformations = d->extended
- ? d->extended->supportsTransformations(fontD->fontEngine, d->state->matrix)
- : d->engine->type() == QPaintEngine::CoreGraphics || d->state->matrix.isAffine();
+ bool engineRequiresPretransformedGlyphPositions = d->extended
+ ? d->extended->requiresPretransformedGlyphPositions(fontD->fontEngine, d->state->matrix)
+ : d->engine->type() != QPaintEngine::CoreGraphics && !d->state->matrix.isAffine();
for (int i=0; i<count; ++i) {
QPointF processedPosition = position + glyphPositions[i];
- if (!supportsTransformations)
+ if (engineRequiresPretransformedGlyphPositions)
processedPosition = d->state->transform().map(processedPosition);
fixedPointPositions[i] = QFixedPoint::fromPointF(processedPosition);
}
@@ -5738,17 +5734,21 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText
return;
}
- QFontEngine *fe = staticText_d->font.d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *fe = staticText_d->font.d->engineForScript(QChar::Script_Common);
if (fe->type() == QFontEngine::Multi)
fe = static_cast<QFontEngineMulti *>(fe)->engine(0);
- bool supportsTransformations = d->extended->supportsTransformations(fe,
- d->state->matrix);
- if (supportsTransformations && !staticText_d->untransformedCoordinates) {
- staticText_d->untransformedCoordinates = true;
- staticText_d->needsRelayout = true;
- } else if (!supportsTransformations && staticText_d->untransformedCoordinates) {
+
+ bool engineRequiresPretransform = d->extended->requiresPretransformedGlyphPositions(fe, d->state->matrix);
+ if (staticText_d->untransformedCoordinates && engineRequiresPretransform) {
+ // The coordinates are untransformed, and the engine can't deal with that
+ // nativly, so we have to pre-transform the static text.
staticText_d->untransformedCoordinates = false;
staticText_d->needsRelayout = true;
+ } else if (!staticText_d->untransformedCoordinates && !engineRequiresPretransform) {
+ // The coordinates are already transformed, but the engine can handle that
+ // nativly, so undo the transform of the static text.
+ staticText_d->untransformedCoordinates = true;
+ staticText_d->needsRelayout = true;
}
// Don't recalculate entire layout because of translation, rather add the dx and dy
@@ -5845,7 +5845,7 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif
int len = str.length();
int numGlyphs = len;
QVarLengthGlyphLayoutArray glyphs(len);
- QFontEngine *fontEngine = d->state->font.d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *fontEngine = d->state->font.d->engineForScript(QChar::Script_Common);
if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0)) {
glyphs.resize(numGlyphs);
if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0))
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index 9f390b9865..874b244bd6 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -60,8 +60,6 @@
#include <QtGui/qfontmetrics.h>
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -932,6 +930,4 @@ inline void QPainter::drawPicture(const QPoint &pt, const QPicture &p)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPAINTER_H
diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h
index 7c3365875e..e22c1729f3 100644
--- a/src/gui/painting/qpainterpath.h
+++ b/src/gui/painting/qpainterpath.h
@@ -49,8 +49,6 @@
#include <QtCore/qvector.h>
#include <QtCore/qscopedpointer.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -375,6 +373,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QPainterPath &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPAINTERPATH_H
diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h
index 4ab2b9d88a..45cce640c5 100644
--- a/src/gui/painting/qpathclipper_p.h
+++ b/src/gui/painting/qpathclipper_p.h
@@ -60,8 +60,6 @@
#include <private/qdatabuffer_p.h>
#include <stdio.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -488,6 +486,4 @@ inline QPathEdge::Direction QWingedEdge::flip(QPathEdge::Direction direction)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPATHCLIPPER_P_H
diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h
index 792aeefad1..45bb5ad4b4 100644
--- a/src/gui/painting/qpdfwriter.h
+++ b/src/gui/painting/qpdfwriter.h
@@ -45,8 +45,6 @@
#include <QtCore/qobject.h>
#include <QtGui/qpagedpaintdevice.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -85,6 +83,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h
index 3e5e258123..c5144f784f 100644
--- a/src/gui/painting/qpen.h
+++ b/src/gui/painting/qpen.h
@@ -45,8 +45,6 @@
#include <QtGui/qcolor.h>
#include <QtGui/qbrush.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -139,6 +137,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QPen &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPEN_H
diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h
index 0429ec7e89..1b19b2c379 100644
--- a/src/gui/painting/qplatformbackingstore.h
+++ b/src/gui/painting/qplatformbackingstore.h
@@ -56,8 +56,6 @@
#include <QtGui/qwindow.h>
#include <QtGui/qregion.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -95,6 +93,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMBACKINGSTORE_H
diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h
index 32de4ddd65..1039e842ab 100644
--- a/src/gui/painting/qpolygon.h
+++ b/src/gui/painting/qpolygon.h
@@ -46,8 +46,6 @@
#include <QtCore/qpoint.h>
#include <QtCore/qrect.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -185,6 +183,4 @@ inline QPolygonF QPolygonF::translated(qreal dx, qreal dy) const
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPOLYGON_H
diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h
index dee996c523..0e436e3fb4 100644
--- a/src/gui/painting/qregion.h
+++ b/src/gui/painting/qregion.h
@@ -50,8 +50,6 @@
#include <QtCore/qdatastream.h>
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -173,6 +171,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QRegion &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QREGION_H
diff --git a/src/gui/painting/qrgb.h b/src/gui/painting/qrgb.h
index 06c479e5cd..d7a01840e8 100644
--- a/src/gui/painting/qrgb.h
+++ b/src/gui/painting/qrgb.h
@@ -44,14 +44,13 @@
#include <QtCore/qglobal.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
typedef unsigned int QRgb; // RGB triplet
-const QRgb RGB_MASK = 0x00ffffff; // masks RGB values
+// non-namespaced Qt global variable
+const Q_DECL_UNUSED QRgb RGB_MASK = 0x00ffffff; // masks RGB values
inline int qRed(QRgb rgb) // get red part of RGB
{ return ((rgb >> 16) & 0xff); }
@@ -82,6 +81,4 @@ inline bool qIsGray(QRgb rgb)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QRGB_H
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index 2ffdc9cd59..8769aeaba9 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -129,6 +129,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
switch (m_type) {
case Raster_A8: format = QFontEngine::Format_A8; break;
case Raster_RGBMask: format = QFontEngine::Format_A32; break;
+ case Raster_ARGB: format = QFontEngine::Format_ARGB; break;
default: format = QFontEngine::Format_Mono; break;
}
@@ -275,6 +276,8 @@ QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g, QFixed subPixelPosition
{
if (m_type == QFontEngineGlyphCache::Raster_RGBMask)
return m_current_fontengine->alphaRGBMapForGlyph(g, subPixelPosition, m_transform);
+ else if (m_type == QFontEngineGlyphCache::Raster_ARGB)
+ return m_current_fontengine->bitmapForGlyph(g, subPixelPosition, m_transform);
return m_current_fontengine->alphaMapForGlyph(g, subPixelPosition, m_transform);
}
@@ -306,6 +309,7 @@ void QImageTextureGlyphCache::createTextureData(int width, int height)
m_image = QImage(width, height, QImage::Format_RGB32);
break;
case QFontEngineGlyphCache::Raster_ARGB:
+ m_image = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
break;
}
}
@@ -322,7 +326,8 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP
}
#endif
- if (m_type == QFontEngineGlyphCache::Raster_RGBMask) {
+ if (m_type == QFontEngineGlyphCache::Raster_RGBMask
+ || m_type == QFontEngineGlyphCache::Raster_ARGB) {
QImage ref(m_image.bits() + (c.x * 4 + c.y * m_image.bytesPerLine()),
qMax(mask.width(), c.w), qMax(mask.height(), c.h), m_image.bytesPerLine(),
m_image.format());
diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h
index d0fe7ab8cb..d93f57ad80 100644
--- a/src/gui/painting/qtextureglyphcache_p.h
+++ b/src/gui/painting/qtextureglyphcache_p.h
@@ -60,10 +60,6 @@
#include <private/qfontengineglyphcache_p.h>
-#if defined(Q_OS_VXWORKS) && defined(m_type)
-# undef m_type
-#endif
-
#ifndef QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH
#define QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH 256
#endif
diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h
index f98642cd98..060362f63e 100644
--- a/src/gui/painting/qtransform.h
+++ b/src/gui/painting/qtransform.h
@@ -50,12 +50,6 @@
#include <QtCore/qpoint.h>
#include <QtCore/qrect.h>
-#if defined(Q_OS_VXWORKS) && defined(m_type)
-# undef m_type
-#endif
-
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -389,6 +383,4 @@ inline QTransform operator -(const QTransform &a, qreal n)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTRANSFORM_H
diff --git a/src/gui/painting/qvectorpath_p.h b/src/gui/painting/qvectorpath_p.h
index f8ba02dc79..e97d6e1dce 100644
--- a/src/gui/painting/qvectorpath_p.h
+++ b/src/gui/painting/qvectorpath_p.h
@@ -60,8 +60,6 @@
#include <private/qpainter_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -187,6 +185,4 @@ Q_GUI_EXPORT const QVectorPath &qtVectorPathForPath(const QPainterPath &path);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h
index 4979c3b03b..95733f5da7 100644
--- a/src/gui/text/qabstracttextdocumentlayout.h
+++ b/src/gui/text/qabstracttextdocumentlayout.h
@@ -48,8 +48,6 @@
#include <QtGui/qtextcursor.h>
#include <QtGui/qpalette.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -144,6 +142,4 @@ Q_DECLARE_INTERFACE(QTextObjectInterface, "org.qt-project.Qt.QTextObjectInterfac
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QABSTRACTTEXTDOCUMENTLAYOUT_H
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 2961cb9493..279d165322 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -55,7 +55,6 @@
#include "qthread.h"
#include "qthreadstorage.h"
-#include <private/qunicodetables_p.h>
#include "qfont_p.h"
#include <private/qfontengine_p.h>
#include <private/qpainter_p.h>
@@ -207,8 +206,8 @@ extern QMutex *qt_fontdatabase_mutex();
QFontEngine *QFontPrivate::engineForScript(int script) const
{
QMutexLocker locker(qt_fontdatabase_mutex());
- if (script >= QUnicodeTables::Inherited)
- script = QUnicodeTables::Common;
+ if (script <= QChar::Script_Latin)
+ script = QChar::Script_Common;
if (engineData && engineData->fontCache != QFontCache::instance()) {
// throw out engineData that came from a different thread
engineData->ref.deref();
@@ -319,12 +318,12 @@ void QFontPrivate::resolve(uint mask, const QFontPrivate *other)
QFontEngineData::QFontEngineData()
: ref(1), fontCache(QFontCache::instance())
{
- memset(engines, 0, QUnicodeTables::ScriptCount * sizeof(QFontEngine *));
+ memset(engines, 0, QChar::ScriptCount * sizeof(QFontEngine *));
}
QFontEngineData::~QFontEngineData()
{
- for (int i = 0; i < QUnicodeTables::ScriptCount; ++i) {
+ for (int i = 0; i < QChar::ScriptCount; ++i) {
if (engines[i])
engines[i]->ref.deref();
engines[i] = 0;
@@ -1667,7 +1666,7 @@ void QFont::setRawMode(bool enable)
*/
bool QFont::exactMatch() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return (d->rawMode
? engine->type() != QFontEngine::Box
@@ -2363,7 +2362,7 @@ QFontInfo &QFontInfo::operator=(const QFontInfo &fi)
*/
QString QFontInfo::family() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->fontDef.family;
}
@@ -2378,7 +2377,7 @@ QString QFontInfo::family() const
*/
QString QFontInfo::styleName() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->fontDef.styleName;
}
@@ -2390,7 +2389,7 @@ QString QFontInfo::styleName() const
*/
int QFontInfo::pointSize() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->fontDef.pointSize);
}
@@ -2402,7 +2401,7 @@ int QFontInfo::pointSize() const
*/
qreal QFontInfo::pointSizeF() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->fontDef.pointSize;
}
@@ -2414,7 +2413,7 @@ qreal QFontInfo::pointSizeF() const
*/
int QFontInfo::pixelSize() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->fontDef.pixelSize;
}
@@ -2426,7 +2425,7 @@ int QFontInfo::pixelSize() const
*/
bool QFontInfo::italic() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->fontDef.style != QFont::StyleNormal;
}
@@ -2438,7 +2437,7 @@ bool QFontInfo::italic() const
*/
QFont::Style QFontInfo::style() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return (QFont::Style)engine->fontDef.style;
}
@@ -2450,7 +2449,7 @@ QFont::Style QFontInfo::style() const
*/
int QFontInfo::weight() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->fontDef.weight;
@@ -2515,7 +2514,7 @@ bool QFontInfo::strikeOut() const
*/
bool QFontInfo::fixedPitch() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
#ifdef Q_OS_MAC
if (!engine->fontDef.fixedPitchComputed) {
@@ -2539,7 +2538,7 @@ bool QFontInfo::fixedPitch() const
*/
QFont::StyleHint QFontInfo::styleHint() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return (QFont::StyleHint) engine->fontDef.styleHint;
}
@@ -2567,7 +2566,7 @@ bool QFontInfo::rawMode() const
*/
bool QFontInfo::exactMatch() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return (d->rawMode
? engine->type() != QFontEngine::Box
@@ -2675,7 +2674,7 @@ void QFontCache::clear()
end = engineDataCache.end();
while (it != end) {
QFontEngineData *data = it.value();
- for (int i = 0; i < QUnicodeTables::ScriptCount; ++i) {
+ for (int i = 0; i < QChar::ScriptCount; ++i) {
if (data->engines[i]) {
data->engines[i]->ref.deref();
data->engines[i] = 0;
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index c59b222ccc..24a1c4c7c3 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -47,8 +47,6 @@
#include <QtCore/qsharedpointer.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -350,6 +348,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QFont &);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QFONT_H
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index b5e753e246..a35896e763 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -57,7 +57,6 @@
#include "QtCore/qmap.h"
#include "QtCore/qobject.h"
#include "QtCore/qstringlist.h"
-#include <private/qunicodetables_p.h>
#include <QtGui/qfontdatabase.h>
#include "private/qfixed_p.h"
@@ -143,7 +142,7 @@ public:
QAtomicInt ref;
QFontCache *fontCache;
- QFontEngine *engines[QUnicodeTables::ScriptCount];
+ QFontEngine *engines[QChar::ScriptCount];
};
diff --git a/src/gui/text/qfont_qpa.cpp b/src/gui/text/qfont_qpa.cpp
index a955f5446d..be432dc52f 100644
--- a/src/gui/text/qfont_qpa.cpp
+++ b/src/gui/text/qfont_qpa.cpp
@@ -72,7 +72,7 @@ QString QFont::defaultFamily() const
{
QPlatformFontDatabase *fontDB = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
const QStringList fallbacks = fontDB->fallbacksForFamily(QString(), QFont::StyleNormal
- , QFont::StyleHint(d->request.styleHint), QUnicodeTables::Common);
+ , QFont::StyleHint(d->request.styleHint), QChar::Script_Common);
if (!fallbacks.isEmpty())
return fallbacks.first();
return QString();
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 5b728403cb..f937e7a820 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -48,7 +48,6 @@
#include "qmutex.h"
#include "qfile.h"
#include "qfileinfo.h"
-#include "private/qunicodetables_p.h"
#include "qfontengine_p.h"
#include <qpa/qplatformintegration.h>
@@ -601,48 +600,48 @@ QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create)
static const int scriptForWritingSystem[] = {
- QUnicodeTables::Common, // Any
- QUnicodeTables::Latin, // Latin
- QUnicodeTables::Greek, // Greek
- QUnicodeTables::Cyrillic, // Cyrillic
- QUnicodeTables::Armenian, // Armenian
- QUnicodeTables::Hebrew, // Hebrew
- QUnicodeTables::Arabic, // Arabic
- QUnicodeTables::Syriac, // Syriac
- QUnicodeTables::Thaana, // Thaana
- QUnicodeTables::Devanagari, // Devanagari
- QUnicodeTables::Bengali, // Bengali
- QUnicodeTables::Gurmukhi, // Gurmukhi
- QUnicodeTables::Gujarati, // Gujarati
- QUnicodeTables::Oriya, // Oriya
- QUnicodeTables::Tamil, // Tamil
- QUnicodeTables::Telugu, // Telugu
- QUnicodeTables::Kannada, // Kannada
- QUnicodeTables::Malayalam, // Malayalam
- QUnicodeTables::Sinhala, // Sinhala
- QUnicodeTables::Thai, // Thai
- QUnicodeTables::Lao, // Lao
- QUnicodeTables::Tibetan, // Tibetan
- QUnicodeTables::Myanmar, // Myanmar
- QUnicodeTables::Georgian, // Georgian
- QUnicodeTables::Khmer, // Khmer
- QUnicodeTables::Common, // SimplifiedChinese
- QUnicodeTables::Common, // TraditionalChinese
- QUnicodeTables::Common, // Japanese
- QUnicodeTables::Hangul, // Korean
- QUnicodeTables::Common, // Vietnamese
- QUnicodeTables::Common, // Yi
- QUnicodeTables::Common, // Tagalog
- QUnicodeTables::Common, // Hanunoo
- QUnicodeTables::Common, // Buhid
- QUnicodeTables::Common, // Tagbanwa
- QUnicodeTables::Common, // Limbu
- QUnicodeTables::Common, // TaiLe
- QUnicodeTables::Common, // Braille
- QUnicodeTables::Common, // Symbol
- QUnicodeTables::Ogham, // Ogham
- QUnicodeTables::Runic, // Runic
- QUnicodeTables::Nko // Nko
+ QChar::Script_Common, // Any
+ QChar::Script_Latin, // Latin
+ QChar::Script_Greek, // Greek
+ QChar::Script_Cyrillic, // Cyrillic
+ QChar::Script_Armenian, // Armenian
+ QChar::Script_Hebrew, // Hebrew
+ QChar::Script_Arabic, // Arabic
+ QChar::Script_Syriac, // Syriac
+ QChar::Script_Thaana, // Thaana
+ QChar::Script_Devanagari, // Devanagari
+ QChar::Script_Bengali, // Bengali
+ QChar::Script_Gurmukhi, // Gurmukhi
+ QChar::Script_Gujarati, // Gujarati
+ QChar::Script_Oriya, // Oriya
+ QChar::Script_Tamil, // Tamil
+ QChar::Script_Telugu, // Telugu
+ QChar::Script_Kannada, // Kannada
+ QChar::Script_Malayalam, // Malayalam
+ QChar::Script_Sinhala, // Sinhala
+ QChar::Script_Thai, // Thai
+ QChar::Script_Lao, // Lao
+ QChar::Script_Tibetan, // Tibetan
+ QChar::Script_Myanmar, // Myanmar
+ QChar::Script_Georgian, // Georgian
+ QChar::Script_Khmer, // Khmer
+ QChar::Script_Han, // SimplifiedChinese
+ QChar::Script_Han, // TraditionalChinese
+ QChar::Script_Han, // Japanese
+ QChar::Script_Hangul, // Korean
+ QChar::Script_Latin, // Vietnamese
+ QChar::Script_Yi, // Yi
+ QChar::Script_Tagalog, // Tagalog
+ QChar::Script_Hanunoo, // Hanunoo
+ QChar::Script_Buhid, // Buhid
+ QChar::Script_Tagbanwa, // Tagbanwa
+ QChar::Script_Limbu, // Limbu
+ QChar::Script_TaiLe, // TaiLe
+ QChar::Script_Braille, // Braille
+ QChar::Script_Common, // Symbol
+ QChar::Script_Ogham, // Ogham
+ QChar::Script_Runic, // Runic
+ QChar::Script_Nko // Nko
};
int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem)
@@ -1059,7 +1058,7 @@ static void match(int script, const QFontDef &request,
uint score_adjust = 0;
- bool supported = (script == QUnicodeTables::Common);
+ bool supported = (script == QChar::Script_Common);
for (int ws = 1; !supported && ws < QFontDatabase::WritingSystemsCount; ++ws) {
if (scriptForWritingSystem[ws] != script)
continue;
diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h
index 373ff5e950..05f1a85f24 100644
--- a/src/gui/text/qfontdatabase.h
+++ b/src/gui/text/qfontdatabase.h
@@ -46,8 +46,6 @@
#include <QtCore/qstring.h>
#include <QtGui/qfont.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -166,6 +164,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QFONTDATABASE_H
diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp
index a72b21ede3..0d38c6a290 100644
--- a/src/gui/text/qfontdatabase_qpa.cpp
+++ b/src/gui/text/qfontdatabase_qpa.cpp
@@ -104,7 +104,7 @@ Q_GUI_EXPORT void qt_registerAliasToFontFamily(const QString &familyName, const
f->aliases.push_back(alias);
}
-static QStringList fallbackFamilies(const QString &family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script)
+static QStringList fallbackFamilies(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script)
{
QStringList retList = QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(family,style,styleHint,script);
QFontDatabasePrivate *db = privateDb();
@@ -175,7 +175,7 @@ QFontEngine *loadSingleEngine(int script,
QFontCache::Key key(def,script);
QFontEngine *engine = QFontCache::instance()->findEngine(key);
if (!engine) {
- engine = pfdb->fontEngine(def,QUnicodeTables::Script(script),size->handle);
+ engine = pfdb->fontEngine(def, QChar::Script(script), size->handle);
if (engine) {
QFontCache::Key key(def,script);
QFontCache::instance()->instance()->insertEngine(key,engine);
@@ -200,7 +200,7 @@ QFontEngine *loadEngine(int script, const QFontDef &request,
QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint);
if (styleHint == QFont::AnyStyle && request.fixedPitch)
styleHint = QFont::TypeWriter;
- family->fallbackFamilies = fallbackFamilies(family->name,fontStyle,styleHint,QUnicodeTables::Script(script));
+ family->fallbackFamilies = fallbackFamilies(family->name, fontStyle, styleHint, QChar::Script(script));
family->askedForFallback = true;
}
@@ -210,7 +210,7 @@ QFontEngine *loadEngine(int script, const QFontDef &request,
fallbacks = family->fallbackFamilies;
QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
- QFontEngineMulti *pfMultiEngine = pfdb->fontEngineMulti(engine, QUnicodeTables::Script(script));
+ QFontEngineMulti *pfMultiEngine = pfdb->fontEngineMulti(engine, QChar::Script(script));
pfMultiEngine->setFallbackFamiliesList(fallbacks);
engine = pfMultiEngine;
@@ -322,7 +322,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
+ fallbackFamilies(request.family,
QFont::Style(request.style),
QFont::StyleHint(request.styleHint),
- QUnicodeTables::Script(script));
+ QChar::Script(script));
for (int i = 0; !engine && i < fallbacks.size(); i++) {
QFontDef def = request;
@@ -427,7 +427,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
}
if (fe->symbol || (d->request.styleStrategy & QFont::NoFontMerging)) {
- for (int i = 0; i < QUnicodeTables::ScriptCount; ++i) {
+ for (int i = 0; i < QChar::ScriptCount; ++i) {
if (!d->engineData->engines[i]) {
d->engineData->engines[i] = fe;
fe->ref.ref();
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 87fa202fb4..1a7f2b7b4d 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -268,9 +268,9 @@ QFixed QFontEngine::averageCharWidth() const
return bb.xoff;
}
-bool QFontEngine::supportsTransformations(const QTransform &transform) const
+bool QFontEngine::supportsTransformation(const QTransform &transform) const
{
- return (transform.type() >= QTransform::TxProject);
+ return transform.type() < QTransform::TxProject;
}
void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags,
@@ -649,6 +649,13 @@ QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed /*subPixelPosition
return rgbMask;
}
+QImage QFontEngine::bitmapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform&)
+{
+ Q_UNUSED(subPixelPosition);
+
+ return QImage();
+}
+
QFixed QFontEngine::subPixelPositionForX(QFixed x) const
{
if (m_subPixelPositionCount <= 1 || !supportsSubPixelPositions())
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 07e4cae1ee..bedd5753c7 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1570,12 +1570,15 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlag
glyphs->advances_x[i] = design ? QFixed::fromFixed(face->glyph->linearHoriAdvance >> 10)
: QFixed::fromFixed(face->glyph->metrics.horiAdvance).round();
}
- if (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
- glyphs->advances_x[i] = glyphs->advances_x[i].round();
glyphs->advances_y[i] = 0;
}
if (face)
unlockFace();
+
+ if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
+ for (int i = 0; i < glyphs->numGlyphs; ++i)
+ glyphs->advances_x[i] = glyphs->advances_x[i].round();
+ }
}
glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs)
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index c2d22d9e83..a373c3d5f1 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -112,7 +112,8 @@ public:
Format_Render = Format_None,
Format_Mono,
Format_A8,
- Format_A32
+ Format_A32,
+ Format_ARGB
};
enum ShaperFlag {
@@ -191,6 +192,7 @@ public:
virtual QImage alphaMapForGlyph(glyph_t, const QTransform &t);
virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
+ virtual QImage bitmapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
virtual QImage *lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition,
GlyphFormat neededFormat,
const QTransform &t = QTransform(),
@@ -241,7 +243,7 @@ public:
return canRender(utf16, utf16len);
}
- virtual bool supportsTransformations(const QTransform &transform) const;
+ virtual bool supportsTransformation(const QTransform &transform) const;
virtual Type type() const = 0;
diff --git a/src/gui/text/qfontengine_qpa.cpp b/src/gui/text/qfontengine_qpa.cpp
index 4a61b27298..837850e4be 100644
--- a/src/gui/text/qfontengine_qpa.cpp
+++ b/src/gui/text/qfontengine_qpa.cpp
@@ -710,7 +710,7 @@ void QFontEngineMultiQPA::ensureFallbackFamiliesQueried()
if (fallbacksQueried)
return;
QStringList fallbacks = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fallbacksForFamily(engine(0)->fontDef.family, QFont::Style(engine(0)->fontDef.style)
- , QFont::AnyStyle, QUnicodeTables::Script(script));
+ , QFont::AnyStyle, QChar::Script(script));
setFallbackFamiliesList(fallbacks);
}
@@ -762,7 +762,7 @@ QFontEngine* QFontEngineMultiQPA::createMultiFontEngine(QFontEngine *fe, int scr
it++;
}
if (!engine) {
- engine = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fontEngineMulti(fe, QUnicodeTables::Script(script));
+ engine = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fontEngineMulti(fe, QChar::Script(script));
QFontCache::instance()->insertEngine(key, engine, /* insertMulti */ !faceIsLocal);
}
Q_ASSERT(engine);
diff --git a/src/gui/text/qfontengine_qpa_p.h b/src/gui/text/qfontengine_qpa_p.h
index 161b11e2d5..5fbdafdf56 100644
--- a/src/gui/text/qfontengine_qpa_p.h
+++ b/src/gui/text/qfontengine_qpa_p.h
@@ -61,8 +61,6 @@
#include <QtCore/QFile>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QFontEngine;
@@ -268,6 +266,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QFONTENGINE_QPA_P_H
diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp
index df80e9e87d..2959ae666d 100644
--- a/src/gui/text/qfontengine_qpf.cpp
+++ b/src/gui/text/qfontengine_qpf.cpp
@@ -666,9 +666,7 @@ void QFontEngineQPF::draw(QPaintEngine *p, qreal _x, qreal _y, const QTextItemIn
void QFontEngineQPF::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags)
{
- if (renderingFontEngine &&
- (renderingFontEngine->type() != QFontEngine::Proxy
- || static_cast<QProxyFontEngine *>(renderingFontEngine)->capabilities() & QAbstractFontEngine::CanOutlineGlyphs)) {
+ if (renderingFontEngine && renderingFontEngine->type() != QFontEngine::Proxy) {
renderingFontEngine->addOutlineToPath(x, y, glyphs, path, flags);
return;
}
diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h
index 1dc4db00c4..ac01c78399 100644
--- a/src/gui/text/qfontengineglyphcache_p.h
+++ b/src/gui/text/qfontengineglyphcache_p.h
@@ -78,6 +78,7 @@ public:
virtual ~QFontEngineGlyphCache() { }
Type cacheType() const { return m_type; }
+ const QTransform &transform() const { return m_transform; }
QTransform m_transform;
QFontEngineGlyphCache::Type m_type;
diff --git a/src/gui/text/qfontinfo.h b/src/gui/text/qfontinfo.h
index c9cc42ead5..efa8f6ef61 100644
--- a/src/gui/text/qfontinfo.h
+++ b/src/gui/text/qfontinfo.h
@@ -45,8 +45,6 @@
#include <QtGui/qfont.h>
#include <QtCore/qsharedpointer.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -87,6 +85,4 @@ Q_DECLARE_SHARED(QFontInfo)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QFONTINFO_H
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index f3151da16b..d889fa97b5 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -45,7 +45,6 @@
#include "qfont_p.h"
#include "qfontengine_p.h"
-#include <private/qunicodetables_p.h>
#include <math.h>
@@ -262,7 +261,7 @@ bool QFontMetrics::operator ==(const QFontMetrics &other) const
*/
int QFontMetrics::ascent() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->ascent());
}
@@ -280,7 +279,7 @@ int QFontMetrics::ascent() const
*/
int QFontMetrics::descent() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->descent());
}
@@ -295,7 +294,7 @@ int QFontMetrics::descent() const
*/
int QFontMetrics::height() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->ascent()) + qRound(engine->descent());
}
@@ -309,7 +308,7 @@ int QFontMetrics::height() const
*/
int QFontMetrics::leading() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->leading());
}
@@ -323,7 +322,7 @@ int QFontMetrics::leading() const
*/
int QFontMetrics::lineSpacing() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent());
}
@@ -340,7 +339,7 @@ int QFontMetrics::lineSpacing() const
*/
int QFontMetrics::minLeftBearing() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->minLeftBearing());
}
@@ -357,7 +356,7 @@ int QFontMetrics::minLeftBearing() const
*/
int QFontMetrics::minRightBearing() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->minRightBearing());
}
@@ -367,7 +366,7 @@ int QFontMetrics::minRightBearing() const
*/
int QFontMetrics::maxWidth() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->maxCharWidth());
}
@@ -378,10 +377,10 @@ int QFontMetrics::maxWidth() const
*/
int QFontMetrics::xHeight() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
if (d->capital == QFont::SmallCaps)
- return qRound(d->smallCapsFontPrivate()->engineForScript(QUnicodeTables::Common)->ascent());
+ return qRound(d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent());
return qRound(engine->xHeight());
}
@@ -392,7 +391,7 @@ int QFontMetrics::xHeight() const
*/
int QFontMetrics::averageCharWidth() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->averageCharWidth());
}
@@ -403,7 +402,7 @@ int QFontMetrics::averageCharWidth() const
*/
bool QFontMetrics::inFont(QChar ch) const
{
- const int script = QUnicodeTables::script(ch);
+ const int script = ch.script();
QFontEngine *engine = d->engineForScript(script);
Q_ASSERT(engine != 0);
if (engine->type() == QFontEngine::Box)
@@ -417,7 +416,7 @@ bool QFontMetrics::inFont(QChar ch) const
*/
bool QFontMetrics::inFontUcs4(uint ucs4) const
{
- const int script = QUnicodeTables::script(ucs4);
+ const int script = QChar::script(ucs4);
QFontEngine *engine = d->engineForScript(script);
Q_ASSERT(engine != 0);
if (engine->type() == QFontEngine::Box)
@@ -439,7 +438,7 @@ bool QFontMetrics::inFontUcs4(uint ucs4) const
*/
int QFontMetrics::leftBearing(QChar ch) const
{
- const int script = QUnicodeTables::script(ch);
+ const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@@ -474,7 +473,7 @@ int QFontMetrics::leftBearing(QChar ch) const
*/
int QFontMetrics::rightBearing(QChar ch) const
{
- const int script = QUnicodeTables::script(ch);
+ const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@@ -530,7 +529,7 @@ int QFontMetrics::width(const QString &text, int len, int flags) const
// Skip harfbuzz complex shaping, only use advances
int numGlyphs = len;
QVarLengthGlyphLayoutArray glyphs(numGlyphs);
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
if (!engine->stringToCMap(text.data(), len, &glyphs, &numGlyphs, 0)) {
glyphs.resize(numGlyphs);
if (!engine->stringToCMap(text.data(), len, &glyphs, &numGlyphs, 0))
@@ -577,7 +576,7 @@ int QFontMetrics::width(QChar ch) const
if (QChar::category(ch.unicode()) == QChar::Mark_NonSpacing)
return 0;
- const int script = QUnicodeTables::script(ch);
+ const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@@ -607,14 +606,13 @@ int QFontMetrics::width(QChar ch) const
*/
int QFontMetrics::charWidth(const QString &text, int pos) const
{
+ int width = 0;
if (pos < 0 || pos > (int)text.length())
- return 0;
-
- QChar ch = text.unicode()[pos];
- const int script = QUnicodeTables::script(ch);
- int width;
+ return width;
- if (script != QUnicodeTables::Common) {
+ QChar ch = text.at(pos);
+ const int script = ch.script();
+ if (script != QChar::Script_Common) {
// complex script shaping. Have to do some hard work
int from = qMax(0, pos - 8);
int to = qMin(text.length(), pos + 8);
@@ -623,9 +621,7 @@ int QFontMetrics::charWidth(const QString &text, int pos) const
layout.ignoreBidi = true;
layout.itemize();
width = qRound(layout.width(pos-from, 1));
- } else if (QChar::category(ch.unicode()) == QChar::Mark_NonSpacing) {
- width = 0;
- } else {
+ } else if (ch.category() != QChar::Mark_NonSpacing) {
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@@ -694,7 +690,7 @@ QRect QFontMetrics::boundingRect(const QString &text) const
*/
QRect QFontMetrics::boundingRect(QChar ch) const
{
- const int script = QUnicodeTables::script(ch);
+ const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@@ -895,7 +891,7 @@ QString QFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, in
*/
int QFontMetrics::underlinePos() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->underlinePosition());
}
@@ -931,7 +927,7 @@ int QFontMetrics::strikeOutPos() const
*/
int QFontMetrics::lineWidth() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->lineThickness());
}
@@ -1129,7 +1125,7 @@ bool QFontMetricsF::operator ==(const QFontMetricsF &other) const
*/
qreal QFontMetricsF::ascent() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->ascent().toReal();
}
@@ -1148,7 +1144,7 @@ qreal QFontMetricsF::ascent() const
*/
qreal QFontMetricsF::descent() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->descent().toReal();
}
@@ -1163,7 +1159,7 @@ qreal QFontMetricsF::descent() const
*/
qreal QFontMetricsF::height() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return (engine->ascent() + engine->descent()).toReal();
@@ -1178,7 +1174,7 @@ qreal QFontMetricsF::height() const
*/
qreal QFontMetricsF::leading() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->leading().toReal();
}
@@ -1192,7 +1188,7 @@ qreal QFontMetricsF::leading() const
*/
qreal QFontMetricsF::lineSpacing() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return (engine->leading() + engine->ascent() + engine->descent()).toReal();
}
@@ -1209,7 +1205,7 @@ qreal QFontMetricsF::lineSpacing() const
*/
qreal QFontMetricsF::minLeftBearing() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->minLeftBearing();
}
@@ -1226,7 +1222,7 @@ qreal QFontMetricsF::minLeftBearing() const
*/
qreal QFontMetricsF::minRightBearing() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->minRightBearing();
}
@@ -1236,7 +1232,7 @@ qreal QFontMetricsF::minRightBearing() const
*/
qreal QFontMetricsF::maxWidth() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->maxCharWidth();
}
@@ -1247,10 +1243,10 @@ qreal QFontMetricsF::maxWidth() const
*/
qreal QFontMetricsF::xHeight() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
if (d->capital == QFont::SmallCaps)
- return d->smallCapsFontPrivate()->engineForScript(QUnicodeTables::Common)->ascent().toReal();
+ return d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent().toReal();
return engine->xHeight().toReal();
}
@@ -1261,7 +1257,7 @@ qreal QFontMetricsF::xHeight() const
*/
qreal QFontMetricsF::averageCharWidth() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->averageCharWidth().toReal();
}
@@ -1272,7 +1268,7 @@ qreal QFontMetricsF::averageCharWidth() const
*/
bool QFontMetricsF::inFont(QChar ch) const
{
- const int script = QUnicodeTables::script(ch);
+ const int script = ch.script();
QFontEngine *engine = d->engineForScript(script);
Q_ASSERT(engine != 0);
if (engine->type() == QFontEngine::Box)
@@ -1288,7 +1284,7 @@ bool QFontMetricsF::inFont(QChar ch) const
*/
bool QFontMetricsF::inFontUcs4(uint ucs4) const
{
- const int script = QUnicodeTables::script(ucs4);
+ const int script = QChar::script(ucs4);
QFontEngine *engine = d->engineForScript(script);
Q_ASSERT(engine != 0);
if (engine->type() == QFontEngine::Box)
@@ -1310,7 +1306,7 @@ bool QFontMetricsF::inFontUcs4(uint ucs4) const
*/
qreal QFontMetricsF::leftBearing(QChar ch) const
{
- const int script = QUnicodeTables::script(ch);
+ const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@@ -1345,7 +1341,7 @@ qreal QFontMetricsF::leftBearing(QChar ch) const
*/
qreal QFontMetricsF::rightBearing(QChar ch) const
{
- const int script = QUnicodeTables::script(ch);
+ const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@@ -1414,10 +1410,10 @@ qreal QFontMetricsF::width(const QString &text) const
*/
qreal QFontMetricsF::width(QChar ch) const
{
- if (QChar::category(ch.unicode()) == QChar::Mark_NonSpacing)
+ if (ch.category() == QChar::Mark_NonSpacing)
return 0.;
- const int script = QUnicodeTables::script(ch);
+ const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@@ -1482,7 +1478,7 @@ QRectF QFontMetricsF::boundingRect(const QString &text) const
*/
QRectF QFontMetricsF::boundingRect(QChar ch) const
{
- const int script = QUnicodeTables::script(ch);
+ const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@@ -1682,7 +1678,7 @@ QString QFontMetricsF::elidedText(const QString &text, Qt::TextElideMode mode, q
*/
qreal QFontMetricsF::underlinePos() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->underlinePosition().toReal();
}
@@ -1717,7 +1713,7 @@ qreal QFontMetricsF::strikeOutPos() const
*/
qreal QFontMetricsF::lineWidth() const
{
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->lineThickness().toReal();
}
diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h
index ab7437b6fb..00b38eb674 100644
--- a/src/gui/text/qfontmetrics.h
+++ b/src/gui/text/qfontmetrics.h
@@ -48,8 +48,6 @@
#include <QtCore/qrect.h>
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -191,6 +189,4 @@ Q_DECLARE_SHARED(QFontMetricsF)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QFONTMETRICS_H
diff --git a/src/gui/text/qglyphrun.h b/src/gui/text/qglyphrun.h
index 43743d8a99..435379085e 100644
--- a/src/gui/text/qglyphrun.h
+++ b/src/gui/text/qglyphrun.h
@@ -49,8 +49,6 @@
#if !defined(QT_NO_RAWFONT)
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -130,8 +128,6 @@ Q_DECLARE_SHARED(QGlyphRun)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_RAWFONT
#endif // QGLYPHRUN_H
diff --git a/src/gui/text/qglyphrun_p.h b/src/gui/text/qglyphrun_p.h
index c70aa91db1..2e209a3429 100644
--- a/src/gui/text/qglyphrun_p.h
+++ b/src/gui/text/qglyphrun_p.h
@@ -60,8 +60,6 @@
#if !defined(QT_NO_RAWFONT)
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QGlyphRunPrivate: public QSharedData
@@ -111,8 +109,6 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_RAWFONT
#endif // QGLYPHRUN_P_H
diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index 070550730d..08e697cacf 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -278,8 +278,7 @@ void QPlatformFontDatabase::populateFontDatabase()
option to fall back to the fonts given by \a fallbacks if \a fontEngine does not support
a certain character.
*/
-QFontEngineMulti *QPlatformFontDatabase::fontEngineMulti(QFontEngine *fontEngine,
- QUnicodeTables::Script script)
+QFontEngineMulti *QPlatformFontDatabase::fontEngineMulti(QFontEngine *fontEngine, QChar::Script script)
{
return new QFontEngineMultiQPA(fontEngine, script);
}
@@ -288,7 +287,7 @@ QFontEngineMulti *QPlatformFontDatabase::fontEngineMulti(QFontEngine *fontEngine
Returns the font engine that can be used to render the font described by
the font definition, \a fontDef, in the specified \a script.
*/
-QFontEngine *QPlatformFontDatabase::fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle)
+QFontEngine *QPlatformFontDatabase::fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle)
{
Q_UNUSED(script);
Q_UNUSED(handle);
@@ -312,7 +311,7 @@ QFontEngine *QPlatformFontDatabase::fontEngine(const QByteArray &fontData, qreal
Returns a list of alternative fonts for the specified \a family and
\a style and \a script using the \a styleHint given.
*/
-QStringList QPlatformFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
+QStringList QPlatformFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const
{
Q_UNUSED(family);
Q_UNUSED(style);
diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h
index 319447c19f..4b20677cbb 100644
--- a/src/gui/text/qplatformfontdatabase.h
+++ b/src/gui/text/qplatformfontdatabase.h
@@ -59,8 +59,6 @@
#include <QtGui/QFontDatabase>
#include <QtGui/private/qfont_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -98,9 +96,9 @@ class Q_GUI_EXPORT QPlatformFontDatabase
public:
virtual ~QPlatformFontDatabase();
virtual void populateFontDatabase();
- virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QUnicodeTables::Script script);
- virtual QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
- virtual QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
+ virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script);
+ virtual QFontEngine *fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle);
+ virtual QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const;
virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
virtual void releaseHandle(void *handle);
@@ -125,6 +123,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QPLATFORMFONTDATABASE_H
diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h
index 9a8af41437..9fee7f1e44 100644
--- a/src/gui/text/qrawfont.h
+++ b/src/gui/text/qrawfont.h
@@ -53,8 +53,6 @@
#if !defined(QT_NO_RAWFONT)
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -157,8 +155,6 @@ inline QVector<QPointF> QRawFont::advancesForGlyphIndexes(const QVector<quint32>
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_RAWFONT
#endif // QRAWFONT_H
diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h
index f11e7403fc..60fa82712b 100644
--- a/src/gui/text/qstatictext.h
+++ b/src/gui/text/qstatictext.h
@@ -50,8 +50,6 @@
#include <QtGui/qfont.h>
#include <QtGui/qtextoption.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -107,6 +105,4 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QStaticText)
-QT_END_HEADER
-
#endif // QSTATICTEXT_H
diff --git a/src/gui/text/qsyntaxhighlighter.h b/src/gui/text/qsyntaxhighlighter.h
index 0bd81c4273..8af35a1345 100644
--- a/src/gui/text/qsyntaxhighlighter.h
+++ b/src/gui/text/qsyntaxhighlighter.h
@@ -49,8 +49,6 @@
#include <QtCore/qobject.h>
#include <QtGui/qtextobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -102,8 +100,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_SYNTAXHIGHLIGHTER
#endif // QSYNTAXHIGHLIGHTER_H
diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h
index b302fc220c..560e80d174 100644
--- a/src/gui/text/qtextcursor.h
+++ b/src/gui/text/qtextcursor.h
@@ -46,8 +46,6 @@
#include <QtCore/qshareddata.h>
#include <QtGui/qtextformat.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -239,6 +237,4 @@ Q_DECLARE_SHARED(QTextCursor)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTEXTCURSOR_H
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index 7176cb8d12..9d9cbcf6c1 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -48,8 +48,6 @@
#include <QtCore/qvariant.h>
#include <QtGui/qfont.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -296,6 +294,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QTextDocument::FindFlags)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTEXTDOCUMENT_H
diff --git a/src/gui/text/qtextdocumentfragment.h b/src/gui/text/qtextdocumentfragment.h
index f474541c1b..fe9fbffa56 100644
--- a/src/gui/text/qtextdocumentfragment.h
+++ b/src/gui/text/qtextdocumentfragment.h
@@ -44,8 +44,6 @@
#include <QtCore/qstring.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -85,6 +83,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTEXTDOCUMENTFRAGMENT_H
diff --git a/src/gui/text/qtextdocumentwriter.h b/src/gui/text/qtextdocumentwriter.h
index 7fe82ac919..7fba23139b 100644
--- a/src/gui/text/qtextdocumentwriter.h
+++ b/src/gui/text/qtextdocumentwriter.h
@@ -43,8 +43,6 @@
#include <QtCore/qstring.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -87,6 +85,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index f0776c6098..e51e0c0835 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -51,7 +51,6 @@
#include "qfont_p.h"
#include "qfontengine_p.h"
#include "qstring.h"
-#include <private/qunicodetables_p.h>
#include "qtextdocument_p.h"
#include "qrawfont.h"
#include "qrawfont_p.h"
@@ -134,7 +133,7 @@ private:
// along, and nothing else.
if (m_analysis[i].bidiLevel == m_analysis[start].bidiLevel
&& m_analysis[i].flags == m_analysis[start].flags
- && (m_analysis[i].script == m_analysis[start].script || m_string[i] == QLatin1Char('.'))
+ && (script_to_hbscript(m_analysis[i].script) == script_to_hbscript(m_analysis[start].script) || m_string[i] == QLatin1Char('.'))
&& m_analysis[i].flags < QScriptAnalysis::SpaceTabOrObject
&& i - start < MaxItemLength)
continue;
@@ -1004,7 +1003,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
memset(&entire_shaper_item, 0, sizeof(entire_shaper_item));
entire_shaper_item.string = reinterpret_cast<const HB_UChar16 *>(layoutData->string.constData());
entire_shaper_item.stringLength = layoutData->string.length();
- entire_shaper_item.item.script = (HB_Script)si.analysis.script;
+ entire_shaper_item.item.script = script_to_hbscript(si.analysis.script);
entire_shaper_item.item.pos = si.position;
entire_shaper_item.item.length = length(item);
entire_shaper_item.item.bidiLevel = si.analysis.bidiLevel;
@@ -1348,42 +1347,44 @@ void QTextEngine::itemize() const
const ushort *uc = reinterpret_cast<const ushort *>(layoutData->string.unicode());
const ushort *e = uc + length;
- int lastScript = QUnicodeTables::Common;
+ uchar lastScript = QChar::Script_Common;
while (uc < e) {
switch (*uc) {
case QChar::ObjectReplacementCharacter:
- analysis->script = QUnicodeTables::Common;
+ analysis->script = QChar::Script_Common;
analysis->flags = QScriptAnalysis::Object;
break;
case QChar::LineSeparator:
if (analysis->bidiLevel % 2)
--analysis->bidiLevel;
- analysis->script = QUnicodeTables::Common;
+ analysis->script = QChar::Script_Common;
analysis->flags = QScriptAnalysis::LineOrParagraphSeparator;
if (option.flags() & QTextOption::ShowLineAndParagraphSeparators)
*const_cast<ushort*>(uc) = 0x21B5; // visual line separator
break;
case QChar::Tabulation:
- analysis->script = QUnicodeTables::Common;
+ analysis->script = QChar::Script_Common;
analysis->flags = QScriptAnalysis::Tab;
analysis->bidiLevel = control.baseLevel();
break;
case QChar::Space:
case QChar::Nbsp:
if (option.flags() & QTextOption::ShowTabsAndSpaces) {
- analysis->script = QUnicodeTables::Common;
+ analysis->script = QChar::Script_Common;
analysis->flags = QScriptAnalysis::Space;
analysis->bidiLevel = control.baseLevel();
break;
}
// fall through
default:
- int script = QUnicodeTables::script(*uc);
- analysis->script = script == QUnicodeTables::Inherited ? lastScript : script;
+ analysis->script = QChar::script(*uc);
+ if (analysis->script == QChar::Script_Inherited)
+ analysis->script = lastScript;
analysis->flags = QScriptAnalysis::None;
break;
}
lastScript = analysis->script;
+ analysis->script = hbscript_to_script(script_to_hbscript(analysis->script)); // retain the old behavior
++uc;
++analysis;
}
@@ -2035,9 +2036,9 @@ void QScriptLine::setDefaultHeight(QTextEngine *eng)
QPaintDevice *pdev = eng->block.docHandle()->layout()->paintDevice();
if (pdev)
f = QFont(f, pdev);
- e = f.d->engineForScript(QUnicodeTables::Common);
+ e = f.d->engineForScript(QChar::Script_Common);
} else {
- e = eng->fnt.d->engineForScript(QUnicodeTables::Common);
+ e = eng->fnt.d->engineForScript(QChar::Script_Common);
}
QFixed other_ascent = e->ascent();
@@ -2421,7 +2422,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
{
QChar ellipsisChar(0x2026);
- QFontEngine *fe = fnt.d->engineForScript(QUnicodeTables::Common);
+ QFontEngine *fe = fnt.d->engineForScript(QChar::Script_Common);
QGlyphLayoutArray<1> ellipsisGlyph;
{
@@ -2868,8 +2869,8 @@ int QTextEngine::positionInLigature(const QScriptItem *si, int end,
int clusterStart = -1;
int clusterLength = 0;
- if (si->analysis.script != QUnicodeTables::Common &&
- si->analysis.script != QUnicodeTables::Greek) {
+ if (si->analysis.script != QChar::Script_Common &&
+ si->analysis.script != QChar::Script_Greek) {
if (glyph_pos == -1)
return si->position + end;
else {
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index bdecdad66a..2098369811 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -51,8 +51,6 @@
#include <QtGui/qbrush.h>
#include <QtGui/qtextoption.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -1009,6 +1007,4 @@ inline void QTextTableCellFormat::setPadding(qreal padding)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTEXTFORMAT_H
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index f1a027ade4..8a26fed924 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -52,8 +52,6 @@
#include <QtGui/qglyphrun.h>
#include <QtGui/qtextcursor.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -266,6 +264,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTEXTLAYOUT_H
diff --git a/src/gui/text/qtextlist.h b/src/gui/text/qtextlist.h
index 4aebd1ed0c..1fcc99d963 100644
--- a/src/gui/text/qtextlist.h
+++ b/src/gui/text/qtextlist.h
@@ -45,8 +45,6 @@
#include <QtGui/qtextobject.h>
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -88,6 +86,4 @@ inline void QTextList::setFormat(const QTextListFormat &aformat)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTEXTLIST_H
diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h
index 08eaf943a5..87f2cf6197 100644
--- a/src/gui/text/qtextobject.h
+++ b/src/gui/text/qtextobject.h
@@ -46,8 +46,6 @@
#include <QtGui/qtextformat.h>
#include <QtGui/qglyphrun.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -329,6 +327,4 @@ Q_DECLARE_TYPEINFO(QTextFragment, Q_MOVABLE_TYPE);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTEXTOBJECT_H
diff --git a/src/gui/text/qtextoption.h b/src/gui/text/qtextoption.h
index 0030fabe40..a6818eb79a 100644
--- a/src/gui/text/qtextoption.h
+++ b/src/gui/text/qtextoption.h
@@ -47,8 +47,6 @@
#include <QtCore/qmetatype.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -157,6 +155,4 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE( QTextOption::Tab )
-QT_END_HEADER
-
#endif // QTEXTOPTION_H
diff --git a/src/gui/text/qtexttable.h b/src/gui/text/qtexttable.h
index 6dddda210f..9da205af7f 100644
--- a/src/gui/text/qtexttable.h
+++ b/src/gui/text/qtexttable.h
@@ -46,8 +46,6 @@
#include <QtCore/qobject.h>
#include <QtGui/qtextobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -139,6 +137,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTEXTTABLE_H
diff --git a/src/gui/util/qdesktopservices.h b/src/gui/util/qdesktopservices.h
index 15139ea7b7..9b1d71052c 100644
--- a/src/gui/util/qdesktopservices.h
+++ b/src/gui/util/qdesktopservices.h
@@ -45,8 +45,6 @@
#include <QtCore/qstring.h>
#include <QtCore/qstandardpaths.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -94,7 +92,5 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QDESKTOPSERVICES_H
diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp
index b94ec7f1bb..ed3b3b6dd6 100644
--- a/src/gui/util/qvalidator.cpp
+++ b/src/gui/util/qvalidator.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -501,9 +502,6 @@ void QIntValidator::setTop(int top)
setRange(bottom(), top);
}
-
-#ifndef QT_NO_REGEXP
-
/*!
\internal
*/
@@ -520,6 +518,8 @@ QValidator::QValidator(QValidatorPrivate &d, QObject *parent)
{
}
+#ifndef QT_NO_REGEXP
+
class QDoubleValidatorPrivate : public QValidatorPrivate
{
Q_DECLARE_PUBLIC(QDoubleValidator)
@@ -906,6 +906,159 @@ void QRegExpValidator::setRegExp(const QRegExp& rx)
#endif
+#ifndef QT_NO_REGULAREXPRESSION
+
+/*!
+ \class QRegularExpressionValidator
+ \brief The QRegularExpressionValidator class is used to check a string
+ against a regular expression.
+
+ \since 5.1
+
+ QRegularExpressionValidator uses a regular expression (regexp) to
+ determine whether an input string is \l Acceptable, \l
+ Intermediate, or \l Invalid. The regexp can either be supplied
+ when the QRegularExpressionValidator is constructed, or at a later time.
+
+ If the regexp partially matches against the string, the result is
+ considered \l Intermediate. For example, "" and "A" are \l Intermediate for
+ the regexp \b{[A-Z][0-9]} (whereas "_" would be \l Invalid).
+
+ QRegularExpressionValidator automatically wraps the regular expression in
+ the \c{\\A} and \c{\\z} anchors; in other words, it always attempts to do
+ an exact match.
+
+ Example of use:
+ \snippet code/src_gui_util_qvalidator.cpp 5
+
+ Below we present some examples of validators. In practice they would
+ normally be associated with a widget as in the example above.
+
+ \snippet code/src_gui_util_qvalidator.cpp 6
+
+ \sa QRegularExpression, QIntValidator, QDoubleValidator, QRegExpValidator
+*/
+
+class QRegularExpressionValidatorPrivate : public QValidatorPrivate
+{
+ Q_DECLARE_PUBLIC(QRegularExpressionValidator)
+
+public:
+ QRegularExpression origRe; // the one set by the user
+ QRegularExpression usedRe; // the one actually used
+ void setRegularExpression(const QRegularExpression &re);
+};
+
+/*!
+ Constructs a validator with a \a parent object that accepts
+ any string (including an empty one) as valid.
+*/
+
+QRegularExpressionValidator::QRegularExpressionValidator(QObject *parent)
+ : QValidator(*new QRegularExpressionValidatorPrivate, parent)
+{
+ // origRe in the private will be an empty QRegularExpression,
+ // and therefore this validator will match any string.
+}
+
+/*!
+ Constructs a validator with a \a parent object that
+ accepts all strings that match the regular expression \a re.
+*/
+
+QRegularExpressionValidator::QRegularExpressionValidator(const QRegularExpression &re, QObject *parent)
+ : QValidator(*new QRegularExpressionValidatorPrivate, parent)
+{
+ Q_D(QRegularExpressionValidator);
+ d->setRegularExpression(re);
+}
+
+
+/*!
+ Destroys the validator.
+*/
+
+QRegularExpressionValidator::~QRegularExpressionValidator()
+{
+}
+
+/*!
+ Returns \l Acceptable if \a input is matched by the regular expression for
+ this validator, \l Intermediate if it has matched partially (i.e. could be
+ a valid match if additional valid characters are added), and \l Invalid if
+ \a input is not matched.
+
+ In case the \a input is not matched, the \a pos parameter is set to
+ the length of the \a input parameter; otherwise, it is not modified.
+
+ For example, if the regular expression is \b{\\w\\d\\d} (word-character,
+ digit, digit) then "A57" is \l Acceptable, "E5" is \l Intermediate, and
+ "+9" is \l Invalid.
+
+ \sa QRegularExpression::match()
+*/
+
+QValidator::State QRegularExpressionValidator::validate(QString &input, int &pos) const
+{
+ Q_D(const QRegularExpressionValidator);
+
+ // We want a validator with an empty QRegularExpression to match anything;
+ // since we're going to do an exact match (by using d->usedRe), first check if the rx is empty
+ // (and, if so, accept the input).
+ if (d->origRe.pattern().isEmpty())
+ return Acceptable;
+
+ const QRegularExpressionMatch m = d->usedRe.match(input, 0, QRegularExpression::PartialPreferCompleteMatch);
+ if (m.hasMatch()) {
+ return Acceptable;
+ } else if (m.hasPartialMatch()) {
+ return Intermediate;
+ } else {
+ pos = input.size();
+ return Invalid;
+ }
+}
+
+/*!
+ \property QRegularExpressionValidator::regularExpression
+ \brief the regular expression used for validation
+
+ By default, this property contains a regular expression with an empty
+ pattern (which therefore matches any string).
+*/
+
+QRegularExpression QRegularExpressionValidator::regularExpression() const
+{
+ Q_D(const QRegularExpressionValidator);
+ return d->origRe;
+}
+
+void QRegularExpressionValidator::setRegularExpression(const QRegularExpression &re)
+{
+ Q_D(QRegularExpressionValidator);
+ d->setRegularExpression(re);
+}
+
+/*!
+ \internal
+
+ Sets \a re as the regular expression. It wraps the regexp that's actually used
+ between \\A and \\z, therefore forcing an exact match.
+*/
+void QRegularExpressionValidatorPrivate::setRegularExpression(const QRegularExpression &re)
+{
+ Q_Q(QRegularExpressionValidator);
+
+ if (origRe != re) {
+ usedRe = origRe = re; // copies also the pattern options
+ usedRe.setPattern(QStringLiteral("\\A(?:") + re.pattern() + QStringLiteral(")\\z"));
+ emit q->regularExpressionChanged(re);
+ emit q->changed();
+ }
+}
+
+#endif // QT_NO_REGULAREXPRESSION
+
QT_END_NAMESPACE
#endif // QT_NO_VALIDATOR
diff --git a/src/gui/util/qvalidator.h b/src/gui/util/qvalidator.h
index 6ffab4907b..386af1bc74 100644
--- a/src/gui/util/qvalidator.h
+++ b/src/gui/util/qvalidator.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -45,10 +46,9 @@
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qlocale.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -195,10 +195,39 @@ private:
#endif // QT_NO_REGEXP
+#ifndef QT_NO_REGULAREXPRESSION
+
+class QRegularExpressionValidatorPrivate;
+
+class Q_GUI_EXPORT QRegularExpressionValidator : public QValidator
+{
+ Q_OBJECT
+ Q_PROPERTY(QRegularExpression regularExpression READ regularExpression WRITE setRegularExpression NOTIFY regularExpressionChanged)
+
+public:
+ explicit QRegularExpressionValidator(QObject *parent = 0);
+ explicit QRegularExpressionValidator(const QRegularExpression &re, QObject *parent = 0);
+ ~QRegularExpressionValidator();
+
+ virtual QValidator::State validate(QString &input, int &pos) const Q_DECL_OVERRIDE;
+
+ QRegularExpression regularExpression() const;
+
+public Q_SLOTS:
+ void setRegularExpression(const QRegularExpression &re);
+
+Q_SIGNALS:
+ void regularExpressionChanged(const QRegularExpression &re);
+
+private:
+ Q_DISABLE_COPY(QRegularExpressionValidator)
+ Q_DECLARE_PRIVATE(QRegularExpressionValidator)
+};
+
+#endif // QT_NO_REGULAREXPRESSION
+
#endif // QT_NO_VALIDATOR
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QVALIDATOR_H