summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-09-26 21:43:25 +0200
committerLiang Qi <liang.qi@qt.io>2016-09-26 21:43:25 +0200
commit06bd93c4acf49fc24408a60ebdf7a46caf02f9b3 (patch)
treeeedbdaa40fbf20bb99187084dd9edf14f73f05bd /src/gui
parentbafad505a0adb21b819f7617e5e802bf2d52fd54 (diff)
parent41a7d74385eece725435159ca021151e871bf116 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: src/plugins/platforms/ios/qiosmessagedialog.mm Change-Id: Icfbf55c3215ec088e552d0b42a5c94d04b17c65f
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qguiapplication.cpp4
-rw-r--r--src/gui/kernel/qguivariant.cpp3
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp8
-rw-r--r--src/gui/kernel/qpaintdevicewindow.cpp3
-rw-r--r--src/gui/kernel/qwindow.cpp13
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp6
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h4
-rw-r--r--src/gui/painting/qbrush.cpp14
-rw-r--r--src/gui/painting/qcolor.cpp95
-rw-r--r--src/gui/painting/qcolor.h13
-rw-r--r--src/gui/painting/qcolor_p.h5
-rw-r--r--src/gui/painting/qdrawhelper.cpp185
-rw-r--r--src/gui/text/qrawfont.cpp13
-rw-r--r--src/gui/text/qtextengine.cpp2
14 files changed, 149 insertions, 219 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 2ed7eb2cfb..16add8f627 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -2794,10 +2794,10 @@ void QGuiApplicationPrivate::reportRefreshRateChange(QWindowSystemInterfacePriva
void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e)
{
- if (!e->exposed)
+ if (!e->window)
return;
- QWindow *window = e->exposed.data();
+ QWindow *window = e->window.data();
if (!window)
return;
QWindowPrivate *p = qt_window_private(window);
diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp
index 4ae4b209ca..bde0d20ea8 100644
--- a/src/gui/kernel/qguivariant.cpp
+++ b/src/gui/kernel/qguivariant.cpp
@@ -260,8 +260,7 @@ static bool convert(const QVariant::Private *d, int t,
static_cast<QColor *>(result)->setNamedColor(*v_cast<QString>(d));
return static_cast<QColor *>(result)->isValid();
} else if (d->type == QVariant::ByteArray) {
- static_cast<QColor *>(result)->setNamedColor(QString::fromLatin1(
- *v_cast<QByteArray>(d)));
+ static_cast<QColor *>(result)->setNamedColor(QLatin1String(*v_cast<QByteArray>(d)));
return true;
} else if (d->type == QVariant::Brush) {
if (v_cast<QBrush>(d)->style() == Qt::SolidPattern) {
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 76663cdc01..1085b546a7 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -170,11 +170,11 @@ static inline qreal initialGlobalScaleFactor()
The QT_SCALE_FACTOR environment variable can be used to set
a global scale factor for all windows in the processs. This
is useful for testing and debugging (you can simulate any
- devicePixelRatio without needing access to sepcial hardware),
+ devicePixelRatio without needing access to special hardware),
and perhaps also for targeting a specific application to
a specific display type (embedded use cases).
- 2) A per-screen scale factors
+ 2) Per-screen scale factors
Some platform plugins support providing a per-screen scale
factor based on display density information. These platforms
include X11, Windows, and Android.
@@ -187,13 +187,13 @@ static inline qreal initialGlobalScaleFactor()
Enabling either will make QHighDpiScaling call QPlatformScreen::pixelDensity()
and use the value provided as the scale factor for the screen in
question. Disabling is done on a 'veto' basis where either the
- environment or the application source can disable. The intended use
+ environment or the application can disable the scaling. The intended use
cases are 'My system is not providing correct display density
information' and 'My application needs to work in display pixels',
respectively.
The QT_SCREEN_SCALE_FACTORS environment variable can be used to set the screen
- scale factors manually.Set this to a semicolon-separated
+ scale factors manually. Set this to a semicolon-separated
list of scale factors (matching the order of QGuiApplications::screens()),
or to a list of name=value pairs (where name matches QScreen::name()).
diff --git a/src/gui/kernel/qpaintdevicewindow.cpp b/src/gui/kernel/qpaintdevicewindow.cpp
index c35478da38..4521c2f62c 100644
--- a/src/gui/kernel/qpaintdevicewindow.cpp
+++ b/src/gui/kernel/qpaintdevicewindow.cpp
@@ -187,9 +187,6 @@ void QPaintDeviceWindow::exposeEvent(QExposeEvent *exposeEvent)
// sometimes relative to the parent, depending on the platform plugin.
// We require local coords here.
d->doFlush(QRect(QPoint(0, 0), size()));
- } else if (!d->dirtyRegion.isEmpty()) {
- // Updates while non-exposed were ignored. Schedule an update now.
- requestUpdate();
}
}
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 18e8bcf99c..23e783fcb4 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -2175,11 +2175,14 @@ void QWindowPrivate::deliverUpdateRequest()
Schedules a QEvent::UpdateRequest event to be delivered to this window.
The event is delivered in sync with the display vsync on platforms
- where this is possible. When driving animations, this function should
- be called once after drawing has completed.
-
- Calling this function multiple times will result in a single event
- being delivered to the window.
+ where this is possible. Otherwise, the event is delivered after a
+ delay of 5 ms. The additional time is there to give the event loop
+ a bit of idle time to gather system events, and can be overridden
+ using the QT_QPA_UPDATE_IDLE_TIME environment variable.
+
+ When driving animations, this function should be called once after drawing
+ has completed. Calling this function multiple times will result in a single
+ event being delivered to the window.
Subclasses of QWindow should reimplement event(), intercept the event and
call the application's rendering code, then call the base class
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 7c6bbc26c8..bb778bc5fc 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -361,10 +361,10 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, con
}
-QWindowSystemInterfacePrivate::ExposeEvent::ExposeEvent(QWindow *exposed, const QRegion &region)
+QWindowSystemInterfacePrivate::ExposeEvent::ExposeEvent(QWindow *window, const QRegion &region)
: WindowSystemEvent(Expose)
- , exposed(exposed)
- , isExposed(exposed && exposed->handle() ? exposed->handle()->isExposed() : false)
+ , window(window)
+ , isExposed(window && window->handle() ? window->handle()->isExposed() : false)
, region(region)
{
}
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index bdbf191cbd..f471e1f550 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -330,8 +330,8 @@ public:
class ExposeEvent : public WindowSystemEvent {
public:
- ExposeEvent(QWindow *exposed, const QRegion &region);
- QPointer<QWindow> exposed;
+ ExposeEvent(QWindow *window, const QRegion &region);
+ QPointer<QWindow> window;
bool isExposed;
QRegion region;
};
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index acea5682d1..ebb035a2c1 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -584,7 +584,7 @@ void QBrush::detach(Qt::BrushStyle newStyle)
return;
}
- QScopedPointer<QBrushData> x;
+ QScopedPointer<QBrushData, QBrushDataPointerDeleter> x;
switch(newStyle) {
case Qt::TexturePattern: {
QTexturedBrushData *tbd = new QTexturedBrushData;
@@ -600,28 +600,30 @@ void QBrush::detach(Qt::BrushStyle newStyle)
}
case Qt::LinearGradientPattern:
case Qt::RadialGradientPattern:
- case Qt::ConicalGradientPattern:
- x.reset(new QGradientBrushData);
+ case Qt::ConicalGradientPattern: {
+ QGradientBrushData *gbd = new QGradientBrushData;
switch (d->style) {
case Qt::LinearGradientPattern:
case Qt::RadialGradientPattern:
case Qt::ConicalGradientPattern:
- static_cast<QGradientBrushData *>(x.data())->gradient =
+ gbd->gradient =
static_cast<QGradientBrushData *>(d.data())->gradient;
break;
default:
break;
}
+ x.reset(gbd);
break;
+ }
default:
x.reset(new QBrushData);
break;
}
- x->ref.store(1);
+ x->ref.store(1); // must be first lest the QBrushDataPointerDeleter turns into a no-op
x->style = newStyle;
x->color = d->color;
x->transform = d->transform;
- d.reset(x.take());
+ d.swap(x);
}
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 650ba0187e..05790c4504 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -79,12 +79,12 @@ static inline int hex2int(char s)
return h < 0 ? h : (h << 4) | h;
}
-bool qt_get_hex_rgb(const char *name, QRgb *rgb)
+static bool get_hex_rgb(const char *name, int len, QRgb *rgb)
{
if (name[0] != '#')
return false;
name++;
- int len = qstrlen(name);
+ --len;
int a, r, g, b;
a = 255;
if (len == 12) {
@@ -119,15 +119,19 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb)
return true;
}
-bool qt_get_hex_rgb(const QChar *str, int len, QRgb *rgb)
+bool qt_get_hex_rgb(const char *name, QRgb *rgb)
+{
+ return get_hex_rgb(name, qstrlen(name), rgb);
+}
+
+static bool get_hex_rgb(const QChar *str, int len, QRgb *rgb)
{
if (len > 13)
return false;
char tmp[16];
for (int i = 0; i < len; ++i)
tmp[i] = str[i].toLatin1();
- tmp[len] = 0;
- return qt_get_hex_rgb(tmp, rgb);
+ return get_hex_rgb(tmp, len, rgb);
}
#ifndef QT_NO_COLORNAMES
@@ -309,7 +313,7 @@ inline bool operator<(const char *name, const RGBData &data)
inline bool operator<(const RGBData &data, const char *name)
{ return qstrcmp(data.name, name) < 0; }
-static bool get_named_rgb(const char *name_no_space, QRgb *rgb)
+static bool get_named_rgb_no_space(const char *name_no_space, QRgb *rgb)
{
const RGBData *r = std::lower_bound(rgbTbl, rgbTbl + rgbTblSize, name_no_space);
if ((r != rgbTbl + rgbTblSize) && !(name_no_space < *r)) {
@@ -319,9 +323,8 @@ static bool get_named_rgb(const char *name_no_space, QRgb *rgb)
return false;
}
-bool qt_get_named_rgb(const char *name, QRgb* rgb)
+static bool get_named_rgb(const char *name, int len, QRgb* rgb)
{
- int len = int(strlen(name));
if (len > 255)
return false;
char name_no_space[256];
@@ -332,10 +335,10 @@ bool qt_get_named_rgb(const char *name, QRgb* rgb)
}
name_no_space[pos] = 0;
- return get_named_rgb(name_no_space, rgb);
+ return get_named_rgb_no_space(name_no_space, rgb);
}
-bool qt_get_named_rgb(const QChar *name, int len, QRgb *rgb)
+static bool get_named_rgb(const QChar *name, int len, QRgb *rgb)
{
if (len > 255)
return false;
@@ -346,32 +349,22 @@ bool qt_get_named_rgb(const QChar *name, int len, QRgb *rgb)
name_no_space[pos++] = name[i].toLower().toLatin1();
}
name_no_space[pos] = 0;
- return get_named_rgb(name_no_space, rgb);
+ return get_named_rgb_no_space(name_no_space, rgb);
}
-QStringList qt_get_colornames()
+#endif // QT_NO_COLORNAMES
+
+static QStringList get_colornames()
{
- int i = 0;
QStringList lst;
+#ifndef QT_NO_COLORNAMES
lst.reserve(rgbTblSize);
- for (i = 0; i < rgbTblSize; i++)
+ for (int i = 0; i < rgbTblSize; i++)
lst << QLatin1String(rgbTbl[i].name);
+#endif
return lst;
}
-#else
-
-bool qt_get_named_rgb(const char *, QRgb*)
-{
- return false;
-}
-
-QStringList qt_get_colornames()
-{
- return QStringList();
-}
-#endif // QT_NO_COLORNAMES
-
/*!
\class QColor
\brief The QColor class provides colors based on RGB, HSV or CMYK values.
@@ -801,12 +794,14 @@ QColor::QColor(Spec spec) Q_DECL_NOTHROW
/*!
\fn QColor::QColor(const char *name)
+ \overload
+ \sa setNamedColor(), name(), isValid()
+*/
- Constructs a named color in the same way as setNamedColor() using
- the given \a name.
-
- The color is left invalid if the \a name cannot be parsed.
-
+/*!
+ \fn QColor::QColor(QLatin1String name)
+ \overload
+ \since 5.8
\sa setNamedColor(), name(), isValid()
*/
@@ -887,6 +882,16 @@ void QColor::setNamedColor(const QString &name)
}
/*!
+ \overload
+ \since 5.8
+*/
+
+void QColor::setNamedColor(QLatin1String name)
+{
+ setColorFromString(name);
+}
+
+/*!
\since 4.7
Returns \c true if the \a name is a valid color name and can
@@ -902,16 +907,26 @@ bool QColor::isValidColor(const QString &name)
return !name.isEmpty() && QColor().setColorFromString(name);
}
-bool QColor::setColorFromString(const QString &name)
+/*!
+ \overload
+ \since 5.8
+*/
+bool QColor::isValidColor(QLatin1String name) Q_DECL_NOTHROW
{
- if (name.isEmpty()) {
+ return name.size() && QColor().setColorFromString(name);
+}
+
+template <typename String>
+bool QColor::setColorFromString(const String &name)
+{
+ if (!name.size()) {
invalidate();
return true;
}
- if (name.startsWith(QLatin1Char('#'))) {
+ if (name[0] == QLatin1Char('#')) {
QRgb rgba;
- if (qt_get_hex_rgb(name.constData(), name.length(), &rgba)) {
+ if (get_hex_rgb(name.data(), name.size(), &rgba)) {
setRgba(rgba);
return true;
} else {
@@ -922,7 +937,7 @@ bool QColor::setColorFromString(const QString &name)
#ifndef QT_NO_COLORNAMES
QRgb rgb;
- if (qt_get_named_rgb(name.constData(), name.length(), &rgb)) {
+ if (get_named_rgb(name.data(), name.size(), &rgb)) {
setRgba(rgb);
return true;
} else
@@ -940,11 +955,7 @@ bool QColor::setColorFromString(const QString &name)
*/
QStringList QColor::colorNames()
{
-#ifndef QT_NO_COLORNAMES
- return qt_get_colornames();
-#else
- return QStringList();
-#endif
+ return get_colornames();
}
/*!
diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h
index 6cf3a8e262..db6eb92916 100644
--- a/src/gui/painting/qcolor.h
+++ b/src/gui/painting/qcolor.h
@@ -73,7 +73,8 @@ public:
QColor(QRgb rgb) Q_DECL_NOTHROW;
QColor(QRgba64 rgba64) Q_DECL_NOTHROW;
QColor(const QString& name);
- QColor(const char *name);
+ QColor(const char *aname) : QColor(QLatin1String(aname)) {}
+ QColor(QLatin1String name);
QColor(Spec spec) Q_DECL_NOTHROW;
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
@@ -93,7 +94,9 @@ public:
// ### Qt 6: merge overloads
QString name() const;
QString name(NameFormat format) const;
+
void setNamedColor(const QString& name);
+ void setNamedColor(QLatin1String name);
static QStringList colorNames();
@@ -219,11 +222,13 @@ public:
operator QVariant() const;
static bool isValidColor(const QString &name);
+ static bool isValidColor(QLatin1String) Q_DECL_NOTHROW;
private:
void invalidate() Q_DECL_NOTHROW;
- bool setColorFromString(const QString &name);
+ template <typename String>
+ bool setColorFromString(const String &name);
Spec cspec;
union {
@@ -272,8 +277,8 @@ inline QColor::QColor() Q_DECL_NOTHROW
inline QColor::QColor(int r, int g, int b, int a)
{ setRgb(r, g, b, a); }
-inline QColor::QColor(const char *aname)
-{ setNamedColor(QLatin1String(aname)); }
+inline QColor::QColor(QLatin1String aname)
+{ setNamedColor(aname); }
inline QColor::QColor(const QString& aname)
{ setNamedColor(aname); }
diff --git a/src/gui/painting/qcolor_p.h b/src/gui/painting/qcolor_p.h
index b5e92e2ea2..b44f2b163a 100644
--- a/src/gui/painting/qcolor_p.h
+++ b/src/gui/painting/qcolor_p.h
@@ -53,15 +53,10 @@
#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qrgb.h"
-#include "QtCore/qstringlist.h"
QT_BEGIN_NAMESPACE
-bool qt_get_named_rgb(const char *, QRgb*);
-bool qt_get_named_rgb(const QChar *, int len, QRgb*);
bool qt_get_hex_rgb(const char *, QRgb *);
-bool qt_get_hex_rgb(const QChar *, int len, QRgb *);
-QStringList qt_get_colornames();
QT_END_NAMESPACE
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index c1a49b7d9a..7685f7f4ca 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -836,7 +836,10 @@ static const uint *QT_FASTCALL convertGrayscale8FromARGB32PM(uint *buffer, const
}
template <QPixelLayout::BPP bpp> static
-uint QT_FASTCALL fetchPixel(const uchar *src, int index);
+uint QT_FASTCALL fetchPixel(const uchar *, int)
+{
+ Q_UNREACHABLE();
+}
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP1LSB>(const uchar *src, int index)
@@ -1554,92 +1557,11 @@ static const QRgba64 *QT_FASTCALL fetchUntransformed64(QRgba64 *buffer, const Op
}
}
-// blendType is either BlendTransformed or BlendTransformedTiled
-template<TextureBlendType blendType>
-static const uint *QT_FASTCALL fetchTransformedARGB32PM(uint *buffer, const Operator *, const QSpanData *data,
- int y, int x, int length)
-{
- int image_width = data->texture.width;
- int image_height = data->texture.height;
-
- const qreal cx = x + qreal(0.5);
- const qreal cy = y + qreal(0.5);
-
- const uint *end = buffer + length;
- uint *b = buffer;
- if (data->fast_matrix) {
- // The increment pr x in the scanline
- int fdx = (int)(data->m11 * fixed_scale);
- int fdy = (int)(data->m12 * fixed_scale);
-
- int fx = int((data->m21 * cy
- + data->m11 * cx + data->dx) * fixed_scale);
- int fy = int((data->m22 * cy
- + data->m12 * cx + data->dy) * fixed_scale);
-
- while (b < end) {
- int px = fx >> 16;
- int py = fy >> 16;
-
- if (blendType == BlendTransformedTiled) {
- px %= image_width;
- py %= image_height;
- if (px < 0) px += image_width;
- if (py < 0) py += image_height;
- } else {
- px = qBound(0, px, image_width - 1);
- py = qBound(0, py, image_height - 1);
- }
- *b = reinterpret_cast<const uint *>(data->texture.scanLine(py))[px];
-
- fx += fdx;
- fy += fdy;
- ++b;
- }
- } else {
- const qreal fdx = data->m11;
- const qreal fdy = data->m12;
- const qreal fdw = data->m13;
-
- qreal fx = data->m21 * cy + data->m11 * cx + data->dx;
- qreal fy = data->m22 * cy + data->m12 * cx + data->dy;
- qreal fw = data->m23 * cy + data->m13 * cx + data->m33;
-
- while (b < end) {
- const qreal iw = fw == 0 ? 1 : 1 / fw;
- const qreal tx = fx * iw;
- const qreal ty = fy * iw;
- int px = int(tx) - (tx < 0);
- int py = int(ty) - (ty < 0);
-
- if (blendType == BlendTransformedTiled) {
- px %= image_width;
- py %= image_height;
- if (px < 0) px += image_width;
- if (py < 0) py += image_height;
- } else {
- px = qBound(0, px, image_width - 1);
- py = qBound(0, py, image_height - 1);
- }
- *b = reinterpret_cast<const uint *>(data->texture.scanLine(py))[px];
-
- fx += fdx;
- fy += fdy;
- fw += fdw;
- //force increment to avoid /0
- if (!fw) {
- fw += fdw;
- }
- ++b;
- }
- }
- return buffer;
-}
-
-template<TextureBlendType blendType> /* either BlendTransformed or BlendTransformedTiled */
+template<TextureBlendType blendType, QPixelLayout::BPP bpp>
static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const QSpanData *data,
int y, int x, int length)
{
+ Q_STATIC_ASSERT(blendType == BlendTransformed || blendType == BlendTransformedTiled);
int image_width = data->texture.width;
int image_height = data->texture.height;
@@ -1647,9 +1569,12 @@ static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *,
const qreal cy = y + qreal(0.5);
const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
- FetchPixelFunc fetch = qFetchPixel[layout->bpp];
+ if (bpp != QPixelLayout::BPPNone) // Like this to not ICE on GCC 5.3.1
+ Q_ASSERT(layout->bpp == bpp);
+ // When templated 'fetch' should be inlined at compile time:
+ const FetchPixelFunc fetch = (bpp == QPixelLayout::BPPNone) ? qFetchPixel[layout->bpp] : fetchPixel<bpp>;
- const uint *end = buffer + length;
+ uint *const end = buffer + length;
uint *b = buffer;
if (data->fast_matrix) {
// The increment pr x in the scanline
@@ -2585,12 +2510,17 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
}
// blendType = BlendTransformedBilinear or BlendTransformedBilinearTiled
-template<TextureBlendType blendType>
+template<TextureBlendType blendType, QPixelLayout::BPP bpp>
static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *,
const QSpanData *data, int y, int x, int length)
{
const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
const QVector<QRgb> *clut = data->texture.colorTable;
+ if (bpp != QPixelLayout::BPPNone) // Like this to not ICE on GCC 5.3.1
+ Q_ASSERT(layout->bpp == bpp);
+ // When templated 'fetch' should be inlined at compile time:
+ const FetchPixelsFunc fetch = (bpp == QPixelLayout::BPPNone) ? qFetchPixels[layout->bpp] : fetchPixels<bpp>;
+ const FetchPixelFunc fetch1 = (bpp == QPixelLayout::BPPNone) ? qFetchPixel[layout->bpp] : fetchPixel<bpp>;
int image_width = data->texture.width;
int image_height = data->texture.height;
@@ -2628,7 +2558,6 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
// The idea is first to do the interpolation between the row s1 and the row s2
// into an intermediate buffer, then we interpolate between two pixel of this buffer.
- FetchPixelsFunc fetch = qFetchPixels[layout->bpp];
// +1 for the last pixel to interpolate with, and +1 for rounding errors.
uint buf1[buffer_size + 2];
uint buf2[buffer_size + 2];
@@ -2717,7 +2646,6 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
fx += fdx;
}
} else {
- FetchPixelFunc fetch = qFetchPixel[layout->bpp];
uint buf1[buffer_size];
uint buf2[buffer_size];
uint *b = buffer;
@@ -2728,19 +2656,10 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
int x1 = (fx >> 16);
int x2;
fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2);
-
- if (layout->bpp == QPixelLayout::BPP32) {
- buf1[i * 2 + 0] = ((const uint*)s1)[x1];
- buf1[i * 2 + 1] = ((const uint*)s1)[x2];
- buf2[i * 2 + 0] = ((const uint*)s2)[x1];
- buf2[i * 2 + 1] = ((const uint*)s2)[x2];
- } else {
- buf1[i * 2 + 0] = fetch(s1, x1);
- buf1[i * 2 + 1] = fetch(s1, x2);
- buf2[i * 2 + 0] = fetch(s2, x1);
- buf2[i * 2 + 1] = fetch(s2, x2);
- }
-
+ buf1[i * 2 + 0] = fetch1(s1, x1);
+ buf1[i * 2 + 1] = fetch1(s1, x2);
+ buf2[i * 2 + 0] = fetch1(s2, x1);
+ buf2[i * 2 + 1] = fetch1(s2, x2);
fx += fdx;
}
layout->convertToARGB32PM(buf1, buf1, len * 2, clut, 0);
@@ -2770,7 +2689,6 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
}
}
} else { //rotation
- FetchPixelFunc fetch = qFetchPixel[layout->bpp];
uint buf1[buffer_size];
uint buf2[buffer_size];
uint *b = buffer;
@@ -2789,19 +2707,10 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
const uchar *s1 = data->texture.scanLine(y1);
const uchar *s2 = data->texture.scanLine(y2);
-
- if (layout->bpp == QPixelLayout::BPP32) {
- buf1[i * 2 + 0] = ((const uint*)s1)[x1];
- buf1[i * 2 + 1] = ((const uint*)s1)[x2];
- buf2[i * 2 + 0] = ((const uint*)s2)[x1];
- buf2[i * 2 + 1] = ((const uint*)s2)[x2];
- } else {
- buf1[i * 2 + 0] = fetch(s1, x1);
- buf1[i * 2 + 1] = fetch(s1, x2);
- buf2[i * 2 + 0] = fetch(s2, x1);
- buf2[i * 2 + 1] = fetch(s2, x2);
- }
-
+ buf1[i * 2 + 0] = fetch1(s1, x1);
+ buf1[i * 2 + 1] = fetch1(s1, x2);
+ buf2[i * 2 + 0] = fetch1(s2, x1);
+ buf2[i * 2 + 1] = fetch1(s2, x2);
fx += fdx;
fy += fdy;
}
@@ -2848,7 +2757,6 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
qreal fy = data->m22 * cy + data->m12 * cx + data->dy;
qreal fw = data->m23 * cy + data->m13 * cx + data->m33;
- FetchPixelFunc fetch = qFetchPixel[layout->bpp];
uint buf1[buffer_size];
uint buf2[buffer_size];
uint *b = buffer;
@@ -2876,18 +2784,10 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
const uchar *s1 = data->texture.scanLine(y1);
const uchar *s2 = data->texture.scanLine(y2);
-
- if (layout->bpp == QPixelLayout::BPP32) {
- buf1[i * 2 + 0] = ((const uint*)s1)[x1];
- buf1[i * 2 + 1] = ((const uint*)s1)[x2];
- buf2[i * 2 + 0] = ((const uint*)s2)[x1];
- buf2[i * 2 + 1] = ((const uint*)s2)[x2];
- } else {
- buf1[i * 2 + 0] = fetch(s1, x1);
- buf1[i * 2 + 1] = fetch(s1, x2);
- buf2[i * 2 + 0] = fetch(s2, x1);
- buf2[i * 2 + 1] = fetch(s2, x2);
- }
+ buf1[i * 2 + 0] = fetch1(s1, x1);
+ buf1[i * 2 + 1] = fetch1(s1, x2);
+ buf2[i * 2 + 0] = fetch1(s2, x1);
+ buf2[i * 2 + 1] = fetch1(s2, x2);
fx += fdx;
fy += fdy;
@@ -3293,23 +3193,32 @@ static SourceFetchProc sourceFetchUntransformed[QImage::NImageFormats] = {
};
static const SourceFetchProc sourceFetchGeneric[NBlendTypes] = {
- fetchUntransformed, // Untransformed
- fetchUntransformed, // Tiled
- fetchTransformed<BlendTransformed>, // Transformed
- fetchTransformed<BlendTransformedTiled>, // TransformedTiled
- fetchTransformedBilinear<BlendTransformedBilinear>, // Bilinear
- fetchTransformedBilinear<BlendTransformedBilinearTiled> // BilinearTiled
+ fetchUntransformed, // Untransformed
+ fetchUntransformed, // Tiled
+ fetchTransformed<BlendTransformed, QPixelLayout::BPPNone>, // Transformed
+ fetchTransformed<BlendTransformedTiled, QPixelLayout::BPPNone>, // TransformedTiled
+ fetchTransformedBilinear<BlendTransformedBilinear, QPixelLayout::BPPNone>, // TransformedBilinear
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QPixelLayout::BPPNone> // TransformedBilinearTiled
};
static SourceFetchProc sourceFetchARGB32PM[NBlendTypes] = {
fetchUntransformedARGB32PM, // Untransformed
fetchUntransformedARGB32PM, // Tiled
- fetchTransformedARGB32PM<BlendTransformed>, // Transformed
- fetchTransformedARGB32PM<BlendTransformedTiled>, // TransformedTiled
+ fetchTransformed<BlendTransformed, QPixelLayout::BPP32>, // Transformed
+ fetchTransformed<BlendTransformedTiled, QPixelLayout::BPP32>, // TransformedTiled
fetchTransformedBilinearARGB32PM<BlendTransformedBilinear>, // Bilinear
fetchTransformedBilinearARGB32PM<BlendTransformedBilinearTiled> // BilinearTiled
};
+static SourceFetchProc sourceFetchAny32[NBlendTypes] = {
+ fetchUntransformed, // Untransformed
+ fetchUntransformed, // Tiled
+ fetchTransformed<BlendTransformed, QPixelLayout::BPP32>, // Transformed
+ fetchTransformed<BlendTransformedTiled, QPixelLayout::BPP32>, // TransformedTiled
+ fetchTransformedBilinear<BlendTransformedBilinear, QPixelLayout::BPP32>, // TransformedBilinear
+ fetchTransformedBilinear<BlendTransformedBilinearTiled, QPixelLayout::BPP32> // TransformedBilinearTiled
+};
+
static const SourceFetchProc64 sourceFetchGeneric64[NBlendTypes] = {
fetchUntransformed64, // Untransformed
fetchUntransformed64, // Tiled
@@ -3325,6 +3234,8 @@ static inline SourceFetchProc getSourceFetch(TextureBlendType blendType, QImage:
return sourceFetchARGB32PM[blendType];
if (blendType == BlendUntransformed || blendType == BlendTiled)
return sourceFetchUntransformed[format];
+ if (qPixelLayouts[format].bpp == QPixelLayout::BPP32)
+ return sourceFetchAny32[blendType];
return sourceFetchGeneric[blendType];
}
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 8e6ffa5e94..4d567b26c2 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -261,9 +261,13 @@ void QRawFont::loadFromData(const QByteArray &fontData,
\a glyphIndex in the underlying font, using the \a transform specified.
If the QRawFont is not valid, this function will return an invalid QImage.
- If \a antialiasingType is set to QRawFont::SubPixelAntialiasing, then the resulting image will be
- in QImage::Format_RGB32 and the RGB values of each pixel will represent the subpixel opacities of
- the pixel in the rasterization of the glyph. Otherwise, the image will be in the format of
+ If the font is a color font, then the resulting image will contain the rendered
+ glyph at the current pixel size. In this case, the \a antialiasingType will be
+ ignored.
+
+ Otherwise, if \a antialiasingType is set to QRawFont::SubPixelAntialiasing, then the resulting image
+ will be in QImage::Format_RGB32 and the RGB values of each pixel will represent the subpixel opacities
+ of the pixel in the rasterization of the glyph. Otherwise, the image will be in the format of
QImage::Format_Indexed8 and each pixel will contain the opacity of the pixel in the
rasterization.
@@ -275,6 +279,9 @@ QImage QRawFont::alphaMapForGlyph(quint32 glyphIndex, AntialiasingType antialias
if (!d->isValid())
return QImage();
+ if (d->fontEngine->glyphFormat == QFontEngine::Format_ARGB)
+ return d->fontEngine->bitmapForGlyph(glyphIndex, QFixed(), transform);
+
if (antialiasingType == SubPixelAntialiasing)
return d->fontEngine->alphaRGBMapForGlyph(glyphIndex, QFixed(), transform);
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 8a13455ee0..5dbeccff7f 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -928,7 +928,7 @@ void QTextEngine::shapeLine(const QScriptLine &line)
if (item == -1)
return;
- const int end = findItem(line.from + line.length - 1, item);
+ const int end = findItem(line.from + line.length + line.trailingSpaces - 1, item);
for ( ; item <= end; ++item) {
QScriptItem &si = layoutData->items[item];
if (si.analysis.flags == QScriptAnalysis::Tab) {