Connect tia.filter.

This commit is contained in:
Christian Speckner 2019-12-16 09:38:16 +01:00
parent fd136e0d49
commit 5977c8561a
7 changed files with 48 additions and 3 deletions

View File

@ -249,3 +249,12 @@ void FBSurfaceSDL2::applyAttributes()
{
reinitializeBlitter();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSDL2::setScalingInterpolation(FrameBuffer::ScalingInterpolation interpolation)
{
if (interpolation == myInterpolationMode) return;
myInterpolationMode = interpolation;
reload();
}

View File

@ -62,6 +62,8 @@ class FBSurfaceSDL2 : public FBSurface
void reload() override;
void resize(uInt32 width, uInt32 height) override;
void setScalingInterpolation(FrameBuffer::ScalingInterpolation) override;
protected:
void applyAttributes() override;
@ -81,7 +83,7 @@ class FBSurfaceSDL2 : public FBSurface
FrameBufferSDL2& myFB;
unique_ptr<Blitter> myBlitter;
const FrameBuffer::ScalingInterpolation myInterpolationMode;
FrameBuffer::ScalingInterpolation myInterpolationMode;
SDL_Surface* mySurface;
SDL_Rect mySrcR, myDstR;

View File

@ -29,6 +29,7 @@ namespace Common {
}
#include "FrameBufferConstants.hxx"
#include "FrameBuffer.hxx"
#include "bspf.hxx"
/**
@ -335,6 +336,11 @@ class FBSurface
*/
Attributes& attributes() { return myAttributes; }
/**
Configure scaling interpolation.
*/
virtual void setScalingInterpolation(FrameBuffer::ScalingInterpolation) = 0;
/**
The child class chooses which (if any) of the actual attributes
can be applied.

View File

@ -293,6 +293,8 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
Logger::info(post_about);
}
if (myTIASurface) myTIASurface->updateSurfaceSettings();
return FBInitStatus::Success;
}

View File

@ -25,6 +25,19 @@
#include "PNGLibrary.hxx"
#include "TIASurface.hxx"
namespace {
FrameBuffer::ScalingInterpolation interpolationModeFromSettings(const Settings& settings)
{
const string setting = settings.getString("tia.filter");
if (setting == "sharp") return FrameBuffer::ScalingInterpolation::sharp;
if (setting == "soft") return FrameBuffer::ScalingInterpolation::blur;
if (setting == "none") return FrameBuffer::ScalingInterpolation::none;
return FrameBuffer::ScalingInterpolation::sharp;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TIASurface::TIASurface(OSystem& system)
: myOSystem(system),
@ -44,7 +57,7 @@ TIASurface::TIASurface(OSystem& system)
myTiaSurface = myFB.allocateSurface(
AtariNTSC::outWidth(TIAConstants::frameBufferWidth),
TIAConstants::frameBufferHeight,
FrameBuffer::ScalingInterpolation::sharp
interpolationModeFromSettings(myOSystem.settings())
);
// Generate scanline data, and a pre-defined scanline surface
@ -55,7 +68,7 @@ TIASurface::TIASurface(OSystem& system)
scanData[i] = 0x00000000;
scanData[i+1] = 0xff000000;
}
mySLineSurface = myFB.allocateSurface(1, scanHeight, FrameBuffer::ScalingInterpolation::sharp, scanData);
mySLineSurface = myFB.allocateSurface(1, scanHeight, interpolationModeFromSettings(myOSystem.settings()), scanData);
// Base TIA surface for use in taking snapshots in 1x mode
myBaseTiaSurface = myFB.allocateSurface(TIAConstants::frameBufferWidth*2,
@ -458,3 +471,10 @@ void TIASurface::renderForSnapshot()
mySLineSurface->render();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIASurface::updateSurfaceSettings()
{
myTiaSurface->setScalingInterpolation(interpolationModeFromSettings(myOSystem.settings()));
mySLineSurface->setScalingInterpolation(interpolationModeFromSettings(myOSystem.settings()));
}

View File

@ -156,6 +156,11 @@ class TIASurface
*/
void saveSnapShot() { mySaveSnapFlag = true; }
/**
Update surface settings.
*/
void updateSurfaceSettings();
private:
/**
Average current calculated buffer's pixel with previous calculated buffer's pixel (50:50).

View File

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