Skip to content

Commit

Permalink
Removed old Pandora compatibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Sep 13, 2016
1 parent 284b9fa commit 7d916c2
Showing 1 changed file with 0 additions and 126 deletions.
126 changes: 0 additions & 126 deletions src/sdl/utils.cpp
Expand Up @@ -263,96 +263,6 @@ surface stretch_surface_vertical(
return optimize ? create_optimized_surface(dst) : dst;
}

#ifdef PANDORA
static void
scale_surface_down(surface& dst, const surface& src, const int w_dst, const int h_dst)
{
const_surface_lock src_lock(src);
surface_lock dst_lock(dst);

const Uint32* const src_pixels = src_lock.pixels();
Uint32* const dst_pixels = dst_lock.pixels();

int y_dst = 0; // The current y in the destination surface

int y_src = 0; // The current y in the source surface
int y_src_next = 0; // The next y in the source surface
int y_step = 0; // The y stepper
int h_src = src->h; // The height of the source surface

for( ; y_dst != h_dst; ++y_dst, y_src = y_src_next) {

y_step += h_src;
do {
++y_src_next;
y_step -= h_dst;
} while(y_step >= h_dst);

int x_dst = 0; // The current x in the destination surface

int x_src = 0; // The current x in the source surface
int x_src_next = 0; // The next x in the source surface
int x_step = 0; // The x stepper
int w_src = src->w; // The width of the source surface

for( ; x_dst != w_dst; ++x_dst, x_src = x_src_next) {

x_step += w_src;
do {
++x_src_next;
x_step -= w_dst;
} while(x_step >= w_dst);

int r_sum = 0, g_sum = 0, b_sum = 0, a_sum = 0;
int samples = 0;

// We now have a rectangle, (xsrc,ysrc,xratio,yratio)
// which we want to derive the pixel from
for(int x = x_src; x < x_src_next; ++x) {
for(int y = y_src; y < y_src_next; ++y) {

++samples;

const Uint32 pixel = src_pixels[y_src * w_src + x_src];
const Uint8 a = pixel >> 24;
if(a) {
a_sum += a;
r_sum += a * static_cast<Uint8>(pixel >> 16);
g_sum += a * static_cast<Uint8>(pixel >> 8);
b_sum += a * static_cast<Uint8>(pixel);
}
}
}

if(a_sum) {

const int adjustment = (a_sum | 1) >> 1;
r_sum += adjustment;
g_sum += adjustment;
b_sum += adjustment;

r_sum /= a_sum;
g_sum /= a_sum;
b_sum /= a_sum;

assert(samples == (x_src_next - x_src) * (y_src_next - y_src));
if(samples != 1) {
a_sum += (samples | 1) >> 1;
a_sum /= samples;
}
}

dst_pixels[y_dst * w_dst + x_dst] =
static_cast<Uint8>(a_sum) << 24
| static_cast<Uint8>(r_sum) << 16
| static_cast<Uint8>(g_sum) << 8
| static_cast<Uint8>(b_sum);
}
}
}

#endif

Uint32 blend_rgba(const surface& surf, unsigned char r, unsigned char g, unsigned char b, unsigned char a, unsigned char drop)
{
// We simply decrement each component.
Expand Down Expand Up @@ -603,9 +513,6 @@ surface scale_surface_sharp(const surface& surf, int w, int h, bool optimize)
return nullptr;
}

#ifdef PANDORA
scale_surface_down(dst, src, w, h);
#else
{
const_surface_lock src_lock(src);
surface_lock dst_lock(dst);
Expand Down Expand Up @@ -665,7 +572,6 @@ surface scale_surface_sharp(const surface& surf, int w, int h, bool optimize)

}
}
#endif

return optimize ? create_optimized_surface(dst) : dst;
}
Expand Down Expand Up @@ -1835,38 +1741,6 @@ surface blend_surface(
const Uint16 blue = ratio * static_cast<Uint8>(color);
ratio = 256 - ratio;

#ifdef PANDORA
/*
* Use an optimised version of the generic algorithm. The optimised
* version processes 8 pixels a time. If the number of pixels is not an
* exact multiple of 8 it falls back to the generic algorithm to handle
* the last pixels.
*/
uint16x8_t vred = vdupq_n_u16(red);
uint16x8_t vgreen = vdupq_n_u16(green);
uint16x8_t vblue = vdupq_n_u16(blue);

uint8x8_t vratio = vdup_n_u8(ratio);

const int div = (nsurf->w * surf->h) / 8;
for(int i = 0; i < div; ++i, beg += 8) {
uint8x8x4_t rgba = vld4_u8(reinterpret_cast<Uint8*>(beg));

uint16x8_t b = vmull_u8(rgba.val[0], vratio);
uint16x8_t g = vmull_u8(rgba.val[1], vratio);
uint16x8_t r = vmull_u8(rgba.val[2], vratio);

b = vaddq_u16(b, vblue);
g = vaddq_u16(g, vgreen);
r = vaddq_u16(r, vred);

rgba.val[0] = vshrn_n_u16(b, 8);
rgba.val[1] = vshrn_n_u16(g, 8);
rgba.val[2] = vshrn_n_u16(r, 8);

vst4_u8(reinterpret_cast<Uint8*>(beg), rgba);
}
#endif
while(beg != end) {
Uint8 a = static_cast<Uint8>(*beg >> 24);
Uint8 r = (ratio * static_cast<Uint8>(*beg >> 16) + red) >> 8;
Expand Down

0 comments on commit 7d916c2

Please sign in to comment.