diff options
author | rsn8887 | 2018-01-09 12:05:15 -0600 |
---|---|---|
committer | rsn8887 | 2018-01-17 18:52:48 -0600 |
commit | 6f2a8bdbca43b003a66e405f9f5ab8e3a46bd893 (patch) | |
tree | caf2adc4da301b63d5144c4060eb6a888ea257d9 | |
parent | edef1d5076011fca2e0aff36923321ab11f584bc (diff) | |
download | scummvm-rg350-6f2a8bdbca43b003a66e405f9f5ab8e3a46bd893.tar.gz scummvm-rg350-6f2a8bdbca43b003a66e405f9f5ab8e3a46bd893.tar.bz2 scummvm-rg350-6f2a8bdbca43b003a66e405f9f5ab8e3a46bd893.zip |
PSP2: remove code duplication in psp2 graphicsmanager
-rw-r--r-- | backends/graphics/psp2sdl/psp2sdl-graphics.cpp | 225 | ||||
-rw-r--r-- | backends/graphics/psp2sdl/psp2sdl-graphics.h | 3 | ||||
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.h | 4 |
3 files changed, 4 insertions, 228 deletions
diff --git a/backends/graphics/psp2sdl/psp2sdl-graphics.cpp b/backends/graphics/psp2sdl/psp2sdl-graphics.cpp index 4be48b55e0..28e1e71332 100644 --- a/backends/graphics/psp2sdl/psp2sdl-graphics.cpp +++ b/backends/graphics/psp2sdl/psp2sdl-graphics.cpp @@ -214,229 +214,6 @@ void PSP2SdlGraphicsManager::updateShader() { } } -void PSP2SdlGraphicsManager::internUpdateScreen() { - SDL_Surface *srcSurf, *origSurf; - int height, width; - ScalerProc *scalerProc; - int scale1; - - // definitions not available for non-DEBUG here. (needed this to compile in SYMBIAN32 & linux?) -#if defined(DEBUG) - assert(_hwScreen != NULL); - assert(_hwScreen->map->sw_data != NULL); -#endif - - // If the shake position changed, fill the dirty area with blackness - if (_currentShakePos != _newShakePos || - (_cursorNeedsRedraw && _mouseBackup.y <= _currentShakePos)) { - SDL_Rect blackrect = {0, 0, (Uint16)(_videoMode.screenWidth * _videoMode.scaleFactor), (Uint16)(_newShakePos * _videoMode.scaleFactor)}; - - if (_videoMode.aspectRatioCorrection && !_overlayVisible) - blackrect.h = real2Aspect(blackrect.h - 1) + 1; - - SDL_FillRect(_hwScreen, &blackrect, 0); - - _currentShakePos = _newShakePos; - - _forceRedraw = true; - } - - // Check whether the palette was changed in the meantime and update the - // screen surface accordingly. - if (_screen && _paletteDirtyEnd != 0) { - SDL_SetColors(_screen, _currentPalette + _paletteDirtyStart, - _paletteDirtyStart, - _paletteDirtyEnd - _paletteDirtyStart); - - _paletteDirtyEnd = 0; - - _forceRedraw = true; - } - - if (!_overlayVisible) { - origSurf = _screen; - srcSurf = _tmpscreen; - width = _videoMode.screenWidth; - height = _videoMode.screenHeight; - scalerProc = _scalerProc; - scale1 = _videoMode.scaleFactor; - } else { - origSurf = _overlayscreen; - srcSurf = _tmpscreen2; - width = _videoMode.overlayWidth; - height = _videoMode.overlayHeight; - scalerProc = Normal1x; - - scale1 = 1; - } - - // Add the area covered by the mouse cursor to the list of dirty rects if - // we have to redraw the mouse. - if (_cursorNeedsRedraw) - undrawMouse(); - -#ifdef USE_OSD - updateOSD(); -#endif - - // Force a full redraw if requested - if (_forceRedraw) { - _numDirtyRects = 1; - _dirtyRectList[0].x = 0; - _dirtyRectList[0].y = 0; - _dirtyRectList[0].w = width; - _dirtyRectList[0].h = height; - } - - // Only draw anything if necessary - if (_numDirtyRects > 0 || _cursorNeedsRedraw) { - SDL_Rect *r; - SDL_Rect dst; - uint32 srcPitch, dstPitch; - SDL_Rect *lastRect = _dirtyRectList + _numDirtyRects; - - for (r = _dirtyRectList; r != lastRect; ++r) { - dst = *r; - dst.x++; // Shift rect by one since 2xSai needs to access the data around - dst.y++; // any pixel to scale it, and we want to avoid mem access crashes. - - if (SDL_BlitSurface(origSurf, r, srcSurf, &dst) != 0) - error("SDL_BlitSurface failed: %s", SDL_GetError()); - } - - SDL_LockSurface(srcSurf); - srcPitch = srcSurf->pitch; - dstPitch = _hwScreen->pitch; - - for (r = _dirtyRectList; r != lastRect; ++r) { - register int dst_y = r->y + _currentShakePos; - register int dst_h = 0; -#ifdef USE_SCALERS - register int orig_dst_y = 0; -#endif - register int rx1 = r->x * scale1; - - if (dst_y < height) { - dst_h = r->h; - if (dst_h > height - dst_y) - dst_h = height - dst_y; - -#ifdef USE_SCALERS - orig_dst_y = dst_y; -#endif - dst_y = dst_y * scale1; - - if (_videoMode.aspectRatioCorrection && !_overlayVisible) - dst_y = real2Aspect(dst_y); - - assert(scalerProc != NULL); - 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); - } - - r->x = rx1; - r->y = dst_y; - r->w = r->w * scale1; - r->h = dst_h * scale1; - -#ifdef USE_SCALERS - 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); -#endif - } - SDL_UnlockSurface(srcSurf); - // Readjust the dirty rect list in case we are doing a full update. - // This is necessary if shaking is active. - if (_forceRedraw) { - _dirtyRectList[0].y = 0; - _dirtyRectList[0].h = _videoMode.hardwareHeight; - } - - drawMouse(); - -#ifdef USE_OSD - drawOSD(); -#endif - -#ifdef USE_SDL_DEBUG_FOCUSRECT - // We draw the focus rectangle on top of everything, to assure it's easily visible. - // Of course when the overlay is visible we do not show it, since it is only for game - // specific focus. - if (_enableFocusRect && !_overlayVisible) { - int y = _focusRect.top + _currentShakePos; - int h = 0; - int x = _focusRect.left * scale1; - int w = _focusRect.width() * scale1; - - if (y < height) { - h = _focusRect.height(); - if (h > height - y) - h = height - y; - - y *= scale1; - - if (_videoMode.aspectRatioCorrection && !_overlayVisible) - y = real2Aspect(y); - - if (h > 0 && w > 0) { - // Use white as color for now. - Uint32 rectColor = SDL_MapRGB(_hwScreen->format, 0xFF, 0xFF, 0xFF); - - // First draw the top and bottom lines - // then draw the left and right lines - if (_hwScreen->format->BytesPerPixel == 2) { - uint16 *top = (uint16 *)((byte *)_hwScreen->pixels + y * _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 *right = ((byte *)_hwScreen->pixels + y * _hwScreen->pitch + (x + w - 1) * 2); - - while (w--) { - *top++ = rectColor; - *bottom++ = rectColor; - } - - while (h--) { - *(uint16 *)left = rectColor; - *(uint16 *)right = rectColor; - - left += _hwScreen->pitch; - right += _hwScreen->pitch; - } - } else if (_hwScreen->format->BytesPerPixel == 4) { - uint32 *top = (uint32 *)((byte *)_hwScreen->pixels + y * _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 *right = ((byte *)_hwScreen->pixels + y * _hwScreen->pitch + (x + w - 1) * 4); - - while (w--) { - *top++ = rectColor; - *bottom++ = rectColor; - } - - while (h--) { - *(uint32 *)left = rectColor; - *(uint32 *)right = rectColor; - - left += _hwScreen->pitch; - right += _hwScreen->pitch; - } - } - } - } - } -#endif - - // Finally, blit all our changes to the screen - if (!_displayDisabled) { - PSP2_UpdateRects(_hwScreen, _numDirtyRects, _dirtyRectList); - } - } - - _numDirtyRects = 0; - _forceRedraw = false; - _cursorNeedsRedraw = false; -} - void PSP2SdlGraphicsManager::setAspectRatioCorrection(bool enable) { Common::StackLock lock(_graphicsMutex); @@ -473,7 +250,7 @@ SDL_Surface *PSP2SdlGraphicsManager::SDL_SetVideoMode(int width, int height, int return screen; } -void PSP2SdlGraphicsManager::PSP2_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) { +void PSP2SdlGraphicsManager::SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) { int x, y, w, h; float sx, sy; float ratio = (float)screen->w / (float)screen->h; diff --git a/backends/graphics/psp2sdl/psp2sdl-graphics.h b/backends/graphics/psp2sdl/psp2sdl-graphics.h index 0cabeb094d..3264323d1e 100644 --- a/backends/graphics/psp2sdl/psp2sdl-graphics.h +++ b/backends/graphics/psp2sdl/psp2sdl-graphics.h @@ -39,11 +39,10 @@ protected: virtual void unloadGFXMode() override; virtual bool hotswapGFXMode() override; - virtual void internUpdateScreen() override; virtual void updateShader() override; virtual void setAspectRatioCorrection(bool enable) override; virtual SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) override; - void PSP2_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects); + virtual void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) override; void PSP2_UpdateFiltering(); bool _hardwareAspectRatioCorrection; diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index 60f5d29f55..c6c2f35fae 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -187,8 +187,8 @@ protected: void deinitializeRenderer(); void recreateScreenTexture(); - virtual SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags); - void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects); + virtual SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) override; + virtual void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) override; #endif /** Unseen game screen */ |