OPENGL: Implement cursor scaling

This commit is contained in:
Cameron Cawley 2021-11-16 22:38:36 +00:00 committed by Eugene Sandulenko
parent 267f1f18fb
commit 2db20b702e

View File

@ -763,6 +763,8 @@ void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int
_cursorDontScale = dontScale;
if (!w || !h) {
if (_cursor)
_cursor->unloadScaler();
delete _cursor;
_cursor = nullptr;
return;
@ -781,9 +783,17 @@ void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int
// In case the color format has changed we will need to create the texture.
if (!_cursor || _cursor->getFormat() != inputFormat) {
if (_cursor)
_cursor->unloadScaler();
delete _cursor;
_cursor = nullptr;
#ifdef USE_SCALERS
bool wantScaler = (_currentState.scaleFactor > 1) && !dontScale
&& _scalerPlugins[_currentState.scalerIndex]->get<ScalerPluginObject>().canDrawCursor();
#else
bool wantScaler = false;
#endif
GLenum glIntFormat, glFormat, glType;
Graphics::PixelFormat textureFormat;
@ -798,10 +808,14 @@ void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int
} else {
textureFormat = _defaultFormatAlpha;
}
// TODO: Enable SW scaling for cursors
_cursor = createSurface(textureFormat, true);
_cursor = createSurface(textureFormat, false, wantScaler);
assert(_cursor);
_cursor->enableLinearFiltering(_currentState.filtering);
#ifdef USE_SCALERS
if (wantScaler) {
_cursor->setScaler(_currentState.scalerIndex, _currentState.scaleFactor);
}
#endif
}
_cursor->allocate(w, h);