Browse Source
SDL1.2 was deprecated in the 2.12.0 release with:
commit e52c6ba341
Author: Daniel P. Berrange <berrange@redhat.com>
Date: Mon Jan 15 14:25:33 2018 +0000
ui: deprecate use of SDL 1.2 in favour of 2.0 series
The SDL 2.0 release was made in Aug, 2013:
https://www.libsdl.org/release/
That will soon be 4 + 1/2 years ago, which is enough time to consider
the 2.0 series widely supported.
Thus we deprecate the SDL 1.2 support, which will allow us to delete it
in the last release of 2018. By this time, SDL 2.0 will be more than 5
years old.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 20180115142533.24585-1-berrange@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
It is thus able to be removed in the 3.1.0 release.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20180822131554.3398-4-berrange@redhat.com>
[ kraxel: rebase ]
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
pull/78/head
committed by
Gerd Hoffmann
7 changed files with 7 additions and 1431 deletions
File diff suppressed because it is too large
@ -1,93 +0,0 @@ |
|||
/*
|
|||
* SDL_zoom - surface scaling |
|||
* |
|||
* Copyright (c) 2009 Citrix Systems, Inc. |
|||
* |
|||
* Derived from: SDL_rotozoom, LGPL (c) A. Schiffler from the SDL_gfx library. |
|||
* Modifications by Stefano Stabellini. |
|||
* |
|||
* This work is licensed under the terms of the GNU GPL version 2. |
|||
* See the COPYING file in the top-level directory. |
|||
* |
|||
*/ |
|||
|
|||
#include "qemu/osdep.h" |
|||
#include "sdl_zoom.h" |
|||
|
|||
static void sdl_zoom_rgb16(SDL_Surface *src, SDL_Surface *dst, int smooth, |
|||
SDL_Rect *dst_rect); |
|||
static void sdl_zoom_rgb32(SDL_Surface *src, SDL_Surface *dst, int smooth, |
|||
SDL_Rect *dst_rect); |
|||
|
|||
#define BPP 32 |
|||
#include "sdl_zoom_template.h" |
|||
#undef BPP |
|||
#define BPP 16 |
|||
#include "sdl_zoom_template.h" |
|||
#undef BPP |
|||
|
|||
int sdl_zoom_blit(SDL_Surface *src_sfc, SDL_Surface *dst_sfc, int smooth, |
|||
SDL_Rect *in_rect) |
|||
{ |
|||
SDL_Rect zoom, src_rect; |
|||
int extra; |
|||
|
|||
/* Grow the size of the modified rectangle to avoid edge artefacts */ |
|||
src_rect.x = (in_rect->x > 0) ? (in_rect->x - 1) : 0; |
|||
src_rect.y = (in_rect->y > 0) ? (in_rect->y - 1) : 0; |
|||
|
|||
src_rect.w = in_rect->w + 1; |
|||
if (src_rect.x + src_rect.w > src_sfc->w) |
|||
src_rect.w = src_sfc->w - src_rect.x; |
|||
|
|||
src_rect.h = in_rect->h + 1; |
|||
if (src_rect.y + src_rect.h > src_sfc->h) |
|||
src_rect.h = src_sfc->h - src_rect.y; |
|||
|
|||
/* (x,y) : round down */ |
|||
zoom.x = (int)(((float)(src_rect.x * dst_sfc->w)) / (float)(src_sfc->w)); |
|||
zoom.y = (int)(((float)(src_rect.y * dst_sfc->h)) / (float)(src_sfc->h)); |
|||
|
|||
/* (w,h) : round up */ |
|||
zoom.w = (int)( ((double)((src_rect.w * dst_sfc->w) + (src_sfc->w - 1))) / |
|||
(double)(src_sfc->w)); |
|||
|
|||
zoom.h = (int)( ((double)((src_rect.h * dst_sfc->h) + (src_sfc->h - 1))) / |
|||
(double)(src_sfc->h)); |
|||
|
|||
/* Account for any (x,y) rounding by adding one-source-pixel's worth
|
|||
* of destination pixels and then edge checking. |
|||
*/ |
|||
|
|||
extra = ((dst_sfc->w-1) / src_sfc->w) + 1; |
|||
|
|||
if ((zoom.x + zoom.w) < (dst_sfc->w - extra)) |
|||
zoom.w += extra; |
|||
else |
|||
zoom.w = dst_sfc->w - zoom.x; |
|||
|
|||
extra = ((dst_sfc->h-1) / src_sfc->h) + 1; |
|||
|
|||
if ((zoom.y + zoom.h) < (dst_sfc->h - extra)) |
|||
zoom.h += extra; |
|||
else |
|||
zoom.h = dst_sfc->h - zoom.y; |
|||
|
|||
/* The rectangle (zoom.x, zoom.y, zoom.w, zoom.h) is the area on the
|
|||
* destination surface that needs to be updated. |
|||
*/ |
|||
if (src_sfc->format->BitsPerPixel == 32) |
|||
sdl_zoom_rgb32(src_sfc, dst_sfc, smooth, &zoom); |
|||
else if (src_sfc->format->BitsPerPixel == 16) |
|||
sdl_zoom_rgb16(src_sfc, dst_sfc, smooth, &zoom); |
|||
else { |
|||
fprintf(stderr, "pixel format not supported\n"); |
|||
return -1; |
|||
} |
|||
|
|||
/* Return the rectangle of the update to the caller */ |
|||
*in_rect = zoom; |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
@ -1,25 +0,0 @@ |
|||
/*
|
|||
* SDL_zoom - surface scaling |
|||
* |
|||
* Copyright (c) 2009 Citrix Systems, Inc. |
|||
* |
|||
* Derived from: SDL_rotozoom, LGPL (c) A. Schiffler from the SDL_gfx library. |
|||
* Modifications by Stefano Stabellini. |
|||
* |
|||
* This work is licensed under the terms of the GNU GPL version 2. |
|||
* See the COPYING file in the top-level directory. |
|||
* |
|||
*/ |
|||
|
|||
#ifndef SDL_ZOOM_H |
|||
#define SDL_ZOOM_H |
|||
|
|||
#include <SDL.h> |
|||
|
|||
#define SMOOTHING_OFF 0 |
|||
#define SMOOTHING_ON 1 |
|||
|
|||
int sdl_zoom_blit(SDL_Surface *src_sfc, SDL_Surface *dst_sfc, |
|||
int smooth, SDL_Rect *src_rect); |
|||
|
|||
#endif /* SDL_ZOOM_H */ |
|||
@ -1,219 +0,0 @@ |
|||
/*
|
|||
* SDL_zoom_template - surface scaling |
|||
* |
|||
* Copyright (c) 2009 Citrix Systems, Inc. |
|||
* |
|||
* Derived from: SDL_rotozoom, LGPL (c) A. Schiffler from the SDL_gfx library. |
|||
* Modifications by Stefano Stabellini. |
|||
* |
|||
* This work is licensed under the terms of the GNU GPL version 2. |
|||
* See the COPYING file in the top-level directory. |
|||
* |
|||
*/ |
|||
|
|||
#if BPP == 16 |
|||
#define SDL_TYPE Uint16 |
|||
#elif BPP == 32 |
|||
#define SDL_TYPE Uint32 |
|||
#else |
|||
#error unsupport depth |
|||
#endif |
|||
|
|||
/*
|
|||
* Simple helper functions to make the code looks nicer |
|||
* |
|||
* Assume spf = source SDL_PixelFormat |
|||
* dpf = dest SDL_PixelFormat |
|||
* |
|||
*/ |
|||
#define getRed(color) (((color) & spf->Rmask) >> spf->Rshift) |
|||
#define getGreen(color) (((color) & spf->Gmask) >> spf->Gshift) |
|||
#define getBlue(color) (((color) & spf->Bmask) >> spf->Bshift) |
|||
#define getAlpha(color) (((color) & spf->Amask) >> spf->Ashift) |
|||
|
|||
#define setRed(r, pcolor) do { \ |
|||
*pcolor = ((*pcolor) & (~(dpf->Rmask))) + \ |
|||
(((r) & (dpf->Rmask >> dpf->Rshift)) << dpf->Rshift); \ |
|||
} while (0) |
|||
|
|||
#define setGreen(g, pcolor) do { \ |
|||
*pcolor = ((*pcolor) & (~(dpf->Gmask))) + \ |
|||
(((g) & (dpf->Gmask >> dpf->Gshift)) << dpf->Gshift); \ |
|||
} while (0) |
|||
|
|||
#define setBlue(b, pcolor) do { \ |
|||
*pcolor = ((*pcolor) & (~(dpf->Bmask))) + \ |
|||
(((b) & (dpf->Bmask >> dpf->Bshift)) << dpf->Bshift); \ |
|||
} while (0) |
|||
|
|||
#define setAlpha(a, pcolor) do { \ |
|||
*pcolor = ((*pcolor) & (~(dpf->Amask))) + \ |
|||
(((a) & (dpf->Amask >> dpf->Ashift)) << dpf->Ashift); \ |
|||
} while (0) |
|||
|
|||
static void glue(sdl_zoom_rgb, BPP)(SDL_Surface *src, SDL_Surface *dst, int smooth, |
|||
SDL_Rect *dst_rect) |
|||
{ |
|||
int x, y, sx, sy, *sax, *say, *csax, *csay, csx, csy, ex, ey, t1, t2, sstep, sstep_jump; |
|||
SDL_TYPE *c00, *c01, *c10, *c11, *sp, *csp, *dp; |
|||
int d_gap; |
|||
SDL_PixelFormat *spf = src->format; |
|||
SDL_PixelFormat *dpf = dst->format; |
|||
|
|||
if (smooth) { |
|||
/* For interpolation: assume source dimension is one pixel.
|
|||
* Smaller here to avoid overflow on right and bottom edge. |
|||
*/ |
|||
sx = (int) (65536.0 * (float) (src->w - 1) / (float) dst->w); |
|||
sy = (int) (65536.0 * (float) (src->h - 1) / (float) dst->h); |
|||
} else { |
|||
sx = (int) (65536.0 * (float) src->w / (float) dst->w); |
|||
sy = (int) (65536.0 * (float) src->h / (float) dst->h); |
|||
} |
|||
|
|||
sax = g_new(int, dst->w + 1); |
|||
say = g_new(int, dst->h + 1); |
|||
|
|||
sp = csp = (SDL_TYPE *) src->pixels; |
|||
dp = (SDL_TYPE *) (dst->pixels + dst_rect->y * dst->pitch + |
|||
dst_rect->x * dst->format->BytesPerPixel); |
|||
|
|||
csx = 0; |
|||
csax = sax; |
|||
for (x = 0; x <= dst->w; x++) { |
|||
*csax = csx; |
|||
csax++; |
|||
csx &= 0xffff; |
|||
csx += sx; |
|||
} |
|||
csy = 0; |
|||
csay = say; |
|||
for (y = 0; y <= dst->h; y++) { |
|||
*csay = csy; |
|||
csay++; |
|||
csy &= 0xffff; |
|||
csy += sy; |
|||
} |
|||
|
|||
d_gap = dst->pitch - dst_rect->w * dst->format->BytesPerPixel; |
|||
|
|||
if (smooth) { |
|||
csay = say; |
|||
for (y = 0; y < dst_rect->y; y++) { |
|||
csay++; |
|||
sstep = (*csay >> 16) * src->pitch; |
|||
csp = (SDL_TYPE *) ((Uint8 *) csp + sstep); |
|||
} |
|||
|
|||
/* Calculate sstep_jump */ |
|||
csax = sax; |
|||
sstep_jump = 0; |
|||
for (x = 0; x < dst_rect->x; x++) { |
|||
csax++; |
|||
sstep = (*csax >> 16); |
|||
sstep_jump += sstep; |
|||
} |
|||
|
|||
for (y = 0; y < dst_rect->h ; y++) { |
|||
/* Setup colour source pointers */ |
|||
c00 = csp + sstep_jump; |
|||
c01 = c00 + 1; |
|||
c10 = (SDL_TYPE *) ((Uint8 *) csp + src->pitch) + sstep_jump; |
|||
c11 = c10 + 1; |
|||
csax = sax + dst_rect->x; |
|||
|
|||
for (x = 0; x < dst_rect->w; x++) { |
|||
|
|||
/* Interpolate colours */ |
|||
ex = (*csax & 0xffff); |
|||
ey = (*csay & 0xffff); |
|||
t1 = ((((getRed(*c01) - getRed(*c00)) * ex) >> 16) + |
|||
getRed(*c00)) & (dpf->Rmask >> dpf->Rshift); |
|||
t2 = ((((getRed(*c11) - getRed(*c10)) * ex) >> 16) + |
|||
getRed(*c10)) & (dpf->Rmask >> dpf->Rshift); |
|||
setRed((((t2 - t1) * ey) >> 16) + t1, dp); |
|||
t1 = ((((getGreen(*c01) - getGreen(*c00)) * ex) >> 16) + |
|||
getGreen(*c00)) & (dpf->Gmask >> dpf->Gshift); |
|||
t2 = ((((getGreen(*c11) - getGreen(*c10)) * ex) >> 16) + |
|||
getGreen(*c10)) & (dpf->Gmask >> dpf->Gshift); |
|||
setGreen((((t2 - t1) * ey) >> 16) + t1, dp); |
|||
t1 = ((((getBlue(*c01) - getBlue(*c00)) * ex) >> 16) + |
|||
getBlue(*c00)) & (dpf->Bmask >> dpf->Bshift); |
|||
t2 = ((((getBlue(*c11) - getBlue(*c10)) * ex) >> 16) + |
|||
getBlue(*c10)) & (dpf->Bmask >> dpf->Bshift); |
|||
setBlue((((t2 - t1) * ey) >> 16) + t1, dp); |
|||
t1 = ((((getAlpha(*c01) - getAlpha(*c00)) * ex) >> 16) + |
|||
getAlpha(*c00)) & (dpf->Amask >> dpf->Ashift); |
|||
t2 = ((((getAlpha(*c11) - getAlpha(*c10)) * ex) >> 16) + |
|||
getAlpha(*c10)) & (dpf->Amask >> dpf->Ashift); |
|||
setAlpha((((t2 - t1) * ey) >> 16) + t1, dp); |
|||
|
|||
/* Advance source pointers */ |
|||
csax++; |
|||
sstep = (*csax >> 16); |
|||
c00 += sstep; |
|||
c01 += sstep; |
|||
c10 += sstep; |
|||
c11 += sstep; |
|||
/* Advance destination pointer */ |
|||
dp++; |
|||
} |
|||
/* Advance source pointer */ |
|||
csay++; |
|||
csp = (SDL_TYPE *) ((Uint8 *) csp + (*csay >> 16) * src->pitch); |
|||
/* Advance destination pointers */ |
|||
dp = (SDL_TYPE *) ((Uint8 *) dp + d_gap); |
|||
} |
|||
|
|||
|
|||
} else { |
|||
csay = say; |
|||
|
|||
for (y = 0; y < dst_rect->y; y++) { |
|||
csay++; |
|||
sstep = (*csay >> 16) * src->pitch; |
|||
csp = (SDL_TYPE *) ((Uint8 *) csp + sstep); |
|||
} |
|||
|
|||
/* Calculate sstep_jump */ |
|||
csax = sax; |
|||
sstep_jump = 0; |
|||
for (x = 0; x < dst_rect->x; x++) { |
|||
csax++; |
|||
sstep = (*csax >> 16); |
|||
sstep_jump += sstep; |
|||
} |
|||
|
|||
for (y = 0 ; y < dst_rect->h ; y++) { |
|||
sp = csp + sstep_jump; |
|||
csax = sax + dst_rect->x; |
|||
|
|||
for (x = 0; x < dst_rect->w; x++) { |
|||
|
|||
/* Draw */ |
|||
*dp = *sp; |
|||
|
|||
/* Advance source pointers */ |
|||
csax++; |
|||
sstep = (*csax >> 16); |
|||
sp += sstep; |
|||
|
|||
/* Advance destination pointer */ |
|||
dp++; |
|||
} |
|||
/* Advance source pointers */ |
|||
csay++; |
|||
sstep = (*csay >> 16) * src->pitch; |
|||
csp = (SDL_TYPE *) ((Uint8 *) csp + sstep); |
|||
|
|||
/* Advance destination pointer */ |
|||
dp = (SDL_TYPE *) ((Uint8 *) dp + d_gap); |
|||
} |
|||
} |
|||
|
|||
g_free(sax); |
|||
g_free(say); |
|||
} |
|||
|
|||
#undef SDL_TYPE |
|||
|
|||
Loading…
Reference in new issue