1
0
Fork 0

DDS-TC identify images coming from Canvas

This is to allow the DDS texture cache to take appropriate action (such as not compressing these images to ensure that the aspect ratio is good).
This commit is contained in:
Richard Harrison 2020-11-17 19:08:00 +01:00
parent 35da4231dd
commit b41bc317dd

View file

@ -27,6 +27,8 @@
#include <osgDB/ReadFile>
#include <stdexcept>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
namespace canvas
{
//----------------------------------------------------------------------------
@ -80,12 +82,15 @@ namespace canvas
//----------------------------------------------------------------------------
osg::ref_ptr<osg::Image> FGCanvasSystemAdapter::getImage(const std::string& path) const
{
SGPath p(SGPath::fromUtf8(path));
SGPath p(SGPath::fromUtf8(path));
osg::ref_ptr<simgear::SGReaderWriterOptions> localReaderWriterOptions = simgear::SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions());
localReaderWriterOptions->setLoadOriginHint(simgear::SGReaderWriterOptions::LoadOriginHint::ORIGIN_CANVAS);
if( p.isAbsolute() )
{
SGPath valid_path = fgValidatePath(p, false);
if( !valid_path.isNull() )
return osgDB::readRefImageFile(valid_path.utf8Str());
return osgDB::readRefImageFile(valid_path.utf8Str(), localReaderWriterOptions);
SG_LOG(SG_IO, SG_ALERT, "canvas::Image: reading '" << path << "' denied");
}
@ -93,7 +98,7 @@ namespace canvas
{
SGPath tpath = globals->resolve_resource_path(path);
if( !tpath.isNull() )
return osgDB::readRefImageFile(tpath.utf8Str());
return osgDB::readRefImageFile(tpath.utf8Str(), localReaderWriterOptions);
SG_LOG(SG_IO, SG_ALERT, "canvas::Image: No such image: '" << path << "'");
}