diff --git a/src/common/FrameBufferSDL2.cxx b/src/common/FrameBufferSDL2.cxx index a7687b8c4..6da6735a0 100644 --- a/src/common/FrameBufferSDL2.cxx +++ b/src/common/FrameBufferSDL2.cxx @@ -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; } diff --git a/src/common/FrameBufferSDL2.hxx b/src/common/FrameBufferSDL2.hxx index d75610829..eefbeae36 100644 --- a/src/common/FrameBufferSDL2.hxx +++ b/src/common/FrameBufferSDL2.hxx @@ -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 diff --git a/src/common/sdl_blitter/BilinearBlitter.cxx b/src/common/sdl_blitter/BilinearBlitter.cxx index 0cfacbcba..e92714159 100644 --- a/src/common/sdl_blitter/BilinearBlitter.cxx +++ b/src/common/sdl_blitter/BilinearBlitter.cxx @@ -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); } diff --git a/src/common/sdl_blitter/QisBlitter.cxx b/src/common/sdl_blitter/QisBlitter.cxx index a9dd85292..b4c2a6750 100644 --- a/src/common/sdl_blitter/QisBlitter.cxx +++ b/src/common/sdl_blitter/QisBlitter.cxx @@ -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); } diff --git a/src/macos/Info-Stella.plist b/src/macos/Info-Stella.plist index ac022cb7c..8f37a40c3 100644 --- a/src/macos/Info-Stella.plist +++ b/src/macos/Info-Stella.plist @@ -61,6 +61,8 @@ x86_64 10.7.0 + NSHighResolutionCapable + NSMainNibFile SDLMain NSPrincipalClass