mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-18 06:20:14 +00:00
5a3954ae0e
Fixes several files incorrectly stated a different license from the actual project, as well as the copyright headers included in all files. This change has no effect on the licensing terms, it should clear up a bit of confusion by contributors. Plus the files get a bit smaller, and we have less duplicated information across the entire project. Overall the project is GPLv2 if not built with Qt, and GPLv3 if it is built with Qt. There are no parts licensed under a different license, all have been adapted from other compatible licenses into GPLv2 or GPLv3.
73 lines
2.4 KiB
C++
73 lines
2.4 KiB
C++
// AUTOGENERATED COPYRIGHT HEADER START
|
|
// Copyright (C) 2021-2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
|
// AUTOGENERATED COPYRIGHT HEADER END
|
|
|
|
#include "gfx-lut.hpp"
|
|
#include "obs/gs/gs-helper.hpp"
|
|
#include "plugin.hpp"
|
|
#include "util/util-logging.hpp"
|
|
|
|
#include "warning-disable.hpp"
|
|
#include <mutex>
|
|
#include "warning-enable.hpp"
|
|
|
|
#ifdef _DEBUG
|
|
#define ST_PREFIX "<%s> "
|
|
#define D_LOG_ERROR(x, ...) P_LOG_ERROR(ST_PREFIX##x, __FUNCTION_SIG__, __VA_ARGS__)
|
|
#define D_LOG_WARNING(x, ...) P_LOG_WARN(ST_PREFIX##x, __FUNCTION_SIG__, __VA_ARGS__)
|
|
#define D_LOG_INFO(x, ...) P_LOG_INFO(ST_PREFIX##x, __FUNCTION_SIG__, __VA_ARGS__)
|
|
#define D_LOG_DEBUG(x, ...) P_LOG_DEBUG(ST_PREFIX##x, __FUNCTION_SIG__, __VA_ARGS__)
|
|
#else
|
|
#define ST_PREFIX "<transition::shader> "
|
|
#define D_LOG_ERROR(...) P_LOG_ERROR(ST_PREFIX __VA_ARGS__)
|
|
#define D_LOG_WARNING(...) P_LOG_WARN(ST_PREFIX __VA_ARGS__)
|
|
#define D_LOG_INFO(...) P_LOG_INFO(ST_PREFIX __VA_ARGS__)
|
|
#define D_LOG_DEBUG(...) P_LOG_DEBUG(ST_PREFIX __VA_ARGS__)
|
|
#endif
|
|
|
|
using namespace streamfx;
|
|
|
|
std::shared_ptr<streamfx::gfx::lut::data> streamfx::gfx::lut::data::instance()
|
|
{
|
|
static std::weak_ptr<streamfx::gfx::lut::data> _instance;
|
|
static std::mutex _mutex;
|
|
|
|
std::lock_guard<std::mutex> lock(_mutex);
|
|
|
|
auto reference = _instance.lock();
|
|
if (!reference) {
|
|
reference = std::shared_ptr<streamfx::gfx::lut::data>(new streamfx::gfx::lut::data());
|
|
_instance = reference;
|
|
}
|
|
return reference;
|
|
}
|
|
|
|
streamfx::gfx::lut::data::data() : _producer_effect(), _consumer_effect()
|
|
{
|
|
auto gctx = streamfx::obs::gs::context();
|
|
|
|
std::filesystem::path lut_producer_path = streamfx::data_file_path("effects/lut-producer.effect");
|
|
if (std::filesystem::exists(lut_producer_path)) {
|
|
try {
|
|
_producer_effect = std::make_shared<streamfx::obs::gs::effect>(lut_producer_path);
|
|
} catch (std::exception const& ex) {
|
|
D_LOG_ERROR("Loading LUT Producer effect failed: %s", ex.what());
|
|
}
|
|
}
|
|
|
|
std::filesystem::path lut_consumer_path = streamfx::data_file_path("effects/lut-consumer.effect");
|
|
if (std::filesystem::exists(lut_consumer_path)) {
|
|
try {
|
|
_consumer_effect = std::make_shared<streamfx::obs::gs::effect>(lut_consumer_path);
|
|
} catch (std::exception const& ex) {
|
|
D_LOG_ERROR("Loading LUT Consumer effect failed: %s", ex.what());
|
|
}
|
|
}
|
|
}
|
|
|
|
streamfx::gfx::lut::data::~data()
|
|
{
|
|
auto gctx = streamfx::obs::gs::context();
|
|
_producer_effect.reset();
|
|
_consumer_effect.reset();
|
|
}
|