Use qsizetype for qt_memfill functions

Just in case the image is larger than 2 GB (512 megapixels).

Change-Id: I343f2beed55440a7ac0bfffd15636cbc68dfa13d
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 1e2bf51d3e)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Thiago Macieira 2018-11-02 14:44:13 -07:00 committed by Allan Sandfeld Jensen
parent 92f4523c8a
commit f8d41309c8
8 changed files with 32 additions and 29 deletions

View File

@ -6278,7 +6278,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
#if defined(Q_CC_MSVC) && !defined(_MIPS_)
template <class T>
inline void qt_memfill_template(T *dest, T color, int count)
inline void qt_memfill_template(T *dest, T color, qsizetype count)
{
while (count--)
*dest++ = color;
@ -6287,9 +6287,12 @@ inline void qt_memfill_template(T *dest, T color, int count)
#else
template <class T>
inline void qt_memfill_template(T *dest, T color, int count)
inline void qt_memfill_template(T *dest, T color, qsizetype count)
{
int n = (count + 7) / 8;
if (!count)
return;
qsizetype n = (count + 7) / 8;
switch (count & 0x07)
{
case 0: do { *dest++ = color; Q_FALLTHROUGH();
@ -6305,7 +6308,7 @@ inline void qt_memfill_template(T *dest, T color, int count)
}
template <>
inline void qt_memfill_template(quint16 *dest, quint16 value, int count)
inline void qt_memfill_template(quint16 *dest, quint16 value, qsizetype count)
{
if (count < 3) {
switch (count) {
@ -6327,19 +6330,19 @@ inline void qt_memfill_template(quint16 *dest, quint16 value, int count)
}
#endif
void qt_memfill64(quint64 *dest, quint64 color, int count)
void qt_memfill64(quint64 *dest, quint64 color, qsizetype count)
{
qt_memfill_template<quint64>(dest, color, count);
}
#if !defined(__SSE2__)
void qt_memfill16(quint16 *dest, quint16 color, int count)
void qt_memfill16(quint16 *dest, quint16 color, qsizetype count)
{
qt_memfill_template<quint16>(dest, color, count);
}
#endif
#if !defined(__SSE2__) && !defined(__ARM_NEON__) && !defined(__MIPS_DSP__)
void qt_memfill32(quint32 *dest, quint32 color, int count)
void qt_memfill32(quint32 *dest, quint32 color, qsizetype count)
{
qt_memfill_template<quint32>(dest, color, count);
}

View File

@ -43,7 +43,7 @@
QT_BEGIN_NAMESPACE
void qt_memfill32(quint32 *dest, quint32 color, int count)
void qt_memfill32(quint32 *dest, quint32 color, qsizetype count)
{
qt_memfill32_asm_mips_dsp(dest, color, count);
}

View File

@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
#if defined(QT_COMPILER_SUPPORTS_MIPS_DSP)
extern "C" void qt_memfill32_asm_mips_dsp(quint32 *dest, quint32 value, int count);
extern "C" void qt_memfill32_asm_mips_dsp(quint32 *dest, quint32 value, qsizetype count);
extern "C" void comp_func_SourceOver_asm_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha);

View File

@ -47,7 +47,7 @@
QT_BEGIN_NAMESPACE
void qt_memfill32(quint32 *dest, quint32 value, int count)
void qt_memfill32(quint32 *dest, quint32 value, qsizetype count)
{
const int epilogueSize = count % 16;
#if defined(Q_CC_GHS) || defined(Q_CC_MSVC)

View File

@ -123,7 +123,7 @@ void qt_transform_image_rgb16_on_rgb16_neon(uchar *destPixels, int dbpl,
const QTransform &targetRectTransform,
int const_alpha);
void qt_memfill32_neon(quint32 *dest, quint32 value, int count);
void qt_memfill32_neon(quint32 *dest, quint32 value, qsizetype count);
void qt_memrotate90_16_neon(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl);
void qt_memrotate270_16_neon(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl);

View File

@ -163,9 +163,9 @@ extern SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::N
extern DrawHelper qDrawHelper[QImage::NImageFormats];
void qBlendTexture(int count, const QSpan *spans, void *userData);
extern void qt_memfill64(quint64 *dest, quint64 value, int count);
extern void qt_memfill32(quint32 *dest, quint32 value, int count);
extern void qt_memfill16(quint16 *dest, quint16 value, int count);
extern void qt_memfill64(quint64 *dest, quint64 value, qsizetype count);
extern void qt_memfill32(quint32 *dest, quint32 value, qsizetype count);
extern void qt_memfill16(quint16 *dest, quint16 value, qsizetype count);
typedef void (QT_FASTCALL *CompositionFunction)(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha);
typedef void (QT_FASTCALL *CompositionFunction64)(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha);
@ -888,35 +888,35 @@ inline quint24::operator uint() const
}
template <class T> Q_STATIC_TEMPLATE_FUNCTION
void qt_memfill(T *dest, T value, int count);
void qt_memfill(T *dest, T value, qsizetype count);
template<> inline void qt_memfill(quint64 *dest, quint64 color, int count)
template<> inline void qt_memfill(quint64 *dest, quint64 color, qsizetype count)
{
qt_memfill64(dest, color, count);
}
template<> inline void qt_memfill(quint32 *dest, quint32 color, int count)
template<> inline void qt_memfill(quint32 *dest, quint32 color, qsizetype count)
{
qt_memfill32(dest, color, count);
}
template<> inline void qt_memfill(quint16 *dest, quint16 color, int count)
template<> inline void qt_memfill(quint16 *dest, quint16 color, qsizetype count)
{
qt_memfill16(dest, color, count);
}
template<> inline void qt_memfill(quint8 *dest, quint8 color, int count)
template<> inline void qt_memfill(quint8 *dest, quint8 color, qsizetype count)
{
memset(dest, color, count);
}
template <class T>
inline void qt_memfill(T *dest, T value, int count)
inline void qt_memfill(T *dest, T value, qsizetype count)
{
if (!count)
return;
int n = (count + 7) / 8;
qsizetype n = (count + 7) / 8;
switch (count & 0x07)
{
case 0: do { *dest++ = value; Q_FALLTHROUGH();
@ -937,7 +937,7 @@ inline void qt_rectfill(T *dest, T value,
{
char *d = reinterpret_cast<char*>(dest + x) + y * stride;
if (uint(stride) == (width * sizeof(T))) {
qt_memfill(reinterpret_cast<T*>(d), value, width * height);
qt_memfill(reinterpret_cast<T*>(d), value, qsizetype(width) * height);
} else {
for (int j = 0; j < height; ++j) {
dest = reinterpret_cast<T*>(d);
@ -958,7 +958,7 @@ do { \
/* Duff's device */ \
uint *_d = (uint*)(dest) + length; \
const uint *_s = (uint*)(src) + length; \
int n = ((length) + 7) / 8; \
qsizetype n = ((length) + 7) / 8; \
switch ((length) & 0x07) \
{ \
case 0: do { *--_d = *--_s; Q_FALLTHROUGH(); \
@ -978,7 +978,7 @@ do { \
/* Duff's device */ \
ushort *_d = (ushort*)(dest); \
const ushort *_s = (const ushort*)(src); \
int n = ((length) + 7) / 8; \
qsizetype n = ((length) + 7) / 8; \
switch ((length) & 0x07) \
{ \
case 0: do { *_d++ = *_s++; Q_FALLTHROUGH(); \

View File

@ -233,7 +233,7 @@ void QT_FASTCALL comp_func_Source_sse2(uint *dst, const uint *src, int length, u
}
}
void qt_memfill32(quint32 *dest, quint32 value, int count)
void qt_memfill32(quint32 *dest, quint32 value, qsizetype count)
{
if (count < 7) {
switch (count) {
@ -263,7 +263,7 @@ void qt_memfill32(quint32 *dest, quint32 value, int count)
}
}
int count128 = count / 4;
qsizetype count128 = count / 4;
__m128i *dst128 = reinterpret_cast<__m128i*>(dest);
__m128i *end128 = dst128 + count128;
const __m128i value128 = _mm_set_epi32(value, value, value, value);
@ -314,7 +314,7 @@ void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, u
}
}
void qt_memfill16(quint16 *dest, quint16 value, int count)
void qt_memfill16(quint16 *dest, quint16 value, qsizetype count)
{
if (count < 3) {
switch (count) {

View File

@ -57,8 +57,8 @@
QT_BEGIN_NAMESPACE
#ifdef __SSE2__
void qt_memfill32(quint32 *dest, quint32 value, int count);
void qt_memfill16(quint16 *dest, quint16 value, int count);
void qt_memfill32(quint32 *dest, quint32 value, qsizetype count);
void qt_memfill16(quint16 *dest, quint16 value, qsizetype count);
void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y,
const QRgba64 &color,
const uchar *src, int width, int height, int stride);