Move the fetch and store pixel functions to qdrawhelper.cpp

These functions have begun showing in the tst_symbols unit test as
"symbol does not start with q". Since they're never called directly,
they're never inlined. Since they were inline, the compiler was probably
deciding to not export them.

Something changed and it could be anything (new compiler version, new
options, etc.). So mark them static.

Change-Id: I838dfc94edd7f09c202743bff0daf9d20c10c3a6
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Thiago Macieira 2012-09-23 10:46:05 +02:00 committed by The Qt Project
parent 1f808a1d1d
commit 5d9a57432e
2 changed files with 111 additions and 113 deletions

View File

@ -250,6 +250,117 @@ static const uint *QT_FASTCALL convertFromARGB32PM(uint *buffer, const uint *src
return buffer;
}
template <QPixelLayout::BPP bpp> static
uint QT_FASTCALL fetchPixel(const uchar *src, int index);
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP1LSB>(const uchar *src, int index)
{
return (src[index >> 3] >> (index & 7)) & 1;
}
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP1MSB>(const uchar *src, int index)
{
return (src[index >> 3] >> (~index & 7)) & 1;
}
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP8>(const uchar *src, int index)
{
return src[index];
}
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP16>(const uchar *src, int index)
{
return reinterpret_cast<const quint16 *>(src)[index];
}
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP24>(const uchar *src, int index)
{
return reinterpret_cast<const quint24 *>(src)[index];
}
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP32>(const uchar *src, int index)
{
return reinterpret_cast<const uint *>(src)[index];
}
template <QPixelLayout::BPP bpp>
inline const uint *QT_FASTCALL fetchPixels(uint *buffer, const uchar *src, int index, int count)
{
for (int i = 0; i < count; ++i)
buffer[i] = fetchPixel<bpp>(src, index + i);
return buffer;
}
template <>
inline const uint *QT_FASTCALL fetchPixels<QPixelLayout::BPP32>(uint *, const uchar *src, int index, int)
{
return reinterpret_cast<const uint *>(src) + index;
}
template <QPixelLayout::BPP width> static
void QT_FASTCALL storePixel(uchar *dest, int index, uint pixel);
template <>
inline void QT_FASTCALL storePixel<QPixelLayout::BPP1LSB>(uchar *dest, int index, uint pixel)
{
if (pixel)
dest[index >> 3] |= 1 << (index & 7);
else
dest[index >> 3] &= ~(1 << (index & 7));
}
template <>
inline void QT_FASTCALL storePixel<QPixelLayout::BPP1MSB>(uchar *dest, int index, uint pixel)
{
if (pixel)
dest[index >> 3] |= 1 << (~index & 7);
else
dest[index >> 3] &= ~(1 << (~index & 7));
}
template <>
inline void QT_FASTCALL storePixel<QPixelLayout::BPP8>(uchar *dest, int index, uint pixel)
{
dest[index] = uchar(pixel);
}
template <>
inline void QT_FASTCALL storePixel<QPixelLayout::BPP16>(uchar *dest, int index, uint pixel)
{
reinterpret_cast<quint16 *>(dest)[index] = quint16(pixel);
}
template <>
inline void QT_FASTCALL storePixel<QPixelLayout::BPP24>(uchar *dest, int index, uint pixel)
{
reinterpret_cast<quint24 *>(dest)[index] = quint24(pixel);
}
template <>
inline void QT_FASTCALL storePixel<QPixelLayout::BPP32>(uchar *dest, int index, uint pixel)
{
reinterpret_cast<uint *>(dest)[index] = pixel;
}
template <QPixelLayout::BPP width>
inline void QT_FASTCALL storePixels(uchar *dest, const uint *src, int index, int count)
{
for (int i = 0; i < count; ++i)
storePixel<width>(dest, index + i, src[i]);
}
template <>
inline void QT_FASTCALL storePixels<QPixelLayout::BPP32>(uchar *dest, const uint *src, int index, int count)
{
memcpy(reinterpret_cast<uint *>(dest) + index, src, count * sizeof(uint));
}
// Note:
// convertToArgb32() assumes that no color channel is less than 4 bits.
// convertFromArgb32() assumes that no color channel is more than 8 bits.

View File

@ -996,120 +996,7 @@ struct QPixelLayout
ConvertFunc convertFromARGB32PM;
};
template <QPixelLayout::BPP bpp>
uint QT_FASTCALL fetchPixel(const uchar *src, int index);
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP1LSB>(const uchar *src, int index)
{
return (src[index >> 3] >> (index & 7)) & 1;
}
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP1MSB>(const uchar *src, int index)
{
return (src[index >> 3] >> (~index & 7)) & 1;
}
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP8>(const uchar *src, int index)
{
return src[index];
}
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP16>(const uchar *src, int index)
{
return reinterpret_cast<const quint16 *>(src)[index];
}
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP24>(const uchar *src, int index)
{
return reinterpret_cast<const quint24 *>(src)[index];
}
template <>
inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP32>(const uchar *src, int index)
{
return reinterpret_cast<const uint *>(src)[index];
}
template <QPixelLayout::BPP bpp>
inline const uint *QT_FASTCALL fetchPixels(uint *buffer, const uchar *src, int index, int count)
{
for (int i = 0; i < count; ++i)
buffer[i] = fetchPixel<bpp>(src, index + i);
return buffer;
}
template <>
inline const uint *QT_FASTCALL fetchPixels<QPixelLayout::BPP32>(uint *, const uchar *src, int index, int)
{
return reinterpret_cast<const uint *>(src) + index;
}
typedef const uint *(QT_FASTCALL *FetchPixelsFunc)(uint *buffer, const uchar *src, int index, int count);
template <QPixelLayout::BPP width>
void QT_FASTCALL storePixel(uchar *dest, int index, uint pixel);
template <>
inline void QT_FASTCALL storePixel<QPixelLayout::BPP1LSB>(uchar *dest, int index, uint pixel)
{
if (pixel)
dest[index >> 3] |= 1 << (index & 7);
else
dest[index >> 3] &= ~(1 << (index & 7));
}
template <>
inline void QT_FASTCALL storePixel<QPixelLayout::BPP1MSB>(uchar *dest, int index, uint pixel)
{
if (pixel)
dest[index >> 3] |= 1 << (~index & 7);
else
dest[index >> 3] &= ~(1 << (~index & 7));
}
template <>
inline void QT_FASTCALL storePixel<QPixelLayout::BPP8>(uchar *dest, int index, uint pixel)
{
dest[index] = uchar(pixel);
}
template <>
inline void QT_FASTCALL storePixel<QPixelLayout::BPP16>(uchar *dest, int index, uint pixel)
{
reinterpret_cast<quint16 *>(dest)[index] = quint16(pixel);
}
template <>
inline void QT_FASTCALL storePixel<QPixelLayout::BPP24>(uchar *dest, int index, uint pixel)
{
reinterpret_cast<quint24 *>(dest)[index] = quint24(pixel);
}
template <>
inline void QT_FASTCALL storePixel<QPixelLayout::BPP32>(uchar *dest, int index, uint pixel)
{
reinterpret_cast<uint *>(dest)[index] = pixel;
}
template <QPixelLayout::BPP width>
inline void QT_FASTCALL storePixels(uchar *dest, const uint *src, int index, int count)
{
for (int i = 0; i < count; ++i)
storePixel<width>(dest, index + i, src[i]);
}
template <>
inline void QT_FASTCALL storePixels<QPixelLayout::BPP32>(uchar *dest, const uint *src, int index, int count)
{
memcpy(reinterpret_cast<uint *>(dest) + index, src, count * sizeof(uint));
}
typedef void (QT_FASTCALL *StorePixelsFunc)(uchar *dest, const uint *src, int index, int count);
extern QPixelLayout qPixelLayouts[QImage::NImageFormats];