SDL,GRAPHICS: Add option for AR correction without scalers

This commit is contained in:
Eric Culp 2012-08-25 12:16:46 -04:00 committed by Filippos Karapetis
parent 4674c7c7b0
commit 39608f391c
3 changed files with 43 additions and 9 deletions

View File

@ -89,7 +89,7 @@ AspectRatio::AspectRatio(int w, int h) {
_kh = h;
}
#if !defined(__SYMBIAN32__) && defined(USE_SCALERS)
#if !defined(__SYMBIAN32__) && defined(USE_ASPECT)
static AspectRatio getDesiredAspectRatio() {
const size_t AR_COUNT = 4;
const char *desiredAspectRatioAsStrings[AR_COUNT] = { "auto", "4/3", "16/9", "16/10" };
@ -152,15 +152,22 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
_enableFocusRectDebugCode = ConfMan.getBool("use_sdl_debug_focusrect");
#endif
#if !defined(__SYMBIAN32__) && defined(USE_SCALERS)
#if !defined(__SYMBIAN32__)
#if defined(USE_SCALERS)
_videoMode.mode = GFX_DOUBLESIZE;
_videoMode.scaleFactor = 2;
_videoMode.aspectRatioCorrection = ConfMan.getBool("aspect_ratio");
_videoMode.desiredAspectRatio = getDesiredAspectRatio();
#else // for small screen platforms
_videoMode.mode = GFX_NORMAL;
_videoMode.scaleFactor = 1;
#endif
#if defined(USE_ASPECT)
_videoMode.aspectRatioCorrection = ConfMan.getBool("aspect_ratio");
_videoMode.desiredAspectRatio = getDesiredAspectRatio();
#else // for small screen platforms
_videoMode.aspectRatioCorrection = false;
#endif
#endif
// HACK: just pick first scaler plugin
_normalPlugin = _scalerPlugins.front();
@ -250,6 +257,7 @@ bool SurfaceSdlGraphicsManager::getFeatureState(OSystem::Feature f) const {
switch (f) {
case OSystem::kFeatureFullscreenMode:
return _videoMode.fullscreen;
#ifdef USE_ASPECT
case OSystem::kFeatureAspectRatioCorrection:
return _videoMode.aspectRatioCorrection;
case OSystem::kFeatureFilteringMode:
@ -1364,6 +1372,9 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
src += _destbuffer->pitch;
}
}
#endif
#ifdef USE_ASPECT
if (_videoMode.aspectRatioCorrection && orig_dst_y < height && !_overlayVisible) {
if (_useOldSrc)
r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1);
@ -1683,9 +1694,10 @@ void SurfaceSdlGraphicsManager::addDirtyRect(int x, int y, int w, int h, bool re
h = height - y;
}
#ifdef USE_SCALERS
if (_videoMode.aspectRatioCorrection && !_overlayVisible && !realCoordinates)
#ifdef USE_ASPECT
if (_videoMode.aspectRatioCorrection && !_overlayVisible && !realCoordinates) {
makeRectStretchable(x, y, w, h, _videoMode.filtering);
}
#endif
if (w == width && h == height) {
@ -1844,7 +1856,7 @@ void SurfaceSdlGraphicsManager::clearOverlay() {
if (_useOldSrc)
(*_scalerPlugin)->enableSource(true);
#ifdef USE_SCALERS
#ifdef USE_ASPECT
if (_videoMode.aspectRatioCorrection)
stretch200To240((uint8 *)_overlayscreen->pixels, _overlayscreen->pitch,
_videoMode.overlayWidth, _videoMode.screenHeight * _videoMode.scaleFactor, 0, 0, 0,
@ -2232,7 +2244,7 @@ void SurfaceSdlGraphicsManager::blitCursor() {
}
#endif
#ifdef USE_SCALERS
#ifdef USE_ASPECT
if (!_cursorDontScale && _videoMode.aspectRatioCorrection)
stretch200To240Nearest((uint8 *)_mouseSurface->pixels, _mouseSurface->pitch, rW, rH1, 0, 0, 0);
#endif

18
configure vendored
View File

@ -188,6 +188,7 @@ _lua=yes
_build_scalers=yes
_build_hq_scalers=yes
_build_edge_scalers=yes
_build_aspect=yes
_enable_prof=no
_enable_asan=no
_enable_tsan=no
@ -1060,6 +1061,7 @@ Optional Features:
--disable-scalers exclude scalers
--disable-hq-scalers exclude HQ2x and HQ3x scalers (disables Edge scalers as well)
--disable-edge-scalers exclude Edge2x and Edge3x scalers
--disable-aspect exclude aspect ratio correction
--disable-translation don't build support for translated messages
--disable-taskbar don't build support for taskbar and launcher integration
--disable-cloud don't build cloud support
@ -1255,6 +1257,7 @@ for ac_option in $@; do
--disable-scalers) _build_scalers=no ;;
--disable-hq-scalers) _build_hq_scalers=no ;;
--disable-edge-scalers) _build_edge_scalers=no ;;
--disable-aspect) _build_aspect=no ;;
--enable-alsa) _alsa=yes ;;
--disable-alsa) _alsa=no ;;
--enable-seq-midi) _seq_midi=yes ;;
@ -3282,12 +3285,14 @@ if test -n "$_host"; then
fi
_port_mk="backends/platform/$_backend/android.mk"
_build_scalers=no
_build_aspect=no
_seq_midi=no
_timidity=no
;;
androidsdl | androidsdl-armeabi | androidsdl-armeabi-v7a | androidsdl-mips | androidsdl-x86 | androidsdl-arm64-v8a | androidsdl-x86_64)
DEFINES="$DEFINES -DANDROIDSDL"
_unix=yes
_build_aspect=no
_seq_midi=no
_timidity=no
_backend="androidsdl"
@ -3409,6 +3414,7 @@ if test -n "$_host"; then
append_var CXXFLAGS "-fdelete-null-pointer-checks"
_backend="dc"
_build_scalers=no
_build_aspect=no
# These two are needed due to shortcomings of the
# detection systems. Do not remove until auto-
# detection works correctly.
@ -3436,6 +3442,7 @@ if test -n "$_host"; then
append_var DEFINES "-DVECTOR_RENDERER_FORMAT=1555"
_backend="ds"
_build_scalers=no
_build_aspect=no
_mt32emu=no
_nuked_opl=no
_tinygl=no
@ -3448,6 +3455,7 @@ if test -n "$_host"; then
gamecube)
_backend="wii"
_build_scalers=no
_build_aspect=no
_vkeybd=yes
_mt32emu=no
_port_mk="backends/platform/wii/wii.mk"
@ -3510,6 +3518,7 @@ if test -n "$_host"; then
append_var ASFLAGS "-arch armv6"
_backend="iphone"
_build_scalers=no
_build_aspect=no
_mt32emu=no
_seq_midi=no
_timidity=no
@ -3569,6 +3578,7 @@ if test -n "$_host"; then
_backend="n64"
_mt32emu=no
_build_scalers=no
_build_aspect=no
_savegame_timestamp=no
_translation=no
_text_console=no
@ -3647,6 +3657,7 @@ if test -n "$_host"; then
psp)
_backend="psp"
_build_scalers=no
_build_aspect=no
_mt32emu=no
_port_mk="backends/platform/psp/psp.mk"
;;
@ -3673,6 +3684,7 @@ if test -n "$_host"; then
wii)
_backend="wii"
_build_scalers=no
_build_aspect=no
_vkeybd=yes
_port_mk="backends/platform/wii/wii.mk"
add_line_to_config_mk 'GAMECUBE = 0'
@ -4360,6 +4372,8 @@ define_in_config_if_yes "$_build_hq_scalers" 'USE_HQ_SCALERS'
define_in_config_if_yes "$_build_edge_scalers" 'USE_EDGE_SCALERS'
define_in_config_if_yes "$_build_aspect" 'USE_ASPECT'
#
# Check for math lib
#
@ -6005,6 +6019,10 @@ if test "$_build_scalers" = yes ; then
fi
fi
if test "$_build_aspect" = yes; then
echo_n ", aspect ratio correction"
fi
if test "$_mt32emu" = yes ; then
echo_n ", MT-32 emulator"
fi

View File

@ -83,12 +83,16 @@ MODULE_OBJS += \
tinygl/zdirtyrect.o
endif
ifdef USE_ASPECT
MODULE_OBJS += \
scaler/aspect.o
endif
ifdef USE_SCALERS
MODULE_OBJS += \
scaler/dotmatrix.o \
scaler/sai.o \
scaler/pm.o \
scaler/aspect.o \
scaler/downscaler.o \
scaler/scale2x.o \
scaler/scale3x.o \