Files
rawTherapee/rtengine/clutstore.h
Flössie bf499055e1 Apply HaldCLUT::getRGB() per tile line
`getRGB()` now takes a whole tile line instead of a single pixel.
2016-04-26 21:57:58 +02:00

82 lines
1.7 KiB
C++

#pragma once
#include <memory>
#include <cstdint>
#include <gtkmm.h>
#include "cache.h"
#include "alignedbuffer.h"
namespace rtengine
{
class CLUT
{
public:
CLUT() = default;
CLUT(const CLUT& other) = delete;
CLUT& operator =(const CLUT& other) = delete;
virtual ~CLUT() = default;
virtual explicit operator bool() const = 0;
virtual Glib::ustring getFilename() const = 0;
virtual Glib::ustring getProfile() const = 0;
virtual void getRGB(std::size_t line_size, const float* r, const float* g, const float* b, float* out_rgbx) const = 0;
static void splitClutFilename(
const Glib::ustring& filename,
Glib::ustring& name,
Glib::ustring& extension,
Glib::ustring& profile_name
);
};
class HaldCLUT
: public CLUT
{
public:
HaldCLUT();
~HaldCLUT();
bool load(const Glib::ustring& filename);
explicit operator bool() const override;
Glib::ustring getFilename() const override;
Glib::ustring getProfile() const override;
void getRGB(std::size_t line_size, const float* r, const float* g, const float* b, float* out_rgbx) const override;
private:
AlignedBuffer<std::uint16_t> clut_image;
unsigned int clut_level;
float flevel_minus_one;
float flevel_minus_two;
Glib::ustring clut_filename;
Glib::ustring clut_profile;
};
class CLUTStore
{
public:
static CLUTStore& getInstance();
CLUTStore(const CLUTStore& other) = delete;
CLUTStore& operator =(const CLUTStore& other) = delete;
std::shared_ptr<CLUT> getClut(const Glib::ustring& filename);
void releaseClut(const std::shared_ptr<CLUT>& clut);
void clearCache();
private:
CLUTStore();
Cache<Glib::ustring, std::shared_ptr<CLUT>> cache;
};
}