annotate src/filters/scanline.cpp @ 562:114f58b5b6d0

new glyph rendering skeleton complete.
author Robert McIntyre <rlm@mit.edu>
date Fri, 31 Aug 2012 09:22:52 -0500
parents f9f4f1b99eed
children
rev   line source
rlm@1 1 #include "../Port.h"
rlm@1 2
rlm@1 3 extern u32 RGB_LOW_BITS_MASK;
rlm@1 4
rlm@1 5 void Scanlines(u8 *srcPtr, u32 srcPitch, u8 *,
rlm@1 6 u8 *dstPtr, u32 dstPitch, int width, int height)
rlm@1 7 {
rlm@1 8 u8 *nextLine, *finish;
rlm@1 9
rlm@1 10 nextLine = dstPtr + dstPitch;
rlm@1 11
rlm@1 12 do
rlm@1 13 {
rlm@1 14 u32 *bP = (u32 *) srcPtr;
rlm@1 15 u32 *dP = (u32 *) dstPtr;
rlm@1 16 u32 *nL = (u32 *) nextLine;
rlm@1 17 u32 currentPixel;
rlm@1 18 u32 nextPixel;
rlm@1 19
rlm@1 20 finish = (u8 *) bP + ((width + 2) << 1);
rlm@1 21 nextPixel = *bP++;
rlm@1 22
rlm@1 23 do
rlm@1 24 {
rlm@1 25 currentPixel = nextPixel;
rlm@1 26 nextPixel = *bP++;
rlm@1 27 u32 colorA, colorB;
rlm@1 28
rlm@1 29 #ifdef WORDS_BIGENDIAN
rlm@1 30 colorA = currentPixel >> 16;
rlm@1 31 colorB = currentPixel & 0xffff;
rlm@1 32 #else
rlm@1 33 colorA = currentPixel & 0xffff;
rlm@1 34 colorB = currentPixel >> 16;
rlm@1 35 #endif
rlm@1 36
rlm@1 37 *(dP) = colorA | colorA << 16;
rlm@1 38 *(nL) = 0;
rlm@1 39
rlm@1 40 #ifdef WORDS_BIGENDIAN
rlm@1 41 colorA = nextPixel >> 16;
rlm@1 42 #else
rlm@1 43 colorA = nextPixel & 0xffff;
rlm@1 44 #endif
rlm@1 45
rlm@1 46 *(dP + 1) = colorB | (colorB << 16);
rlm@1 47 *(nL + 1) = 0;
rlm@1 48
rlm@1 49 dP += 2;
rlm@1 50 nL += 2;
rlm@1 51 }
rlm@1 52 while ((u8 *) bP < finish);
rlm@1 53
rlm@1 54 srcPtr += srcPitch;
rlm@1 55 dstPtr += dstPitch << 1;
rlm@1 56 nextLine += dstPitch << 1;
rlm@1 57 }
rlm@1 58 while (--height);
rlm@1 59 }
rlm@1 60
rlm@1 61 void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
rlm@1 62 u8 *dstPtr, u32 dstPitch, int width, int height)
rlm@1 63 {
rlm@1 64 u8 *nextLine, *finish;
rlm@1 65
rlm@1 66 nextLine = dstPtr + dstPitch;
rlm@1 67
rlm@1 68 do
rlm@1 69 {
rlm@1 70 u32 *bP = (u32 *) srcPtr;
rlm@1 71 u32 *dP = (u32 *) dstPtr;
rlm@1 72 u32 *nL = (u32 *) nextLine;
rlm@1 73 u32 currentPixel;
rlm@1 74 u32 nextPixel;
rlm@1 75
rlm@1 76 finish = (u8 *) bP + ((width + 1) << 2);
rlm@1 77 nextPixel = *bP++;
rlm@1 78
rlm@1 79 do
rlm@1 80 {
rlm@1 81 currentPixel = nextPixel;
rlm@1 82 nextPixel = *bP++;
rlm@1 83
rlm@1 84 u32 colorA, colorB;
rlm@1 85
rlm@1 86 colorA = currentPixel;
rlm@1 87 colorB = nextPixel;
rlm@1 88
rlm@1 89 *(dP) = colorA;
rlm@1 90 *(dP + 1) = colorA;
rlm@1 91 *(nL) = 0;
rlm@1 92 *(nL + 1) = 0;
rlm@1 93
rlm@1 94 *(dP + 2) = colorB;
rlm@1 95 *(dP + 3) = colorB;
rlm@1 96 *(nL + 2) = 0;
rlm@1 97 *(nL + 3) = 0;
rlm@1 98
rlm@1 99 nextPixel = *bP++;
rlm@1 100
rlm@1 101 dP += 4;
rlm@1 102 nL += 4;
rlm@1 103 }
rlm@1 104 while ((u8 *) bP < finish);
rlm@1 105
rlm@1 106 srcPtr += srcPitch;
rlm@1 107 dstPtr += dstPitch << 1;
rlm@1 108 nextLine += dstPitch << 1;
rlm@1 109 }
rlm@1 110 while (--height);
rlm@1 111 }
rlm@1 112
rlm@1 113 void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
rlm@1 114 u8 *dstPtr, u32 dstPitch, int width, int height)
rlm@1 115 {
rlm@1 116 u8 *nextLine, *finish;
rlm@1 117 u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
rlm@1 118
rlm@1 119 nextLine = dstPtr + dstPitch;
rlm@1 120
rlm@1 121 do
rlm@1 122 {
rlm@1 123 u32 *bP = (u32 *) srcPtr;
rlm@1 124 u32 *dP = (u32 *) dstPtr;
rlm@1 125 u32 *nL = (u32 *) nextLine;
rlm@1 126 u32 currentPixel;
rlm@1 127 u32 nextPixel;
rlm@1 128
rlm@1 129 finish = (u8 *) bP + ((width + 2) << 1);
rlm@1 130 nextPixel = *bP++;
rlm@1 131
rlm@1 132 do
rlm@1 133 {
rlm@1 134 currentPixel = nextPixel;
rlm@1 135 nextPixel = *bP++;
rlm@1 136
rlm@1 137 u32 colorA, colorB;
rlm@1 138
rlm@1 139 #ifdef WORDS_BIGENDIAN
rlm@1 140 colorA = currentPixel >> 16;
rlm@1 141 colorB = currentPixel & 0xFFFF;
rlm@1 142 #else
rlm@1 143 colorA = currentPixel & 0xFFFF;
rlm@1 144 colorB = currentPixel >> 16;
rlm@1 145 #endif
rlm@1 146
rlm@1 147 *(dP) = colorA = colorA | ((((colorA & colorMask) >> 1) +
rlm@1 148 ((colorB & colorMask) >> 1))) << 16;
rlm@1 149 colorA = ((colorA & colorMask) >> 1);
rlm@1 150 colorA += ((colorA & colorMask) >> 1);
rlm@1 151 *(nL) = colorA;
rlm@1 152
rlm@1 153 colorA = nextPixel & 0xFFFF;
rlm@1 154
rlm@1 155 *(dP + 1) = colorB = colorB | ((((colorA & colorMask) >> 1) +
rlm@1 156 ((colorB & colorMask) >> 1))) << 16;
rlm@1 157 colorB = ((colorB & colorMask) >> 1);
rlm@1 158 colorB += ((colorB & colorMask) >> 1);
rlm@1 159
rlm@1 160 *(nL + 1) = colorB;
rlm@1 161
rlm@1 162 dP += 2;
rlm@1 163 nL += 2;
rlm@1 164 }
rlm@1 165 while ((u8 *) bP < finish);
rlm@1 166
rlm@1 167 srcPtr += srcPitch;
rlm@1 168 dstPtr += dstPitch << 1;
rlm@1 169 nextLine += dstPitch << 1;
rlm@1 170 }
rlm@1 171 while (--height);
rlm@1 172 }
rlm@1 173
rlm@1 174 void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
rlm@1 175 u8 *dstPtr, u32 dstPitch, int width, int height)
rlm@1 176 {
rlm@1 177 u8 *nextLine, *finish;
rlm@1 178 u32 colorMask = ~RGB_LOW_BITS_MASK;
rlm@1 179
rlm@1 180 nextLine = dstPtr + dstPitch;
rlm@1 181
rlm@1 182 do
rlm@1 183 {
rlm@1 184 u32 *bP = (u32 *) srcPtr;
rlm@1 185 u32 *dP = (u32 *) dstPtr;
rlm@1 186 u32 *nL = (u32 *) nextLine;
rlm@1 187 u32 currentPixel;
rlm@1 188 u32 nextPixel;
rlm@1 189
rlm@1 190 finish = (u8 *) bP + ((width + 1) << 2);
rlm@1 191 nextPixel = *bP++;
rlm@1 192
rlm@1 193 do
rlm@1 194 {
rlm@1 195 currentPixel = nextPixel;
rlm@1 196 nextPixel = *bP++;
rlm@1 197
rlm@1 198 u32 colorA, colorB, temp;
rlm@1 199
rlm@1 200 colorA = currentPixel;
rlm@1 201 colorB = nextPixel;
rlm@1 202
rlm@1 203 *(dP) = colorA;
rlm@1 204 *(dP + 1) = temp = ((colorA & colorMask) >> 1) +
rlm@1 205 ((colorB & colorMask) >> 1);
rlm@1 206 temp = ((temp & colorMask) >> 1);
rlm@1 207 temp += ((temp & colorMask) >> 1);
rlm@1 208 colorA = ((colorA & colorMask) >> 1);
rlm@1 209 colorA += ((colorA & colorMask) >> 1);
rlm@1 210
rlm@1 211 *(nL) = colorA;
rlm@1 212 *(nL + 1) = temp;
rlm@1 213
rlm@1 214 dP += 2;
rlm@1 215 nL += 2;
rlm@1 216 }
rlm@1 217 while ((u8 *) bP < finish);
rlm@1 218
rlm@1 219 srcPtr += srcPitch;
rlm@1 220 dstPtr += dstPitch << 1;
rlm@1 221 nextLine += dstPitch << 1;
rlm@1 222 }
rlm@1 223 while (--height);
rlm@1 224 }
rlm@1 225