diff options
author | Liang Qi <liang.qi@qt.io> | 2017-01-26 00:37:14 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2017-01-26 00:37:14 +0000 |
commit | 398a7e736cb42ac42f0887989585b1121b7e6e62 (patch) | |
tree | 916854b706b9b057fa1483f76dd48998a8aa28a0 /src/gui/painting | |
parent | 4d3a35f63788fa5ff7a11a5bb7bd6176bd2ac70e (diff) | |
parent | 318b58562ae89453fb98e8145cd0440e14ba60b0 (diff) |
Merge "Merge remote-tracking branch 'origin/5.8' into dev" into refs/staging/dev
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qcolor.cpp | 8 | ||||
-rw-r--r-- | src/gui/painting/qcoregraphics.mm | 2 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 66 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_p.h | 8 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 18 | ||||
-rw-r--r-- | src/gui/painting/qtriangulatingstroker.cpp | 2 |
6 files changed, 54 insertions, 50 deletions
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 6a8091bf8b..9e1785c11d 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -545,12 +545,8 @@ static QStringList get_colornames() \section1 The HSL Color Model - HSL is similar to HSV. Instead of value parameter from HSV, - HSL has the lightness parameter. - The lightness parameter goes from black to color and from color to white. - If you go outside at the night its black or dark gray. At day its colorful but - if you look in a really strong light a things they are going to white and - wash out. + HSL is similar to HSV, however instead of the Value parameter, HSL + specifies a Lightness parameter. \section1 The CMYK Color Model diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm index 34dfd51204..2f09037cfe 100644 --- a/src/gui/painting/qcoregraphics.mm +++ b/src/gui/painting/qcoregraphics.mm @@ -473,6 +473,8 @@ QMacCGContext::QMacCGContext(QPaintDevice *paintDevice) : context(0) context = CGBitmapContextCreate(image->bits(), image->width(), image->height(), 8, image->bytesPerLine(), colorspace, flags); CGContextTranslateCTM(context, 0, image->height()); + const qreal devicePixelRatio = paintDevice->devicePixelRatioF(); + CGContextScaleCTM(context, devicePixelRatio, devicePixelRatio); CGContextScaleCTM(context, 1, -1); } diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 6f82ab871c..021361b738 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -3004,8 +3004,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint sbuf1[buffer_size]; uint sbuf2[buffer_size]; - QRgba64 buf1[buffer_size]; - QRgba64 buf2[buffer_size]; + quint64 buf1[buffer_size]; + quint64 buf2[buffer_size]; QRgba64 *b = buffer; while (length) { int len = qMin(length, buffer_size / 2); @@ -3081,9 +3081,9 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co fx += fdx; } - layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf1, sbuf1, len * 2, clut, 0); if (disty) - layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf2, sbuf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = (fracX & 0x0000ffff); @@ -3101,7 +3101,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co vt = _mm_add_epi16(vt, _mm_srli_si128(vt, 8)); _mm_storel_epi64((__m128i*)(b+i), vt); #else - b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty); + b[i] = interpolate_4_pixels_rgb64((QRgba64 *)buf1 + i*2, (QRgba64 *)buf2 + i*2, distx, disty); #endif fracX += fdx; } @@ -3112,8 +3112,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint sbuf1[buffer_size]; uint sbuf2[buffer_size]; - QRgba64 buf1[buffer_size]; - QRgba64 buf2[buffer_size]; + quint64 buf1[buffer_size]; + quint64 buf2[buffer_size]; QRgba64 *end = buffer + length; QRgba64 *b = buffer; @@ -3221,13 +3221,13 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co fx += fdx; fy += fdy; } - layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0); - layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf1, sbuf1, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf2, sbuf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = (fracX & 0x0000ffff); int disty = (fracY & 0x0000ffff); - b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty); + b[i] = interpolate_4_pixels_rgb64((QRgba64 *)buf1 + i*2, (QRgba64 *)buf2 + i*2, distx, disty); fracX += fdx; fracY += fdy; } @@ -3244,8 +3244,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint sbuf1[buffer_size]; uint sbuf2[buffer_size]; - QRgba64 buf1[buffer_size]; - QRgba64 buf2[buffer_size]; + quint64 buf1[buffer_size]; + quint64 buf2[buffer_size]; QRgba64 *b = buffer; int distxs[buffer_size / 2]; @@ -3293,13 +3293,13 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co fw += fdw; } - layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0); - layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf1, sbuf1, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf2, sbuf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = distxs[i]; int disty = distys[i]; - b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty); + b[i] = interpolate_4_pixels_rgb64((QRgba64 *)buf1 + i*2, (QRgba64 *)buf2 + i*2, distx, disty); } length -= len; @@ -3846,7 +3846,7 @@ void blend_color_generic_rgb64(int count, const QSpan *spans, void *userData) return blend_color_generic(count, spans, userData); } - QRgba64 buffer[buffer_size]; + quint64 buffer[buffer_size]; const QRgba64 color = data->solid.color; while (count--) { @@ -3854,7 +3854,7 @@ void blend_color_generic_rgb64(int count, const QSpan *spans, void *userData) int length = spans->len; while (length) { int l = qMin(buffer_size, length); - QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l); + QRgba64 *dest = op.destFetch64((QRgba64 *)buffer, data->rasterBuffer, x, spans->y, l); op.funcSolid64(dest, l, color, spans->coverage); op.destStore64(data->rasterBuffer, x, spans->y, dest, l); length -= l; @@ -4035,11 +4035,11 @@ public: } }; -class BlendSrcGenericRGB64 : public QBlendBase<QRgba64> +class BlendSrcGenericRGB64 : public QBlendBase<quint64> { public: BlendSrcGenericRGB64(QSpanData *d, const Operator &o) - : QBlendBase<QRgba64>(d, o) + : QBlendBase<quint64>(d, o) { } @@ -4048,20 +4048,20 @@ public: return op.func64 && op.destFetch64 && op.destStore64; } - const QRgba64 *fetch(int x, int y, int len) + const quint64 *fetch(int x, int y, int len) { - dest = op.destFetch64(buffer, data->rasterBuffer, x, y, len); - return op.srcFetch64(src_buffer, &op, data, y, x, len); + dest = (quint64 *)op.destFetch64((QRgba64 *)buffer, data->rasterBuffer, x, y, len); + return (const quint64 *)op.srcFetch64((QRgba64 *)src_buffer, &op, data, y, x, len); } - void process(int, int, int len, int coverage, const QRgba64 *src, int offset) + void process(int, int, int len, int coverage, const quint64 *src, int offset) { - op.func64(dest + offset, src + offset, len, coverage); + op.func64((QRgba64 *)dest + offset, (const QRgba64 *)src + offset, len, coverage); } void store(int x, int y, int len) { - op.destStore64(data->rasterBuffer, x, y, dest, len); + op.destStore64(data->rasterBuffer, x, y, (QRgba64 *)dest, len); } }; @@ -4140,8 +4140,8 @@ static void blend_untransformed_generic_rgb64(int count, const QSpan *spans, voi qWarning("Unsupported blend"); return blend_untransformed_generic(count, spans, userData); } - QRgba64 buffer[buffer_size]; - QRgba64 src_buffer[buffer_size]; + quint64 buffer[buffer_size]; + quint64 src_buffer[buffer_size]; const int image_width = data->texture.width; const int image_height = data->texture.height; @@ -4165,8 +4165,8 @@ static void blend_untransformed_generic_rgb64(int count, const QSpan *spans, voi const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; while (length) { int l = qMin(buffer_size, length); - const QRgba64 *src = op.srcFetch64(src_buffer, &op, data, sy, sx, l); - QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l); + const QRgba64 *src = op.srcFetch64((QRgba64 *)src_buffer, &op, data, sy, sx, l); + QRgba64 *dest = op.destFetch64((QRgba64 *)buffer, data->rasterBuffer, x, spans->y, l); op.func64(dest, src, l, coverage); op.destStore64(data->rasterBuffer, x, spans->y, dest, l); x += l; @@ -4381,8 +4381,8 @@ static void blend_tiled_generic_rgb64(int count, const QSpan *spans, void *userD qDebug("unsupported rgb64 blend"); return blend_tiled_generic(count, spans, userData); } - QRgba64 buffer[buffer_size]; - QRgba64 src_buffer[buffer_size]; + quint64 buffer[buffer_size]; + quint64 src_buffer[buffer_size]; const int image_width = data->texture.width; const int image_height = data->texture.height; @@ -4409,8 +4409,8 @@ static void blend_tiled_generic_rgb64(int count, const QSpan *spans, void *userD int l = qMin(image_width - sx, length); if (buffer_size < l) l = buffer_size; - const QRgba64 *src = op.srcFetch64(src_buffer, &op, data, sy, sx, l); - QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l); + const QRgba64 *src = op.srcFetch64((QRgba64 *)src_buffer, &op, data, sy, sx, l); + QRgba64 *dest = op.destFetch64((QRgba64 *)buffer, data->rasterBuffer, x, spans->y, l); op.func64(dest, src, l, coverage); op.destStore64(data->rasterBuffer, x, spans->y, dest, l); x += l; diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index f35b763f93..cf2213042d 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -64,6 +64,8 @@ #include "private/qrasterdefs_p.h" #include <private/qsimd_p.h> +#include <QtCore/qsharedpointer.h> + QT_BEGIN_NAMESPACE #if defined(Q_CC_GNU) @@ -334,7 +336,11 @@ struct QSpanData QGradientData gradient; QTextureData texture; }; - QExplicitlySharedDataPointer<const QSharedData> cachedGradient; + class Pinnable { + protected: + ~Pinnable() {} + }; // QSharedPointer<const void> is not supported + QSharedPointer<const Pinnable> cachedGradient; void init(QRasterBuffer *rb, const QRasterPaintEngine *pe); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 68b8d78ac6..09177db2ab 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4183,7 +4183,7 @@ void QRasterBuffer::flushToARGBImage(QImage *target) const class QGradientCache { public: - struct CacheInfo : public QSharedData + struct CacheInfo : QSpanData::Pinnable { inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) : stops(qMove(s)), opacity(op), interpolationMode(mode) {} @@ -4194,9 +4194,9 @@ public: QGradient::InterpolationMode interpolationMode; }; - typedef QMultiHash<quint64, QExplicitlySharedDataPointer<const CacheInfo> > QGradientColorTableHash; + typedef QMultiHash<quint64, QSharedPointer<const CacheInfo>> QGradientColorTableHash; - inline QExplicitlySharedDataPointer<const CacheInfo> getBuffer(const QGradient &gradient, int opacity) { + inline QSharedPointer<const CacheInfo> getBuffer(const QGradient &gradient, int opacity) { quint64 hash_val = 0; const QGradientStops stops = gradient.stops(); @@ -4210,7 +4210,7 @@ public: return addCacheElement(hash_val, gradient, opacity); else { do { - const QExplicitlySharedDataPointer<const CacheInfo> &cache_info = it.value(); + const auto &cache_info = it.value(); if (cache_info->stops == stops && cache_info->opacity == opacity && cache_info->interpolationMode == gradient.interpolationMode()) return cache_info; ++it; @@ -4226,12 +4226,12 @@ protected: inline void generateGradientColorTable(const QGradient& g, QRgba64 *colorTable, int size, int opacity) const; - QExplicitlySharedDataPointer<const CacheInfo> addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) { + QSharedPointer<const CacheInfo> addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) { if (cache.size() == maxCacheSize()) { // may remove more than 1, but OK cache.erase(cache.begin() + (qrand() % maxCacheSize())); } - QExplicitlySharedDataPointer<CacheInfo> cache_entry(new CacheInfo (gradient.stops(), opacity, gradient.interpolationMode())); + auto cache_entry = QSharedPointer<CacheInfo>::create(gradient.stops(), opacity, gradient.interpolationMode()); generateGradientColorTable(gradient, cache_entry->buffer64, paletteSize(), opacity); for (int i = 0; i < GRADIENT_STOPTABLE_SIZE; ++i) cache_entry->buffer32[i] = cache_entry->buffer64[i].toArgb32(); @@ -4471,7 +4471,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QLinearGradient *g = static_cast<const QLinearGradient *>(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QExplicitlySharedDataPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); cachedGradient = cacheInfo; gradient.colorTable32 = cacheInfo->buffer32; gradient.colorTable64 = cacheInfo->buffer64; @@ -4493,7 +4493,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QRadialGradient *g = static_cast<const QRadialGradient *>(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QExplicitlySharedDataPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); cachedGradient = cacheInfo; gradient.colorTable32 = cacheInfo->buffer32; gradient.colorTable64 = cacheInfo->buffer64; @@ -4519,7 +4519,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QConicalGradient *g = static_cast<const QConicalGradient *>(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QExplicitlySharedDataPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); cachedGradient = cacheInfo; gradient.colorTable32 = cacheInfo->buffer32; gradient.colorTable64 = cacheInfo->buffer64; diff --git a/src/gui/painting/qtriangulatingstroker.cpp b/src/gui/painting/qtriangulatingstroker.cpp index d9a3231165..6243f1e2a4 100644 --- a/src/gui/painting/qtriangulatingstroker.cpp +++ b/src/gui/painting/qtriangulatingstroker.cpp @@ -321,7 +321,7 @@ void QTriangulatingStroker::cubicTo(const qreal *pts) if (threshold < 4) threshold = 4; qreal threshold_minus_1 = threshold - 1; - float vx, vy; + float vx = 0, vy = 0; float cx = m_cx, cy = m_cy; float x, y; |