mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
SDL: Take advantage that each ScalerPluginObject can use a scale factor of 1.
This commit is contained in:
committed by
Filippos Karapetis
parent
6942dba3da
commit
e8d0182cd5
@@ -1191,19 +1191,6 @@ void SurfaceSdlGraphicsManager::updateScreen() {
|
||||
internUpdateScreen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple blit function. Copies a rectangle from one surface to another.
|
||||
*
|
||||
* @param byteWidth The width of the region to copy in bytes.
|
||||
*/
|
||||
static void blitSurface(byte *srcPtr, int srcPitch, byte *dstPtr, int dstPitch, int byteWidth, int height) {
|
||||
while (height--) {
|
||||
memcpy(dstPtr, srcPtr, byteWidth);
|
||||
dstPtr += dstPitch;
|
||||
srcPtr += srcPitch;
|
||||
}
|
||||
}
|
||||
|
||||
void SurfaceSdlGraphicsManager::internUpdateScreen() {
|
||||
SDL_Surface *srcSurf, *origSurf;
|
||||
int height, width;
|
||||
@@ -1258,18 +1245,20 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
|
||||
_forceRedraw = true;
|
||||
}
|
||||
|
||||
int oldScaleFactor;
|
||||
if (!_overlayVisible) {
|
||||
origSurf = _screen;
|
||||
srcSurf = _tmpscreen;
|
||||
width = _videoMode.screenWidth;
|
||||
height = _videoMode.screenHeight;
|
||||
scale1 = _videoMode.scaleFactor;
|
||||
oldScaleFactor = scale1 = _videoMode.scaleFactor;
|
||||
} else {
|
||||
origSurf = _overlayscreen;
|
||||
srcSurf = _tmpscreen2;
|
||||
width = _videoMode.overlayWidth;
|
||||
height = _videoMode.overlayHeight;
|
||||
scale1 = 1;
|
||||
oldScaleFactor = _scalerPlugin->setFactor(1);
|
||||
}
|
||||
|
||||
// Add the area covered by the mouse cursor to the list of dirty rects if
|
||||
@@ -1345,17 +1334,13 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
|
||||
if (_videoMode.aspectRatioCorrection && !_overlayVisible)
|
||||
dst_y = real2Aspect(dst_y);
|
||||
|
||||
if (_overlayVisible) {
|
||||
blitSurface((byte *)srcSurf->pixels + (r->x + _maxExtraPixels) * 2 + (r->y + _maxExtraPixels) * srcPitch, srcPitch,
|
||||
(byte *)_hwScreen->pixels + dst_x * 2 + dst_y * dstPitch, dstPitch, dst_w * 2, dst_h);
|
||||
if (_useOldSrc && !_overlayVisible) {
|
||||
// scale into _destbuffer instead of _hwScreen to avoid AR problems
|
||||
_scalerPlugin->scale((byte *)srcSurf->pixels + (r->x + _maxExtraPixels) * 2 + (r->y + _maxExtraPixels) * srcPitch, srcPitch,
|
||||
(byte *)_destbuffer->pixels + dst_x * 2 + orig_dst_y * scale1 * _destbuffer->pitch, _destbuffer->pitch, r->w, dst_h, r->x, r->y);
|
||||
} else {
|
||||
if (_useOldSrc) {
|
||||
// scale into _destbuffer instead of _hwScreen to avoid AR problems
|
||||
_scalerPlugin->scale((byte *)srcSurf->pixels + (r->x + _maxExtraPixels) * 2 + (r->y + _maxExtraPixels) * srcPitch, srcPitch,
|
||||
(byte *)_destbuffer->pixels + dst_x * 2 + orig_dst_y * scale1 * _destbuffer->pitch, _destbuffer->pitch, r->w, dst_h, r->x, r->y);
|
||||
} else
|
||||
_scalerPlugin->scale((byte *)srcSurf->pixels + (r->x + _maxExtraPixels) * 2 + (r->y + _maxExtraPixels) * srcPitch, srcPitch,
|
||||
(byte *)_hwScreen->pixels + dst_x * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h, r->x, r->y);
|
||||
_scalerPlugin->scale((byte *)srcSurf->pixels + (r->x + _maxExtraPixels) * 2 + (r->y + _maxExtraPixels) * srcPitch, srcPitch,
|
||||
(byte *)_hwScreen->pixels + dst_x * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h, r->x, r->y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1494,6 +1479,9 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the old scale factor
|
||||
_scalerPlugin->setFactor(oldScaleFactor);
|
||||
|
||||
_numDirtyRects = 0;
|
||||
_forceRedraw = false;
|
||||
_cursorNeedsRedraw = false;
|
||||
@@ -2241,10 +2229,12 @@ void SurfaceSdlGraphicsManager::blitCursor() {
|
||||
_normalPlugin->setFactor(oldFactor);
|
||||
}
|
||||
} else {
|
||||
blitSurface(
|
||||
(byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch * _maxExtraPixels + _maxExtraPixels * _mouseOrigSurface->format->BytesPerPixel,
|
||||
_mouseOrigSurface->pitch, (byte *)_mouseSurface->pixels, _mouseSurface->pitch,
|
||||
_mouseCurState.w * 2, _mouseCurState.h);
|
||||
int oldScaleFactor = _scalerPlugin->setFactor(1);
|
||||
_scalerPlugin->scale(
|
||||
(byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch * _maxExtraPixels + _maxExtraPixels * _mouseOrigSurface->format->BytesPerPixel,
|
||||
_mouseOrigSurface->pitch, (byte *)_mouseSurface->pixels, _mouseSurface->pitch,
|
||||
_mouseCurState.w, _mouseCurState.h, 0, 0);
|
||||
_scalerPlugin->setFactor(oldScaleFactor);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user