Enable conditional compilation for PNG support. Some ports (libretro) don't need it at all.

This commit is contained in:
Stephen Anthony 2019-04-21 20:07:56 -02:30
parent 32d90c1935
commit eb13d515fb
11 changed files with 71 additions and 16 deletions

View File

@ -59,6 +59,9 @@
* Fixed 'Dancing Plate (Unknown) (PAL)' to use joystick.
* PNG image support is now conditionally compiled into Stella. All
major ports (Linux/macOS/Windows) have it enabled by default.
-Have fun!

17
configure vendored
View File

@ -22,6 +22,7 @@ _build_sound=yes
_build_debugger=yes
_build_joystick=yes
_build_cheats=yes
_build_png=yes
_build_static=no
_build_profile=no
_build_debug=no
@ -198,6 +199,8 @@ Optional Features:
--disable-joystick
--enable-cheats enable/disable cheatcode support [enabled]
--disable-cheats
--enable-png enable/disable PNG image support [enabled]
--disable-png
--enable-windowed enable/disable windowed rendering modes [enabled]
--disable-windowed
--enable-shared build shared binary [enabled]
@ -237,6 +240,8 @@ for ac_option in $@; do
--disable-joystick) _build_joystick=no ;;
--enable-cheats) _build_cheats=yes ;;
--disable-cheats) _build_cheats=no ;;
--enable-png) _build_png=yes ;;
--disable-png) _build_png=no ;;
--enable-windowed) _build_windowed=yes ;;
--disable-windowed) _build_windowed=no ;;
--enable-shared) _build_static=no ;;
@ -669,6 +674,14 @@ else
echo
fi
if test "$_build_png" = yes ; then
echo_n " PNG image support enabled"
echo
else
echo_n " PNG image support disabled"
echo
fi
if test "$_build_windowed" = "yes" ; then
echo_n " Windowed rendering modes enabled"
echo
@ -802,6 +815,10 @@ if test "$_build_cheats" = yes ; then
INCLUDES="$INCLUDES -I$CHEAT"
fi
if test "$_build_png" = yes ; then
DEFINES="$DEFINES -DPNG_SUPPORT"
fi
if test "$_build_profile" = no ; then
_build_profile=
fi

View File

@ -546,9 +546,11 @@ bool PhysicalKeyboardHandler::handleAltEvent(StellaKey key, StellaMod mod, bool
myOSystem.state().toggleTimeMachine();
break;
#ifdef PNG_SUPPORT
case KBDK_S:
myOSystem.png().toggleContinuousSnapshots(StellaModTest::isShift(mod));
break;
#endif
default:
handled = false;

View File

@ -15,6 +15,8 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#if defined(PNG_SUPPORT)
#include <cmath>
#include "bspf.hxx"
@ -493,3 +495,5 @@ void PNGLibrary::png_user_error(png_structp ctx, png_const_charp str)
PNGLibrary::ReadInfoType PNGLibrary::ReadInfo = {
nullptr, nullptr, 0, 0, 0, 0, 0
};
#endif // PNG_SUPPORT

View File

@ -18,6 +18,8 @@
#ifndef PNGLIBRARY_HXX
#define PNGLIBRARY_HXX
#if defined(PNG_SUPPORT)
#include <png.h>
class OSystem;
@ -197,4 +199,6 @@ class PNGLibrary
PNGLibrary& operator=(PNGLibrary&&) = delete;
};
#endif // PNG_SUPPORT
#endif

View File

@ -61,9 +61,10 @@ void TiaOutputWidget::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix)
{
if (execDepth > 0) {
#ifdef PNG_SUPPORT
if(execDepth > 0)
drawWidget(false);
}
ostringstream sspath;
sspath << instance().snapshotSaveDir()
<< instance().console().properties().get(PropType::Cart_Name);
@ -93,6 +94,9 @@ void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix)
if (execDepth == 0) {
instance().frameBuffer().showMessage(message);
}
#else
instance().frameBuffer().showMessage("PNG image saving not supported");
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -118,7 +118,9 @@ void EventHandler::reset(EventHandlerState state)
{
setState(state);
myOSystem.state().reset();
#ifdef PNG_SUPPORT
myOSystem.png().setContinuousSnapInterval(0);
#endif
// Reset events almost immediately after starting emulation mode
// We wait a little while (0.5s), since 'hold' events may be present,
@ -219,9 +221,11 @@ void EventHandler::poll(uInt64 time)
cheat->evaluate();
#endif
#ifdef PNG_SUPPORT
// Handle continuous snapshots
if(myOSystem.png().continuousSnapEnabled())
myOSystem.png().updateTime(time);
#endif
}
else if(myOverlay)
{

View File

@ -81,7 +81,10 @@ OSystem::OSystem()
myFeatures += "Debugger ";
#endif
#ifdef CHEATCODE_SUPPORT
myFeatures += "Cheats";
myFeatures += "Cheats ";
#endif
#ifdef PNG_SUPPORT
myFeatures += "PNG";
#endif
// Get build info
@ -154,8 +157,10 @@ bool OSystem::create()
// Create random number generator
myRandom = make_unique<Random>(uInt32(TimerManager::getTicks()));
#ifdef PNG_SUPPORT
// Create PNG handler
myPNGLib = make_unique<PNGLibrary>(*this);
#endif
return true;
}

View File

@ -18,6 +18,9 @@
#ifndef OSYSTEM_HXX
#define OSYSTEM_HXX
#ifdef PNG_SUPPORT
class PNGLibrary;
#endif
#ifdef CHEATCODE_SUPPORT
class CheatManager;
#endif
@ -29,7 +32,6 @@ class Menu;
class TimeMachine;
class FrameBuffer;
class EventHandler;
class PNGLibrary;
class Properties;
class PropertiesSet;
class Random;
@ -173,13 +175,6 @@ class OSystem
*/
TimerManager& timer() const { return *myTimerManager; }
/**
Get the PNG handler of the system.
@return The PNGlib object
*/
PNGLibrary& png() const { return *myPNGLib; }
/**
This method should be called to initiate the process of loading settings
from the config file. It takes care of loading settings, applying
@ -212,6 +207,15 @@ class OSystem
CheatManager& cheat() const { return *myCheatManager; }
#endif
#ifdef PNG_SUPPORT
/**
Get the PNG handler of the system.
@return The PNGlib object
*/
PNGLibrary& png() const { return *myPNGLib; }
#endif
/**
Set all config file paths for the OSystem.
*/
@ -491,15 +495,17 @@ class OSystem
unique_ptr<CheatManager> myCheatManager;
#endif
#ifdef PNG_SUPPORT
// PNG object responsible for loading/saving PNG images
unique_ptr<PNGLibrary> myPNGLib;
#endif
// Pointer to the StateManager object
unique_ptr<StateManager> myStateManager;
// Pointer to the TimerManager object
unique_ptr<TimerManager> myTimerManager;
// PNG object responsible for loading/saving PNG images
unique_ptr<PNGLibrary> myPNGLib;
// The list of log messages
string myLogMessages;

View File

@ -398,7 +398,9 @@ void TIASurface::render()
if(mySaveSnapFlag)
{
mySaveSnapFlag = false;
#ifdef PNG_SUPPORT
myOSystem.png().takeSnapshot();
#endif
}
}

View File

@ -95,9 +95,10 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
// Initialize to empty properties entry
mySurfaceErrorMsg = "";
mySurfaceIsValid = true;
mySurfaceIsValid = false;
myRomInfo.clear();
#ifdef PNG_SUPPORT
// Get a valid filename representing a snapshot file for this rom
const string& filename = instance().snapshotLoadDir() +
myProperties.get(PropType::Cart_Name) + ".png";
@ -111,12 +112,15 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
const GUI::Rect& src = mySurface->srcRect();
float scale = std::min(float(myAvail.w) / src.width(), float(myAvail.h) / src.height());
mySurface->setDstSize(uInt32(src.width() * scale), uInt32(src.height() * scale));
mySurfaceIsValid = true;
}
catch(const runtime_error& e)
{
mySurfaceIsValid = false;
mySurfaceErrorMsg = e.what();
}
#else
mySurfaceErrorMsg = "PNG image loading not supported";
#endif
if(mySurface)
mySurface->setVisible(mySurfaceIsValid);