summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2015-10-22 14:38:44 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-10-22 19:40:19 +0000
commit8ea61d6d2a63e49a7734fe70a2f2ddd2e14f7ca4 (patch)
tree0d08935e3613a72a2ddd49fe2fd5a510fa50d27e /src
parentf343989852b555fd960f5eaae51ece1423ba4373 (diff)
Fix alignment issues on 32 bit in qConvertA2RGB30PMToARGB64PM_sse2 and qConvertARGB32PMToARGB64PM_sse2
On 32 bit platforms the pointers may end up being 4 byte aligned. Happens with MSVC on 32 bit Windows. _mm_store_si128 is documented to require 16 byte alignment. Change-Id: I80737fedf9e7f436a51a83924117cc0bc63017cc Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qdrawhelper.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 64a363868a..6cfc4b9307 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -503,14 +503,16 @@ static const uint *QT_FASTCALL convertRGBA8888PMFromARGB32PM(uint *buffer, const
template<bool RGBA, bool maskAlpha>
static inline void qConvertARGB32PMToARGB64PM_sse2(QRgba64 *buffer, const uint *src, int count)
{
+ if (count <= 0)
+ return;
+
const __m128i amask = _mm_set1_epi32(0xff000000);
int i = 0;
- if (((uintptr_t)buffer & 0xf) && count > 0) {
+ for (; ((uintptr_t)buffer & 0xf) && i < count; ++i) {
uint s = *src++;
if (RGBA)
s = RGBA2ARGB(s);
*buffer++ = QRgba64::fromArgb32(s);
- i++;
}
for (; i < count-3; i += 4) {
__m128i vs = _mm_loadu_si128((const __m128i*)src);
@@ -641,15 +643,18 @@ static const uint *QT_FASTCALL convertA2RGB30PMToARGB32PM(uint *buffer, const ui
template<QtPixelOrder PixelOrder>
static inline void qConvertA2RGB30PMToARGB64PM_sse2(QRgba64 *buffer, const uint *src, int count)
{
+ if (count <= 0)
+ return;
+
const __m128i rmask = _mm_set1_epi32(0x3ff00000);
const __m128i gmask = _mm_set1_epi32(0x000ffc00);
const __m128i bmask = _mm_set1_epi32(0x000003ff);
const __m128i afactor = _mm_set1_epi16(0x5555);
int i = 0;
- if (((uintptr_t)buffer & 0xf) && count > 0) {
+
+ for (; ((uintptr_t)buffer & 0xf) && i < count; ++i)
*buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++);
- i++;
- }
+
for (; i < count-3; i += 4) {
__m128i vs = _mm_loadu_si128((const __m128i*)src);
src += 4;