Lysa  0.0
Lysa 3D Engine
ImageManager Class Reference
+ Inheritance diagram for ImageManager:

Public Member Functions

 ImageManager (size_t capacity, size_t maximum=std::numeric_limits< uint32 >::max ())
 
 ~ImageManager () override
 
void save (unique_id image_id, const std::string &filepath)
 
Image & load (const std::string &filepath, vireo::ImageFormat imageFormat=vireo::ImageFormat::R8G8B8A8_SRGB)
 
Image & create (const std::shared_ptr< vireo::Image > &image, const std::string &name="Image")
 
Image & create (const void *data, uint32 width, uint32 height, vireo::ImageFormat imageFormat=vireo::ImageFormat::R8G8B8A8_SRGB, const std::string &name="Image")
 
auto getBlankImage () const
 
auto getBlankCubeMap () const
 
auto getImages () const
 
Image & get (const std::string &name)
 
bool contains (const std::string &name) const
 
bool destroy (unique_id id) override
 
bool destroy (const Image &image) override
 
uint64 getRevision () const
 
auto getSnapshot () const
 
- Public Member Functions inherited from ResourcesManager< Image >
 ResourcesManager (ResourcesManager &) = delete
 
void collectRetired ()
 
Image & create (Args &&...args)
 
void destroy (const std::vector< unique_id > &ids)
 
void forEach (Func &&func)
 
void forEach (Func &&func) const
 
unique_id getCapacity () const
 
bool have (const unique_id id) const
 
ResourcesManager & operator= (ResourcesManager &) = delete
 
Image & operator[] (const unique_id id)
 
const Image & operator[] (const unique_id id) const
 
void requireAvailable (const size_t count)
 
void setRetirementProvider (std::function< UsageGuards ()> provider)
 
void use (const unique_id id)
 
virtual ~ResourcesManager ()
 

Additional Inherited Members

- Public Typedefs inherited from ResourcesManager< Image >
using UsageGuards = std::vector< std::weak_ptr< const void > >
 
- Protected Member Functions inherited from ResourcesManager< Image >
 ResourcesManager (const size_t capacity, const std::string &name)
 
Image & allocate (std::unique_ptr< Image > instance)
 
void enableGrowth (size_t maximum=std::numeric_limits< uint32 >::max ())
 
bool isFull () const
 
- Protected Attributes inherited from ResourcesManager< Image >
std::vector< std::unique_ptr< Image > > resources
 
std::recursive_mutex resourcesMutex
 

Constructor & Destructor Documentation

ImageManager ( size_t  capacity,
size_t  maximum = std::numeric_limits< uint32 >::max () 
)

Construct a new manager

Parameters
capacityInitial capacity
maximumMaximum number of image descriptors supported by the global layout
~ImageManager ( )
override

Member Function Documentation

bool contains ( const std::string &  name) const

Returns true if an image with the given name exists

Parameters
nameName of the image
Image& create ( const std::shared_ptr< vireo::Image > &  image,
const std::string &  name = "Image" 
)

Creates a bitmap from an array in memory

Parameters
image
nameOptional name
Image& create ( const void *  data,
uint32  width,
uint32  height,
vireo::ImageFormat  imageFormat = vireo::ImageFormat::R8G8B8A8_SRGB,
const std::string &  name = "Image" 
)

Creates a bitmap from an array in memory

Parameters
dataPixels array
widthWidth in pixels
heightHeight in pixels
imageFormatPixel format
nameOptional name
bool destroy ( const Image &  res)
inlineoverridevirtual

Releases a resource by reference, decrementing its reference counter.

Parameters
resResource to destroy.
Returns
true if the resource was actually freed, false if references remain.

Reimplemented from lysa::ResourcesManager< Image >::destroy()

bool destroy ( unique_id  id)
overridevirtual

Releases a resource by ID, decrementing its reference counter. The slot is returned to the free list only when the counter reaches zero.

Parameters
idUnique identifier of the resource to destroy.
Returns
true if the resource was actually freed, false if references remain.

Reimplemented from lysa::ResourcesManager< Image >::destroy()

Image& get ( const std::string &  name)

Returns the image with the given name, or raise an Exception if not found

Parameters
nameName of the image (as stored at creation)
auto getBlankCubeMap ( ) const
inline

Returns the default cubemap blank image used as a safe fallback.

auto getBlankImage ( ) const
inline

Returns the default 2D blank image used as a safe fallback.

auto getImages ( ) const
inline

Return the global GPU image array

uint64 getRevision ( ) const
inline

Current image table revision.

auto getSnapshot ( ) const
inline

Atomically capture image slots and their revision for descriptor set snapshots.

Image& load ( const std::string &  filepath,
vireo::ImageFormat  imageFormat = vireo::ImageFormat::R8G8B8A8_SRGB 
)

Load a bitmap from a file.
Supports JPEG and PNG formats

Parameters
filepathSource file URI
imageFormatImage pixel format
void save ( unique_id  image_id,
const std::string &  filepath 
)

Save an image into a file.
Supports PNG and HDR formats.

Parameters
image_idImage
filepathDestination file URI