diff options
author | Martin Smith <msmith@trolltech.com> | 2010-02-16 07:16:45 (GMT) |
---|---|---|
committer | Martin Smith <msmith@trolltech.com> | 2010-02-16 07:16:45 (GMT) |
commit | 20c00cc256c4c588fdf137de13bdc83d4eb3cc8f (patch) | |
tree | 5f7d86a9737f0254124d81f76ae3e7e41c4588ca /src | |
parent | 791601cf2bef4f097f5da82b95a05fa731118b40 (diff) | |
parent | 1a5c3af0f3e75a518c27c6bdd3f58896a49b167e (diff) | |
download | Qt-20c00cc256c4c588fdf137de13bdc83d4eb3cc8f.zip Qt-20c00cc256c4c588fdf137de13bdc83d4eb3cc8f.tar.gz Qt-20c00cc256c4c588fdf137de13bdc83d4eb3cc8f.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qcontiguouscache.h | 35 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 4 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_sse2.cpp | 127 |
3 files changed, 84 insertions, 82 deletions
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 1f7fdb2..aa5603d 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -221,22 +221,29 @@ void QContiguousCache<T>::setCapacity(int asize) x.d->alloc = asize; x.d->count = qMin(d->count, asize); x.d->offset = d->offset + d->count - x.d->count; - x.d->start = x.d->offset % x.d->alloc; - T *dest = x.p->array + (x.d->start + x.d->count-1) % x.d->alloc; - T *src = p->array + (d->start + d->count-1) % d->alloc; + if(asize) + x.d->start = x.d->offset % x.d->alloc; + else + x.d->start = 0; + int oldcount = x.d->count; - while (oldcount--) { - if (QTypeInfo<T>::isComplex) { - new (dest) T(*src); - } else { - *dest = *src; + if(oldcount) + { + T *dest = x.p->array + (x.d->start + x.d->count-1) % x.d->alloc; + T *src = p->array + (d->start + d->count-1) % d->alloc; + while (oldcount--) { + if (QTypeInfo<T>::isComplex) { + new (dest) T(*src); + } else { + *dest = *src; + } + if (dest == x.p->array) + dest = x.p->array + x.d->alloc; + dest--; + if (src == p->array) + src = p->array + d->alloc; + src--; } - if (dest == x.p->array) - dest = x.p->array + x.d->alloc; - dest--; - if (src == p->array) - src = p->array + d->alloc; - src--; } /* free old */ free(p); diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 96d2435..86aaa78 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5132,6 +5132,8 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool } /*! + \obsolete + Paints the given \a items using the provided \a painter, after the background has been drawn, and before the foreground has been drawn. All painting is done in \e scene coordinates. Before @@ -5154,7 +5156,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool \snippet doc/src/snippets/graphicssceneadditemsnippet.cpp 0 - \obsolete Since Qt 4.6, this function is not called anymore unless + Since Qt 4.6, this function is not called anymore unless the QGraphicsView::IndirectPainting flag is given as an Optimization flag. diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp index 1dba914..6ac64d3 100644 --- a/src/gui/painting/qdrawhelper_sse2.cpp +++ b/src/gui/painting/qdrawhelper_sse2.cpp @@ -63,36 +63,36 @@ QT_BEGIN_NAMESPACE * colorMask must have 0x00ff00ff on each 32 bits component * half must have the value 128 (0x80) for each 32 bits compnent */ -Q_STATIC_INLINE_FUNCTION __m128i BYTE_MUL_SSE2(const __m128i pixelVector, const __m128i alphaChannel, const __m128i colorMask, const __m128i half) -{ - // 1. separate the colors in 2 vectors so each color is on 16 bits - // (in order to be multiplied by the alpha - // each 32 bit of dstVectorAG are in the form 0x00AA00GG - // each 32 bit of dstVectorRB are in the form 0x00RR00BB - __m128i pixelVectorAG = _mm_srli_epi16(pixelVector, 8); - __m128i pixelVectorRB = _mm_and_si128(pixelVector, colorMask); - - // 2. multiply the vectors by the alpha channel - pixelVectorAG = _mm_mullo_epi16(pixelVectorAG, alphaChannel); - pixelVectorRB = _mm_mullo_epi16(pixelVectorRB, alphaChannel); - - // 3. devide by 255, that's the tricky part. - // we do it like for BYTE_MUL(), with bit shift: X/255 ~= (X + X/256 + rounding)/256 - /// so first (X + X/256 + rounding) - pixelVectorRB = _mm_add_epi16(pixelVectorRB, _mm_srli_epi16(pixelVectorRB, 8)); - pixelVectorRB = _mm_add_epi16(pixelVectorRB, half); - pixelVectorAG = _mm_add_epi16(pixelVectorAG, _mm_srli_epi16(pixelVectorAG, 8)); - pixelVectorAG = _mm_add_epi16(pixelVectorAG, half); - - /// second devide by 256 - pixelVectorRB = _mm_srli_epi16(pixelVectorRB, 8); - /// for AG, we could >> 8 to divide followed by << 8 to put the - /// bytes in the correct position. By masking instead, we execute - /// only one instruction - pixelVectorAG = _mm_andnot_si128(colorMask, pixelVectorAG); - - // 4. combine the 2 pairs of colors - return _mm_or_si128(pixelVectorAG, pixelVectorRB); +#define BYTE_MUL_SSE2(result, pixelVector, alphaChannel, colorMask, half) \ +{ \ + /* 1. separate the colors in 2 vectors so each color is on 16 bits \ + (in order to be multiplied by the alpha \ + each 32 bit of dstVectorAG are in the form 0x00AA00GG \ + each 32 bit of dstVectorRB are in the form 0x00RR00BB */\ + __m128i pixelVectorAG = _mm_srli_epi16(pixelVector, 8); \ + __m128i pixelVectorRB = _mm_and_si128(pixelVector, colorMask); \ + \ + /* 2. multiply the vectors by the alpha channel */\ + pixelVectorAG = _mm_mullo_epi16(pixelVectorAG, alphaChannel); \ + pixelVectorRB = _mm_mullo_epi16(pixelVectorRB, alphaChannel); \ + \ + /* 3. devide by 255, that's the tricky part. \ + we do it like for BYTE_MUL(), with bit shift: X/255 ~= (X + X/256 + rounding)/256 */ \ + /** so first (X + X/256 + rounding) */\ + pixelVectorRB = _mm_add_epi16(pixelVectorRB, _mm_srli_epi16(pixelVectorRB, 8)); \ + pixelVectorRB = _mm_add_epi16(pixelVectorRB, half); \ + pixelVectorAG = _mm_add_epi16(pixelVectorAG, _mm_srli_epi16(pixelVectorAG, 8)); \ + pixelVectorAG = _mm_add_epi16(pixelVectorAG, half); \ + \ + /** second devide by 256 */\ + pixelVectorRB = _mm_srli_epi16(pixelVectorRB, 8); \ + /** for AG, we could >> 8 to divide followed by << 8 to put the \ + bytes in the correct position. By masking instead, we execute \ + only one instruction */\ + pixelVectorAG = _mm_andnot_si128(colorMask, pixelVectorAG); \ + \ + /* 4. combine the 2 pairs of colors */ \ + result = _mm_or_si128(pixelVectorAG, pixelVectorRB); \ } /* @@ -101,34 +101,29 @@ Q_STATIC_INLINE_FUNCTION __m128i BYTE_MUL_SSE2(const __m128i pixelVector, const * colorMask must have 0x00ff00ff on each 32 bits component * half must have the value 128 (0x80) for each 32 bits compnent */ -Q_STATIC_INLINE_FUNCTION __m128i INTERPOLATE_PIXEL_255_SSE2(const __m128i srcVector, - const __m128i dstVector, - const __m128i alphaChannel, - const __m128i oneMinusAlphaChannel , - const __m128i colorMask, - const __m128i half) { - // interpolate AG - __m128i srcVectorAG = _mm_srli_epi16(srcVector, 8); - __m128i dstVectorAG = _mm_srli_epi16(dstVector, 8); - __m128i srcVectorAGalpha = _mm_mullo_epi16(srcVectorAG, alphaChannel); - __m128i dstVectorAGoneMinusAlphalpha = _mm_mullo_epi16(dstVectorAG, oneMinusAlphaChannel); - __m128i finalAG = _mm_add_epi16(srcVectorAGalpha, dstVectorAGoneMinusAlphalpha); - finalAG = _mm_add_epi16(finalAG, _mm_srli_epi16(finalAG, 8)); - finalAG = _mm_add_epi16(finalAG, half); - finalAG = _mm_andnot_si128(colorMask, finalAG); - - // interpolate RB - __m128i srcVectorRB = _mm_and_si128(srcVector, colorMask); - __m128i dstVectorRB = _mm_and_si128(dstVector, colorMask); - __m128i srcVectorRBalpha = _mm_mullo_epi16(srcVectorRB, alphaChannel); - __m128i dstVectorRBoneMinusAlphalpha = _mm_mullo_epi16(dstVectorRB, oneMinusAlphaChannel); - __m128i finalRB = _mm_add_epi16(srcVectorRBalpha, dstVectorRBoneMinusAlphalpha); - finalRB = _mm_add_epi16(finalRB, _mm_srli_epi16(finalRB, 8)); - finalRB = _mm_add_epi16(finalRB, half); - finalRB = _mm_srli_epi16(finalRB, 8); - - // combine - return _mm_or_si128(finalAG, finalRB); +#define INTERPOLATE_PIXEL_255_SSE2(result, srcVector, dstVector, alphaChannel, oneMinusAlphaChannel, colorMask, half) { \ + /* interpolate AG */\ + __m128i srcVectorAG = _mm_srli_epi16(srcVector, 8); \ + __m128i dstVectorAG = _mm_srli_epi16(dstVector, 8); \ + __m128i srcVectorAGalpha = _mm_mullo_epi16(srcVectorAG, alphaChannel); \ + __m128i dstVectorAGoneMinusAlphalpha = _mm_mullo_epi16(dstVectorAG, oneMinusAlphaChannel); \ + __m128i finalAG = _mm_add_epi16(srcVectorAGalpha, dstVectorAGoneMinusAlphalpha); \ + finalAG = _mm_add_epi16(finalAG, _mm_srli_epi16(finalAG, 8)); \ + finalAG = _mm_add_epi16(finalAG, half); \ + finalAG = _mm_andnot_si128(colorMask, finalAG); \ + \ + /* interpolate RB */\ + __m128i srcVectorRB = _mm_and_si128(srcVector, colorMask); \ + __m128i dstVectorRB = _mm_and_si128(dstVector, colorMask); \ + __m128i srcVectorRBalpha = _mm_mullo_epi16(srcVectorRB, alphaChannel); \ + __m128i dstVectorRBoneMinusAlphalpha = _mm_mullo_epi16(dstVectorRB, oneMinusAlphaChannel); \ + __m128i finalRB = _mm_add_epi16(srcVectorRBalpha, dstVectorRBoneMinusAlphalpha); \ + finalRB = _mm_add_epi16(finalRB, _mm_srli_epi16(finalRB, 8)); \ + finalRB = _mm_add_epi16(finalRB, half); \ + finalRB = _mm_srli_epi16(finalRB, 8); \ + \ + /* combine */\ + result = _mm_or_si128(finalAG, finalRB); \ } void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, @@ -165,7 +160,8 @@ void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, alphaChannel = _mm_sub_epi16(one, alphaChannel); const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); - const __m128i destMultipliedByOneMinusAlpha = BYTE_MUL_SSE2(dstVector, alphaChannel, colorMask, half); + __m128i destMultipliedByOneMinusAlpha; + BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half); // result = s + d * (1-alpha) const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha); @@ -197,14 +193,15 @@ void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, for (; x < w-3; x += 4) { __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]); if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) { - srcVector = BYTE_MUL_SSE2(srcVector, constAlphaVector, colorMask, half); + BYTE_MUL_SSE2(srcVector, srcVector, constAlphaVector, colorMask, half); __m128i alphaChannel = _mm_srli_epi32(srcVector, 24); alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); alphaChannel = _mm_sub_epi16(one, alphaChannel); const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); - const __m128i destMultipliedByOneMinusAlpha = BYTE_MUL_SSE2(dstVector, alphaChannel, colorMask, half); + __m128i destMultipliedByOneMinusAlpha; + BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half); const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha); _mm_storeu_si128((__m128i *)&dst[x], result); @@ -252,12 +249,8 @@ void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]); if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) { const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); - const __m128i result = INTERPOLATE_PIXEL_255_SSE2(srcVector, - dstVector, - constAlphaVector, - oneMinusConstAlpha, - colorMask, - half); + __m128i result; + INTERPOLATE_PIXEL_255_SSE2(result, srcVector, dstVector, constAlphaVector, oneMinusConstAlpha, colorMask, half); _mm_storeu_si128((__m128i *)&dst[x], result); } } |