summaryrefslogtreecommitdiff
path: root/src/resources/dye/dye.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-23 22:01:44 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-23 22:01:44 +0300
commit3c404128c4669a1f4f190e20a89553677717fc50 (patch)
tree2db4e5031089c800c4e00fd6244e578f44a7c910 /src/resources/dye/dye.cpp
parent89b267d6d73bbc59f7c313b8a22b97fbb27f99a8 (diff)
downloadmv-3c404128c4669a1f4f190e20a89553677717fc50.tar.gz
mv-3c404128c4669a1f4f190e20a89553677717fc50.tar.bz2
mv-3c404128c4669a1f4f190e20a89553677717fc50.tar.xz
mv-3c404128c4669a1f4f190e20a89553677717fc50.zip
Add missing comments into defines.
Diffstat (limited to 'src/resources/dye/dye.cpp')
-rw-r--r--src/resources/dye/dye.cpp67
1 files changed, 42 insertions, 25 deletions
diff --git a/src/resources/dye/dye.cpp b/src/resources/dye/dye.cpp
index 3aa42d7e7..e37b2e943 100644
--- a/src/resources/dye/dye.cpp
+++ b/src/resources/dye/dye.cpp
@@ -36,7 +36,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
Dye::Dye(const std::string &restrict description)
{
@@ -164,9 +164,11 @@ void Dye::normalDye(uint32_t *restrict pixels,
const uint32_t p = pixels[ptr];
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int alpha = p & 0xff000000;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int alpha = p & 0xff;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (alpha)
{
unsigned int color[3];
@@ -174,11 +176,13 @@ void Dye::normalDye(uint32_t *restrict pixels,
color[0] = (p) & 255U;
color[1] = (p >> 8U) & 255U;
color[2] = (p >> 16U) & 255U;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
color[0] = (p >> 24U) & 255U;
color[1] = (p >> 16U) & 255U;
color[2] = (p >> 8U) & 255U;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const unsigned int cmax = std::max(
color[0], std::max(color[1], color[2]));
if (cmax == 0)
@@ -205,10 +209,11 @@ void Dye::normalDye(uint32_t *restrict pixels,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
pixels[ptr] = (color[0]) | (color[1] << 8)
| (color[2] << 16) | alpha;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
pixels[ptr] = (color[0] << 24) | (color[1] << 16)
| (color[2] << 8) | alpha;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
endlabel:{}
}
@@ -222,9 +227,11 @@ endlabel:{}
const uint32_t p = *pixels;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int alpha = p & 0xff000000;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int alpha = p & 0xff;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (!alpha)
continue;
unsigned int color[3];
@@ -232,11 +239,12 @@ endlabel:{}
color[0] = (p) & 255U;
color[1] = (p >> 8U) & 255U;
color[2] = (p >> 16U) & 255U;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
color[0] = (p >> 24U) & 255U;
color[1] = (p >> 16U) & 255U;
color[2] = (p >> 8U) & 255U;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
const unsigned int cmax = std::max(
color[0], std::max(color[1], color[2]));
@@ -263,10 +271,11 @@ endlabel:{}
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
*pixels = (color[0]) | (color[1] << 8)
| (color[2] << 16) | alpha;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
*pixels = (color[0] << 24) | (color[1] << 16)
| (color[2] << 8) | alpha;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
#endif // ENABLE_CILKPLUS
}
@@ -283,9 +292,11 @@ void Dye::normalOGLDye(uint32_t *restrict pixels,
const uint32_t p = pixels[ptr];
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int alpha = p & 255;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int alpha = p & 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (alpha)
{
unsigned int color[3];
@@ -293,11 +304,12 @@ void Dye::normalOGLDye(uint32_t *restrict pixels,
color[0] = (p >> 24U) & 255U;
color[1] = (p >> 16U) & 255U;
color[2] = (p >> 8U) & 255U;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
color[0] = (p) & 255U;
color[1] = (p >> 8U) & 255U;
color[2] = (p >> 16U) & 255U;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
const unsigned int cmax = std::max(
color[0], std::max(color[1], color[2]));
@@ -324,10 +336,11 @@ void Dye::normalOGLDye(uint32_t *restrict pixels,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
pixels[ptr] = (color[0] << 24) | (color[1] << 16)
| (color[2] << 8) | alpha;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
pixels[ptr] = (color[0]) | (color[1] << 8)
| (color[2] << 16) | alpha;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
endlabel:{}
}
@@ -341,9 +354,11 @@ endlabel:{}
const uint32_t p = *pixels;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int alpha = p & 255;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int alpha = p & 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
if (!alpha)
continue;
unsigned int color[3];
@@ -351,11 +366,12 @@ endlabel:{}
color[0] = (p >> 24U) & 255U;
color[1] = (p >> 16U) & 255U;
color[2] = (p >> 8U) & 255U;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
color[0] = (p) & 255U;
color[1] = (p >> 8U) & 255U;
color[2] = (p >> 16U) & 255U;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
const unsigned int cmax = std::max(
color[0], std::max(color[1], color[2]));
@@ -382,10 +398,11 @@ endlabel:{}
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
*pixels = (color[0] << 24) | (color[1] << 16)
| (color[2] << 8) | alpha;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
*pixels = (color[0]) | (color[1] << 8)
| (color[2] << 16) | alpha;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
#endif // ENABLE_CILKPLUS
}