summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qimage.cpp57
-rw-r--r--src/gui/image/qimage_p.h2
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp8
-rw-r--r--src/gui/text/qdistancefield.cpp4
-rw-r--r--src/gui/text/qfontengine.cpp5
-rw-r--r--src/gui/text/qfontengine_ft.cpp13
-rw-r--r--src/gui/text/qfontengine_ft_p.h1
-rw-r--r--src/gui/text/qfontengine_p.h2
8 files changed, 63 insertions, 29 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index f902f1b715..64a53b4c0e 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -104,35 +104,22 @@ QImageData::QImageData()
{
}
-/*! \fn QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors)
+/*! \fn QImageData * QImageData::create(const QSize &size, QImage::Format format)
\internal
Creates a new image data.
Returns 0 if invalid parameters are give or anything else failed.
*/
-QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors)
+QImageData * QImageData::create(const QSize &size, QImage::Format format)
{
- if (!size.isValid() || numColors < 0 || format == QImage::Format_Invalid)
+ if (!size.isValid() || format == QImage::Format_Invalid)
return 0; // invalid parameter(s)
uint width = size.width();
uint height = size.height();
uint depth = qt_depthForFormat(format);
- switch (format) {
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- numColors = 2;
- break;
- case QImage::Format_Indexed8:
- numColors = qBound(0, numColors, 256);
- break;
- default:
- numColors = 0;
- break;
- }
-
const int bytes_per_line = ((width * depth + 31) >> 5) << 2; // bytes per scanline (must be multiple of 4)
// sanity check for potential overflows
@@ -144,13 +131,16 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu
return 0;
QScopedPointer<QImageData> d(new QImageData);
- d->colortable.resize(numColors);
- if (depth == 1) {
+
+ switch (format) {
+ case QImage::Format_Mono:
+ case QImage::Format_MonoLSB:
+ d->colortable.resize(2);
d->colortable[0] = QColor(Qt::black).rgba();
d->colortable[1] = QColor(Qt::white).rgba();
- } else {
- for (int i = 0; i < numColors; ++i)
- d->colortable[i] = 0;
+ break;
+ default:
+ break;
}
d->width = width;
@@ -779,7 +769,7 @@ QImage::QImage() Q_DECL_NOEXCEPT
QImage::QImage(int width, int height, Format format)
: QPaintDevice()
{
- d = QImageData::create(QSize(width, height), format, 0);
+ d = QImageData::create(QSize(width, height), format);
}
/*!
@@ -794,7 +784,7 @@ QImage::QImage(int width, int height, Format format)
QImage::QImage(const QSize &size, Format format)
: QPaintDevice()
{
- d = QImageData::create(size, format, 0);
+ d = QImageData::create(size, format);
}
@@ -838,6 +828,17 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm
d->cleanupFunction = cleanupFunction;
d->cleanupInfo = cleanupInfo;
+ switch (format) {
+ case QImage::Format_Mono:
+ case QImage::Format_MonoLSB:
+ d->colortable.resize(2);
+ d->colortable[0] = QColor(Qt::black).rgba();
+ d->colortable[1] = QColor(Qt::white).rgba();
+ break;
+ default:
+ break;
+ }
+
return d;
}
@@ -2242,7 +2243,15 @@ QRgb QImage::pixel(int x, int y) const
case Format_MonoLSB:
return d->colortable.at((*(s + (x >> 3)) >> (x & 7)) & 1);
case Format_Indexed8:
- return d->colortable.at((int)s[x]);
+ {
+ int index = (int)s[x];
+ if (index < d->colortable.size()) {
+ return d->colortable.at(index);
+ } else {
+ qWarning("QImage::pixel: color table index %d out of range.", index);
+ return 0;
+ }
+ }
case Format_RGB32:
return 0xff000000 | reinterpret_cast<const QRgb *>(s)[x];
case Format_ARGB32: // Keep old behaviour.
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index 8106289ad1..3e76f39b94 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -63,7 +63,7 @@ class QImageWriter;
struct Q_GUI_EXPORT QImageData { // internal image data
QImageData();
~QImageData();
- static QImageData *create(const QSize &size, QImage::Format format, int numColors = 0);
+ static QImageData *create(const QSize &size, QImage::Format format);
static QImageData *create(uchar *data, int w, int h, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction = 0, void *cleanupInfo = 0);
QAtomicInt ref;
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index 5f5b7f46ec..597d347915 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -1287,9 +1287,13 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ
const char *renderer = reinterpret_cast<const char *>(funcs->glGetString(GL_RENDERER));
const char *ver = reinterpret_cast<const char *>(funcs->glGetString(GL_VERSION));
- // Blacklist PowerVR Rogue G6200 as it has problems with its BGRA support.
+ // Blacklist GPU chipsets that have problems with their BGRA support.
const bool blackListed = (qstrcmp(renderer, "PowerVR Rogue G6200") == 0
- && ::strstr(ver, "1.3") != 0);
+ && ::strstr(ver, "1.3") != 0) ||
+ (qstrcmp(renderer, "Mali-T760") == 0
+ && ::strstr(ver, "3.1") != 0) ||
+ (qstrcmp(renderer, "Mali-T720") == 0
+ && ::strstr(ver, "3.1") != 0);
const bool supports_bgra = has_bgra_ext && !blackListed;
diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp
index 473ddd0172..d90134482d 100644
--- a/src/gui/text/qdistancefield.cpp
+++ b/src/gui/text/qdistancefield.cpp
@@ -693,8 +693,10 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path
static bool imageHasNarrowOutlines(const QImage &im)
{
- if (im.isNull())
+ if (im.isNull() || im.width() < 1 || im.height() < 1)
return false;
+ else if (im.width() == 1 || im.height() == 1)
+ return true;
int minHThick = 999;
int minVThick = 999;
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 96f7e06a47..74317e99c3 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1222,6 +1222,11 @@ int QFontEngine::glyphCount() const
return count;
}
+Qt::HANDLE QFontEngine::handle() const
+{
+ return Q_NULLPTR;
+}
+
const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize)
{
const uchar *header = table;
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 9d62a03f4c..86fb0e8ae4 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1782,6 +1782,12 @@ void QFontEngineFT::unlockAlphaMapForGlyph()
QFontEngine::unlockAlphaMapForGlyph();
}
+static inline bool is2dRotation(const QTransform &t)
+{
+ return qFuzzyCompare(t.m11(), t.m22()) && qFuzzyCompare(t.m12(), -t.m21())
+ && qFuzzyCompare(t.m11()*t.m22() - t.m12()*t.m21(), 1.0);
+}
+
QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g,
QFixed subPixelPosition,
GlyphFormat format,
@@ -1795,7 +1801,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g,
Glyph *glyph = glyphSet != 0 ? glyphSet->getGlyph(g, subPixelPosition) : 0;
if (!glyph || glyph->format != format || (!fetchBoundingBox && !glyph->data)) {
QScopedValueRollback<HintStyle> saved_default_hint_style(default_hint_style);
- if (t.type() >= QTransform::TxScale)
+ if (t.type() >= QTransform::TxScale && !is2dRotation(t))
default_hint_style = HintNone; // disable hinting if the glyphs are transformed
lockFace();
@@ -2007,6 +2013,11 @@ QFontEngine *QFontEngineFT::cloneWithSize(qreal pixelSize) const
}
}
+Qt::HANDLE QFontEngineFT::handle() const
+{
+ return non_locked_face();
+}
+
QT_END_NAMESPACE
#endif // QT_NO_FREETYPE
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index f9b37ff039..3421c873d5 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -288,6 +288,7 @@ private:
void setDefaultHintStyle(HintStyle style) Q_DECL_OVERRIDE;
QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE;
+ Qt::HANDLE handle() const Q_DECL_OVERRIDE;
bool initFromFontEngine(const QFontEngineFT *fontEngine);
HintStyle defaultHintStyle() const { return default_hint_style; }
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 1ef3a360d4..1430444c7e 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -235,6 +235,8 @@ public:
virtual QFontEngine *cloneWithSize(qreal /*pixelSize*/) const { return 0; }
+ virtual Qt::HANDLE handle() const;
+
void *harfbuzzFont() const;
void *harfbuzzFace() const;
bool supportsScript(QChar::Script script) const;