[Scummvm-git-logs] scummvm master -> e09c521cd8b91069808dcdeda9d19e842a798349
spleen1981
noreply at scummvm.org
Fri Nov 1 23:16:58 UTC 2024
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
742f88bd15 LIBRETRO: add GUI resolution settings
958b6b74b1 LIBRETRO: add NEON feature test to LibretroOpenGLGraphics
e09c521cd8 LIBRETRO: refactor av_status
Commit: 742f88bd154e1376b2c8ea4a71f658b70383cf9c
https://github.com/scummvm/scummvm/commit/742f88bd154e1376b2c8ea4a71f658b70383cf9c
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2024-11-02T00:16:47+01:00
Commit Message:
LIBRETRO: add GUI resolution settings
Changed paths:
backends/platform/libretro/include/libretro-core-options-intl.h
backends/platform/libretro/include/libretro-core-options.h
backends/platform/libretro/include/libretro-core.h
backends/platform/libretro/include/libretro-defs.h
backends/platform/libretro/include/libretro-graphics-opengl.h
backends/platform/libretro/include/libretro-graphics-surface.h
backends/platform/libretro/include/libretro-os.h
backends/platform/libretro/include/portdefs.h
backends/platform/libretro/src/libretro-core.cpp
backends/platform/libretro/src/libretro-graphics-opengl.cpp
backends/platform/libretro/src/libretro-graphics-surface.cpp
backends/platform/libretro/src/libretro-os-base.cpp
diff --git a/backends/platform/libretro/include/libretro-core-options-intl.h b/backends/platform/libretro/include/libretro-core-options-intl.h
index dd1da6f27f5..779dcf78e4b 100644
--- a/backends/platform/libretro/include/libretro-core-options-intl.h
+++ b/backends/platform/libretro/include/libretro-core-options-intl.h
@@ -573,6 +573,32 @@ struct retro_core_option_v2_definition option_defs_it[] = {
},
NULL,
},
+#ifdef USE_HIGHRES
+ {
+ "scummvm_gui_aspect_ratio",
+ "Video > Rapporto aspetto GUI",
+ "Rapporto aspetto ScummVM Launcher",
+ "Imposta il rapporto d'aspetto per ScummVM Launcher.",
+ NULL,
+ NULL,
+ {
+ { NULL, NULL }
+ },
+ NULL,
+ },
+ {
+ "scummvm_gui_h_res",
+ "Video > Risoluzione GUI",
+ "Risoluzione ScummVM Launcher",
+ "Imposta la risoluzione per ScummVM Launcher.",
+ NULL,
+ NULL,
+ {
+ { NULL, NULL }
+ },
+ NULL,
+ },
+#endif
{ NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
};
struct retro_core_options_v2 options_it = {
diff --git a/backends/platform/libretro/include/libretro-core-options.h b/backends/platform/libretro/include/libretro-core-options.h
index c65dfb8f8c7..258817bde3f 100644
--- a/backends/platform/libretro/include/libretro-core-options.h
+++ b/backends/platform/libretro/include/libretro-core-options.h
@@ -656,6 +656,36 @@ struct retro_core_option_v2_definition option_defs_us[] = {
"disabled"
#endif
},
+#ifdef USE_HIGHRES
+ {
+ "scummvm_gui_aspect_ratio",
+ "Video > GUI aspect ratio",
+ "ScummVM Launcher aspect ratio",
+ "Set ScummVM Launcher aspect ratio.",
+ NULL,
+ "video",
+ {
+ {"0", "4:3"},
+ {"1", "16:9"},
+ {NULL, NULL}, },
+ "1"
+ },
+ {
+ "scummvm_gui_h_res",
+ "Video > GUI resolution",
+ "ScummVM Launcher resolution",
+ "Set ScummVM Launcher aspect ratio.",
+ NULL,
+ "video",
+ {
+ {"240", "LD"},
+ {"480", "SD"},
+ {"720", "HD"},
+ {"1080", "FHD"},
+ {NULL, NULL}, },
+ "720"
+ },
+#endif
{ NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
};
diff --git a/backends/platform/libretro/include/libretro-core.h b/backends/platform/libretro/include/libretro-core.h
index 2597647286c..2557d1ab757 100644
--- a/backends/platform/libretro/include/libretro-core.h
+++ b/backends/platform/libretro/include/libretro-core.h
@@ -42,6 +42,8 @@ int retro_setting_get_mouse_fine_control_speed_reduction(void);
bool retro_setting_get_gamepad_cursor_only(void);
float retro_setting_get_gamepad_cursor_speed(void);
float retro_setting_get_gamepad_acceleration_time(void);
+int retro_setting_get_gui_res_w(void);
+int retro_setting_get_gui_res_h(void);
void retro_set_size(unsigned width, unsigned height);
diff --git a/backends/platform/libretro/include/libretro-defs.h b/backends/platform/libretro/include/libretro-defs.h
index 63aa8e7f657..5058b4e0f70 100644
--- a/backends/platform/libretro/include/libretro-defs.h
+++ b/backends/platform/libretro/include/libretro-defs.h
@@ -40,6 +40,7 @@
#define AUDIO_STATUS_UPDATE_AV_INFO (1 << 5)
#define AUDIO_STATUS_RESET_PENDING (1 << 6)
#define AUDIO_STATUS_UPDATE_GEOMETRY (1 << 7)
+#define AV_STATUS_UPDATE_GUI (1 << 8)
// Video status
#define VIDEO_GRAPHIC_MODE_REQUEST_SW (1 << 0)
diff --git a/backends/platform/libretro/include/libretro-graphics-opengl.h b/backends/platform/libretro/include/libretro-graphics-opengl.h
index e7c7f5daf42..f603f02845a 100644
--- a/backends/platform/libretro/include/libretro-graphics-opengl.h
+++ b/backends/platform/libretro/include/libretro-graphics-opengl.h
@@ -36,8 +36,13 @@ public:
bool isOverlayInGUI(void){ return _overlayInGUI; }
void setMousePosition(int x, int y);
void resetContext(OpenGL::ContextType contextType);
+ OSystem::TransactionError endGFXTransaction() override;
+
protected:
bool gameNeedsAspectRatioCorrection() const override { return false; }
+ void handleResizeImpl(const int width, const int height) override;
+private:
+ void overrideCursorScaling(void);
};
class LibretroHWFramebuffer : public OpenGL::Backbuffer {
diff --git a/backends/platform/libretro/include/libretro-graphics-surface.h b/backends/platform/libretro/include/libretro-graphics-surface.h
index b12fbf5b319..21b526aa3aa 100644
--- a/backends/platform/libretro/include/libretro-graphics-surface.h
+++ b/backends/platform/libretro/include/libretro-graphics-surface.h
@@ -28,19 +28,22 @@ public:
Graphics::ManagedSurface _screen;
Graphics::Surface _gameScreen;
Graphics::Surface _overlay;
- Graphics::Surface _mouseImage;
- Graphics::Palette _mousePalette;
+ Graphics::Surface _cursor;
+ Graphics::Palette _cursorPalette;
Graphics::Palette _gamePalette;
private:
- bool _mouseDontScale;
- bool _mousePaletteEnabled;
- bool _mouseVisible;
+ bool _cursorDontScale;
+ bool _cursorPaletteEnabled;
bool _screenUpdatePending;
- int _mouseHotspotX;
- int _mouseHotspotY;
- int _mouseKeyColor;
+ int _cursorHotspotX;
+ int _cursorHotspotY;
+ int _cursorKeyColor;
int _screenChangeID;
+ int _cursorHotspotXScaled;
+ int _cursorHotspotYScaled;
+ float _cursorWidthScaled;
+ float _cursorHeightScaled;
public:
LibretroGraphics();
@@ -60,7 +63,6 @@ public:
int16 getOverlayWidth(void) const override;
Graphics::PixelFormat getOverlayFormat() const override;
const Graphics::ManagedSurface *getScreen(void);
- bool showMouse(bool visible) override;
void warpMouse(int x, int y) override;
void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 255, bool dontScale = false, const Graphics::PixelFormat *format = NULL, const byte *mask = nullptr) override;
void setCursorPalette(const byte *colors, uint start, uint num) override;
@@ -78,7 +80,7 @@ public:
int getScreenChangeID() const override;
void beginGFXTransaction() override {}
- OSystem::TransactionError endGFXTransaction() override { return OSystem::kTransactionSuccess; }
+ OSystem::TransactionError endGFXTransaction() override;
void fillScreen(uint32 col) override {}
void fillScreen(const Common::Rect &r, uint32 col) override {}
void setFocusRectangle(const Common::Rect &rect) override {}
@@ -87,7 +89,7 @@ public:
void realUpdateScreen(void);
bool gameNeedsAspectRatioCorrection() const override { return false; }
- void handleResizeImpl(const int width, const int height) override {};
+ void handleResizeImpl(const int width, const int height) override;
void setSystemMousePosition(const int x, const int y) override {}
void setMousePosition(int x, int y);
@@ -96,5 +98,7 @@ public:
protected:
void setPalette(const byte *colors, uint start, uint num) override;
void grabPalette(byte *colors, uint start, uint num) const override;
+private:
+ void overrideCursorScaling();
};
#endif //BACKENDS_LIBRETRO_GRAPHICS_SURFACE_H
diff --git a/backends/platform/libretro/include/libretro-os.h b/backends/platform/libretro/include/libretro-os.h
index d202368ca18..a7c3dcf3437 100644
--- a/backends/platform/libretro/include/libretro-os.h
+++ b/backends/platform/libretro/include/libretro-os.h
@@ -92,6 +92,7 @@ public:
int16 getScreenWidth(void);
int16 getScreenHeight(void);
bool isOverlayInGUI(void);
+ bool inLauncher(void);
#ifdef USE_OPENGL
void resetGraphicsContext(void);
diff --git a/backends/platform/libretro/include/portdefs.h b/backends/platform/libretro/include/portdefs.h
index 4e6592fed83..048e1d64e4e 100644
--- a/backends/platform/libretro/include/portdefs.h
+++ b/backends/platform/libretro/include/portdefs.h
@@ -38,7 +38,7 @@
This conflicts with the use of _X as a variable name. */
#undef _X
-#if defined(DINGUX) || defined(_3DS)
+#ifndef USE_HIGHRES
#define RES_W_OVERLAY 320
#define RES_H_OVERLAY 200
#define RES_INIT_MAX_W 320
diff --git a/backends/platform/libretro/src/libretro-core.cpp b/backends/platform/libretro/src/libretro-core.cpp
index bba39ca94a8..71ad82450c3 100644
--- a/backends/platform/libretro/src/libretro-core.cpp
+++ b/backends/platform/libretro/src/libretro-core.cpp
@@ -85,6 +85,8 @@ static uint8 video_hw_mode = 0;
static unsigned base_width = RES_W_OVERLAY;
static unsigned base_height = RES_H_OVERLAY;
+static unsigned gui_width = RES_W_OVERLAY;
+static unsigned gui_height = RES_H_OVERLAY;
static unsigned max_width = RES_INIT_MAX_W;
static unsigned max_height = RES_INIT_MAX_H;
@@ -94,7 +96,7 @@ static uint8 frameskip_type;
static uint8 frameskip_threshold;
static uint32 frameskip_counter = 0;
-static uint8 audio_status = AUDIO_STATUS_MUTE;
+static uint16 audio_status = AUDIO_STATUS_MUTE;
static unsigned retro_audio_buff_occupancy = 0;
static uint8 retro_audio_buff_underrun_threshold = 25;
@@ -133,6 +135,16 @@ void *retro_get_proc_address(const char *name) {
}
#endif
+#ifdef USE_HIGHRES
+static void retro_gui_res_reset() {
+ if (retro_emu_thread_started()) {
+ LIBRETRO_G_SYSTEM->beginGFXTransaction();
+ LIBRETRO_G_SYSTEM->initSize(0, 0, nullptr);
+ LIBRETRO_G_SYSTEM->endGFXTransaction();
+ }
+}
+#endif
+
static void setup_hw_rendering(void) {
enum retro_pixel_format pixel_fmt;
@@ -549,6 +561,30 @@ static void update_variables(void) {
}
}
+#ifdef USE_HIGHRES
+ var.key = "scummvm_gui_h_res";
+ var.value = NULL;
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
+ uint16 new_gui_height = (int)atoi(var.value);
+ audio_status |= new_gui_height != gui_height && LIBRETRO_G_SYSTEM->inLauncher() ? AV_STATUS_UPDATE_GUI : 0;
+ gui_height = new_gui_height;
+ }
+
+ var.key = "scummvm_gui_aspect_ratio";
+ var.value = NULL;
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
+ uint8 num = 4;
+ uint8 den = 3;
+ if (atoi(var.value)) {
+ num = 16;
+ den = 9;
+ }
+ uint16 new_gui_width = gui_height * num / den + (gui_height * num % den != 0);
+ audio_status |= (new_gui_width != gui_width) && LIBRETRO_G_SYSTEM->inLauncher() ? AV_STATUS_UPDATE_GUI : 0;
+ gui_width = new_gui_width;
+ }
+#endif
+
if (!(audio_status & AUDIO_STATUS_BUFFER_SUPPORT)) {
if (frameskip_type > 1) {
retro_log_cb(RETRO_LOG_WARN, "Selected frameskip mode not available.\n");
@@ -640,6 +676,14 @@ float retro_setting_get_frame_rate(void) {
return frame_rate;
}
+int retro_setting_get_gui_res_w(void) {
+ return gui_width;
+}
+
+int retro_setting_get_gui_res_h(void) {
+ return gui_height;
+}
+
bool retro_get_input_bitmask_supported(void) {
return input_bitmask_supported;
}
@@ -892,6 +936,8 @@ void retro_init(void) {
audio_status = environ_cb(RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK, &buf_status_cb) ? (audio_status | AUDIO_STATUS_BUFFER_SUPPORT) : (audio_status & ~AUDIO_STATUS_BUFFER_SUPPORT);
update_variables();
+ max_width = gui_width > max_width ? gui_width : max_width;
+ max_height = gui_height > max_height ? gui_height : max_height;
retro_set_options_display();
@@ -1059,18 +1105,24 @@ void retro_run(void) {
except in case of core options reset to defaults, for which the following call is needed*/
retro_update_options_display();
+#ifdef USE_HIGHRES
+ if (audio_status & AV_STATUS_UPDATE_GUI) {
+ retro_gui_res_reset();
+ audio_status &= ~AV_STATUS_UPDATE_GUI;
+ }
+#endif
+
if (audio_status & (AUDIO_STATUS_UPDATE_AV_INFO | AUDIO_STATUS_UPDATE_GEOMETRY)) {
struct retro_system_av_info info;
retro_get_system_av_info(&info);
- if (audio_status & AUDIO_STATUS_UPDATE_GEOMETRY) {
- environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &info);
- audio_status &= ~AUDIO_STATUS_UPDATE_GEOMETRY;
- } else {
+ if (audio_status & AUDIO_STATUS_UPDATE_AV_INFO)
environ_cb(RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO, &info);
- audio_status &= ~AUDIO_STATUS_UPDATE_AV_INFO;
- }
+ else
+ environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &info);
+
+ audio_status &= ~(AUDIO_STATUS_UPDATE_AV_INFO | AUDIO_STATUS_UPDATE_GEOMETRY);
#ifdef USE_OPENGL
- context_reset();
+ context_reset();
#endif
}
diff --git a/backends/platform/libretro/src/libretro-graphics-opengl.cpp b/backends/platform/libretro/src/libretro-graphics-opengl.cpp
index 630d098c713..b1ad55293b6 100644
--- a/backends/platform/libretro/src/libretro-graphics-opengl.cpp
+++ b/backends/platform/libretro/src/libretro-graphics-opengl.cpp
@@ -44,21 +44,55 @@ void LibretroOpenGLGraphics::setMouseCursor(const void *buf, uint w, uint h, int
@TODO: root cause to be investigated. */
delete _cursor;
_cursor = nullptr;
+
OpenGL::OpenGLGraphicsManager::setMouseCursor(buf, w, h, hotspotX, hotspotY, keycolor, dontScale, format, mask);
+
+ overrideCursorScaling();
+
+}
+
+void LibretroOpenGLGraphics::overrideCursorScaling(){
+ OpenGL::OpenGLGraphicsManager::recalculateCursorScaling();
+
+ if (_cursor){
+ const frac_t screenScaleFactor = _cursorDontScale ? intToFrac(1) : intToFrac(getWindowHeight()) / 200; /* hard coded as base resolution 320x200 is hard coded upstream */
+
+ _cursorHotspotXScaled = fracToInt(_cursorHotspotX * screenScaleFactor);
+ _cursorWidthScaled = fracToDouble(_cursor->getWidth() * screenScaleFactor);
+
+ _cursorHotspotYScaled = fracToInt(_cursorHotspotY * screenScaleFactor);
+ _cursorHeightScaled = fracToDouble(_cursor->getHeight() * screenScaleFactor);
+ }
}
void LibretroOpenGLGraphics::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
/* Override for ScummVM Launcher */
if (nullptr == ConfMan.getActiveDomain()){
- width = RES_W_OVERLAY;
- height = RES_H_OVERLAY;
+ width = retro_setting_get_gui_res_w();
+ height = retro_setting_get_gui_res_h();
}
+ /* no need to update now libretro gui res settings changes if not in ScummVM launcher */
+ if (! width)
+ return;
+
retro_set_size(width, height);
handleResize(width, height);
OpenGL::OpenGLGraphicsManager::initSize(width, height, format);
LIBRETRO_G_SYSTEM->refreshRetroSettings();
}
+OSystem::TransactionError LibretroOpenGLGraphics::endGFXTransaction() {
+ OSystem::TransactionError res = OpenGL::OpenGLGraphicsManager::endGFXTransaction();
+ overrideCursorScaling();
+
+ return res;
+}
+
+void LibretroOpenGLGraphics::handleResizeImpl(const int width, const int height) {
+ OpenGL::OpenGLGraphicsManager::handleResizeImpl(width, height);
+ overrideCursorScaling();
+}
+
void LibretroHWFramebuffer::activateInternal(){
GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, retro_get_hw_fb()));
}
@@ -74,5 +108,5 @@ void LibretroOpenGLGraphics::resetContext(OpenGL::ContextType contextType) {
notifyContextCreate(contextType, new LibretroHWFramebuffer(), rgba8888, rgba8888);
if (_overlayInGUI)
- g_gui.scheduleFullRedraw();
+ g_gui.checkScreenChange();
}
diff --git a/backends/platform/libretro/src/libretro-graphics-surface.cpp b/backends/platform/libretro/src/libretro-graphics-surface.cpp
index 6ea71a01237..b5615aa9db5 100644
--- a/backends/platform/libretro/src/libretro-graphics-surface.cpp
+++ b/backends/platform/libretro/src/libretro-graphics-surface.cpp
@@ -20,6 +20,7 @@
#include "graphics/managed_surface.h"
#include "gui/message.h"
+#include "gui/gui-manager.h"
#include "backends/platform/libretro/include/libretro-defs.h"
#include "backends/platform/libretro/include/libretro-core.h"
@@ -27,19 +28,18 @@
#include "backends/platform/libretro/include/libretro-timer.h"
#include "backends/platform/libretro/include/libretro-graphics-surface.h"
-LibretroGraphics::LibretroGraphics() : _mousePaletteEnabled(false),
- _mouseVisible(false),
- _mouseKeyColor(0),
- _mouseDontScale(false),
+LibretroGraphics::LibretroGraphics() : _cursorPaletteEnabled(false),
+ _cursorKeyColor(0),
+ _cursorDontScale(false),
_screenUpdatePending(false),
_gamePalette(256),
- _mousePalette(256),
+ _cursorPalette(256),
_screenChangeID(1 << (sizeof(int) * 8 - 2)){}
LibretroGraphics::~LibretroGraphics() {
_gameScreen.free();
_overlay.free();
- _mouseImage.free();
+ _cursor.free();
_screen.free();
}
@@ -72,12 +72,17 @@ const OSystem::GraphicsMode *LibretroGraphics::getSupportedGraphicsModes() const
void LibretroGraphics::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
Graphics::PixelFormat actFormat = format ? *format : Graphics::PixelFormat::createFormatCLUT8();
-
+ bool force_gui_redraw = false;
/* Override for ScummVM Launcher */
if (nullptr == ConfMan.getActiveDomain()){
- width = RES_W_OVERLAY;
- height = RES_H_OVERLAY;
+ /* 0 w/h is used to notify libretro gui res settings is changed */
+ force_gui_redraw = (width == 0);
+ width = retro_setting_get_gui_res_w();
+ height = retro_setting_get_gui_res_h();
}
+ /* no need to update now libretro gui res settings changes if not in ScummVM launcher */
+ if (! width)
+ return;
if (_gameScreen.w != width || _gameScreen.h != height || _gameScreen.format != actFormat)
_gameScreen.create(width, height, actFormat);
@@ -85,14 +90,17 @@ void LibretroGraphics::initSize(uint width, uint height, const Graphics::PixelFo
if (_overlay.w != width || _overlay.h != height)
_overlay.create(width, height, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
- if (getWindowWidth() != width || getWindowHeight() != height) {
+ if (getWindowWidth() != width || getWindowHeight() != height)
_screen.create(width, height, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
- handleResize(width, height);
- recalculateDisplayAreas();
- retro_set_size(width, height);
- LIBRETRO_G_SYSTEM->refreshRetroSettings();
- ++_screenChangeID;
- }
+
+ handleResize(width, height);
+ recalculateDisplayAreas();
+ retro_set_size(width, height);
+ LIBRETRO_G_SYSTEM->refreshRetroSettings();
+ ++_screenChangeID;
+
+ if (force_gui_redraw)
+ g_gui.checkScreenChange();
}
int16 LibretroGraphics::getHeight() const {
@@ -123,9 +131,10 @@ void LibretroGraphics::realUpdateScreen(void) {
if (srcSurface.w && srcSurface.h)
_screen.blitFrom(srcSurface, Common::Rect(srcSurface.w,srcSurface.h),Common::Rect(_screen.w,_screen.h),&_gamePalette);
- if (_mouseVisible && _mouseImage.w && _mouseImage.h)
- _screen.transBlitFrom(_mouseImage, Common::Point(_cursorX - _mouseHotspotX, _cursorY - _mouseHotspotY), _mouseKeyColor, false, 0, 0xff, _mousePaletteEnabled ? &_mousePalette : &_gamePalette);
-
+ if (_cursorVisible && _cursor.w && _cursor.h) {
+ Common::Point topLeft(_cursorX - _cursorHotspotXScaled, _cursorY - _cursorHotspotYScaled);
+ _screen.transBlitFrom(_cursor, Common::Rect( _cursor.w, _cursor.h), Common::Rect(topLeft, topLeft + Common::Point(_cursorWidthScaled, _cursorHeightScaled)), _cursorKeyColor, false, 0, 0xff, nullptr, false, _cursorPaletteEnabled ? &_cursorPalette : &_gamePalette);
+ }
_screenUpdatePending = false;
}
@@ -153,38 +162,54 @@ Graphics::PixelFormat LibretroGraphics::getOverlayFormat() const {
return _overlay.format;
}
-bool LibretroGraphics::showMouse(bool visible) {
- const bool wasVisible = _mouseVisible;
- _mouseVisible = visible;
- return wasVisible;
-}
-
void LibretroGraphics::warpMouse(int x, int y) {
LIBRETRO_G_SYSTEM->_mouseX = x;
LIBRETRO_G_SYSTEM->_mouseY = y;
WindowedGraphicsManager::warpMouse(x, y);
}
+void LibretroGraphics::overrideCursorScaling(){
+ const frac_t screenScaleFactor = _cursorDontScale ? intToFrac(1) : intToFrac(getWindowHeight()) / 200; /* hard coded as base resolution 320x200 is hard coded upstream */
+
+ _cursorHotspotXScaled = fracToInt(_cursorHotspotX * screenScaleFactor);
+ _cursorWidthScaled = fracToDouble(_cursor.w * screenScaleFactor);
+
+ _cursorHotspotYScaled = fracToInt(_cursorHotspotY * screenScaleFactor);
+ _cursorHeightScaled = fracToDouble(_cursor.h * screenScaleFactor);
+}
+
void LibretroGraphics::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format, const byte *mask) {
if (!buf || !w || !h)
return;
const Graphics::PixelFormat mformat = format ? *format : Graphics::PixelFormat::createFormatCLUT8();
- if (_mouseImage.w != w || _mouseImage.h != h || _mouseImage.format != mformat)
- _mouseImage.create(w, h, mformat);
+ if (_cursor.w != w || _cursor.h != h || _cursor.format != mformat)
+ _cursor.create(w, h, mformat);
+
+ _cursor.copyRectToSurface(buf, _cursor.pitch, 0, 0, w, h);
+
+ _cursorHotspotX = hotspotX;
+ _cursorHotspotY = hotspotY;
+ _cursorKeyColor = keycolor;
+ _cursorDontScale = dontScale;
- _mouseImage.copyRectToSurface(buf, _mouseImage.pitch, 0, 0, w, h);
+ overrideCursorScaling();
+}
+
+
+OSystem::TransactionError LibretroGraphics::endGFXTransaction() {
+ overrideCursorScaling();
+ return OSystem::TransactionError::kTransactionSuccess;
+}
- _mouseHotspotX = hotspotX;
- _mouseHotspotY = hotspotY;
- _mouseKeyColor = keycolor;
- _mouseDontScale = dontScale;
+void LibretroGraphics::handleResizeImpl(const int width, const int height) {
+ overrideCursorScaling();
}
void LibretroGraphics::setCursorPalette(const byte *colors, uint start, uint num) {
- _mousePalette.set(colors, start, num);
- _mousePaletteEnabled = true;
+ _cursorPalette.set(colors, start, num);
+ _cursorPaletteEnabled = true;
}
bool LibretroGraphics::isOverlayInGUI(void) {
@@ -213,11 +238,11 @@ bool LibretroGraphics::hasFeature(OSystem::Feature f) const {
void LibretroGraphics::setFeatureState(OSystem::Feature f, bool enable) {
if (f == OSystem::kFeatureCursorPalette)
- _mousePaletteEnabled = enable;
+ _cursorPaletteEnabled = enable;
}
bool LibretroGraphics::getFeatureState(OSystem::Feature f) const {
- return (f == OSystem::kFeatureCursorPalette) ? _mousePaletteEnabled : false;
+ return (f == OSystem::kFeatureCursorPalette) ? _cursorPaletteEnabled : false;
}
void LibretroGraphics::setMousePosition(int x, int y){
diff --git a/backends/platform/libretro/src/libretro-os-base.cpp b/backends/platform/libretro/src/libretro-os-base.cpp
index e7bb67090f1..49b713816f8 100644
--- a/backends/platform/libretro/src/libretro-os-base.cpp
+++ b/backends/platform/libretro/src/libretro-os-base.cpp
@@ -169,3 +169,7 @@ void OSystem_libretro::resetGraphicsManager(void) {
#endif
_graphicsManager = new LibretroGraphics();
}
+
+bool OSystem_libretro::inLauncher() {
+ return (nullptr == ConfMan.getActiveDomain());
+}
Commit: 958b6b74b130153f6f0e60993d078c42b98c1f50
https://github.com/scummvm/scummvm/commit/958b6b74b130153f6f0e60993d078c42b98c1f50
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2024-11-02T00:16:47+01:00
Commit Message:
LIBRETRO: add NEON feature test to LibretroOpenGLGraphics
Changed paths:
backends/platform/libretro/include/libretro-graphics-opengl.h
backends/platform/libretro/src/libretro-graphics-opengl.cpp
diff --git a/backends/platform/libretro/include/libretro-graphics-opengl.h b/backends/platform/libretro/include/libretro-graphics-opengl.h
index f603f02845a..3dcc533b225 100644
--- a/backends/platform/libretro/include/libretro-graphics-opengl.h
+++ b/backends/platform/libretro/include/libretro-graphics-opengl.h
@@ -37,7 +37,7 @@ public:
void setMousePosition(int x, int y);
void resetContext(OpenGL::ContextType contextType);
OSystem::TransactionError endGFXTransaction() override;
-
+ bool hasFeature(OSystem::Feature f) const override;
protected:
bool gameNeedsAspectRatioCorrection() const override { return false; }
void handleResizeImpl(const int width, const int height) override;
diff --git a/backends/platform/libretro/src/libretro-graphics-opengl.cpp b/backends/platform/libretro/src/libretro-graphics-opengl.cpp
index b1ad55293b6..11fdf54da70 100644
--- a/backends/platform/libretro/src/libretro-graphics-opengl.cpp
+++ b/backends/platform/libretro/src/libretro-graphics-opengl.cpp
@@ -93,6 +93,14 @@ void LibretroOpenGLGraphics::handleResizeImpl(const int width, const int height)
overrideCursorScaling();
}
+bool LibretroOpenGLGraphics::hasFeature(OSystem::Feature f) const {
+ return
+#ifdef SCUMMVM_NEON
+ (f == OSystem::kFeatureCpuNEON) ||
+#endif
+ OpenGL::OpenGLGraphicsManager::hasFeature(f);
+}
+
void LibretroHWFramebuffer::activateInternal(){
GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, retro_get_hw_fb()));
}
Commit: e09c521cd8b91069808dcdeda9d19e842a798349
https://github.com/scummvm/scummvm/commit/e09c521cd8b91069808dcdeda9d19e842a798349
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2024-11-02T00:16:47+01:00
Commit Message:
LIBRETRO: refactor av_status
Changed paths:
backends/platform/libretro/include/libretro-defs.h
backends/platform/libretro/src/libretro-core.cpp
diff --git a/backends/platform/libretro/include/libretro-defs.h b/backends/platform/libretro/include/libretro-defs.h
index 5058b4e0f70..7d7b9416517 100644
--- a/backends/platform/libretro/include/libretro-defs.h
+++ b/backends/platform/libretro/include/libretro-defs.h
@@ -37,9 +37,9 @@
#define AUDIO_STATUS_BUFFER_ACTIVE (1 << 2)
#define AUDIO_STATUS_BUFFER_UNDERRUN (1 << 3)
#define AUDIO_STATUS_UPDATE_LATENCY (1 << 4)
-#define AUDIO_STATUS_UPDATE_AV_INFO (1 << 5)
-#define AUDIO_STATUS_RESET_PENDING (1 << 6)
-#define AUDIO_STATUS_UPDATE_GEOMETRY (1 << 7)
+#define AV_STATUS_UPDATE_AV_INFO (1 << 5)
+#define AV_STATUS_RESET_PENDING (1 << 6)
+#define AV_STATUS_UPDATE_GEOMETRY (1 << 7)
#define AV_STATUS_UPDATE_GUI (1 << 8)
// Video status
diff --git a/backends/platform/libretro/src/libretro-core.cpp b/backends/platform/libretro/src/libretro-core.cpp
index 71ad82450c3..acb368057da 100644
--- a/backends/platform/libretro/src/libretro-core.cpp
+++ b/backends/platform/libretro/src/libretro-core.cpp
@@ -96,7 +96,7 @@ static uint8 frameskip_type;
static uint8 frameskip_threshold;
static uint32 frameskip_counter = 0;
-static uint16 audio_status = AUDIO_STATUS_MUTE;
+static uint16 av_status = AUDIO_STATUS_MUTE;
static unsigned retro_audio_buff_occupancy = 0;
static uint8 retro_audio_buff_underrun_threshold = 25;
@@ -237,9 +237,9 @@ static void audio_run(void) {
}
if (samples_produced)
- audio_status &= ~AUDIO_STATUS_MUTE;
+ av_status &= ~AUDIO_STATUS_MUTE;
else {
- audio_status |= AUDIO_STATUS_MUTE;
+ av_status |= AUDIO_STATUS_MUTE;
return;
}
@@ -260,14 +260,14 @@ static void audio_run(void) {
static void retro_audio_buff_status_cb(bool active, unsigned occupancy, bool underrun_likely) {
if (active)
- audio_status |= AUDIO_STATUS_BUFFER_ACTIVE;
+ av_status |= AUDIO_STATUS_BUFFER_ACTIVE;
else
- audio_status &= ~AUDIO_STATUS_BUFFER_ACTIVE;
+ av_status &= ~AUDIO_STATUS_BUFFER_ACTIVE;
if (occupancy < retro_audio_buff_underrun_threshold)
- audio_status |= AUDIO_STATUS_BUFFER_UNDERRUN;
+ av_status |= AUDIO_STATUS_BUFFER_UNDERRUN;
else if (occupancy > (retro_audio_buff_underrun_threshold << 2))
- audio_status &= ~AUDIO_STATUS_BUFFER_UNDERRUN;
+ av_status &= ~AUDIO_STATUS_BUFFER_UNDERRUN;
retro_audio_buff_occupancy = occupancy;
}
@@ -566,7 +566,7 @@ static void update_variables(void) {
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
uint16 new_gui_height = (int)atoi(var.value);
- audio_status |= new_gui_height != gui_height && LIBRETRO_G_SYSTEM->inLauncher() ? AV_STATUS_UPDATE_GUI : 0;
+ av_status |= new_gui_height != gui_height && LIBRETRO_G_SYSTEM->inLauncher() ? AV_STATUS_UPDATE_GUI : 0;
gui_height = new_gui_height;
}
@@ -580,12 +580,12 @@ static void update_variables(void) {
den = 9;
}
uint16 new_gui_width = gui_height * num / den + (gui_height * num % den != 0);
- audio_status |= (new_gui_width != gui_width) && LIBRETRO_G_SYSTEM->inLauncher() ? AV_STATUS_UPDATE_GUI : 0;
+ av_status |= (new_gui_width != gui_width) && LIBRETRO_G_SYSTEM->inLauncher() ? AV_STATUS_UPDATE_GUI : 0;
gui_width = new_gui_width;
}
#endif
- if (!(audio_status & AUDIO_STATUS_BUFFER_SUPPORT)) {
+ if (!(av_status & AUDIO_STATUS_BUFFER_SUPPORT)) {
if (frameskip_type > 1) {
retro_log_cb(RETRO_LOG_WARN, "Selected frameskip mode not available.\n");
retro_osd_notification("Selected frameskip mode not available");
@@ -594,11 +594,11 @@ static void update_variables(void) {
}
if (old_frameskip_type != frameskip_type || old_frame_rate != frame_rate || old_sample_rate != sample_rate) {
- audio_status |= AUDIO_STATUS_UPDATE_LATENCY;
+ av_status |= AUDIO_STATUS_UPDATE_LATENCY;
if (old_frame_rate != frame_rate || old_sample_rate != sample_rate) {
audio_buffer_init(sample_rate, (uint16) frame_rate);
if (g_system)
- audio_status |= (AUDIO_STATUS_UPDATE_AV_INFO & AUDIO_STATUS_RESET_PENDING);
+ av_status |= (AV_STATUS_UPDATE_AV_INFO & AV_STATUS_RESET_PENDING);
}
}
@@ -872,9 +872,9 @@ void retro_set_size(unsigned width, unsigned height) {
} else if (width > max_width || height > max_height) {
max_width = width;
max_height = height;
- audio_status |= AUDIO_STATUS_UPDATE_AV_INFO;
+ av_status |= AV_STATUS_UPDATE_AV_INFO;
} else
- audio_status |= AUDIO_STATUS_UPDATE_GEOMETRY;
+ av_status |= AV_STATUS_UPDATE_GEOMETRY;
base_width = width;
base_height = height;
@@ -933,7 +933,7 @@ void retro_init(void) {
struct retro_audio_buffer_status_callback buf_status_cb;
buf_status_cb.callback = retro_audio_buff_status_cb;
- audio_status = environ_cb(RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK, &buf_status_cb) ? (audio_status | AUDIO_STATUS_BUFFER_SUPPORT) : (audio_status & ~AUDIO_STATUS_BUFFER_SUPPORT);
+ av_status = environ_cb(RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK, &buf_status_cb) ? (av_status | AUDIO_STATUS_BUFFER_SUPPORT) : (av_status & ~AUDIO_STATUS_BUFFER_SUPPORT);
update_variables();
max_width = gui_width > max_width ? gui_width : max_width;
@@ -1106,27 +1106,27 @@ void retro_run(void) {
retro_update_options_display();
#ifdef USE_HIGHRES
- if (audio_status & AV_STATUS_UPDATE_GUI) {
+ if (av_status & AV_STATUS_UPDATE_GUI) {
retro_gui_res_reset();
- audio_status &= ~AV_STATUS_UPDATE_GUI;
+ av_status &= ~AV_STATUS_UPDATE_GUI;
}
#endif
- if (audio_status & (AUDIO_STATUS_UPDATE_AV_INFO | AUDIO_STATUS_UPDATE_GEOMETRY)) {
+ if (av_status & (AV_STATUS_UPDATE_AV_INFO | AV_STATUS_UPDATE_GEOMETRY)) {
struct retro_system_av_info info;
retro_get_system_av_info(&info);
- if (audio_status & AUDIO_STATUS_UPDATE_AV_INFO)
+ if (av_status & AV_STATUS_UPDATE_AV_INFO)
environ_cb(RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO, &info);
else
environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &info);
- audio_status &= ~(AUDIO_STATUS_UPDATE_AV_INFO | AUDIO_STATUS_UPDATE_GEOMETRY);
+ av_status &= ~(AV_STATUS_UPDATE_AV_INFO | AV_STATUS_UPDATE_GEOMETRY);
#ifdef USE_OPENGL
context_reset();
#endif
}
- if (audio_status & AUDIO_STATUS_UPDATE_LATENCY) {
+ if (av_status & AUDIO_STATUS_UPDATE_LATENCY) {
uint32 audio_latency;
float frame_time_msec = 1000.0f / frame_rate;
@@ -1137,11 +1137,11 @@ void retro_run(void) {
/* This can only be called from within retro_run() */
environ_cb(RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY, &audio_latency);
- audio_status &= ~AUDIO_STATUS_UPDATE_LATENCY;
+ av_status &= ~AUDIO_STATUS_UPDATE_LATENCY;
}
- if (audio_status & AUDIO_STATUS_RESET_PENDING) {
- audio_status &= ~AUDIO_STATUS_RESET_PENDING;
+ if (av_status & AV_STATUS_RESET_PENDING) {
+ av_status &= ~AV_STATUS_RESET_PENDING;
retro_reset();
return;
}
@@ -1156,7 +1156,7 @@ void retro_run(void) {
/* Determine frameskip need based on settings */
if (frameskip_type == 2)
- skip_frame = ((audio_status & (AUDIO_STATUS_BUFFER_UNDERRUN | AUDIO_STATUS_BUFFER_ACTIVE)) == (AUDIO_STATUS_BUFFER_UNDERRUN | AUDIO_STATUS_BUFFER_ACTIVE));
+ skip_frame = ((av_status & (AUDIO_STATUS_BUFFER_UNDERRUN | AUDIO_STATUS_BUFFER_ACTIVE)) == (AUDIO_STATUS_BUFFER_UNDERRUN | AUDIO_STATUS_BUFFER_ACTIVE));
else if (frameskip_type == 1)
skip_frame = !(current_frame % frameskip_no == 0);
else if (frameskip_type == 3)
@@ -1165,7 +1165,7 @@ void retro_run(void) {
/* No frame skipping if
- no incoming audio (e.g. GUI)
- doing a THREAD_SWITCH_UPDATE loop */
- skip_frame = skip_frame && !(audio_status & AUDIO_STATUS_MUTE);
+ skip_frame = skip_frame && !(av_status & AUDIO_STATUS_MUTE);
/* Reset frameskip counter if not flagged */
if ((!skip_frame && frameskip_counter) || frameskip_counter >= FRAMESKIP_MAX) {
More information about the Scummvm-git-logs
mailing list