ManaPlus
dyepalette.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2007-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef RESOURCES_DYE_DYEPALETTE_H
25 #define RESOURCES_DYE_DYEPALETTE_H
26 
27 #include "resources/dye/dyecolor.h"
28 
29 #include "utils/vector.h"
30 
32 
33 #include <string>
34 
35 #include "localconsts.h"
36 
37 #define DYEPALETTE(palette, color) \
38  ((palette).*DyePalette::funcReplace##color)
39 
40 #define DYEPALETTEP(palette, color) \
41  ((palette)->*DyePalette::funcReplace##color)
42 
47 {
48  public:
54  DyePalette(const std::string &restrict pallete,
55  const uint8_t blockSize);
56 
58 
59 
63  void getColor(const unsigned int intensity,
64  unsigned int (&restrict color)[3]) const restrict2;
65 
69  void getColor(double intensity,
70  int (&restrict color)[3]) const restrict2;
71 
75  void replaceSColorDefault(uint32_t *restrict pixels,
76  const int bufSize) const restrict2;
77 
81  void replaceAColorDefault(uint32_t *restrict pixels,
82  const int bufSize) const restrict2;
83 
84 #ifdef SIMD_SUPPORTED
88  __attribute__ ((target ("sse2")))
89  void replaceSColorSse2(uint32_t *restrict pixels,
90  const int bufSize) const restrict2;
91 
95  __attribute__ ((target ("avx2")))
96  void replaceSColorAvx2(uint32_t *restrict pixels,
97  const int bufSize) const restrict2;
98 
102  __attribute__ ((target ("sse2")))
103  void replaceAColorSse2(uint32_t *restrict pixels,
104  const int bufSize) const restrict2;
105 
109  __attribute__ ((target ("avx2")))
110  void replaceAColorAvx2(uint32_t *restrict pixels,
111  const int bufSize) const restrict2;
112 #endif // SIMD_SUPPORTED
113 
114 #ifdef USE_OPENGL
118  void replaceSOGLColorDefault(uint32_t *restrict pixels,
119  const int bufSize) const restrict2;
120 #ifdef SIMD_SUPPORTED
124  __attribute__ ((target ("avx2")))
125  void replaceAOGLColorAvx2(uint32_t *restrict pixels,
126  const int bufSize) const restrict2;
127 
131  __attribute__ ((target ("sse2")))
132  void replaceSOGLColorSse2(uint32_t *restrict pixels,
133  const int bufSize) const restrict2;
137  __attribute__ ((target ("avx2")))
138  void replaceSOGLColorAvx2(uint32_t *restrict pixels,
139  const int bufSize) const restrict2;
140 
144  __attribute__ ((target ("sse2")))
145  void replaceAOGLColorSse2(uint32_t *restrict pixels,
146  const int bufSize) const restrict2;
147 #endif // SIMD_SUPPORTED
148 
152  void replaceAOGLColorDefault(uint32_t *restrict pixels,
153  const int bufSize) const restrict2;
154 
155 #endif // USE_OPENGL
156 
157  static unsigned int hexDecode(const signed char c)
158  noexcept2 A_CONST A_WARN_UNUSED;
159 
160  static void hexToColor(const std::string &restrict hexStr,
161  const uint8_t blockSize,
162  DyeColor &color) noexcept2;
163 
164  static void initFunctions();
165 
166 #ifdef USE_OPENGL
173 #endif // USE_OPENGL
174 
181 
182 #ifndef UNITTESTS
183  private:
184 #endif // UNITTESTS
185  STD_VECTOR<DyeColor> mColors;
186 };
187 
188 #endif // RESOURCES_DYE_DYEPALETTE_H
static void initFunctions()
Definition: dyepalette.cpp:253
static DyeFunctionPtr funcReplaceAOGLColorSse2
Definition: dyepalette.h:171
void getColor(const unsigned int intensity, unsigned int(&color)[3]) const
Definition: dyepalette.cpp:152
static DyeFunctionPtr funcReplaceSColorAvx2
Definition: dyepalette.h:177
void replaceAColorDefault(uint32_t *pixels, const int bufSize) const
static DyeFunctionPtr funcReplaceAColorSse2
Definition: dyepalette.h:179
static DyeFunctionPtr funcReplaceSColor
Definition: dyepalette.h:175
void replaceAOGLColorDefault(uint32_t *pixels, const int bufSize) const
static DyeFunctionPtr funcReplaceAColor
Definition: dyepalette.h:178
static DyeFunctionPtr funcReplaceSOGLColor
Definition: dyepalette.h:167
void replaceSOGLColorDefault(uint32_t *pixels, const int bufSize) const
static void hexToColor(const std::string &hexStr, const uint8_t blockSize, DyeColor &color)
Definition: dyepalette.cpp:125
void replaceSColorDefault(uint32_t *pixels, const int bufSize) const
static DyeFunctionPtr funcReplaceSOGLColorSse2
Definition: dyepalette.h:168
static DyeFunctionPtr funcReplaceSColorSse2
Definition: dyepalette.h:176
static DyeFunctionPtr funcReplaceAOGLColorAvx2
Definition: dyepalette.h:172
static unsigned int hexDecode(const signed char c) A_CONST
Definition: dyepalette.cpp:140
DyePalette(const std::string &pallete, const uint8_t blockSize)
Definition: dyepalette.cpp:68
static DyeFunctionPtr funcReplaceAOGLColor
Definition: dyepalette.h:170
static DyeFunctionPtr funcReplaceSOGLColorAvx2
Definition: dyepalette.h:169
static DyeFunctionPtr funcReplaceAColorAvx2
Definition: dyepalette.h:180
std::vector< DyeColor > mColors
Definition: dyepalette.h:185
void(DyePalette::* DyeFunctionPtr)(uint32_t *pixels, const int bufSize) const
Definition: dyepaletteptr.h:29
#define restrict
Definition: localconsts.h:165
#define restrict2
Definition: localconsts.h:166
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
union EAthena::ItemFlags __attribute__((packed))