diff --git a/stepmania/src/SDL_rotozoom.cpp b/stepmania/src/SDL_rotozoom.cpp index 07738681ca..1ce6817255 100644 --- a/stepmania/src/SDL_rotozoom.cpp +++ b/stepmania/src/SDL_rotozoom.cpp @@ -2,13 +2,7 @@ SDL_rotozoom.c - rotozoomer for 32bit or 8bit surfaces - LGPL (c) A. Schiffler - - This file is indented with a tab size of 8, unlike the rest of the SM - source which has a tab size of 4. I'm leaving it that way so I can - send patches upstream. (Since 8 is the de-facto standard tab size, - it'd be nice to fix the rest of the source to use it, but I don't want - to do a full-source commit ...) -glenn + LGPL (c) A. Schiffler, Glenn Maynard */ #include "SDL_rotozoom.h" @@ -55,83 +49,83 @@ void zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst) * 1..2, so sax[0] is 1. sx is the total number of pixels, so sx/2 is the * distance from the start of the sample to its center. */ for (x = 0; x < dst->w; x++) { - float sax = sx*x + sx/2; + float sax = sx*x + sx/2; - /* sx/2 is the distance from the start of the sample to the center; - * sx/4 is the distance from the center of the sample to the center of - * either pixel. */ - float xstep = sx/4; + /* sx/2 is the distance from the start of the sample to the center; + * sx/4 is the distance from the center of the sample to the center of + * either pixel. */ + float xstep = sx/4; - /* source x coordinates of left and right pixels to sample */ - esx0.push_back(int(sax-xstep)); - esx1.push_back(int(sax+xstep)); + /* source x coordinates of left and right pixels to sample */ + esx0.push_back(int(sax-xstep)); + esx1.push_back(int(sax+xstep)); - if(esx1[x] == esx0[x]) { - /* If the sampled pixels happen to be the same, the distance - * will be 0. Avoid division by zero. */ - ex0.push_back(1.f); - } else { - int xdist = esx1[x] - esx0[x]; + if(esx1[x] == esx0[x]) { + /* If the sampled pixels happen to be the same, the distance + * will be 0. Avoid division by zero. */ + ex0.push_back(1.f); + } else { + int xdist = esx1[x] - esx0[x]; - /* fleft is the left pixel sampled; +.5 is the center: */ - float fleft = esx0[x] + .5f; - - /* sax is somewhere between the centers of both sampled - * pixels; find the percentage: */ - float p = (sax - fleft) / xdist; - ex0.push_back(1-p); - } + /* fleft is the left pixel sampled; +.5 is the center: */ + float fleft = esx0[x] + .5f; + + /* sax is somewhere between the centers of both sampled + * pixels; find the percentage: */ + float p = (sax - fleft) / xdist; + ex0.push_back(1-p); + } } for (y = 0; y < dst->h; y++) { - float say = sy*y + sy/2; + float say = sy*y + sy/2; - float ystep = sy/4; + float ystep = sy/4; - esy0.push_back(int(say-ystep)); - esy1.push_back(int(say+ystep)); + esy0.push_back(int(say-ystep)); + esy1.push_back(int(say+ystep)); - if(esy0[y] == esy1[y]) { - ey0.push_back(1.f); - } else { - int ydist = esy1[y] - esy0[y]; - float ftop = esy0[y] + .5f; - float p = (say - ftop) / ydist; - ey0.push_back(1-p); - } + if(esy0[y] == esy1[y]) { + ey0.push_back(1.f); + } else { + int ydist = esy1[y] - esy0[y]; + float ftop = esy0[y] + .5f; + float p = (say - ftop) / ydist; + ey0.push_back(1-p); + } } tColorRGBA *sp = (tColorRGBA *) src->pixels; /* Scan destination */ for (y = 0; y < dst->h; y++) { - tColorRGBA *dp = (tColorRGBA *) ((Uint8 *) dst->pixels + dst->pitch*y); - /* current source pointer and next source pointer (first and second - * rows sampled for this row): */ - tColorRGBA *csp = (tColorRGBA *) ((Uint8 *) sp + esy0[y] * src->pitch); - tColorRGBA *ncsp = (tColorRGBA *) ((Uint8 *) sp + esy1[y] * src->pitch); + tColorRGBA *dp = (tColorRGBA *) ((Uint8 *) dst->pixels + dst->pitch*y); + /* current source pointer and next source pointer (first and second + * rows sampled for this row): */ + tColorRGBA *csp = (tColorRGBA *) ((Uint8 *) sp + esy0[y] * src->pitch); + tColorRGBA *ncsp = (tColorRGBA *) ((Uint8 *) sp + esy1[y] * src->pitch); - for (x = 0; x < dst->w; x++) { - /* Grab pointers to the sampled pixels: */ - tColorRGBA *c00 = csp + esx0[x]; - tColorRGBA *c01 = csp + esx1[x]; - tColorRGBA *c10 = ncsp + esx0[x]; - tColorRGBA *c11 = ncsp + esx1[x]; + for (x = 0; x < dst->w; x++) { + /* Grab pointers to the sampled pixels: */ + tColorRGBA *c00 = csp + esx0[x]; + tColorRGBA *c01 = csp + esx1[x]; + tColorRGBA *c10 = ncsp + esx0[x]; + tColorRGBA *c11 = ncsp + esx1[x]; - for(int c = 0; c < 4; ++c) { - float x0, x1; - x0 = c00->c[c] * ex0[x]; - x0 += c01->c[c] * (1-ex0[x]); - x1 = c10->c[c] * ex0[x]; - x1 += c11->c[c] * (1-ex0[x]); + for(int c = 0; c < 4; ++c) { + float x0, x1; + x0 = c00->c[c] * ex0[x]; + x0 += c01->c[c] * (1-ex0[x]); + x1 = c10->c[c] * ex0[x]; + x1 += c11->c[c] * (1-ex0[x]); - float res = (x0 * ey0[y]) + (x1 * (1-ey0[y])); - dp->c[c] = Uint8(res); - } + float res = (x0 * ey0[y]) + (x1 * (1-ey0[y])); + dp->c[c] = Uint8(res); + } - /* Advance destination pointer. */ - dp++; - } + /* Advance destination pointer. */ + dp++; + } } }