Add pixel alpha multiply with color table to SDL
This commit is contained in:
parent
7f2052f328
commit
01a32157da
|
@ -0,0 +1,295 @@
|
|||
SDL_blit_A.c | 270 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 270 insertions(+)
|
||||
|
||||
diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c
|
||||
index 219cdcc..d8e921e 100644
|
||||
--- a/src/video/SDL_blit_A.c
|
||||
+++ b/src/video/SDL_blit_A.c
|
||||
@@ -27,3 +34,270 @@
|
||||
+
|
||||
+/*!
|
||||
+\brief Alpha adjustment table for custom blitter.
|
||||
+
|
||||
+The table provides values for a modified, non-linear
|
||||
+transfer function which maintain brightness.
|
||||
+
|
||||
+*/
|
||||
+const unsigned int GFX_ALPHA_ADJUST_ARRAY[256] = {
|
||||
+ 0, /* 0 */
|
||||
+ 15, /* 1 */
|
||||
+ 22, /* 2 */
|
||||
+ 27, /* 3 */
|
||||
+ 31, /* 4 */
|
||||
+ 35, /* 5 */
|
||||
+ 39, /* 6 */
|
||||
+ 42, /* 7 */
|
||||
+ 45, /* 8 */
|
||||
+ 47, /* 9 */
|
||||
+ 50, /* 10 */
|
||||
+ 52, /* 11 */
|
||||
+ 55, /* 12 */
|
||||
+ 57, /* 13 */
|
||||
+ 59, /* 14 */
|
||||
+ 61, /* 15 */
|
||||
+ 63, /* 16 */
|
||||
+ 65, /* 17 */
|
||||
+ 67, /* 18 */
|
||||
+ 69, /* 19 */
|
||||
+ 71, /* 20 */
|
||||
+ 73, /* 21 */
|
||||
+ 74, /* 22 */
|
||||
+ 76, /* 23 */
|
||||
+ 78, /* 24 */
|
||||
+ 79, /* 25 */
|
||||
+ 81, /* 26 */
|
||||
+ 82, /* 27 */
|
||||
+ 84, /* 28 */
|
||||
+ 85, /* 29 */
|
||||
+ 87, /* 30 */
|
||||
+ 88, /* 31 */
|
||||
+ 90, /* 32 */
|
||||
+ 91, /* 33 */
|
||||
+ 93, /* 34 */
|
||||
+ 94, /* 35 */
|
||||
+ 95, /* 36 */
|
||||
+ 97, /* 37 */
|
||||
+ 98, /* 38 */
|
||||
+ 99, /* 39 */
|
||||
+ 100, /* 40 */
|
||||
+ 102, /* 41 */
|
||||
+ 103, /* 42 */
|
||||
+ 104, /* 43 */
|
||||
+ 105, /* 44 */
|
||||
+ 107, /* 45 */
|
||||
+ 108, /* 46 */
|
||||
+ 109, /* 47 */
|
||||
+ 110, /* 48 */
|
||||
+ 111, /* 49 */
|
||||
+ 112, /* 50 */
|
||||
+ 114, /* 51 */
|
||||
+ 115, /* 52 */
|
||||
+ 116, /* 53 */
|
||||
+ 117, /* 54 */
|
||||
+ 118, /* 55 */
|
||||
+ 119, /* 56 */
|
||||
+ 120, /* 57 */
|
||||
+ 121, /* 58 */
|
||||
+ 122, /* 59 */
|
||||
+ 123, /* 60 */
|
||||
+ 124, /* 61 */
|
||||
+ 125, /* 62 */
|
||||
+ 126, /* 63 */
|
||||
+ 127, /* 64 */
|
||||
+ 128, /* 65 */
|
||||
+ 129, /* 66 */
|
||||
+ 130, /* 67 */
|
||||
+ 131, /* 68 */
|
||||
+ 132, /* 69 */
|
||||
+ 133, /* 70 */
|
||||
+ 134, /* 71 */
|
||||
+ 135, /* 72 */
|
||||
+ 136, /* 73 */
|
||||
+ 137, /* 74 */
|
||||
+ 138, /* 75 */
|
||||
+ 139, /* 76 */
|
||||
+ 140, /* 77 */
|
||||
+ 141, /* 78 */
|
||||
+ 141, /* 79 */
|
||||
+ 142, /* 80 */
|
||||
+ 143, /* 81 */
|
||||
+ 144, /* 82 */
|
||||
+ 145, /* 83 */
|
||||
+ 146, /* 84 */
|
||||
+ 147, /* 85 */
|
||||
+ 148, /* 86 */
|
||||
+ 148, /* 87 */
|
||||
+ 149, /* 88 */
|
||||
+ 150, /* 89 */
|
||||
+ 151, /* 90 */
|
||||
+ 152, /* 91 */
|
||||
+ 153, /* 92 */
|
||||
+ 153, /* 93 */
|
||||
+ 154, /* 94 */
|
||||
+ 155, /* 95 */
|
||||
+ 156, /* 96 */
|
||||
+ 157, /* 97 */
|
||||
+ 158, /* 98 */
|
||||
+ 158, /* 99 */
|
||||
+ 159, /* 100 */
|
||||
+ 160, /* 101 */
|
||||
+ 161, /* 102 */
|
||||
+ 162, /* 103 */
|
||||
+ 162, /* 104 */
|
||||
+ 163, /* 105 */
|
||||
+ 164, /* 106 */
|
||||
+ 165, /* 107 */
|
||||
+ 165, /* 108 */
|
||||
+ 166, /* 109 */
|
||||
+ 167, /* 110 */
|
||||
+ 168, /* 111 */
|
||||
+ 168, /* 112 */
|
||||
+ 169, /* 113 */
|
||||
+ 170, /* 114 */
|
||||
+ 171, /* 115 */
|
||||
+ 171, /* 116 */
|
||||
+ 172, /* 117 */
|
||||
+ 173, /* 118 */
|
||||
+ 174, /* 119 */
|
||||
+ 174, /* 120 */
|
||||
+ 175, /* 121 */
|
||||
+ 176, /* 122 */
|
||||
+ 177, /* 123 */
|
||||
+ 177, /* 124 */
|
||||
+ 178, /* 125 */
|
||||
+ 179, /* 126 */
|
||||
+ 179, /* 127 */
|
||||
+ 180, /* 128 */
|
||||
+ 181, /* 129 */
|
||||
+ 182, /* 130 */
|
||||
+ 182, /* 131 */
|
||||
+ 183, /* 132 */
|
||||
+ 184, /* 133 */
|
||||
+ 184, /* 134 */
|
||||
+ 185, /* 135 */
|
||||
+ 186, /* 136 */
|
||||
+ 186, /* 137 */
|
||||
+ 187, /* 138 */
|
||||
+ 188, /* 139 */
|
||||
+ 188, /* 140 */
|
||||
+ 189, /* 141 */
|
||||
+ 190, /* 142 */
|
||||
+ 190, /* 143 */
|
||||
+ 191, /* 144 */
|
||||
+ 192, /* 145 */
|
||||
+ 192, /* 146 */
|
||||
+ 193, /* 147 */
|
||||
+ 194, /* 148 */
|
||||
+ 194, /* 149 */
|
||||
+ 195, /* 150 */
|
||||
+ 196, /* 151 */
|
||||
+ 196, /* 152 */
|
||||
+ 197, /* 153 */
|
||||
+ 198, /* 154 */
|
||||
+ 198, /* 155 */
|
||||
+ 199, /* 156 */
|
||||
+ 200, /* 157 */
|
||||
+ 200, /* 158 */
|
||||
+ 201, /* 159 */
|
||||
+ 201, /* 160 */
|
||||
+ 202, /* 161 */
|
||||
+ 203, /* 162 */
|
||||
+ 203, /* 163 */
|
||||
+ 204, /* 164 */
|
||||
+ 205, /* 165 */
|
||||
+ 205, /* 166 */
|
||||
+ 206, /* 167 */
|
||||
+ 206, /* 168 */
|
||||
+ 207, /* 169 */
|
||||
+ 208, /* 170 */
|
||||
+ 208, /* 171 */
|
||||
+ 209, /* 172 */
|
||||
+ 210, /* 173 */
|
||||
+ 210, /* 174 */
|
||||
+ 211, /* 175 */
|
||||
+ 211, /* 176 */
|
||||
+ 212, /* 177 */
|
||||
+ 213, /* 178 */
|
||||
+ 213, /* 179 */
|
||||
+ 214, /* 180 */
|
||||
+ 214, /* 181 */
|
||||
+ 215, /* 182 */
|
||||
+ 216, /* 183 */
|
||||
+ 216, /* 184 */
|
||||
+ 217, /* 185 */
|
||||
+ 217, /* 186 */
|
||||
+ 218, /* 187 */
|
||||
+ 218, /* 188 */
|
||||
+ 219, /* 189 */
|
||||
+ 220, /* 190 */
|
||||
+ 220, /* 191 */
|
||||
+ 221, /* 192 */
|
||||
+ 221, /* 193 */
|
||||
+ 222, /* 194 */
|
||||
+ 222, /* 195 */
|
||||
+ 223, /* 196 */
|
||||
+ 224, /* 197 */
|
||||
+ 224, /* 198 */
|
||||
+ 225, /* 199 */
|
||||
+ 225, /* 200 */
|
||||
+ 226, /* 201 */
|
||||
+ 226, /* 202 */
|
||||
+ 227, /* 203 */
|
||||
+ 228, /* 204 */
|
||||
+ 228, /* 205 */
|
||||
+ 229, /* 206 */
|
||||
+ 229, /* 207 */
|
||||
+ 230, /* 208 */
|
||||
+ 230, /* 209 */
|
||||
+ 231, /* 210 */
|
||||
+ 231, /* 211 */
|
||||
+ 232, /* 212 */
|
||||
+ 233, /* 213 */
|
||||
+ 233, /* 214 */
|
||||
+ 234, /* 215 */
|
||||
+ 234, /* 216 */
|
||||
+ 235, /* 217 */
|
||||
+ 235, /* 218 */
|
||||
+ 236, /* 219 */
|
||||
+ 236, /* 220 */
|
||||
+ 237, /* 221 */
|
||||
+ 237, /* 222 */
|
||||
+ 238, /* 223 */
|
||||
+ 238, /* 224 */
|
||||
+ 239, /* 225 */
|
||||
+ 240, /* 226 */
|
||||
+ 240, /* 227 */
|
||||
+ 241, /* 228 */
|
||||
+ 241, /* 229 */
|
||||
+ 242, /* 230 */
|
||||
+ 242, /* 231 */
|
||||
+ 243, /* 232 */
|
||||
+ 243, /* 233 */
|
||||
+ 244, /* 234 */
|
||||
+ 244, /* 235 */
|
||||
+ 245, /* 236 */
|
||||
+ 245, /* 237 */
|
||||
+ 246, /* 238 */
|
||||
+ 246, /* 239 */
|
||||
+ 247, /* 240 */
|
||||
+ 247, /* 241 */
|
||||
+ 248, /* 242 */
|
||||
+ 248, /* 243 */
|
||||
+ 249, /* 244 */
|
||||
+ 249, /* 245 */
|
||||
+ 250, /* 246 */
|
||||
+ 250, /* 247 */
|
||||
+ 251, /* 248 */
|
||||
+ 251, /* 249 */
|
||||
+ 252, /* 250 */
|
||||
+ 252, /* 251 */
|
||||
+ 253, /* 252 */
|
||||
+ 253, /* 253 */
|
||||
+ 254, /* 254 */
|
||||
+ 255 /* 255 */
|
||||
+};
|
||||
+
|
||||
/*
|
||||
In Visual C, VC6 has mmintrin.h in the "Processor Pack" add-on.
|
||||
Checking if _mm_free is #defined in malloc.h is is the only way to
|
||||
@@ -2679,6 +2985,7 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
|
||||
int dstskip = info->d_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src;
|
||||
SDL_PixelFormat *dstfmt = info->dst;
|
||||
+ uint8_t alpha_multiply = srcfmt->alpha;
|
||||
|
||||
int srcbpp;
|
||||
int dstbpp;
|
||||
@@ -2705,6 +3012,8 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
|
||||
unsigned sA;
|
||||
unsigned dA;
|
||||
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
|
||||
+ sA=(sA*alpha_multiply)>>8;
|
||||
+ sA=GFX_ALPHA_ADJUST_ARRAY[sA & 255];
|
||||
if(sA) {
|
||||
DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
|
||||
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
|
Loading…
Reference in New Issue