Merge branch 'master' into gizmos
This commit is contained in:
@@ -78,6 +78,14 @@ Color::Color(const char *data, const PixelFormat::Format &format)
|
||||
}
|
||||
}
|
||||
|
||||
Color::Color(const QColor &c)
|
||||
{
|
||||
set_red(c.redF());
|
||||
set_green(c.greenF());
|
||||
set_blue(c.blueF());
|
||||
set_alpha(c.alphaF());
|
||||
}
|
||||
|
||||
void Color::toHsv(float *hue, float *sat, float *val) const
|
||||
{
|
||||
float fCMax = qMax(qMax(red(), green()), blue());
|
||||
@@ -207,6 +215,11 @@ QColor Color::toQColor() const
|
||||
return c;
|
||||
}
|
||||
|
||||
float Color::GetRoughLuminance() const
|
||||
{
|
||||
return (2*red()+blue()+3*green())/6.0f;
|
||||
}
|
||||
|
||||
const Color &Color::operator+=(const Color &rhs)
|
||||
{
|
||||
for (int i=0;i<kRGBAChannels;i++) {
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
|
||||
Color(const char *data, const PixelFormat::Format &format);
|
||||
|
||||
Color(const QColor& c);
|
||||
|
||||
/**
|
||||
* @brief Creates a Color struct from hue/saturation/value
|
||||
*
|
||||
@@ -86,6 +88,10 @@ public:
|
||||
|
||||
QColor toQColor() const;
|
||||
|
||||
// Suuuuper rough luminance value mostly used for UI (determining whether to overlay with black
|
||||
// or white text)
|
||||
float GetRoughLuminance() const;
|
||||
|
||||
// Assignment math operators
|
||||
const Color& operator+=(const Color& rhs);
|
||||
const Color& operator-=(const Color& rhs);
|
||||
|
||||
@@ -49,6 +49,13 @@ OCIO::ConstConfigRcPtr ColorManager::GetConfig() const
|
||||
return config_;
|
||||
}
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::CreateConfigFromFile(const QString &filename)
|
||||
{
|
||||
OCIO_SET_C_LOCALE_FOR_SCOPE;
|
||||
|
||||
return OCIO::Config::CreateFromFile(filename.toUtf8());
|
||||
}
|
||||
|
||||
const QString &ColorManager::GetConfigFilename() const
|
||||
{
|
||||
return config_filename_;
|
||||
@@ -61,7 +68,10 @@ OCIO::ConstConfigRcPtr ColorManager::GetDefaultConfig()
|
||||
|
||||
void ColorManager::SetUpDefaultConfig()
|
||||
{
|
||||
OCIO_SET_C_LOCALE_FOR_SCOPE;
|
||||
|
||||
if (!qgetenv("OCIO").isEmpty()) {
|
||||
// Attempt to set config from "OCIO" environment variable
|
||||
try {
|
||||
default_config_ = OCIO::Config::CreateFromEnv();
|
||||
|
||||
@@ -71,7 +81,7 @@ void ColorManager::SetUpDefaultConfig()
|
||||
}
|
||||
}
|
||||
|
||||
// Kind of hacky, but it'll work
|
||||
// Extract OCIO config - kind of hacky, but it'll work
|
||||
QString dir = QDir(FileFunctions::GetTempFilePath()).filePath(QStringLiteral("ocioconf"));
|
||||
|
||||
FileFunctions::CopyDirectory(QStringLiteral(":/ocioconf"),
|
||||
@@ -80,7 +90,7 @@ void ColorManager::SetUpDefaultConfig()
|
||||
|
||||
qDebug() << "Extracting default OCIO config to" << dir;
|
||||
|
||||
default_config_ = OCIO::Config::CreateFromFile(QDir(dir).filePath(QStringLiteral("config.ocio")).toUtf8());
|
||||
default_config_ = CreateConfigFromFile(QDir(dir).filePath(QStringLiteral("config.ocio")));
|
||||
}
|
||||
|
||||
void ColorManager::SetConfig(const QString &filename)
|
||||
@@ -372,4 +382,15 @@ void ColorManager::AssociateAlphaInternal(ColorManager::AlphaAction action, T *d
|
||||
}
|
||||
}
|
||||
|
||||
ColorManager::SetLocale::SetLocale(const char* new_locale)
|
||||
{
|
||||
old_locale_ = setlocale(LC_NUMERIC, nullptr);
|
||||
setlocale(LC_NUMERIC, new_locale);
|
||||
}
|
||||
|
||||
ColorManager::SetLocale::~SetLocale()
|
||||
{
|
||||
setlocale(LC_NUMERIC, old_locale_.toUtf8());
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "codec/frame.h"
|
||||
#include "colorprocessor.h"
|
||||
|
||||
#define OCIO_SET_C_LOCALE_FOR_SCOPE ColorManager::SetLocale d("C")
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
class ColorManager : public QObject
|
||||
@@ -36,6 +38,8 @@ public:
|
||||
|
||||
OCIO::ConstConfigRcPtr GetConfig() const;
|
||||
|
||||
static OCIO::ConstConfigRcPtr CreateConfigFromFile(const QString& filename);
|
||||
|
||||
const QString& GetConfigFilename() const;
|
||||
|
||||
static OCIO::ConstConfigRcPtr GetDefaultConfig();
|
||||
@@ -90,6 +94,18 @@ public:
|
||||
|
||||
static void SetOCIOMethodForMode(RenderMode::Mode mode, OCIOMethod method);
|
||||
|
||||
class SetLocale
|
||||
{
|
||||
public:
|
||||
SetLocale(const char* new_locale);
|
||||
|
||||
~SetLocale();
|
||||
|
||||
private:
|
||||
QString old_locale_;
|
||||
|
||||
};
|
||||
|
||||
signals:
|
||||
void ConfigChanged();
|
||||
|
||||
|
||||
@@ -44,10 +44,12 @@ ColorProcessor::ColorProcessor(ColorManager *config, const QString &input, const
|
||||
display_transform->setLooksOverrideEnabled(true);
|
||||
}
|
||||
|
||||
OCIO_SET_C_LOCALE_FOR_SCOPE;
|
||||
processor_ = config->GetConfig()->getProcessor(display_transform);
|
||||
|
||||
} else {
|
||||
|
||||
OCIO_SET_C_LOCALE_FOR_SCOPE;
|
||||
processor_ = config->GetConfig()->getProcessor(input.toUtf8(),
|
||||
output.toUtf8());
|
||||
|
||||
|
||||
@@ -14,8 +14,16 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
file(GLOB_RECURSE OCIOCONF_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.ocio *.spi3d *.spi1d)
|
||||
set(QRC_BODY "")
|
||||
foreach(OCIOCONF_FILE ${OCIOCONF_RESOURCES})
|
||||
string(APPEND QRC_BODY "<file>${OCIOCONF_FILE}</file>\n")
|
||||
configure_file(${OCIOCONF_FILE} ${OCIOCONF_FILE} COPYONLY)
|
||||
endforeach()
|
||||
configure_file(ocioconf.qrc.in ocioconf.qrc @ONLY)
|
||||
|
||||
set(OLIVE_RESOURCES
|
||||
${OLIVE_RESOURCES}
|
||||
render/ocioconf/ocioconf.qrc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/ocioconf.qrc
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
ourbasename=$(basename "$0")
|
||||
|
||||
rm ocioconf.qrc
|
||||
echo "<RCC>" >> ocioconf.qrc
|
||||
echo " <qresource prefix=\"/ocioconf\">" >> ocioconf.qrc
|
||||
|
||||
for f in $(find * -type f)
|
||||
do
|
||||
if [ "$f" != "CMakeLists.txt" ] && [ "$f" != "ocioconf.qrc" ] && [ "$f" != "$ourbasename" ]
|
||||
then
|
||||
echo " <file>$f</file>" >> ocioconf.qrc
|
||||
fi
|
||||
done
|
||||
|
||||
echo " </qresource>" >> ocioconf.qrc
|
||||
echo "</RCC>" >> ocioconf.qrc
|
||||
@@ -1,19 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/ocioconf">
|
||||
<file>config.ocio</file>
|
||||
<file>looks/Filmic_False_Colour.spi3d</file>
|
||||
<file>looks/Filmic_to_0-35_1-30.spi1d</file>
|
||||
<file>looks/Filmic_to_0-48_1-09.spi1d</file>
|
||||
<file>looks/Filmic_to_0-60_1-04.spi1d</file>
|
||||
<file>looks/Filmic_to_0-70_1-03.spi1d</file>
|
||||
<file>looks/Filmic_to_0-85_1-011.spi1d</file>
|
||||
<file>looks/Filmic_to_0.99_1-0075.spi1d</file>
|
||||
<file>looks/Filmic_to_1.20_1-00.spi1d</file>
|
||||
<file>luts/F-Log_to_Linear.spi1d</file>
|
||||
<file>luts/V-Log_to_linear.spi1d</file>
|
||||
<file>luts/V3_LogC_400_to_linear.spi1d</file>
|
||||
<file>luts/V3_LogC_800_to_linear.spi1d</file>
|
||||
<file>luts/desat65cube.spi3d</file>
|
||||
<file>luts/sRGB_OETF_to_Linear.spi1d</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/ocioconf">
|
||||
@QRC_BODY@
|
||||
</qresource>
|
||||
</RCC>
|
||||
Reference in New Issue
Block a user