From 6528af73e7e3fda1c3abdebac1d9dc13aba8af10 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 13 Aug 2014 12:19:30 +0200 Subject: [PATCH 2/4] Move SubpixelAntialiasingType from QFontEngineFT to QFontEngine To be able to use the SubpixelAntialiasingType enum without depending on QFontEngineFT we need to move it to QFontEngine. The patch also cleans up the left-overs of other enums moved the same way. Change-Id: I025bc8a5b429d376cfab0a643121ed6f99204988 Reviewed-by: Konstantin Ritt (cherry picked from commit 9e1d6eec8eb7e393d1d0cc7efd24629e80b59289) --- src/gui/text/qfontengine_ft.cpp | 12 ++--- src/gui/text/qfontengine_ft_p.h | 8 --- src/gui/text/qfontengine_p.h | 8 +++ .../fontconfig/qfontconfigdatabase.cpp | 60 +++++++++++----------- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index f5ca559..ad4276b 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -813,11 +813,11 @@ int QFontEngineFT::loadFlags(QGlyphSet *set, GlyphFormat format, int flags, if (format == Format_Mono) { load_target = FT_LOAD_TARGET_MONO; } else if (format == Format_A32) { - if (subpixelType == QFontEngineFT::Subpixel_RGB || subpixelType == QFontEngineFT::Subpixel_BGR) { + if (subpixelType == Subpixel_RGB || subpixelType == Subpixel_BGR) { if (default_hint_style == HintFull) load_target = FT_LOAD_TARGET_LCD; hsubpixel = true; - } else if (subpixelType == QFontEngineFT::Subpixel_VRGB || subpixelType == QFontEngineFT::Subpixel_VBGR) { + } else if (subpixelType == Subpixel_VRGB || subpixelType == Subpixel_VBGR) { if (default_hint_style == HintFull) load_target = FT_LOAD_TARGET_LCD_V; vfactor = 3; @@ -977,9 +977,9 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, glyph_buffer = new uchar[glyph_buffer_size]; if (hsubpixel) - convertRGBToARGB(slot->bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, slot->bitmap.pitch, subpixelType != QFontEngineFT::Subpixel_RGB, false); + convertRGBToARGB(slot->bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, slot->bitmap.pitch, subpixelType != Subpixel_RGB, false); else if (vfactor != 1) - convertRGBToARGB_V(slot->bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, slot->bitmap.pitch, subpixelType != QFontEngineFT::Subpixel_VRGB, false); + convertRGBToARGB_V(slot->bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, slot->bitmap.pitch, subpixelType != Subpixel_VRGB, false); } else #endif { @@ -1091,10 +1091,10 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, convoluteBitmap(bitmap.buffer, convoluted, bitmap.width, info.height, bitmap.pitch); buffer = convoluted; } - convertRGBToARGB(buffer + 1, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch, subpixelType != QFontEngineFT::Subpixel_RGB, useLegacyLcdFilter); + convertRGBToARGB(buffer + 1, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch, subpixelType != Subpixel_RGB, useLegacyLcdFilter); delete [] convoluted; } else if (vfactor != 1) { - convertRGBToARGB_V(bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch, subpixelType != QFontEngineFT::Subpixel_VRGB, true); + convertRGBToARGB_V(bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch, subpixelType != Subpixel_VRGB, true); } else if (format == Format_A32 && bitmap.pixel_mode == FT_PIXEL_MODE_GRAY) { convertGRAYToARGB(bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch); } diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 8bdf991..ba603b9 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -150,14 +150,6 @@ public: uchar *data; }; - enum SubpixelAntialiasingType { - Subpixel_None, - Subpixel_RGB, - Subpixel_BGR, - Subpixel_VRGB, - Subpixel_VBGR - }; - struct GlyphInfo { unsigned short width; unsigned short height; diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index fc849d7..fdd4785 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -261,6 +261,14 @@ public: }; virtual void setDefaultHintStyle(HintStyle) { } + enum SubpixelAntialiasingType { + Subpixel_None, + Subpixel_RGB, + Subpixel_BGR, + Subpixel_VRGB, + Subpixel_VBGR + }; + private: const Type m_type; diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index e10e10b..d95bcb9 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -517,15 +517,15 @@ QFontEngineMulti *QFontconfigDatabase::fontEngineMulti(QFontEngine *fontEngine, } namespace { -QFontEngineFT::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintingPreference, FcPattern *match) +QFontEngine::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintingPreference, FcPattern *match) { switch (hintingPreference) { case QFont::PreferNoHinting: - return QFontEngineFT::HintNone; + return QFontEngine::HintNone; case QFont::PreferVerticalHinting: - return QFontEngineFT::HintLight; + return QFontEngine::HintLight; case QFont::PreferFullHinting: - return QFontEngineFT::HintFull; + return QFontEngine::HintFull; case QFont::PreferDefaultHinting: break; } @@ -545,21 +545,21 @@ QFontEngineFT::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hint hint_style = FC_HINT_FULL; switch (hint_style) { case FC_HINT_NONE: - return QFontEngineFT::HintNone; + return QFontEngine::HintNone; case FC_HINT_SLIGHT: - return QFontEngineFT::HintLight; + return QFontEngine::HintLight; case FC_HINT_MEDIUM: - return QFontEngineFT::HintMedium; + return QFontEngine::HintMedium; case FC_HINT_FULL: - return QFontEngineFT::HintFull; + return QFontEngine::HintFull; default: Q_UNREACHABLE(); break; } - return QFontEngineFT::HintFull; + return QFontEngine::HintFull; } -QFontEngineFT::SubpixelAntialiasingType subpixelTypeFromMatch(FcPattern *match) +QFontEngine::SubpixelAntialiasingType subpixelTypeFromMatch(FcPattern *match) { int subpixel = FC_RGBA_UNKNOWN; FcPatternGetInteger(match, FC_RGBA, 0, &subpixel); @@ -567,20 +567,20 @@ QFontEngineFT::SubpixelAntialiasingType subpixelTypeFromMatch(FcPattern *match) switch (subpixel) { case FC_RGBA_UNKNOWN: case FC_RGBA_NONE: - return QFontEngineFT::Subpixel_None; + return QFontEngine::Subpixel_None; case FC_RGBA_RGB: - return QFontEngineFT::Subpixel_RGB; + return QFontEngine::Subpixel_RGB; case FC_RGBA_BGR: - return QFontEngineFT::Subpixel_BGR; + return QFontEngine::Subpixel_BGR; case FC_RGBA_VRGB: - return QFontEngineFT::Subpixel_VRGB; + return QFontEngine::Subpixel_VRGB; case FC_RGBA_VBGR: - return QFontEngineFT::Subpixel_VBGR; + return QFontEngine::Subpixel_VBGR; default: Q_UNREACHABLE(); break; } - return QFontEngineFT::Subpixel_None; + return QFontEngine::Subpixel_None; } } // namespace @@ -599,7 +599,7 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, void *usrPtr) bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias); engine = new QFontEngineFT(fontDef); - QFontEngineFT::GlyphFormat format; + QFontEngine::GlyphFormat format; // try and get the pattern FcPattern *pattern = FcPatternCreate(); @@ -634,20 +634,20 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, void *usrPtr) } if (antialias) { - QFontEngineFT::SubpixelAntialiasingType subpixelType = QFontEngineFT::Subpixel_None; + QFontEngine::SubpixelAntialiasingType subpixelType = QFontEngine::Subpixel_None; if (!(f.styleStrategy & QFont::NoSubpixelAntialias)) subpixelType = subpixelTypeFromMatch(match); engine->subpixelType = subpixelType; - format = (subpixelType == QFontEngineFT::Subpixel_None) - ? QFontEngineFT::Format_A8 - : QFontEngineFT::Format_A32; + format = (subpixelType == QFontEngine::Subpixel_None) + ? QFontEngine::Format_A8 + : QFontEngine::Format_A32; } else - format = QFontEngineFT::Format_Mono; + format = QFontEngine::Format_Mono; FcPatternDestroy(match); } else - format = antialias ? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono; + format = antialias ? QFontEngine::Format_A8 : QFontEngine::Format_Mono; FcPatternDestroy(pattern); @@ -667,7 +667,7 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QByteArray &fontData, qreal p QFontDef fontDef = engine->fontDef; - QFontEngineFT::GlyphFormat format; + QFontEngine::GlyphFormat format; // try and get the pattern FcPattern *pattern = FcPatternCreate(); @@ -692,17 +692,17 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QByteArray &fontData, qreal p engine->antialias = fc_antialias; if (engine->antialias) { - QFontEngineFT::SubpixelAntialiasingType subpixelType = subpixelTypeFromMatch(match); + QFontEngine::SubpixelAntialiasingType subpixelType = subpixelTypeFromMatch(match); engine->subpixelType = subpixelType; - format = subpixelType == QFontEngineFT::Subpixel_None - ? QFontEngineFT::Format_A8 - : QFontEngineFT::Format_A32; + format = subpixelType == QFontEngine::Subpixel_None + ? QFontEngine::Format_A8 + : QFontEngine::Format_A32; } else - format = QFontEngineFT::Format_Mono; + format = QFontEngine::Format_Mono; FcPatternDestroy(match); } else - format = QFontEngineFT::Format_A8; + format = QFontEngine::Format_A8; FcPatternDestroy(pattern); -- 2.1.1