Program Listing for File Texture.h

Program Listing for File Texture.h#

Return to documentation for file (include/Karana/Scene/Texture.h)

/*
*Copyright(c)2024-2025KaranaDynamicsPtyLtd.Allrightsreserved.
*
*NOTICETOUSER:
*
*Thissourcecodeand/ordocumentation(the"LicensedMaterials")is
*theconfidentialandproprietaryinformationofKaranaDynamicsInc.
*UseoftheseLicensedMaterialsisgovernedbythetermsandconditions
*ofaseparatesoftwarelicenseagreementbetweenKaranaDynamicsandthe
*Licensee("LicenseAgreement").Unlessexpresslypermittedunderthat
*agreement,anyreproduction,modification,distribution,ordisclosure
*oftheLicensedMaterials,inwholeorinpart,toanythirdparty
*withoutthepriorwrittenconsentofKaranaDynamicsisstrictlyprohibited.
*
*THELICENSEDMATERIALSAREPROVIDED"ASIS"WITHOUTWARRANTYOFANYKIND.
*KARANADYNAMICSDISCLAIMSALLWARRANTIES,EXPRESSORIMPLIED,INCLUDING
*BUTNOTLIMITEDTOWARRANTIESOFMERCHANTABILITY,NON-INFRINGEMENT,AND
*FITNESSFORAPARTICULARPURPOSE.
*
*INNOEVENTSHALLKARANADYNAMICSBELIABLEFORANYDAMAGESWHATSOEVER,
*INCLUDINGBUTNOTLIMITEDTOLOSSOFPROFITS,DATA,ORUSE,EVENIF
*ADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGES,WHETHERINCONTRACT,TORT,
*OROTHERWISEARISINGOUTOFORINCONNECTIONWITHTHELICENSEDMATERIALS.
*
*U.S.GovernmentEndUsers:TheLicensedMaterialsarea"commercialitem"
*asdefinedat48C.F.R.2.101,andareprovidedtotheU.S.Government
*onlyasacommercialenditemunderthetermsofthislicense.
*
*AnyuseoftheLicensedMaterialsinindividualorcommercialsoftwaremust
*include,intheuserdocumentationandinternalsourcecodecomments,
*thisNotice,Disclaimer,andU.S.GovernmentUseProvision.
*/


#pragmaonce

#include"Karana/KCore/Base.h"
#include<filesystem>
#include<unsupported/Eigen/CXX11/Tensor>

namespaceKarana::Scene{

namespacefs=std::filesystem;
namespacekc=Karana::Core;

usingTextureData=Eigen::Tensor<uint8_t,3,Eigen::RowMajor>;

classTexture:publicKarana::Core::Base{
public:
Texture(std::string_viewname,constTextureData&data_in);

~Texture();

statickc::ks_ptr<Texture>create(std::string_viewname,constTextureData&data);

statickc::ks_ptr<Texture>create(std::string_viewname,unsignedchar*buffer,intlen);

statickc::ks_ptr<Texture>lookupOrCreateTexture(conststd::filesystem::path&filename);

voidwriteToFile(conststd::filesystem::path&filename);

std::vector<unsignedchar>writeToPngMem()const;

constTextureData&getData()const;

virtualvoidsetData(constTextureData&data);

virtualvoidsetData(TextureData&&data);

protected:
TextureData_data;

private:
staticstd::unordered_map<fs::path,kc::id_t>_texture_cache;
};

classGrayscaleTexture:publicTexture{
public:
GrayscaleTexture(std::string_viewname,constTextureData&data_in);

~GrayscaleTexture();

voidsetData(constTextureData&data_in)final;

virtualvoidsetData(TextureData&&data);

//Addingsuppression,asCodeCheckercomplainsthismethodhasthesamenameasamethodin
//thebaseversion.ThisisjustaCodeCheckerfalsepositive.
//codechecker_suppress[cppcheck-duplInheritedMember]
statickc::ks_ptr<GrayscaleTexture>create(std::string_viewname,constTextureData&data);

statickc::ks_ptr<GrayscaleTexture>
//Addingsuppression,asCodeCheckercomplainsthismethodhasthesamenameasamethodin
//thebaseversion.ThisisjustaCodeCheckerfalsepositive.
//codechecker_suppress[cppcheck-duplInheritedMember]
create(std::string_viewname,unsignedchar*buffer,intlen);

statickc::ks_ptr<GrayscaleTexture>
lookupOrCreateGrayscaleTexture(conststd::filesystem::path&filename);

private:
staticstd::unordered_map<fs::path,kc::id_t>_grayscale_texture_cache;
};

}//namespaceKarana::Scene