00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 #ifdef XFORM_SHAPES
00064
00065 #ifdef XFORM_CONDITIONAL
00066 #define USE_XFORM_FUNC ((XFORM_CONDITIONAL) && xform_pal[*linedata])
00067 #else
00068 #define USE_XFORM_FUNC (xform_pal[*linedata])
00069 #endif
00070
00071
00072
00073
00074 #else
00075 #define USE_XFORM_FUNC 0
00076 #endif
00077
00078
00079
00080
00081
00082 #ifdef FLIP_SHAPES
00083
00084 #ifdef FLIP_CONDITIONAL
00085 const sint32 neg = (FLIP_CONDITIONAL)?-1:0;
00086 #define XNEG(x) (((x)+neg)^neg)
00087 #else
00088 #define XNEG(x) (-(x))
00089 #endif
00090
00091
00092 #else
00093 #define XNEG(x)(+(x))
00094 #endif
00095
00096
00097
00098
00099
00100 #ifdef NO_CLIPPING
00101
00102 #define LINE_END_ASSIGN()
00103 #define NOT_CLIPPED_X (1)
00104 #define NOT_CLIPPED_Y (1)
00105 #define OFFSET_PIXELS (pixels)
00106
00107
00108
00109
00110 #else
00111
00112 #define LINE_END_ASSIGN() do { line_end = line_start+scrn_width; } while (0)
00113 #define NOT_CLIPPED_Y (line >= 0 && line < scrn_height)
00114 #define NOT_CLIPPED_X (pixptr >= line_start && pixptr < line_end)
00115
00116 int scrn_width = clip_window.w;
00117 int scrn_height = clip_window.h;
00118 uintX *line_end;
00119
00120 #define OFFSET_PIXELS (off_pixels)
00121
00122 uint8 *off_pixels = static_cast<uint8*>(pixels) + static_cast<sintptr>(clip_window.x)*sizeof(uintX) + static_cast<sintptr>(clip_window.y)*pitch;
00123 x -= clip_window.x;
00124 y -= clip_window.y;
00125
00126 #endif
00127
00128
00129
00130
00131
00132 #ifdef BLEND_SHAPES
00133
00134 #ifdef BLEND_CONDITIONAL
00135 #define CUSTOM_BLEND(src) static_cast<uintX>((BLEND_CONDITIONAL)?BLEND_SHAPES(src,*pixptr):src)
00136 #else
00137 #define CUSTOM_BLEND(src) static_cast<uintX>(BLEND_SHAPES(src,*pixptr))
00138 #endif
00139
00140
00141
00142
00143 #else
00144
00145 #define CUSTOM_BLEND(src) static_cast<uintX>(src)
00146
00147 #endif
00148
00149
00150
00151
00152 #ifdef DESTALPHA_MASK
00153
00154 #define NOT_DESTINATION_MASKED (*pixptr & RenderSurface::format.a_mask)
00155
00156 #else
00157
00158 #define NOT_DESTINATION_MASKED (1)
00159
00160 #endif
00161
00162
00163
00164
00165
00166
00167
00168 const uint8 *linedata;
00169 sint32 xpos;
00170 sintptr line;
00171 sint32 dlen;
00172
00173 uintX *pixptr;
00174 uintX *endrun;
00175 uintX *line_start;
00176 uint32 pix;
00177
00178
00179 if (framenum >= s->frameCount()) return;
00180 if (s->getPalette() == 0) return;
00181
00182 ShapeFrame *frame = s->getFrame(framenum);
00183 const uint8 *rle_data = frame->rle_data;
00184 const uint32 *line_offsets = frame->line_offsets;
00185 const uint32 *pal = untformed_pal?
00186 &(s->getPalette()->native_untransformed[0]):
00187 &(s->getPalette()->native[0]);
00188
00189
00190 #ifdef XFORM_SHAPES
00191 const uint32 *xform_pal = untformed_pal?
00192 &(s->getPalette()->xform_untransformed[0]):
00193 &(s->getPalette()->xform[0]);
00194 #endif
00195
00196 sint32 width = frame->width;
00197 sint32 height = frame->height;
00198 x -= XNEG(frame->xoff);
00199 y -= frame->yoff;
00200
00201
00202 if (frame->compressed) for (int i=0; i<height; i++)
00203 {
00204 xpos = 0;
00205 line = y+i;
00206
00207 if (NOT_CLIPPED_Y)
00208 {
00209
00210 linedata = rle_data + line_offsets[i];
00211 line_start = reinterpret_cast<uintX *>(static_cast<uint8*>(OFFSET_PIXELS) + pitch*line);
00212
00213 LINE_END_ASSIGN();
00214
00215 do
00216 {
00217 xpos += *linedata++;
00218
00219 if (xpos == width) break;
00220
00221 dlen = *linedata++;
00222 int type = dlen & 1;
00223 dlen >>= 1;
00224
00225 pixptr= line_start+x+XNEG(xpos);
00226 endrun = pixptr + XNEG(dlen);
00227
00228 if (!type)
00229 {
00230 while (pixptr != endrun)
00231 {
00232 if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED)
00233 {
00234 #ifdef XFORM_SHAPES
00235 if (USE_XFORM_FUNC)
00236 {
00237 *pixptr = CUSTOM_BLEND(BlendPreModulated(xform_pal[*linedata],*pixptr));
00238 }
00239 else
00240 #endif
00241 {
00242 *pixptr = CUSTOM_BLEND(pal[*linedata]);
00243 }
00244 }
00245 pixptr += XNEG(1);
00246 linedata++;
00247 }
00248 }
00249 else
00250 {
00251 #ifdef XFORM_SHAPES
00252 pix = xform_pal[*linedata];
00253 if (USE_XFORM_FUNC)
00254 {
00255 while (pixptr != endrun)
00256 {
00257 if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED) *pixptr = CUSTOM_BLEND(BlendPreModulated(xform_pal[*linedata],*pixptr));
00258 pixptr += XNEG(1);
00259 }
00260 }
00261 else
00262 #endif
00263 {
00264 pix = pal[*linedata];
00265 while (pixptr != endrun)
00266 {
00267 if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED)
00268 {
00269 *pixptr = CUSTOM_BLEND(pix);
00270 }
00271 pixptr += XNEG(1);
00272 }
00273 }
00274 linedata++;
00275 }
00276
00277 xpos += dlen;
00278
00279 } while (xpos < width);
00280 }
00281 }
00282
00283 else for (int i=0; i<height; i++)
00284 {
00285 linedata = rle_data + line_offsets[i];
00286 xpos = 0;
00287 line = y+i;
00288
00289 if (NOT_CLIPPED_Y)
00290 {
00291 line_start = reinterpret_cast<uintX *>(static_cast<uint8*>(OFFSET_PIXELS) + pitch*line);
00292 LINE_END_ASSIGN();
00293
00294 do
00295 {
00296 xpos += *linedata++;
00297
00298 if (xpos == width) break;
00299
00300 dlen = *linedata++;
00301
00302 pixptr= line_start+x+XNEG(xpos);
00303 endrun = pixptr + XNEG(dlen);
00304
00305 while (pixptr != endrun)
00306 {
00307 if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED)
00308 {
00309 #ifdef XFORM_SHAPES
00310 if (USE_XFORM_FUNC)
00311 {
00312 *pixptr = CUSTOM_BLEND(BlendPreModulated(xform_pal[*linedata],*pixptr));
00313 }
00314 else
00315 #endif
00316 {
00317 *pixptr = CUSTOM_BLEND(pal[*linedata]);
00318 }
00319 }
00320 pixptr += XNEG(1);
00321 linedata++;
00322 }
00323
00324 xpos += dlen;
00325
00326 } while (xpos < width);
00327 }
00328 }
00329
00330 #undef NOT_DESTINATION_MASKED
00331 #undef OFFSET_PIXELS
00332 #undef CUSTOM_BLEND
00333 #undef LINE_END_ASSIGN
00334 #undef NOT_CLIPPED_X
00335 #undef NOT_CLIPPED_Y
00336 #undef XNEG
00337 #undef USE_XFORM_FUNC