diff options
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/painting.pri | 9 | ||||
-rw-r--r-- | src/gui/painting/qcolor.cpp | 43 | ||||
-rw-r--r-- | src/gui/painting/qcolor.h | 3 | ||||
-rw-r--r-- | src/gui/painting/qcolor_p.cpp | 12 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 2 |
5 files changed, 57 insertions, 12 deletions
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 47ba27d72a..aadcc0f686 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -91,9 +91,12 @@ SSE2_SOURCES += painting/qdrawhelper_sse2.cpp SSSE3_SOURCES += painting/qdrawhelper_ssse3.cpp IWMMXT_SOURCES += painting/qdrawhelper_iwmmxt.cpp AVX_SOURCES += painting/qdrawhelper_avx.cpp -NEON_SOURCES += painting/qdrawhelper_neon.cpp -NEON_HEADERS += painting/qdrawhelper_neon_p.h -NEON_ASM += ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S + +!ios { + NEON_SOURCES += painting/qdrawhelper_neon.cpp + NEON_HEADERS += painting/qdrawhelper_neon_p.h + NEON_ASM += ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S +} MIPS_DSP_SOURCES += painting/qdrawhelper_mips_dsp.cpp MIPS_DSP_HEADERS += painting/qdrawhelper_mips_dsp_p.h painting/qt_mips_asm_dsp_p.h diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 12ca84d8d1..c93320c491 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -90,7 +90,8 @@ QT_BEGIN_NAMESPACE specified. A color can be set by passing an RGB string (such as "#112233"), - or a color name (such as "blue"), to the setNamedColor() function. + or an ARGB string (such as "#ff112233") or a color name (such as "blue"), + to the setNamedColor() function. The color names are taken from the SVG 1.0 color names. The name() function returns the name of the color in the format "#RRGGBB". Colors can also be set using setRgb(), setHsv() and @@ -301,6 +302,17 @@ QT_BEGIN_NAMESPACE */ /*! + \enum QColor::NameFormat + + How to format the output of the name() function + + \value HexRgb #RRGGBB A "#" character followed by three two-digit hexadecimal numbers (i.e. \c{#RRGGBB}). + \value HexArgb #AARRGGBB A "#" character followed by four two-digit hexadecimal numbers (i.e. \c{#AARRGGBB}). + + \sa name() +*/ + +/*! \fn Spec QColor::spec() const Returns how the color was specified. @@ -489,8 +501,28 @@ QColor::QColor(Spec spec) QString QColor::name() const { + return name(HexRgb); +} + +/*! + \since 5.2 + + Returns the name of the color in the specified \a format. + + \sa setNamedColor(), NameFormat +*/ + +QString QColor::name(NameFormat format) const +{ QString s; - s.sprintf("#%02x%02x%02x", red(), green(), blue()); + switch (format) { + case HexRgb: + s.sprintf("#%02x%02x%02x", red(), green(), blue()); + break; + case HexArgb: + s.sprintf("#%02x%02x%02x%02x", alpha(), red(), green(), blue()); + break; + } return s; } @@ -501,6 +533,7 @@ QString QColor::name() const \list \li #RGB (each of R, G, and B is a single hex digit) \li #RRGGBB + \li #AARRGGBB (Since 5.2) \li #RRRGGGBBB \li #RRRRGGGGBBBB \li A name from the list of colors defined in the list of \l{http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color keyword names} @@ -545,9 +578,9 @@ bool QColor::setColorFromString(const QString &name) } if (name.startsWith(QLatin1Char('#'))) { - QRgb rgb; - if (qt_get_hex_rgb(name.constData(), name.length(), &rgb)) { - setRgb(rgb); + QRgb rgba; + if (qt_get_hex_rgb(name.constData(), name.length(), &rgba)) { + setRgba(rgba); return true; } else { invalidate(); diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index ef3503e8d8..1ede5a3682 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -65,6 +65,7 @@ class Q_GUI_EXPORT QColor { public: enum Spec { Invalid, Rgb, Hsv, Cmyk, Hsl }; + enum NameFormat { HexRgb, HexArgb }; QColor(); QColor(Qt::GlobalColor color); @@ -77,7 +78,9 @@ public: bool isValid() const; + // ### Qt 6: merge overloads QString name() const; + QString name(NameFormat format) const; void setNamedColor(const QString& name); static QStringList colorNames(); diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp index 35e607ec54..b913f5338c 100644 --- a/src/gui/painting/qcolor_p.cpp +++ b/src/gui/painting/qcolor_p.cpp @@ -79,7 +79,8 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb) return false; name++; int len = qstrlen(name); - int r, g, b; + int a, r, g, b; + a = 255; if (len == 12) { r = hex2int(name); g = hex2int(name + 4); @@ -88,6 +89,11 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb) r = hex2int(name); g = hex2int(name + 3); b = hex2int(name + 6); + } else if (len == 8) { + a = hex2int(name); + r = hex2int(name + 2); + g = hex2int(name + 4); + b = hex2int(name + 6); } else if (len == 6) { r = hex2int(name); g = hex2int(name + 2); @@ -99,11 +105,11 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb) } else { r = g = b = -1; } - if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255) { + if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255 || (uint)a > 255) { *rgb = 0; return false; } - *rgb = qRgb(r, g ,b); + *rgb = qRgba(r, g ,b, a); return true; } diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 628d12d881..651949192b 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6162,7 +6162,7 @@ void qInitDrawhelperAsm() } #endif // IWMMXT -#if defined(QT_COMPILER_SUPPORTS_NEON) +#if defined(QT_COMPILER_SUPPORTS_NEON) && !defined(Q_OS_IOS) if (features & NEON) { qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon; qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon; |