Commit 3b9bb72b by Jamie Madill

Add a cross-platform rotl implementation.

The _rotl method is unavailable on any platform but Windows, so we can implement the method ourselves. BUG=angle:773 Change-Id: I1342f4cf8a996daf11a36553c3bf7a01a2b182b3 Reviewed-on: https://chromium-review.googlesource.com/238500Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent dff56337
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <limits> #include <limits>
#include <algorithm> #include <algorithm>
#include <string.h> #include <string.h>
#include <stdlib.h>
namespace gl namespace gl
{ {
...@@ -563,6 +564,21 @@ inline bool IsIntegerCastSafe(BigIntT bigValue) ...@@ -563,6 +564,21 @@ inline bool IsIntegerCastSafe(BigIntT bigValue)
return (static_cast<BigIntT>(static_cast<SmallIntT>(bigValue)) == bigValue); return (static_cast<BigIntT>(static_cast<SmallIntT>(bigValue)) == bigValue);
} }
#if defined(_MSC_VER)
#define ANGLE_ROTL(x,y) _rotl(x,y)
#else
inline uint32_t RotL(uint32_t x, int8_t r)
{
return (x << r) | (x >> (32 - r));
}
#define ANGLE_ROTL(x,y) RotL(x,y)
#endif // namespace rx
} }
#endif // COMMON_MATHUTIL_H_ #endif // COMMON_MATHUTIL_H_
...@@ -342,7 +342,7 @@ void LoadRGBA8ToBGRA8(size_t width, size_t height, size_t depth, ...@@ -342,7 +342,7 @@ void LoadRGBA8ToBGRA8(size_t width, size_t height, size_t depth,
for (size_t x = 0; x < width; x++) for (size_t x = 0; x < width; x++)
{ {
uint32_t rgba = source[x]; uint32_t rgba = source[x];
dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00); dest[x] = (ANGLE_ROTL(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00);
} }
} }
} }
......
...@@ -88,7 +88,7 @@ void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth, ...@@ -88,7 +88,7 @@ void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth,
for (; ((reinterpret_cast<intptr_t>(&dest[x]) & 15) != 0) && x < width; x++) for (; ((reinterpret_cast<intptr_t>(&dest[x]) & 15) != 0) && x < width; x++)
{ {
uint32_t rgba = source[x]; uint32_t rgba = source[x];
dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00); dest[x] = (ANGLE_ROTL(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00);
} }
for (; x + 3 < width; x += 4) for (; x + 3 < width; x += 4)
...@@ -108,7 +108,7 @@ void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth, ...@@ -108,7 +108,7 @@ void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth,
for (; x < width; x++) for (; x < width; x++)
{ {
uint32_t rgba = source[x]; uint32_t rgba = source[x];
dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00); dest[x] = (ANGLE_ROTL(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment