mirror of https://github.com/stella-emu/stella.git
Be ready for fractional scaling factors, performance improvements.
This commit is contained in:
parent
7b291db0d5
commit
e5159ca59c
|
@ -33,9 +33,7 @@ FrameBufferSDL2::FrameBufferSDL2(OSystem& osystem)
|
|||
myWindow(nullptr),
|
||||
myRenderer(nullptr),
|
||||
myCenter(false),
|
||||
myRenderTargetSupport(false),
|
||||
myScaleX(1),
|
||||
myScaleY(1)
|
||||
myRenderTargetSupport(false)
|
||||
{
|
||||
ASSERT_MAIN_THREAD;
|
||||
|
||||
|
@ -326,7 +324,7 @@ bool FrameBufferSDL2::setVideoMode(const string& title, const VideoMode& mode)
|
|||
myRenderer = SDL_CreateRenderer(myWindow, -1, renderFlags);
|
||||
|
||||
detectFeatures();
|
||||
calculateScaleFactors();
|
||||
determineDimensions();
|
||||
|
||||
if(myRenderer == nullptr)
|
||||
{
|
||||
|
@ -520,28 +518,14 @@ bool FrameBufferSDL2::hasRenderTargetSupport() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferSDL2::calculateScaleFactors()
|
||||
void FrameBufferSDL2::determineDimensions()
|
||||
{
|
||||
SDL_GetWindowSize(myWindow, &myWindowW, &myWindowH);
|
||||
|
||||
if (myRenderer == nullptr) {
|
||||
myScaleX = myScaleY = 1;
|
||||
return;
|
||||
myRenderW = myWindowW;
|
||||
myRenderH = myWindowH;
|
||||
} else {
|
||||
SDL_GetRendererOutputSize(myRenderer, &myRenderW, &myRenderH);
|
||||
}
|
||||
|
||||
int windowW, windowH, renderW, renderH;
|
||||
|
||||
SDL_GetWindowSize(myWindow, &windowW, &windowH);
|
||||
SDL_GetRendererOutputSize(myRenderer, &renderW, &renderH);
|
||||
|
||||
myScaleX = renderW / windowW;
|
||||
myScaleY = renderH / windowH;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt8 FrameBufferSDL2::scaleX() const {
|
||||
return myScaleX;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt8 FrameBufferSDL2::scaleY() const {
|
||||
return myScaleY;
|
||||
}
|
||||
|
|
|
@ -135,14 +135,14 @@ class FrameBufferSDL2 : public FrameBuffer
|
|||
bool hasRenderTargetSupport() const;
|
||||
|
||||
/**
|
||||
Retina scale factor, x direction;
|
||||
Transform from window to renderer coordinates, x direction
|
||||
*/
|
||||
uInt8 scaleX() const;
|
||||
int scaleX(int x) const { return (x * myRenderW) / myWindowW; }
|
||||
|
||||
/**
|
||||
Retina scale Factor, y direction;
|
||||
Transform from window to renderer coordinates, y direction
|
||||
*/
|
||||
uInt8 scaleY() const;
|
||||
int scaleY(int y) const { return (y * myRenderH) / myWindowH; }
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -218,7 +218,10 @@ class FrameBufferSDL2 : public FrameBuffer
|
|||
*/
|
||||
bool detectRenderTargetSupport();
|
||||
|
||||
void calculateScaleFactors();
|
||||
/**
|
||||
Determine window and renderer dimensions.
|
||||
*/
|
||||
void determineDimensions();
|
||||
|
||||
private:
|
||||
// The SDL video buffer
|
||||
|
@ -237,8 +240,8 @@ class FrameBufferSDL2 : public FrameBuffer
|
|||
// Does the renderer support render targets?
|
||||
bool myRenderTargetSupport;
|
||||
|
||||
// Retina scale factors
|
||||
uInt32 myScaleX, myScaleY;
|
||||
// Window and renderer dimensions
|
||||
int myWindowW, myWindowH, myRenderW, myRenderH;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
|
|
|
@ -47,21 +47,20 @@ void BilinearBlitter::reinitialize(
|
|||
myRecreateTextures = myRecreateTextures || !(
|
||||
mySrcRect.w == srcRect.w &&
|
||||
mySrcRect.h == srcRect.h &&
|
||||
myDstRect.w == destRect.w &&
|
||||
myDstRect.h == destRect.h &&
|
||||
myDstRect.w == myFB.scaleX(destRect.w) &&
|
||||
myDstRect.h == myFB.scaleY(destRect.h) &&
|
||||
attributes == myAttributes &&
|
||||
myStaticData == staticData
|
||||
);
|
||||
|
||||
myStaticData = staticData;
|
||||
mySrcRect = srcRect;
|
||||
myDstRect = destRect;
|
||||
myAttributes = attributes;
|
||||
|
||||
myDstRect.x *= myFB.scaleX();
|
||||
myDstRect.y *= myFB.scaleY();
|
||||
myDstRect.w *= myFB.scaleX();
|
||||
myDstRect.h *= myFB.scaleY();
|
||||
myDstRect.x = myFB.scaleX(destRect.x);
|
||||
myDstRect.y = myFB.scaleY(destRect.y);
|
||||
myDstRect.w = myFB.scaleX(destRect.w);
|
||||
myDstRect.h = myFB.scaleY(destRect.h);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -92,13 +91,13 @@ void BilinearBlitter::blit(SDL_Surface& surface)
|
|||
|
||||
SDL_Texture* texture = myTexture;
|
||||
|
||||
if(myStaticData == nullptr) {
|
||||
SDL_UpdateTexture(myTexture, &mySrcRect, surface.pixels, surface.pitch);
|
||||
myTexture = mySecondaryTexture;
|
||||
mySecondaryTexture = texture;
|
||||
}
|
||||
if(myStaticData == nullptr) {
|
||||
SDL_UpdateTexture(myTexture, &mySrcRect, surface.pixels, surface.pitch);
|
||||
myTexture = mySecondaryTexture;
|
||||
mySecondaryTexture = texture;
|
||||
}
|
||||
|
||||
SDL_RenderCopy(myFB.renderer(), texture, &mySrcRect, &myDstRect);
|
||||
SDL_RenderCopy(myFB.renderer(), texture, &mySrcRect, &myDstRect);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -55,21 +55,20 @@ void QisBlitter::reinitialize(
|
|||
myRecreateTextures = myRecreateTextures || !(
|
||||
mySrcRect.w == srcRect.w &&
|
||||
mySrcRect.h == srcRect.h &&
|
||||
myDstRect.w == destRect.w &&
|
||||
myDstRect.h == destRect.h &&
|
||||
myDstRect.w == myFB.scaleX(destRect.w) &&
|
||||
myDstRect.h == myFB.scaleY(destRect.h) &&
|
||||
attributes == myAttributes &&
|
||||
myStaticData == staticData
|
||||
);
|
||||
|
||||
myStaticData = staticData;
|
||||
mySrcRect = srcRect;
|
||||
myDstRect = destRect;
|
||||
myAttributes = attributes;
|
||||
|
||||
myDstRect.x *= myFB.scaleX();
|
||||
myDstRect.y *= myFB.scaleY();
|
||||
myDstRect.w *= myFB.scaleX();
|
||||
myDstRect.h *= myFB.scaleY();
|
||||
myDstRect.x = myFB.scaleX(destRect.x);
|
||||
myDstRect.y = myFB.scaleY(destRect.y);
|
||||
myDstRect.w = myFB.scaleX(destRect.w);
|
||||
myDstRect.h = myFB.scaleY(destRect.h);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -100,16 +99,16 @@ void QisBlitter::blit(SDL_Surface& surface)
|
|||
|
||||
SDL_Texture* texture = myIntermediateTexture;
|
||||
|
||||
if(myStaticData == nullptr) {
|
||||
SDL_UpdateTexture(mySrcTexture, &mySrcRect, surface.pixels, surface.pitch);
|
||||
if(myStaticData == nullptr) {
|
||||
SDL_UpdateTexture(mySrcTexture, &mySrcRect, surface.pixels, surface.pitch);
|
||||
|
||||
blitToIntermediate();
|
||||
blitToIntermediate();
|
||||
|
||||
myIntermediateTexture = mySecondaryIntermedateTexture;
|
||||
mySecondaryIntermedateTexture = texture;
|
||||
}
|
||||
myIntermediateTexture = mySecondaryIntermedateTexture;
|
||||
mySecondaryIntermedateTexture = texture;
|
||||
}
|
||||
|
||||
SDL_RenderCopy(myFB.renderer(), texture, &myIntermediateRect, &myDstRect);
|
||||
SDL_RenderCopy(myFB.renderer(), texture, &myIntermediateRect, &myDstRect);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@
|
|||
<key>x86_64</key>
|
||||
<string>10.7.0</string>
|
||||
</dict>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>SDLMain</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
|
|
Loading…
Reference in New Issue