PSP2: Replace usage of old SurfaceSdlGraphicsManager APIs

This commit is contained in:
Colin Snover 2017-10-15 16:00:00 -05:00
parent e308605b2f
commit 2ef10faa1e

View File

@ -111,8 +111,8 @@ PSP2SdlGraphicsManager::~PSP2SdlGraphicsManager() {
} }
_vitatex_hwscreen = NULL; _vitatex_hwscreen = NULL;
} }
if (_hwscreen) { if (_hwScreen) {
_hwscreen->pixels = _sdlpixels_hwscreen; _hwScreen->pixels = _sdlpixels_hwscreen;
} }
_sdlpixels_hwscreen = nullptr; _sdlpixels_hwscreen = nullptr;
} }
@ -153,7 +153,7 @@ void PSP2SdlGraphicsManager::unloadGFXMode() {
deinitializeRenderer(); deinitializeRenderer();
if (_hwscreen) { if (_hwScreen) {
if (_vitatex_hwscreen) { if (_vitatex_hwscreen) {
vita2d_free_texture(_vitatex_hwscreen); vita2d_free_texture(_vitatex_hwscreen);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
@ -162,7 +162,7 @@ void PSP2SdlGraphicsManager::unloadGFXMode() {
} }
_vitatex_hwscreen = NULL; _vitatex_hwscreen = NULL;
} }
_hwscreen->pixels = _sdlpixels_hwscreen; _hwScreen->pixels = _sdlpixels_hwscreen;
} }
SurfaceSdlGraphicsManager::unloadGFXMode(); SurfaceSdlGraphicsManager::unloadGFXMode();
} }
@ -172,7 +172,7 @@ bool PSP2SdlGraphicsManager::hotswapGFXMode() {
return false; return false;
// Release the HW screen surface // Release the HW screen surface
if (_hwscreen) { if (_hwScreen) {
if (_vitatex_hwscreen) { if (_vitatex_hwscreen) {
vita2d_free_texture(_vitatex_hwscreen); vita2d_free_texture(_vitatex_hwscreen);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
@ -181,7 +181,7 @@ bool PSP2SdlGraphicsManager::hotswapGFXMode() {
} }
_vitatex_hwscreen = NULL; _vitatex_hwscreen = NULL;
} }
_hwscreen->pixels = _sdlpixels_hwscreen; _hwScreen->pixels = _sdlpixels_hwscreen;
} }
return SurfaceSdlGraphicsManager::hotswapGFXMode(); return SurfaceSdlGraphicsManager::hotswapGFXMode();
} }
@ -222,23 +222,23 @@ void PSP2SdlGraphicsManager::internUpdateScreen() {
// definitions not available for non-DEBUG here. (needed this to compile in SYMBIAN32 & linux?) // definitions not available for non-DEBUG here. (needed this to compile in SYMBIAN32 & linux?)
#if defined(DEBUG) #if defined(DEBUG)
assert(_hwscreen != NULL); assert(_hwScreen != NULL);
assert(_hwscreen->map->sw_data != NULL); assert(_hwScreen->map->sw_data != NULL);
#endif #endif
// If the shake position changed, fill the dirty area with blackness // If the shake position changed, fill the dirty area with blackness
if (_currentShakePos != _newShakePos || if (_currentShakePos != _newShakePos ||
(_mouseNeedsRedraw && _mouseBackup.y <= _currentShakePos)) { (_cursorNeedsRedraw && _mouseBackup.y <= _currentShakePos)) {
SDL_Rect blackrect = {0, 0, (Uint16)(_videoMode.screenWidth * _videoMode.scaleFactor), (Uint16)(_newShakePos * _videoMode.scaleFactor)}; SDL_Rect blackrect = {0, 0, (Uint16)(_videoMode.screenWidth * _videoMode.scaleFactor), (Uint16)(_newShakePos * _videoMode.scaleFactor)};
if (_videoMode.aspectRatioCorrection && !_overlayVisible) if (_videoMode.aspectRatioCorrection && !_overlayVisible)
blackrect.h = real2Aspect(blackrect.h - 1) + 1; blackrect.h = real2Aspect(blackrect.h - 1) + 1;
SDL_FillRect(_hwscreen, &blackrect, 0); SDL_FillRect(_hwScreen, &blackrect, 0);
_currentShakePos = _newShakePos; _currentShakePos = _newShakePos;
_forceFull = true; _forceRedraw = true;
} }
// Check whether the palette was changed in the meantime and update the // Check whether the palette was changed in the meantime and update the
@ -250,7 +250,7 @@ void PSP2SdlGraphicsManager::internUpdateScreen() {
_paletteDirtyEnd = 0; _paletteDirtyEnd = 0;
_forceFull = true; _forceRedraw = true;
} }
if (!_overlayVisible) { if (!_overlayVisible) {
@ -272,7 +272,7 @@ void PSP2SdlGraphicsManager::internUpdateScreen() {
// Add the area covered by the mouse cursor to the list of dirty rects if // Add the area covered by the mouse cursor to the list of dirty rects if
// we have to redraw the mouse. // we have to redraw the mouse.
if (_mouseNeedsRedraw) if (_cursorNeedsRedraw)
undrawMouse(); undrawMouse();
#ifdef USE_OSD #ifdef USE_OSD
@ -280,7 +280,7 @@ void PSP2SdlGraphicsManager::internUpdateScreen() {
#endif #endif
// Force a full redraw if requested // Force a full redraw if requested
if (_forceFull) { if (_forceRedraw) {
_numDirtyRects = 1; _numDirtyRects = 1;
_dirtyRectList[0].x = 0; _dirtyRectList[0].x = 0;
_dirtyRectList[0].y = 0; _dirtyRectList[0].y = 0;
@ -289,7 +289,7 @@ void PSP2SdlGraphicsManager::internUpdateScreen() {
} }
// Only draw anything if necessary // Only draw anything if necessary
if (_numDirtyRects > 0 || _mouseNeedsRedraw) { if (_numDirtyRects > 0 || _cursorNeedsRedraw) {
SDL_Rect *r; SDL_Rect *r;
SDL_Rect dst; SDL_Rect dst;
uint32 srcPitch, dstPitch; uint32 srcPitch, dstPitch;
@ -306,7 +306,7 @@ void PSP2SdlGraphicsManager::internUpdateScreen() {
SDL_LockSurface(srcSurf); SDL_LockSurface(srcSurf);
srcPitch = srcSurf->pitch; srcPitch = srcSurf->pitch;
dstPitch = _hwscreen->pitch; dstPitch = _hwScreen->pitch;
for (r = _dirtyRectList; r != lastRect; ++r) { for (r = _dirtyRectList; r != lastRect; ++r) {
register int dst_y = r->y + _currentShakePos; register int dst_y = r->y + _currentShakePos;
@ -331,7 +331,7 @@ void PSP2SdlGraphicsManager::internUpdateScreen() {
assert(scalerProc != NULL); assert(scalerProc != NULL);
scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch,
(byte *)_hwscreen->pixels + rx1 * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h); (byte *)_hwScreen->pixels + rx1 * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h);
} }
r->x = rx1; r->x = rx1;
@ -341,15 +341,15 @@ void PSP2SdlGraphicsManager::internUpdateScreen() {
#ifdef USE_SCALERS #ifdef USE_SCALERS
if (_videoMode.aspectRatioCorrection && orig_dst_y < height && !_overlayVisible) if (_videoMode.aspectRatioCorrection && orig_dst_y < height && !_overlayVisible)
r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1); r->h = stretch200To240((uint8 *) _hwScreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1);
#endif #endif
} }
SDL_UnlockSurface(srcSurf); SDL_UnlockSurface(srcSurf);
// Readjust the dirty rect list in case we are doing a full update. // Readjust the dirty rect list in case we are doing a full update.
// This is necessary if shaking is active. // This is necessary if shaking is active.
if (_forceFull) { if (_forceRedraw) {
_dirtyRectList[0].y = 0; _dirtyRectList[0].y = 0;
_dirtyRectList[0].h = effectiveScreenHeight(); _dirtyRectList[0].h = _videoMode.hardwareHeight;
} }
drawMouse(); drawMouse();
@ -380,15 +380,15 @@ void PSP2SdlGraphicsManager::internUpdateScreen() {
if (h > 0 && w > 0) { if (h > 0 && w > 0) {
// Use white as color for now. // Use white as color for now.
Uint32 rectColor = SDL_MapRGB(_hwscreen->format, 0xFF, 0xFF, 0xFF); Uint32 rectColor = SDL_MapRGB(_hwScreen->format, 0xFF, 0xFF, 0xFF);
// First draw the top and bottom lines // First draw the top and bottom lines
// then draw the left and right lines // then draw the left and right lines
if (_hwscreen->format->BytesPerPixel == 2) { if (_hwScreen->format->BytesPerPixel == 2) {
uint16 *top = (uint16 *)((byte *)_hwscreen->pixels + y * _hwscreen->pitch + x * 2); uint16 *top = (uint16 *)((byte *)_hwScreen->pixels + y * _hwScreen->pitch + x * 2);
uint16 *bottom = (uint16 *)((byte *)_hwscreen->pixels + (y + h) * _hwscreen->pitch + x * 2); uint16 *bottom = (uint16 *)((byte *)_hwScreen->pixels + (y + h) * _hwScreen->pitch + x * 2);
byte *left = ((byte *)_hwscreen->pixels + y * _hwscreen->pitch + x * 2); byte *left = ((byte *)_hwScreen->pixels + y * _hwScreen->pitch + x * 2);
byte *right = ((byte *)_hwscreen->pixels + y * _hwscreen->pitch + (x + w - 1) * 2); byte *right = ((byte *)_hwScreen->pixels + y * _hwScreen->pitch + (x + w - 1) * 2);
while (w--) { while (w--) {
*top++ = rectColor; *top++ = rectColor;
@ -399,14 +399,14 @@ void PSP2SdlGraphicsManager::internUpdateScreen() {
*(uint16 *)left = rectColor; *(uint16 *)left = rectColor;
*(uint16 *)right = rectColor; *(uint16 *)right = rectColor;
left += _hwscreen->pitch; left += _hwScreen->pitch;
right += _hwscreen->pitch; right += _hwScreen->pitch;
} }
} else if (_hwscreen->format->BytesPerPixel == 4) { } else if (_hwScreen->format->BytesPerPixel == 4) {
uint32 *top = (uint32 *)((byte *)_hwscreen->pixels + y * _hwscreen->pitch + x * 4); uint32 *top = (uint32 *)((byte *)_hwScreen->pixels + y * _hwScreen->pitch + x * 4);
uint32 *bottom = (uint32 *)((byte *)_hwscreen->pixels + (y + h) * _hwscreen->pitch + x * 4); uint32 *bottom = (uint32 *)((byte *)_hwScreen->pixels + (y + h) * _hwScreen->pitch + x * 4);
byte *left = ((byte *)_hwscreen->pixels + y * _hwscreen->pitch + x * 4); byte *left = ((byte *)_hwScreen->pixels + y * _hwScreen->pitch + x * 4);
byte *right = ((byte *)_hwscreen->pixels + y * _hwscreen->pitch + (x + w - 1) * 4); byte *right = ((byte *)_hwScreen->pixels + y * _hwScreen->pitch + (x + w - 1) * 4);
while (w--) { while (w--) {
*top++ = rectColor; *top++ = rectColor;
@ -417,8 +417,8 @@ void PSP2SdlGraphicsManager::internUpdateScreen() {
*(uint32 *)left = rectColor; *(uint32 *)left = rectColor;
*(uint32 *)right = rectColor; *(uint32 *)right = rectColor;
left += _hwscreen->pitch; left += _hwScreen->pitch;
right += _hwscreen->pitch; right += _hwScreen->pitch;
} }
} }
} }
@ -428,13 +428,13 @@ void PSP2SdlGraphicsManager::internUpdateScreen() {
// Finally, blit all our changes to the screen // Finally, blit all our changes to the screen
if (!_displayDisabled) { if (!_displayDisabled) {
PSP2_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList); PSP2_UpdateRects(_hwScreen, _numDirtyRects, _dirtyRectList);
} }
} }
_numDirtyRects = 0; _numDirtyRects = 0;
_forceFull = false; _forceRedraw = false;
_mouseNeedsRedraw = false; _cursorNeedsRedraw = false;
} }
void PSP2SdlGraphicsManager::setAspectRatioCorrection(bool enable) { void PSP2SdlGraphicsManager::setAspectRatioCorrection(bool enable) {