summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpaintengine_raster.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-10-13 15:18:02 +0200
committerLiang Qi <liang.qi@qt.io>2016-10-13 15:18:02 +0200
commit6370c3aa719bd7c1327cef88d263841ba28bb010 (patch)
tree46960631e7abbeaa40e019f6e31c2be5a18e6b92 /src/gui/painting/qpaintengine_raster.cpp
parentb9a32351c8582ede87b6c63967f5c832c0622645 (diff)
parentef416e0faaa83cd122038db397dd24d949c9cafe (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Also bump minimum required Qt version for Android: Ministro updates. Conflicts: src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java src/plugins/platforms/android/androidjnimain.cpp Change-Id: I966f249bebf92da37bfdeb995ad21b027eb03301
Diffstat (limited to 'src/gui/painting/qpaintengine_raster.cpp')
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp53
1 files changed, 27 insertions, 26 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 0edd9125a3..df96a993e3 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -2283,6 +2283,8 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
= QRectF(sr.x() + clippedTargetRect.x() - r.x(), sr.y() + clippedTargetRect.y() - r.y(),
clippedTargetRect.width(), clippedTargetRect.height()).toRect();
+ clippedSourceRect = clippedSourceRect.intersected(img.rect());
+
uint dbpl = d->rasterBuffer->bytesPerLine();
uint sbpl = img.bytesPerLine();
@@ -4147,7 +4149,8 @@ void QRasterBuffer::flushToARGBImage(QImage *target) const
class QGradientCache
{
- struct CacheInfo
+public:
+ struct CacheInfo : public QSharedData
{
inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) :
stops(qMove(s)), opacity(op), interpolationMode(mode) {}
@@ -4158,12 +4161,9 @@ class QGradientCache
QGradient::InterpolationMode interpolationMode;
};
- typedef QMultiHash<quint64, CacheInfo> QGradientColorTableHash;
-
-public:
- typedef QPair<const QRgb *, const QRgba64 *> ColorBufferPair;
+ typedef QMultiHash<quint64, QExplicitlySharedDataPointer<const CacheInfo> > QGradientColorTableHash;
- inline ColorBufferPair getBuffer(const QGradient &gradient, int opacity) {
+ inline QExplicitlySharedDataPointer<const CacheInfo> getBuffer(const QGradient &gradient, int opacity) {
quint64 hash_val = 0;
const QGradientStops stops = gradient.stops();
@@ -4177,10 +4177,9 @@ public:
return addCacheElement(hash_val, gradient, opacity);
else {
do {
- const CacheInfo &cache_info = it.value();
- if (cache_info.stops == stops && cache_info.opacity == opacity && cache_info.interpolationMode == gradient.interpolationMode())
- return qMakePair(reinterpret_cast<const QRgb *>(cache_info.buffer32),
- reinterpret_cast<const QRgba64 *>(cache_info.buffer64));
+ const QExplicitlySharedDataPointer<const CacheInfo> &cache_info = it.value();
+ if (cache_info->stops == stops && cache_info->opacity == opacity && cache_info->interpolationMode == gradient.interpolationMode())
+ return cache_info;
++it;
} while (it != cache.constEnd() && it.key() == hash_val);
// an exact match for these stops and opacity was not found, create new cache
@@ -4194,18 +4193,16 @@ protected:
inline void generateGradientColorTable(const QGradient& g,
QRgba64 *colorTable,
int size, int opacity) const;
- ColorBufferPair addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) {
+ QExplicitlySharedDataPointer<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()));
}
- CacheInfo cache_entry(gradient.stops(), opacity, gradient.interpolationMode());
- generateGradientColorTable(gradient, cache_entry.buffer64, paletteSize(), opacity);
+ QExplicitlySharedDataPointer<CacheInfo> cache_entry(new CacheInfo (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();
- CacheInfo &cache_value = cache.insert(hash_val, cache_entry).value();
- return qMakePair(reinterpret_cast<const QRgb *>(cache_value.buffer32),
- reinterpret_cast<const QRgba64 *>(cache_value.buffer64));
+ cache_entry->buffer32[i] = cache_entry->buffer64[i].toArgb32();
+ return cache.insert(hash_val, cache_entry).value();
}
QGradientColorTableHash cache;
@@ -4424,6 +4421,7 @@ Q_GUI_EXPORT extern QImage qt_imageForBrush(int brushStyle, bool invert);
void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode)
{
Qt::BrushStyle brushStyle = qbrush_style(brush);
+ cachedGradient.reset();
switch (brushStyle) {
case Qt::SolidPattern: {
type = Solid;
@@ -4440,9 +4438,10 @@ 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;
- QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha);
- gradient.colorTable64 = colorBuffers.second;
- gradient.colorTable32 = colorBuffers.first;
+ QExplicitlySharedDataPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha);
+ cachedGradient = cacheInfo;
+ gradient.colorTable32 = cacheInfo->buffer32;
+ gradient.colorTable64 = cacheInfo->buffer64;
gradient.spread = g->spread();
@@ -4461,9 +4460,10 @@ 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;
- QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha);
- gradient.colorTable64 = colorBuffers.second;
- gradient.colorTable32 = colorBuffers.first;
+ QExplicitlySharedDataPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha);
+ cachedGradient = cacheInfo;
+ gradient.colorTable32 = cacheInfo->buffer32;
+ gradient.colorTable64 = cacheInfo->buffer64;
gradient.spread = g->spread();
@@ -4486,9 +4486,10 @@ 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;
- QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha);
- gradient.colorTable64 = colorBuffers.second;
- gradient.colorTable32 = colorBuffers.first;
+ QExplicitlySharedDataPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha);
+ cachedGradient = cacheInfo;
+ gradient.colorTable32 = cacheInfo->buffer32;
+ gradient.colorTable64 = cacheInfo->buffer64;
gradient.spread = QGradient::RepeatSpread;