diff --git a/src/common/FBSurfaceSDL2.cxx b/src/common/FBSurfaceSDL2.cxx index 94483a22b..efc99f015 100644 --- a/src/common/FBSurfaceSDL2.cxx +++ b/src/common/FBSurfaceSDL2.cxx @@ -22,16 +22,16 @@ #include "sdl_blitter/BlitterFactory.hxx" namespace { - BlitterFactory::ScalingAlgorithm scalingAlgorithm(FrameBuffer::ScalingInterpolation interpolation) + BlitterFactory::ScalingAlgorithm scalingAlgorithm(ScalingInterpolation interpolation) { switch (interpolation) { - case FrameBuffer::ScalingInterpolation::none: + case ScalingInterpolation::none: return BlitterFactory::ScalingAlgorithm::nearestNeighbour; - case FrameBuffer::ScalingInterpolation::blur: + case ScalingInterpolation::blur: return BlitterFactory::ScalingAlgorithm::bilinear; - case FrameBuffer::ScalingInterpolation::sharp: + case ScalingInterpolation::sharp: return BlitterFactory::ScalingAlgorithm::quasiInteger; default: @@ -43,7 +43,7 @@ namespace { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FBSurfaceSDL2::FBSurfaceSDL2(FrameBufferSDL2& buffer, uInt32 width, uInt32 height, - FrameBuffer::ScalingInterpolation interpolation, + ScalingInterpolation interpolation, const uInt32* staticData) : myFB(buffer), myInterpolationMode(interpolation) @@ -256,7 +256,7 @@ void FBSurfaceSDL2::applyAttributes() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurfaceSDL2::setScalingInterpolation(FrameBuffer::ScalingInterpolation interpolation) +void FBSurfaceSDL2::setScalingInterpolation(ScalingInterpolation interpolation) { if (interpolation == myInterpolationMode) return; diff --git a/src/common/FBSurfaceSDL2.hxx b/src/common/FBSurfaceSDL2.hxx index 62e9d96a2..01acd2d1c 100644 --- a/src/common/FBSurfaceSDL2.hxx +++ b/src/common/FBSurfaceSDL2.hxx @@ -33,7 +33,7 @@ class FBSurfaceSDL2 : public FBSurface { public: FBSurfaceSDL2(FrameBufferSDL2& buffer, uInt32 width, uInt32 height, - FrameBuffer::ScalingInterpolation interpolation, + ScalingInterpolation interpolation, const uInt32* staticData); ~FBSurfaceSDL2() override; @@ -60,7 +60,7 @@ class FBSurfaceSDL2 : public FBSurface void reload() override; void resize(uInt32 width, uInt32 height) override; - void setScalingInterpolation(FrameBuffer::ScalingInterpolation) override; + void setScalingInterpolation(ScalingInterpolation) override; protected: void applyAttributes() override; @@ -98,8 +98,8 @@ class FBSurfaceSDL2 : public FBSurface FrameBufferSDL2& myFB; unique_ptr myBlitter; - FrameBuffer::ScalingInterpolation myInterpolationMode - {FrameBuffer::ScalingInterpolation::none}; + ScalingInterpolation myInterpolationMode + {ScalingInterpolation::none}; SDL_Surface* mySurface{nullptr}; SDL_Rect mySrcR{0, 0, 0, 0}, myDstR{0, 0, 0, 0}; diff --git a/src/common/FrameBufferSDL2.cxx b/src/common/FrameBufferSDL2.cxx index 7f0dee993..039548f9a 100644 --- a/src/common/FrameBufferSDL2.cxx +++ b/src/common/FrameBufferSDL2.cxx @@ -568,7 +568,7 @@ void FrameBufferSDL2::setWindowIcon() unique_ptr FrameBufferSDL2::createSurface( uInt32 w, uInt32 h, - FrameBuffer::ScalingInterpolation interpolation, + ScalingInterpolation interpolation, const uInt32* data ) const { diff --git a/src/common/FrameBufferSDL2.hxx b/src/common/FrameBufferSDL2.hxx index 20ae489e4..0e1a1c36d 100644 --- a/src/common/FrameBufferSDL2.hxx +++ b/src/common/FrameBufferSDL2.hxx @@ -213,7 +213,7 @@ class FrameBufferSDL2 : public FrameBuffer createSurface( uInt32 w, uInt32 h, - FrameBuffer::ScalingInterpolation interpolation, + ScalingInterpolation interpolation, const uInt32* data ) const override; diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index 0a4846c76..e363a0b82 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -113,7 +113,7 @@ FBInitStatus Debugger::initializeVideo() { string title = string("Stella ") + STELLA_VERSION + ": Debugger mode"; return myOSystem.frameBuffer().createDisplay( - title, FrameBuffer::BufferType::Debugger, mySize + title, BufferType::Debugger, mySize ); } diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index f12592428..0e2532b6e 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -630,7 +630,7 @@ FBInitStatus Console::initializeVideo(bool full) const string& title = string("Stella ") + STELLA_VERSION + ": \"" + myProperties.get(PropType::Cart_Name) + "\""; fbstatus = myOSystem.frameBuffer().createDisplay(title, - FrameBuffer::BufferType::Emulator, size, false); + BufferType::Emulator, size, false); if(fbstatus != FBInitStatus::Success) return fbstatus; diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index 48632404d..108831ce1 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -246,6 +246,25 @@ class FBSurface ColorId color, TextAlign align = TextAlign::Left, int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone); + /** + The rendering attributes that can be modified for this texture. + These probably can only be implemented in child FBSurfaces where + the specific functionality actually exists. + */ + struct Attributes { + bool blending{false}; // Blending is enabled + uInt32 blendalpha{100}; // Alpha to use in blending mode (0-100%) + + bool operator==(const Attributes& other) const { + return blendalpha == other.blendalpha && blending == other.blending; + } + }; + + /** + Get the currently applied attributes. + */ + Attributes& attributes() { return myAttributes; } + ////////////////////////////////////////////////////////////////////////// // Note: The following methods are FBSurface-specific, and must be // implemented in child classes. @@ -324,35 +343,17 @@ class FBSurface */ virtual void resize(uInt32 width, uInt32 height) = 0; - /** - The rendering attributes that can be modified for this texture. - These probably can only be implemented in child FBSurfaces where - the specific functionality actually exists. - */ - struct Attributes { - bool blending{false}; // Blending is enabled - uInt32 blendalpha{100}; // Alpha to use in blending mode (0-100%) - - bool operator==(const Attributes& other) const { - return blendalpha == other.blendalpha && blending == other.blending; - } - }; - - /** - Get the currently applied attributes. - */ - Attributes& attributes() { return myAttributes; } - /** Configure scaling interpolation. */ - virtual void setScalingInterpolation(FrameBuffer::ScalingInterpolation) = 0; + virtual void setScalingInterpolation(ScalingInterpolation) = 0; /** The child class chooses which (if any) of the actual attributes can be applied. */ virtual void applyAttributes() = 0; + ////////////////////////////////////////////////////////////////////////// static void setPalette(const FullPaletteArray& palette) { myPalette = palette; } @@ -367,7 +368,8 @@ class FBSurface */ bool checkBounds(const uInt32 x, const uInt32 y) const; - void wrapString(const string& inStr, int pos, string& leftStr, string& rightStr) const; + void wrapString(const string& inStr, int pos, + string& leftStr, string& rightStr) const; /** Check if the given character is a whitespace. diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index 3e395cd45..a4c7e20c8 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -51,19 +51,6 @@ class TIASurface; class FrameBuffer { public: - enum class BufferType { - None, - Launcher, - Emulator, - Debugger - }; - - enum class ScalingInterpolation { - none, - sharp, - blur - }; - // Zoom level step interval static constexpr float ZOOM_STEPS = 0.25; @@ -262,16 +249,16 @@ class FrameBuffer */ void enableGrabMouse(bool enable); - /** - Sets the use of grabmouse. - */ - bool grabMouseEnabled() const { return myGrabMouse; } - /** Toggles the use of grabmouse (only has effect in emulation mode). */ void toggleGrabMouse(); + /** + Query whether grabmouse is enabled. + */ + bool grabMouseEnabled() const { return myGrabMouse; } + /** Informs the Framebuffer of a change in EventHandler state. */ @@ -291,7 +278,8 @@ class FrameBuffer uInt32 hidpiScaleFactor() const { return myHiDPIEnabled ? 2 : 1; } /** - These methods are used to load/save position and display of the current window. + These methods are used to load/save position and display of the + current window. */ string getPositionKey(); string getDisplayKey(); diff --git a/src/emucore/FrameBufferConstants.hxx b/src/emucore/FrameBufferConstants.hxx index 04bac451b..134086a0a 100644 --- a/src/emucore/FrameBufferConstants.hxx +++ b/src/emucore/FrameBufferConstants.hxx @@ -35,6 +35,19 @@ enum class FBInitStatus { FailNotSupported }; +enum class BufferType { + None, + Launcher, + Emulator, + Debugger +}; + +enum class ScalingInterpolation { + none, + sharp, + blur +}; + // Positions for onscreen/overlaid messages enum class MessagePosition { TopLeft, diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index 6bd364a38..3402ed8cc 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -27,19 +27,19 @@ #include "TIASurface.hxx" namespace { - FrameBuffer::ScalingInterpolation interpolationModeFromSettings(const Settings& settings) + ScalingInterpolation interpolationModeFromSettings(const Settings& settings) { #ifdef RETRON77 // Witv TV / and or scanline interpolation, the image has a height of ~480px. THe R77 runs at 720p, so there // is no benefit from QIS in y-direction. In addition, QIS on the R77 has performance issues if TV effects are // enabled. return settings.getBool("tia.inter") || settings.getInt("tv.filter") != 0 - ? FrameBuffer::ScalingInterpolation::blur - : FrameBuffer::ScalingInterpolation::sharp; + ? ScalingInterpolation::blur + : ScalingInterpolation::sharp; #else return settings.getBool("tia.inter") ? - FrameBuffer::ScalingInterpolation::blur : - FrameBuffer::ScalingInterpolation::sharp; + ScalingInterpolation::blur : + ScalingInterpolation::sharp; #endif } } @@ -57,7 +57,7 @@ TIASurface::TIASurface(OSystem& system) AtariNTSC::outWidth(TIAConstants::frameBufferWidth), TIAConstants::frameBufferHeight, !correctAspect() - ? FrameBuffer::ScalingInterpolation::none + ? ScalingInterpolation::none : interpolationModeFromSettings(myOSystem.settings()) ); diff --git a/src/gui/Launcher.cxx b/src/gui/Launcher.cxx index 6c88cd384..694395cfa 100644 --- a/src/gui/Launcher.cxx +++ b/src/gui/Launcher.cxx @@ -56,7 +56,7 @@ FBInitStatus Launcher::initializeVideo() { string title = string("Stella ") + STELLA_VERSION; return myOSystem.frameBuffer().createDisplay( - title, FrameBuffer::BufferType::Launcher, mySize + title, BufferType::Launcher, mySize ); } diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index 7e29d19e4..01b30015b 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -91,7 +91,7 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node) if(mySurface == nullptr) { mySurface = instance().frameBuffer().allocateSurface( - myAvail.w, myAvail.h, FrameBuffer::ScalingInterpolation::blur); + myAvail.w, myAvail.h, ScalingInterpolation::blur); mySurface->applyAttributes(); dialog().addSurface(mySurface); diff --git a/src/libretro/FBSurfaceLIBRETRO.hxx b/src/libretro/FBSurfaceLIBRETRO.hxx index 89809e011..c436ceaa3 100644 --- a/src/libretro/FBSurfaceLIBRETRO.hxx +++ b/src/libretro/FBSurfaceLIBRETRO.hxx @@ -55,7 +55,7 @@ class FBSurfaceLIBRETRO : public FBSurface void free() override { } void reload() override { } void resize(uInt32 width, uInt32 height) override { } - void setScalingInterpolation(FrameBuffer::ScalingInterpolation) override { } + void setScalingInterpolation(ScalingInterpolation) override { } protected: void applyAttributes() override { } diff --git a/src/libretro/FrameBufferLIBRETRO.cxx b/src/libretro/FrameBufferLIBRETRO.cxx index 1c4235772..31136bae9 100644 --- a/src/libretro/FrameBufferLIBRETRO.cxx +++ b/src/libretro/FrameBufferLIBRETRO.cxx @@ -44,7 +44,7 @@ void FrameBufferLIBRETRO::queryHardware(vector& fullscreenRes, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - unique_ptr - FrameBufferLIBRETRO::createSurface(uInt32 w, uInt32 h, FrameBuffer::ScalingInterpolation, const uInt32* data) const + FrameBufferLIBRETRO::createSurface(uInt32 w, uInt32 h, ScalingInterpolation, const uInt32* data) const { unique_ptr ptr = make_unique (const_cast(*this), w, h, data); diff --git a/src/libretro/FrameBufferLIBRETRO.hxx b/src/libretro/FrameBufferLIBRETRO.hxx index 8d097a25e..3816e7c50 100644 --- a/src/libretro/FrameBufferLIBRETRO.hxx +++ b/src/libretro/FrameBufferLIBRETRO.hxx @@ -158,7 +158,7 @@ class FrameBufferLIBRETRO : public FrameBuffer @param data If non-null, use the given data values as a static surface */ unique_ptr - createSurface(uInt32 w, uInt32 h, FrameBuffer::ScalingInterpolation, const uInt32* data) const override; + createSurface(uInt32 w, uInt32 h, ScalingInterpolation, const uInt32* data) const override; /** Grabs or ungrabs the mouse based on the given boolean value.