Moved some framebuffer enums to appropriate file.

This commit is contained in:
Stephen Anthony 2020-10-16 15:32:43 -02:30
parent cf737d59d0
commit 5da4c9eb1c
15 changed files with 68 additions and 65 deletions

View File

@ -22,16 +22,16 @@
#include "sdl_blitter/BlitterFactory.hxx" #include "sdl_blitter/BlitterFactory.hxx"
namespace { namespace {
BlitterFactory::ScalingAlgorithm scalingAlgorithm(FrameBuffer::ScalingInterpolation interpolation) BlitterFactory::ScalingAlgorithm scalingAlgorithm(ScalingInterpolation interpolation)
{ {
switch (interpolation) { switch (interpolation) {
case FrameBuffer::ScalingInterpolation::none: case ScalingInterpolation::none:
return BlitterFactory::ScalingAlgorithm::nearestNeighbour; return BlitterFactory::ScalingAlgorithm::nearestNeighbour;
case FrameBuffer::ScalingInterpolation::blur: case ScalingInterpolation::blur:
return BlitterFactory::ScalingAlgorithm::bilinear; return BlitterFactory::ScalingAlgorithm::bilinear;
case FrameBuffer::ScalingInterpolation::sharp: case ScalingInterpolation::sharp:
return BlitterFactory::ScalingAlgorithm::quasiInteger; return BlitterFactory::ScalingAlgorithm::quasiInteger;
default: default:
@ -43,7 +43,7 @@ namespace {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FBSurfaceSDL2::FBSurfaceSDL2(FrameBufferSDL2& buffer, FBSurfaceSDL2::FBSurfaceSDL2(FrameBufferSDL2& buffer,
uInt32 width, uInt32 height, uInt32 width, uInt32 height,
FrameBuffer::ScalingInterpolation interpolation, ScalingInterpolation interpolation,
const uInt32* staticData) const uInt32* staticData)
: myFB(buffer), : myFB(buffer),
myInterpolationMode(interpolation) myInterpolationMode(interpolation)
@ -256,7 +256,7 @@ void FBSurfaceSDL2::applyAttributes()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSDL2::setScalingInterpolation(FrameBuffer::ScalingInterpolation interpolation) void FBSurfaceSDL2::setScalingInterpolation(ScalingInterpolation interpolation)
{ {
if (interpolation == myInterpolationMode) return; if (interpolation == myInterpolationMode) return;

View File

@ -33,7 +33,7 @@ class FBSurfaceSDL2 : public FBSurface
{ {
public: public:
FBSurfaceSDL2(FrameBufferSDL2& buffer, uInt32 width, uInt32 height, FBSurfaceSDL2(FrameBufferSDL2& buffer, uInt32 width, uInt32 height,
FrameBuffer::ScalingInterpolation interpolation, ScalingInterpolation interpolation,
const uInt32* staticData); const uInt32* staticData);
~FBSurfaceSDL2() override; ~FBSurfaceSDL2() override;
@ -60,7 +60,7 @@ class FBSurfaceSDL2 : public FBSurface
void reload() override; void reload() override;
void resize(uInt32 width, uInt32 height) override; void resize(uInt32 width, uInt32 height) override;
void setScalingInterpolation(FrameBuffer::ScalingInterpolation) override; void setScalingInterpolation(ScalingInterpolation) override;
protected: protected:
void applyAttributes() override; void applyAttributes() override;
@ -98,8 +98,8 @@ class FBSurfaceSDL2 : public FBSurface
FrameBufferSDL2& myFB; FrameBufferSDL2& myFB;
unique_ptr<Blitter> myBlitter; unique_ptr<Blitter> myBlitter;
FrameBuffer::ScalingInterpolation myInterpolationMode ScalingInterpolation myInterpolationMode
{FrameBuffer::ScalingInterpolation::none}; {ScalingInterpolation::none};
SDL_Surface* mySurface{nullptr}; SDL_Surface* mySurface{nullptr};
SDL_Rect mySrcR{0, 0, 0, 0}, myDstR{0, 0, 0, 0}; SDL_Rect mySrcR{0, 0, 0, 0}, myDstR{0, 0, 0, 0};

View File

@ -568,7 +568,7 @@ void FrameBufferSDL2::setWindowIcon()
unique_ptr<FBSurface> FrameBufferSDL2::createSurface( unique_ptr<FBSurface> FrameBufferSDL2::createSurface(
uInt32 w, uInt32 w,
uInt32 h, uInt32 h,
FrameBuffer::ScalingInterpolation interpolation, ScalingInterpolation interpolation,
const uInt32* data const uInt32* data
) const ) const
{ {

View File

@ -213,7 +213,7 @@ class FrameBufferSDL2 : public FrameBuffer
createSurface( createSurface(
uInt32 w, uInt32 w,
uInt32 h, uInt32 h,
FrameBuffer::ScalingInterpolation interpolation, ScalingInterpolation interpolation,
const uInt32* data const uInt32* data
) const override; ) const override;

View File

@ -113,7 +113,7 @@ FBInitStatus Debugger::initializeVideo()
{ {
string title = string("Stella ") + STELLA_VERSION + ": Debugger mode"; string title = string("Stella ") + STELLA_VERSION + ": Debugger mode";
return myOSystem.frameBuffer().createDisplay( return myOSystem.frameBuffer().createDisplay(
title, FrameBuffer::BufferType::Debugger, mySize title, BufferType::Debugger, mySize
); );
} }

View File

@ -630,7 +630,7 @@ FBInitStatus Console::initializeVideo(bool full)
const string& title = string("Stella ") + STELLA_VERSION + const string& title = string("Stella ") + STELLA_VERSION +
": \"" + myProperties.get(PropType::Cart_Name) + "\""; ": \"" + myProperties.get(PropType::Cart_Name) + "\"";
fbstatus = myOSystem.frameBuffer().createDisplay(title, fbstatus = myOSystem.frameBuffer().createDisplay(title,
FrameBuffer::BufferType::Emulator, size, false); BufferType::Emulator, size, false);
if(fbstatus != FBInitStatus::Success) if(fbstatus != FBInitStatus::Success)
return fbstatus; return fbstatus;

View File

@ -246,6 +246,25 @@ class FBSurface
ColorId color, TextAlign align = TextAlign::Left, ColorId color, TextAlign align = TextAlign::Left,
int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone); 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 // Note: The following methods are FBSurface-specific, and must be
// implemented in child classes. // implemented in child classes.
@ -324,35 +343,17 @@ class FBSurface
*/ */
virtual void resize(uInt32 width, uInt32 height) = 0; 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. 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 The child class chooses which (if any) of the actual attributes
can be applied. can be applied.
*/ */
virtual void applyAttributes() = 0; virtual void applyAttributes() = 0;
//////////////////////////////////////////////////////////////////////////
static void setPalette(const FullPaletteArray& palette) { myPalette = palette; } static void setPalette(const FullPaletteArray& palette) { myPalette = palette; }
@ -367,7 +368,8 @@ class FBSurface
*/ */
bool checkBounds(const uInt32 x, const uInt32 y) const; 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. Check if the given character is a whitespace.

View File

@ -51,19 +51,6 @@ class TIASurface;
class FrameBuffer class FrameBuffer
{ {
public: public:
enum class BufferType {
None,
Launcher,
Emulator,
Debugger
};
enum class ScalingInterpolation {
none,
sharp,
blur
};
// Zoom level step interval // Zoom level step interval
static constexpr float ZOOM_STEPS = 0.25; static constexpr float ZOOM_STEPS = 0.25;
@ -262,16 +249,16 @@ class FrameBuffer
*/ */
void enableGrabMouse(bool enable); 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). Toggles the use of grabmouse (only has effect in emulation mode).
*/ */
void toggleGrabMouse(); void toggleGrabMouse();
/**
Query whether grabmouse is enabled.
*/
bool grabMouseEnabled() const { return myGrabMouse; }
/** /**
Informs the Framebuffer of a change in EventHandler state. Informs the Framebuffer of a change in EventHandler state.
*/ */
@ -291,7 +278,8 @@ class FrameBuffer
uInt32 hidpiScaleFactor() const { return myHiDPIEnabled ? 2 : 1; } 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 getPositionKey();
string getDisplayKey(); string getDisplayKey();

View File

@ -35,6 +35,19 @@ enum class FBInitStatus {
FailNotSupported FailNotSupported
}; };
enum class BufferType {
None,
Launcher,
Emulator,
Debugger
};
enum class ScalingInterpolation {
none,
sharp,
blur
};
// Positions for onscreen/overlaid messages // Positions for onscreen/overlaid messages
enum class MessagePosition { enum class MessagePosition {
TopLeft, TopLeft,

View File

@ -27,19 +27,19 @@
#include "TIASurface.hxx" #include "TIASurface.hxx"
namespace { namespace {
FrameBuffer::ScalingInterpolation interpolationModeFromSettings(const Settings& settings) ScalingInterpolation interpolationModeFromSettings(const Settings& settings)
{ {
#ifdef RETRON77 #ifdef RETRON77
// Witv TV / and or scanline interpolation, the image has a height of ~480px. THe R77 runs at 720p, so there // 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 // is no benefit from QIS in y-direction. In addition, QIS on the R77 has performance issues if TV effects are
// enabled. // enabled.
return settings.getBool("tia.inter") || settings.getInt("tv.filter") != 0 return settings.getBool("tia.inter") || settings.getInt("tv.filter") != 0
? FrameBuffer::ScalingInterpolation::blur ? ScalingInterpolation::blur
: FrameBuffer::ScalingInterpolation::sharp; : ScalingInterpolation::sharp;
#else #else
return settings.getBool("tia.inter") ? return settings.getBool("tia.inter") ?
FrameBuffer::ScalingInterpolation::blur : ScalingInterpolation::blur :
FrameBuffer::ScalingInterpolation::sharp; ScalingInterpolation::sharp;
#endif #endif
} }
} }
@ -57,7 +57,7 @@ TIASurface::TIASurface(OSystem& system)
AtariNTSC::outWidth(TIAConstants::frameBufferWidth), AtariNTSC::outWidth(TIAConstants::frameBufferWidth),
TIAConstants::frameBufferHeight, TIAConstants::frameBufferHeight,
!correctAspect() !correctAspect()
? FrameBuffer::ScalingInterpolation::none ? ScalingInterpolation::none
: interpolationModeFromSettings(myOSystem.settings()) : interpolationModeFromSettings(myOSystem.settings())
); );

View File

@ -56,7 +56,7 @@ FBInitStatus Launcher::initializeVideo()
{ {
string title = string("Stella ") + STELLA_VERSION; string title = string("Stella ") + STELLA_VERSION;
return myOSystem.frameBuffer().createDisplay( return myOSystem.frameBuffer().createDisplay(
title, FrameBuffer::BufferType::Launcher, mySize title, BufferType::Launcher, mySize
); );
} }

View File

@ -91,7 +91,7 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
if(mySurface == nullptr) if(mySurface == nullptr)
{ {
mySurface = instance().frameBuffer().allocateSurface( mySurface = instance().frameBuffer().allocateSurface(
myAvail.w, myAvail.h, FrameBuffer::ScalingInterpolation::blur); myAvail.w, myAvail.h, ScalingInterpolation::blur);
mySurface->applyAttributes(); mySurface->applyAttributes();
dialog().addSurface(mySurface); dialog().addSurface(mySurface);

View File

@ -55,7 +55,7 @@ class FBSurfaceLIBRETRO : public FBSurface
void free() override { } void free() override { }
void reload() override { } void reload() override { }
void resize(uInt32 width, uInt32 height) override { } void resize(uInt32 width, uInt32 height) override { }
void setScalingInterpolation(FrameBuffer::ScalingInterpolation) override { } void setScalingInterpolation(ScalingInterpolation) override { }
protected: protected:
void applyAttributes() override { } void applyAttributes() override { }

View File

@ -44,7 +44,7 @@ void FrameBufferLIBRETRO::queryHardware(vector<Common::Size>& fullscreenRes,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
unique_ptr<FBSurface> unique_ptr<FBSurface>
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<FBSurface> ptr = make_unique<FBSurfaceLIBRETRO> unique_ptr<FBSurface> ptr = make_unique<FBSurfaceLIBRETRO>
(const_cast<FrameBufferLIBRETRO&>(*this), w, h, data); (const_cast<FrameBufferLIBRETRO&>(*this), w, h, data);

View File

@ -158,7 +158,7 @@ class FrameBufferLIBRETRO : public FrameBuffer
@param data If non-null, use the given data values as a static surface @param data If non-null, use the given data values as a static surface
*/ */
unique_ptr<FBSurface> unique_ptr<FBSurface>
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. Grabs or ungrabs the mouse based on the given boolean value.