diff options
-rw-r--r-- | src/localconsts.h | 2 | ||||
-rw-r--r-- | src/resources/dye.cpp | 18 | ||||
-rw-r--r-- | src/resources/dye.h | 18 |
3 files changed, 23 insertions, 15 deletions
diff --git a/src/localconsts.h b/src/localconsts.h index 4187cefd2..f29068c4c 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -64,11 +64,13 @@ #define A_UNUSED __attribute__ ((unused)) #define A_WARN_UNUSED __attribute__ ((warn_unused_result)) #define DEPRECATED __attribute__ ((deprecated)) +#define restrict __restrict__ #else #define A_UNUSED #define A_WARN_UNUSED #define gnu_printf printf #define DEPRECATED +#define restrict #endif #ifdef __clang__ #define gnu_printf printf diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 5817f66b8..68364dc52 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -197,7 +197,7 @@ void DyePalette::getColor(double intensity, int color[3]) const color[2] = static_cast<int>(rest * b1 + intensity * b2); } -void DyePalette::replaceSColor(uint32_t *pixels, const int bufSize) const +void DyePalette::replaceSColor(uint32_t *restrict pixels, const int bufSize) const { std::vector<DyeColor>::const_iterator it_end = mColors.end(); const int sz = mColors.size(); @@ -253,7 +253,8 @@ void DyePalette::replaceSColor(uint32_t *pixels, const int bufSize) const } } -void DyePalette::replaceAColor(uint32_t *pixels, const int bufSize) const +void DyePalette::replaceAColor(uint32_t *restrict pixels, + const int bufSize) const { std::vector<DyeColor>::const_iterator it_end = mColors.end(); const int sz = mColors.size(); @@ -296,7 +297,8 @@ void DyePalette::replaceAColor(uint32_t *pixels, const int bufSize) const } } -void DyePalette::replaceSOGLColor(uint32_t *pixels, const int bufSize) const +void DyePalette::replaceSOGLColor(uint32_t *restrict pixels, + const int bufSize) const { std::vector<DyeColor>::const_iterator it_end = mColors.end(); const int sz = mColors.size(); @@ -345,7 +347,8 @@ void DyePalette::replaceSOGLColor(uint32_t *pixels, const int bufSize) const } } -void DyePalette::replaceAOGLColor(uint32_t *pixels, const int bufSize) const +void DyePalette::replaceAOGLColor(uint32_t *restrict pixels, + const int bufSize) const { std::vector<DyeColor>::const_iterator it_end = mColors.end(); const int sz = mColors.size(); @@ -444,7 +447,8 @@ Dye::~Dye() } } -void Dye::instantiate(std::string &target, const std::string &palettes) +void Dye::instantiate(std::string &restrict target, + const std::string &restrict palettes) { size_t next_pos = target.find('|'); @@ -503,7 +507,7 @@ int Dye::getType() const return 0; } -void Dye::normalDye(uint32_t *pixels, const int bufSize) const +void Dye::normalDye(uint32_t *restrict pixels, const int bufSize) const { for (uint32_t *p_end = pixels + bufSize; pixels != p_end; ++ pixels) { @@ -556,7 +560,7 @@ void Dye::normalDye(uint32_t *pixels, const int bufSize) const } } -void Dye::normalOGLDye(uint32_t *pixels, const int bufSize) const +void Dye::normalOGLDye(uint32_t *restrict pixels, const int bufSize) const { for (uint32_t *p_end = pixels + bufSize; pixels != p_end; ++ pixels) { diff --git a/src/resources/dye.h b/src/resources/dye.h index c5e60b520..fe3f2a606 100644 --- a/src/resources/dye.h +++ b/src/resources/dye.h @@ -63,22 +63,24 @@ class DyePalette final /** * replace colors for SDL for S dye. */ - void replaceSColor(uint32_t *pixels, const int bufSize) const; + void replaceSColor(uint32_t *restrict pixels, const int bufSize) const; /** * replace colors for SDL for S dye. */ - void replaceAColor(uint32_t *pixels, const int bufSize) const; + void replaceAColor(uint32_t *restrict pixels, const int bufSize) const; /** * replace colors for OpenGL for S dye. */ - void replaceSOGLColor(uint32_t *pixels, const int bufSize) const; + void replaceSOGLColor(uint32_t *restrict pixels, + const int bufSize) const; /** * replace colors for OpenGL for A dye. */ - void replaceAOGLColor(uint32_t *pixels, const int bufSize) const; + void replaceAOGLColor(uint32_t *restrict pixels, + const int bufSize) const; static int hexDecode(const signed char c) A_WARN_UNUSED; @@ -110,8 +112,8 @@ class Dye final /** * Fills the blank in a dye placeholder with some palette names. */ - static void instantiate(std::string &target, - const std::string &palettes); + static void instantiate(std::string &restrict target, + const std::string &restrict palettes); /** * Return special dye palete (S) @@ -130,9 +132,9 @@ class Dye final */ int getType() const A_WARN_UNUSED; - void normalDye(uint32_t *pixels, const int bufSize) const; + void normalDye(uint32_t *restrict pixels, const int bufSize) const; - void normalOGLDye(uint32_t *pixels, const int bufSize) const; + void normalOGLDye(uint32_t *restrict pixels, const int bufSize) const; private: /** |