ui: fix build with SDL disabled, drop SDL1 support.
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJcVDv3AAoJEEy22O7T6HE4Q2IQAIKbBCZ03yEmYoPwZhmGPZHE CV+R4poHE+eCC0kau3wbimGnO3895gym/FDTxyVhdki5xvsLQKwh7bNmzamrkM9N Bmr/SCnYdxlC07cdIFJXGbW83y57rQwCmEZTg8HGbpsDNsB+eaxZoBT1hkWUS88m jewyhRNnDG+JPGrNOWHT1wpJSVD0VDlg82CfnfxXL/ff7n30vHGMgWvjr3dHyj95 NjiDHpXR/2NVRrdKHj5ZHB/rJmwWFMbzerzLfr06WmYylcGuCHxPmnz0152ORRCF UqCmj8eLdWfQ1iDHI1k+RYE9HRG26fZmSgRqFBPC7YFy9BWU5BM8YqRn2iHX9vA7 r7KVIot7QJAg15/qnmBd9XjBtDsjr26+xDjBEJc0e9/3UQi3tLNtiI4b/PFHUZIw W4POYPP+NPBKVxufFUD7g02BN+3a0kcXNia7U7916JWeanBmQBn5OUNzGavM0QEn uqhHIch9bTN/mMoLBLbOAGKly9SQUEEkkXiCP2qH61arjNXw9EsZj0JRM7JNHllC +1+Y5DvKZXl2hc3MebLbBDO0p7w6+gN+XK4u8tqcYHGkdozvnZfVBB74Y7d0xBlz j58a8/yC4MiqkdWLujAXiQlpIuz3FmMlm0STn+aburBwjk3x/NP/BOxLbNV++YTv sCFWFRQ13DPFXSEMTDqM =SZn0 -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190201-pull-request' into staging ui: fix build with SDL disabled, drop SDL1 support. # gpg: Signature made Fri 01 Feb 2019 12:30:47 GMT # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/ui-20190201-pull-request: ui: remove support for SDL1.2 in favour of SDL2 hw/display/milkymist-tmu2: Move inlined code from header to source hw/display/milkymist-tmu2: Explicit the dependency to both X11 / OpenGL configure: LM32 Milkymist Texture Mapping Unit (tmu2) also depends of X11 hw/display: Move Milkymist specific hardware out of common-obj list Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
a1bc3e7dc8
@ -185,6 +185,7 @@ F: disas/lm32.c
|
||||
F: hw/lm32/
|
||||
F: hw/*/lm32_*
|
||||
F: hw/*/milkymist-*
|
||||
F: include/hw/display/milkymist_tmu2.h
|
||||
F: include/hw/char/lm32_juart.h
|
||||
F: include/hw/lm32/
|
||||
F: tests/tcg/lm32/
|
||||
|
70
configure
vendored
70
configure
vendored
@ -348,7 +348,6 @@ docs=""
|
||||
fdt=""
|
||||
netmap="no"
|
||||
sdl=""
|
||||
sdlabi=""
|
||||
sdl_image=""
|
||||
virtfs=""
|
||||
mpath=""
|
||||
@ -577,7 +576,6 @@ query_pkg_config() {
|
||||
"${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
|
||||
}
|
||||
pkg_config=query_pkg_config
|
||||
sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
|
||||
sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
|
||||
|
||||
# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
|
||||
@ -1044,8 +1042,6 @@ for opt do
|
||||
;;
|
||||
--enable-sdl) sdl="yes"
|
||||
;;
|
||||
--with-sdlabi=*) sdlabi="$optarg"
|
||||
;;
|
||||
--disable-sdl-image) sdl_image="no"
|
||||
;;
|
||||
--enable-sdl-image) sdl_image="yes"
|
||||
@ -1711,7 +1707,6 @@ disabled with --disable-FEATURE, default is enabled if available:
|
||||
nettle nettle cryptography support
|
||||
gcrypt libgcrypt cryptography support
|
||||
sdl SDL UI
|
||||
--with-sdlabi select preferred SDL ABI 1.2 or 2.0
|
||||
sdl_image SDL Image support for icons
|
||||
gtk gtk UI
|
||||
vte vte support for the gtk UI
|
||||
@ -2927,37 +2922,11 @@ fi
|
||||
|
||||
sdl_probe ()
|
||||
{
|
||||
sdl_too_old=no
|
||||
if test "$sdlabi" = ""; then
|
||||
if $pkg_config --exists "sdl2"; then
|
||||
sdlabi=2.0
|
||||
elif $pkg_config --exists "sdl"; then
|
||||
sdlabi=1.2
|
||||
else
|
||||
sdlabi=2.0
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $sdlabi = "2.0"; then
|
||||
sdl_config=$sdl2_config
|
||||
sdlname=sdl2
|
||||
sdlconfigname=sdl2_config
|
||||
elif test $sdlabi = "1.2"; then
|
||||
sdlname=sdl
|
||||
sdlconfigname=sdl_config
|
||||
else
|
||||
error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
|
||||
fi
|
||||
|
||||
if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
|
||||
sdl_config=$sdlconfigname
|
||||
fi
|
||||
|
||||
if $pkg_config $sdlname --exists; then
|
||||
sdlconfig="$pkg_config $sdlname"
|
||||
if $pkg_config sdl2 --exists; then
|
||||
sdlconfig="$pkg_config sdl2"
|
||||
sdlversion=$($sdlconfig --modversion 2>/dev/null)
|
||||
elif has ${sdl_config}; then
|
||||
sdlconfig="$sdl_config"
|
||||
sdlconfig="$sdl2_config"
|
||||
sdlversion=$($sdlconfig --version)
|
||||
else
|
||||
if test "$sdl" = "yes" ; then
|
||||
@ -2979,8 +2948,8 @@ EOF
|
||||
sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
|
||||
sdl_cflags="$sdl_cflags -Wno-undef" # workaround 2.0.8 bug
|
||||
if test "$static" = "yes" ; then
|
||||
if $pkg_config $sdlname --exists; then
|
||||
sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
|
||||
if $pkg_config sdl2 --exists; then
|
||||
sdl_libs=$($pkg_config sdl2 --static --libs 2>/dev/null)
|
||||
else
|
||||
sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
|
||||
fi
|
||||
@ -2988,11 +2957,7 @@ EOF
|
||||
sdl_libs=$($sdlconfig --libs 2>/dev/null)
|
||||
fi
|
||||
if compile_prog "$sdl_cflags" "$sdl_libs" ; then
|
||||
if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
|
||||
sdl_too_old=yes
|
||||
else
|
||||
sdl=yes
|
||||
fi
|
||||
sdl=yes
|
||||
|
||||
# static link with sdl ? (note: sdl.pc's --static --libs is broken)
|
||||
if test "$sdl" = "yes" -a "$static" = "yes" ; then
|
||||
@ -3008,7 +2973,7 @@ EOF
|
||||
fi # static link
|
||||
else # sdl not found
|
||||
if test "$sdl" = "yes" ; then
|
||||
feature_not_found "sdl" "Install SDL devel"
|
||||
feature_not_found "sdl" "Install SDL2 devel"
|
||||
fi
|
||||
sdl=no
|
||||
fi # sdl compile test
|
||||
@ -4047,6 +4012,16 @@ EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$opengl" = "yes" -a "$have_x11" = "yes"; then
|
||||
for target in $target_list; do
|
||||
case $target in
|
||||
lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
|
||||
need_x11=yes
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
##########################################
|
||||
# libxml2 probe
|
||||
if test "$libxml2" != "no" ; then
|
||||
@ -6221,16 +6196,6 @@ echo "docker $docker"
|
||||
echo "libpmem support $libpmem"
|
||||
echo "libudev $libudev"
|
||||
|
||||
if test "$sdl_too_old" = "yes"; then
|
||||
echo "-> Your SDL version is too old - please upgrade to have SDL support"
|
||||
fi
|
||||
|
||||
if test "$sdlabi" = "1.2"; then
|
||||
echo
|
||||
echo "WARNING: Use of SDL 1.2 is deprecated and will be removed in"
|
||||
echo "WARNING: future releases. Please switch to using SDL 2.0"
|
||||
fi
|
||||
|
||||
if test "$supported_cpu" = "no"; then
|
||||
echo
|
||||
echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
|
||||
@ -6435,7 +6400,6 @@ if test "$have_x11" = "yes" -a "$need_x11" = "yes"; then
|
||||
fi
|
||||
if test "$sdl" = "yes" ; then
|
||||
echo "CONFIG_SDL=m" >> $config_host_mak
|
||||
echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
|
||||
echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
|
||||
echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
|
||||
if test "$sdl_image" = "yes" ; then
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
CONFIG_LM32=y
|
||||
CONFIG_MILKYMIST=y
|
||||
CONFIG_MILKYMIST_TMU2=$(CONFIG_OPENGL)
|
||||
CONFIG_MILKYMIST_TMU2=$(call land,$(CONFIG_X11),$(CONFIG_OPENGL))
|
||||
CONFIG_FRAMEBUFFER=y
|
||||
CONFIG_PTIMER=y
|
||||
CONFIG_PFLASH_CFI01=y
|
||||
|
@ -25,12 +25,12 @@ common-obj-$(CONFIG_BOCHS_DISPLAY) += edid-region.o
|
||||
common-obj-$(CONFIG_BLIZZARD) += blizzard.o
|
||||
common-obj-$(CONFIG_EXYNOS4) += exynos4210_fimd.o
|
||||
common-obj-$(CONFIG_FRAMEBUFFER) += framebuffer.o
|
||||
common-obj-$(CONFIG_MILKYMIST) += milkymist-vgafb.o
|
||||
obj-$(CONFIG_MILKYMIST) += milkymist-vgafb.o
|
||||
common-obj-$(CONFIG_ZAURUS) += tc6393xb.o
|
||||
|
||||
common-obj-$(CONFIG_MILKYMIST_TMU2) += milkymist-tmu2.o
|
||||
milkymist-tmu2.o-cflags := $(X11_CFLAGS)
|
||||
milkymist-tmu2.o-libs := $(X11_LIBS)
|
||||
obj-$(CONFIG_MILKYMIST_TMU2) += milkymist-tmu2.o
|
||||
milkymist-tmu2.o-cflags := $(X11_CFLAGS) $(OPENGL_CFLAGS)
|
||||
milkymist-tmu2.o-libs := $(X11_LIBS) $(OPENGL_LIBS)
|
||||
|
||||
obj-$(CONFIG_OMAP) += omap_dss.o
|
||||
obj-$(CONFIG_OMAP) += omap_lcdc.o
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qapi/error.h"
|
||||
#include "hw/display/milkymist_tmu2.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <epoxy/gl.h>
|
||||
@ -499,3 +500,51 @@ static void milkymist_tmu2_register_types(void)
|
||||
}
|
||||
|
||||
type_init(milkymist_tmu2_register_types)
|
||||
|
||||
DeviceState *milkymist_tmu2_create(hwaddr base, qemu_irq irq)
|
||||
{
|
||||
DeviceState *dev;
|
||||
Display *d;
|
||||
GLXFBConfig *configs;
|
||||
int nelements;
|
||||
int ver_major, ver_minor;
|
||||
|
||||
/* check that GLX will work */
|
||||
d = XOpenDisplay(NULL);
|
||||
if (d == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!glXQueryVersion(d, &ver_major, &ver_minor)) {
|
||||
/*
|
||||
* Yeah, sometimes getting the GLX version can fail.
|
||||
* Isn't X beautiful?
|
||||
*/
|
||||
XCloseDisplay(d);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ver_major < 1) || ((ver_major == 1) && (ver_minor < 3))) {
|
||||
printf("Your GLX version is %d.%d,"
|
||||
"but TMU emulation needs at least 1.3. TMU disabled.\n",
|
||||
ver_major, ver_minor);
|
||||
XCloseDisplay(d);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
configs = glXChooseFBConfig(d, 0, glx_fbconfig_attr, &nelements);
|
||||
if (configs == NULL) {
|
||||
XCloseDisplay(d);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
XFree(configs);
|
||||
XCloseDisplay(d);
|
||||
|
||||
dev = qdev_create(NULL, TYPE_MILKYMIST_TMU2);
|
||||
qdev_init_nofail(dev);
|
||||
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
|
||||
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
@ -88,69 +88,6 @@ static inline DeviceState *milkymist_pfpu_create(hwaddr base,
|
||||
return dev;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OPENGL
|
||||
#include <X11/Xlib.h>
|
||||
#include <epoxy/gl.h>
|
||||
#include <epoxy/glx.h>
|
||||
static const int glx_fbconfig_attr[] = {
|
||||
GLX_GREEN_SIZE, 5,
|
||||
GLX_GREEN_SIZE, 6,
|
||||
GLX_BLUE_SIZE, 5,
|
||||
None
|
||||
};
|
||||
#endif
|
||||
|
||||
static inline DeviceState *milkymist_tmu2_create(hwaddr base,
|
||||
qemu_irq irq)
|
||||
{
|
||||
#ifdef CONFIG_OPENGL
|
||||
DeviceState *dev;
|
||||
Display *d;
|
||||
GLXFBConfig *configs;
|
||||
int nelements;
|
||||
int ver_major, ver_minor;
|
||||
|
||||
/* check that GLX will work */
|
||||
d = XOpenDisplay(NULL);
|
||||
if (d == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!glXQueryVersion(d, &ver_major, &ver_minor)) {
|
||||
/* Yeah, sometimes getting the GLX version can fail.
|
||||
* Isn't X beautiful? */
|
||||
XCloseDisplay(d);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ver_major < 1) || ((ver_major == 1) && (ver_minor < 3))) {
|
||||
printf("Your GLX version is %d.%d,"
|
||||
"but TMU emulation needs at least 1.3. TMU disabled.\n",
|
||||
ver_major, ver_minor);
|
||||
XCloseDisplay(d);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
configs = glXChooseFBConfig(d, 0, glx_fbconfig_attr, &nelements);
|
||||
if (configs == NULL) {
|
||||
XCloseDisplay(d);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
XFree(configs);
|
||||
XCloseDisplay(d);
|
||||
|
||||
dev = qdev_create(NULL, "milkymist-tmu2");
|
||||
qdev_init_nofail(dev);
|
||||
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
|
||||
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq);
|
||||
|
||||
return dev;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline DeviceState *milkymist_ac97_create(hwaddr base,
|
||||
qemu_irq crrequest_irq, qemu_irq crreply_irq, qemu_irq dmar_irq,
|
||||
qemu_irq dmaw_irq)
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "hw/loader.h"
|
||||
#include "elf.h"
|
||||
#include "milkymist-hw.h"
|
||||
#include "hw/display/milkymist_tmu2.h"
|
||||
#include "lm32.h"
|
||||
#include "exec/address-spaces.h"
|
||||
|
||||
|
41
include/hw/display/milkymist_tmu2.h
Normal file
41
include/hw/display/milkymist_tmu2.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* QEMU model of the Milkymist texture mapping unit.
|
||||
*
|
||||
* Copyright (c) 2010 Michael Walle <michael@walle.cc>
|
||||
* Copyright (c) 2010 Sebastien Bourdeauducq
|
||||
* <sebastien.bourdeauducq@lekernel.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* Specification available at:
|
||||
* http://milkymist.walle.cc/socdoc/tmu2.pdf
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HW_DISPLAY_MILKYMIST_TMU2_H
|
||||
#define HW_DISPLAY_MILKYMIST_TMU2_H
|
||||
|
||||
#include "hw/qdev.h"
|
||||
|
||||
#if defined(CONFIG_X11) && defined(CONFIG_OPENGL)
|
||||
DeviceState *milkymist_tmu2_create(hwaddr base, qemu_irq irq);
|
||||
#else
|
||||
static inline DeviceState *milkymist_tmu2_create(hwaddr base, qemu_irq irq)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HW_DISPLAY_MILKYMIST_TMU2_H */
|
@ -17,15 +17,6 @@ they were first deprecated in the 2.10.0 release.
|
||||
What follows is a list of all features currently marked as
|
||||
deprecated.
|
||||
|
||||
@section Build options
|
||||
|
||||
@subsection SDL 1.2
|
||||
|
||||
Previously QEMU has supported building against both SDL 1.2
|
||||
and 2.0 series APIs. Support for the SDL 1.2 builds will be
|
||||
discontinued, so maintainers should switch to using SDL 2.0,
|
||||
which is the default.
|
||||
|
||||
@section System emulator command line arguments
|
||||
|
||||
@subsection -machine enforce-config-section=on|off (since 3.1)
|
||||
|
@ -17,15 +17,10 @@ common-obj-$(call lnot,$(CONFIG_VNC)) += vnc-stubs.o
|
||||
|
||||
# ui-sdl module
|
||||
common-obj-$(CONFIG_SDL) += sdl.mo
|
||||
ifeq ($(CONFIG_SDLABI),1.2)
|
||||
sdl.mo-objs := sdl.o sdl_zoom.o
|
||||
endif
|
||||
ifeq ($(CONFIG_SDLABI),2.0)
|
||||
sdl.mo-objs := sdl2.o sdl2-input.o sdl2-2d.o
|
||||
ifeq ($(CONFIG_OPENGL),y)
|
||||
sdl.mo-objs += sdl2-gl.o
|
||||
endif
|
||||
endif
|
||||
sdl.mo-cflags := $(SDL_CFLAGS)
|
||||
sdl.mo-libs := $(SDL_LIBS)
|
||||
|
||||
|
@ -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
Block a user