NUM_SUBPIXEL_BITS = 8 //!< Number of subpixel bits used when doing bilinear interpolation.
};
-// \todo [2013-03-26 pyry] Big-endian architectures?
+// \note Algorithm assumes that colors are packed to 32-bit values as dictated by
+// tcu::RGBA::*_SHIFT values.
template<int Channel>
static inline deUint8 getChannel (deUint32 color)
return (deUint8)((color >> (Channel*8)) & 0xff);
}
+#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN)
inline deUint32 readRGBA8Raw (const ConstPixelBufferAccess& src, deUint32 x, deUint32 y)
{
return *(const deUint32*)((const deUint8*)src.getDataPtr() + y*src.getRowPitch() + x*4);
}
+#else
+inline deUint32 readRGBA8Raw (const ConstPixelBufferAccess& src, deUint32 x, deUint32 y)
+{
+ return deReverseBytes32(*(const deUint32*)((const deUint8*)src.getDataPtr() + y*src.getRowPitch() + x*4));
+}
+#endif
inline RGBA readRGBA8 (const ConstPixelBufferAccess& src, deUint32 x, deUint32 y)
{
using std::vector;
-// \todo [2012-12-13 pyry] Big-endian architectures?
-
template<int Channel>
static inline deUint8 getChannel (deUint32 color)
{
return v;
}
+#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN)
template<>
inline deUint32 readUnorm8<4> (const tcu::ConstPixelBufferAccess& src, int x, int y)
{
return *(const deUint32*)((const deUint8*)src.getDataPtr() + src.getRowPitch()*y + x*4);
}
+#endif
template<int NumChannels>
static inline void writeUnorm8 (const tcu::PixelBufferAccess& dst, int x, int y, deUint32 val)
ptr[c] = getChannel(val, c);
}
+#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN)
template<>
inline void writeUnorm8<4> (const tcu::PixelBufferAccess& dst, int x, int y, deUint32 val)
{
*(deUint32*)((deUint8*)dst.getDataPtr() + dst.getRowPitch()*y + x*4) = val;
}
+#endif
static inline float compareColors (deUint32 pa, deUint32 pb, int minErrThreshold)
{
return (int)t;
}
+/*--------------------------------------------------------------------*//*!
+ * \brief Reverse bytes in 32-bit integer (for example MSB -> LSB).
+ * \param a Input value.
+ * \return The input with bytes reversed
+ *//*--------------------------------------------------------------------*/
+DE_INLINE deUint32 deReverseBytes32 (deUint32 v)
+{
+ deUint32 b0 = v << 24;
+ deUint32 b1 = (v & 0x0000ff00) << 8;
+ deUint32 b2 = (v & 0x00ff0000) >> 8;
+ deUint32 b3 = v >> 24;
+ return b0|b1|b2|b3;
+}
+
DE_INLINE deInt32 deSafeMul32 (deInt32 a, deInt32 b)
{
deInt32 res = a * b;