From 3480f3ad939e2ae5d0191ed739a57e834658c32e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 24 May 2017 22:58:07 +0300 Subject: Switch in replaceSColor into using custom despatcher. --- src/resources/dye/dyepalette.h | 55 +++++++++++------------------------------- 1 file changed, 14 insertions(+), 41 deletions(-) (limited to 'src/resources/dye/dyepalette.h') diff --git a/src/resources/dye/dyepalette.h b/src/resources/dye/dyepalette.h index d869e39c6..da165305e 100644 --- a/src/resources/dye/dyepalette.h +++ b/src/resources/dye/dyepalette.h @@ -25,11 +25,19 @@ #include "resources/dye/dyecolor.h" +#include "resources/dye/dyepaletteptr.h" + #include #include #include "localconsts.h" +#define DYEPALETTE(palette, color) \ + ((palette).*DyePalette::funcReplace##color) + +#define DYEPALETTEP(palette, color) \ + ((palette)->*DyePalette::funcReplace##color) + /** * Class for performing a linear interpolation between colors. */ @@ -59,54 +67,13 @@ class DyePalette final void getColor(double intensity, int (&restrict color)[3]) const restrict2; - /** - * replace colors for SDL for S dye. - */ - void replaceSColor(uint32_t *restrict pixels, - const int bufSize) const restrict2; - /** * replace colors for SDL for S dye. */ void replaceSColorDefault(uint32_t *restrict pixels, const int bufSize) const restrict2; - /** - * replace colors for SDL for S dye. - */ - FUNCTION_SIMD_DEFAULT - void replaceSColorSimd(uint32_t *restrict pixels, - const int bufSize) const restrict2; - - /** - * replace colors for SDL for S dye. - */ - FUNCTION_SIMD_DEFAULT - void replaceSColorSse2(uint32_t *restrict pixels, - const int bufSize) const restrict2; - - /** - * replace colors for SDL for S dye. - */ - FUNCTION_SIMD_DEFAULT - void replaceSColorAvx2(uint32_t *restrict pixels, - const int bufSize) const restrict2; - #ifdef SIMD_SUPPORTED - /** - * replace colors for SDL for S dye. - */ - __attribute__ ((target ("sse2"))) - void replaceSColorSimd(uint32_t *restrict pixels, - const int bufSize) const restrict2; - - /** - * replace colors for SDL for S dye. - */ - __attribute__ ((target ("avx2"))) - void replaceSColorSimd(uint32_t *restrict pixels, - const int bufSize) const restrict2; - /** * replace colors for SDL for S dye. */ @@ -313,6 +280,12 @@ class DyePalette final const uint8_t blockSize, DyeColor &color) noexcept2; + static void initFunctions(); + + static DyeFunctionPtr funcReplaceSColor; + static DyeFunctionPtr funcReplaceSColorSse2; + static DyeFunctionPtr funcReplaceSColorAvx2; + #ifndef UNITTESTS private: #endif // UNITTESTS -- cgit v1.2.3-70-g09d2