Code style cleanup and prevent crashes when OCIO configuration file is not found
This commit is contained in:
@@ -32,374 +32,343 @@
|
||||
#define OCIO_CAPI_IMPLEMENTATION
|
||||
#include "ocio_capi.h"
|
||||
|
||||
ConstConfigRcPtr* OCIO_getCurrentConfig(void)
|
||||
ConstConfigRcPtr *OCIO_getCurrentConfig(void)
|
||||
{
|
||||
ConstConfigRcPtr* config = new ConstConfigRcPtr();
|
||||
try
|
||||
{
|
||||
ConstConfigRcPtr *config = new ConstConfigRcPtr();
|
||||
try {
|
||||
*config = GetCurrentConfig();
|
||||
|
||||
if(*config)
|
||||
return config;
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void OCIO_setCurrentConfig(const ConstConfigRcPtr* config)
|
||||
void OCIO_setCurrentConfig(const ConstConfigRcPtr *config)
|
||||
{
|
||||
if(config)
|
||||
{
|
||||
try
|
||||
{
|
||||
SetCurrentConfig(*config);
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
try {
|
||||
SetCurrentConfig(*config);
|
||||
}
|
||||
catch (Exception & exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
ConstConfigRcPtr* OCIO_configCreateFromEnv(void)
|
||||
ConstConfigRcPtr *OCIO_configCreateFromEnv(void)
|
||||
{
|
||||
ConstConfigRcPtr* config = new ConstConfigRcPtr();
|
||||
try
|
||||
{
|
||||
ConstConfigRcPtr *config = new ConstConfigRcPtr();
|
||||
|
||||
try {
|
||||
*config = Config::CreateFromEnv();
|
||||
if(*config)
|
||||
|
||||
if (*config)
|
||||
return config;
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ConstConfigRcPtr* OCIO_configCreateFromFile(const char* filename)
|
||||
ConstConfigRcPtr *OCIO_configCreateFromFile(const char *filename)
|
||||
{
|
||||
ConstConfigRcPtr* config = new ConstConfigRcPtr();
|
||||
try
|
||||
{
|
||||
ConstConfigRcPtr *config = new ConstConfigRcPtr();
|
||||
|
||||
try {
|
||||
*config = Config::CreateFromFile(filename);
|
||||
if(*config)
|
||||
|
||||
if (*config)
|
||||
return config;
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void OCIO_configRelease(ConstConfigRcPtr* config)
|
||||
void OCIO_configRelease(ConstConfigRcPtr *config)
|
||||
{
|
||||
if(config){
|
||||
delete config;
|
||||
config =0;
|
||||
}
|
||||
delete config;
|
||||
}
|
||||
|
||||
int OCIO_configGetNumColorSpaces(ConstConfigRcPtr* config)
|
||||
int OCIO_configGetNumColorSpaces(ConstConfigRcPtr *config)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
return (*config)->getNumColorSpaces();
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* OCIO_configGetColorSpaceNameByIndex(ConstConfigRcPtr* config, int index)
|
||||
const char *OCIO_configGetColorSpaceNameByIndex(ConstConfigRcPtr *config, int index)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
return (*config)->getColorSpaceNameByIndex(index);
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ConstColorSpaceRcPtr* OCIO_configGetColorSpace(ConstConfigRcPtr* config, const char* name)
|
||||
ConstColorSpaceRcPtr *OCIO_configGetColorSpace(ConstConfigRcPtr *config, const char *name)
|
||||
{
|
||||
ConstColorSpaceRcPtr* cs = new ConstColorSpaceRcPtr();
|
||||
try
|
||||
{
|
||||
ConstColorSpaceRcPtr *cs = new ConstColorSpaceRcPtr();
|
||||
|
||||
try {
|
||||
*cs = (*config)->getColorSpace(name);
|
||||
if(*cs)
|
||||
|
||||
if (*cs)
|
||||
return cs;
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
delete cs;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int OCIO_configGetIndexForColorSpace(ConstConfigRcPtr* config, const char* name)
|
||||
int OCIO_configGetIndexForColorSpace(ConstConfigRcPtr *config, const char *name)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
return (*config)->getIndexForColorSpace(name);
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char* OCIO_configGetDefaultDisplay(ConstConfigRcPtr* config)
|
||||
const char *OCIO_configGetDefaultDisplay(ConstConfigRcPtr *config)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
return (*config)->getDefaultDisplay();
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int OCIO_configGetNumDisplays(ConstConfigRcPtr* config)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
return (*config)->getNumDisplays();
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* OCIO_configGetDisplay(ConstConfigRcPtr* config, int index)
|
||||
const char *OCIO_configGetDisplay(ConstConfigRcPtr *config, int index)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
return (*config)->getDisplay(index);
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* OCIO_configGetDefaultView(ConstConfigRcPtr* config, const char* display)
|
||||
const char *OCIO_configGetDefaultView(ConstConfigRcPtr *config, const char *display)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
return (*config)->getDefaultView(display);
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int OCIO_configGetNumViews(ConstConfigRcPtr* config, const char* display)
|
||||
int OCIO_configGetNumViews(ConstConfigRcPtr *config, const char *display)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
return (*config)->getNumViews(display);
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* OCIO_configGetView(ConstConfigRcPtr* config, const char* display, int index)
|
||||
const char *OCIO_configGetView(ConstConfigRcPtr *config, const char *display, int index)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
return (*config)->getView(display, index);
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* OCIO_configGetDisplayColorSpaceName(ConstConfigRcPtr* config, const char* display, const char* view)
|
||||
const char *OCIO_configGetDisplayColorSpaceName(ConstConfigRcPtr *config, const char *display, const char *view)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
return (*config)->getDisplayColorSpaceName(display, view);
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr* cs)
|
||||
void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
if(cs){
|
||||
delete cs;
|
||||
cs =0;
|
||||
}
|
||||
delete cs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ConstProcessorRcPtr* OCIO_configGetProcessorWithNames(ConstConfigRcPtr* config, const char* srcName, const char* dstName)
|
||||
ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(ConstConfigRcPtr *config, const char *srcName, const char *dstName)
|
||||
{
|
||||
ConstProcessorRcPtr* p = new ConstProcessorRcPtr();
|
||||
try
|
||||
{
|
||||
ConstProcessorRcPtr *p = new ConstProcessorRcPtr();
|
||||
|
||||
try {
|
||||
*p = (*config)->getProcessor(srcName, dstName);
|
||||
if(*p)
|
||||
|
||||
if (*p)
|
||||
return p;
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern ConstProcessorRcPtr* OCIO_configGetProcessor(ConstConfigRcPtr* config, ConstTransformRcPtr* transform)
|
||||
ConstProcessorRcPtr *OCIO_configGetProcessor(ConstConfigRcPtr *config, ConstTransformRcPtr *transform)
|
||||
{
|
||||
ConstProcessorRcPtr* p = new ConstProcessorRcPtr();
|
||||
try
|
||||
{
|
||||
ConstProcessorRcPtr *p = new ConstProcessorRcPtr();
|
||||
|
||||
try {
|
||||
*p = (*config)->getProcessor(*transform);
|
||||
if(*p)
|
||||
|
||||
if (*p)
|
||||
return p;
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void OCIO_processorApply(ConstProcessorRcPtr* processor, PackedImageDesc* img)
|
||||
void OCIO_processorApply(ConstProcessorRcPtr *processor, PackedImageDesc *img)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
(*processor)->apply(*img);
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void OCIO_processorApplyRGB(ConstProcessorRcPtr* processor, float* pixel)
|
||||
void OCIO_processorApplyRGB(ConstProcessorRcPtr *processor, float *pixel)
|
||||
{
|
||||
(*processor)->applyRGB(pixel);
|
||||
}
|
||||
|
||||
void OCIO_processorApplyRGBA(ConstProcessorRcPtr* processor, float* pixel)
|
||||
void OCIO_processorApplyRGBA(ConstProcessorRcPtr *processor, float *pixel)
|
||||
{
|
||||
(*processor)->applyRGBA(pixel);
|
||||
}
|
||||
|
||||
void OCIO_processorRelease(ConstProcessorRcPtr* p)
|
||||
void OCIO_processorRelease(ConstProcessorRcPtr *p)
|
||||
{
|
||||
if(p){
|
||||
delete p;
|
||||
p = 0;
|
||||
}
|
||||
delete p;
|
||||
}
|
||||
|
||||
const char* OCIO_colorSpaceGetName(ConstColorSpaceRcPtr* cs)
|
||||
const char *OCIO_colorSpaceGetName(ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return (*cs)->getName();
|
||||
}
|
||||
|
||||
const char* OCIO_colorSpaceGetFamily(ConstColorSpaceRcPtr* cs)
|
||||
const char *OCIO_colorSpaceGetFamily(ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return (*cs)->getFamily();
|
||||
}
|
||||
|
||||
|
||||
extern DisplayTransformRcPtr* OCIO_createDisplayTransform(void)
|
||||
DisplayTransformRcPtr *OCIO_createDisplayTransform(void)
|
||||
{
|
||||
DisplayTransformRcPtr* dt = new DisplayTransformRcPtr();
|
||||
DisplayTransformRcPtr *dt = new DisplayTransformRcPtr();
|
||||
|
||||
*dt = DisplayTransform::Create();
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
extern void OCIO_displayTransformSetInputColorSpaceName(DisplayTransformRcPtr* dt, const char * name)
|
||||
void OCIO_displayTransformSetInputColorSpaceName(DisplayTransformRcPtr *dt, const char *name)
|
||||
{
|
||||
(*dt)->setInputColorSpaceName(name);
|
||||
}
|
||||
|
||||
extern void OCIO_displayTransformSetDisplay(DisplayTransformRcPtr* dt, const char * name)
|
||||
void OCIO_displayTransformSetDisplay(DisplayTransformRcPtr *dt, const char *name)
|
||||
{
|
||||
(*dt)->setDisplay(name);
|
||||
}
|
||||
|
||||
extern void OCIO_displayTransformSetView(DisplayTransformRcPtr* dt, const char * name)
|
||||
void OCIO_displayTransformSetView(DisplayTransformRcPtr *dt, const char *name)
|
||||
{
|
||||
(*dt)->setView(name);
|
||||
}
|
||||
|
||||
extern void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *t)
|
||||
void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *t)
|
||||
{
|
||||
(*dt)->setDisplayCC(*t);
|
||||
}
|
||||
|
||||
extern void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *t)
|
||||
void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *t)
|
||||
{
|
||||
(*dt)->setLinearCC(*t);
|
||||
}
|
||||
|
||||
extern void OCIO_displayTransformRelease(DisplayTransformRcPtr* dt)
|
||||
void OCIO_displayTransformRelease(DisplayTransformRcPtr *dt)
|
||||
{
|
||||
if(dt){
|
||||
delete dt;
|
||||
dt = 0;
|
||||
}
|
||||
delete dt;
|
||||
dt = NULL;
|
||||
}
|
||||
|
||||
PackedImageDesc* OCIO_createPackedImageDesc(float * data, long width, long height, long numChannels,
|
||||
PackedImageDesc *OCIO_createPackedImageDesc(float *data, long width, long height, long numChannels,
|
||||
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
PackedImageDesc* id = new PackedImageDesc(data, width, height, numChannels, chanStrideBytes, xStrideBytes, yStrideBytes);
|
||||
try {
|
||||
PackedImageDesc *id = new PackedImageDesc(data, width, height, numChannels, chanStrideBytes, xStrideBytes, yStrideBytes);
|
||||
|
||||
return id;
|
||||
}
|
||||
catch(Exception & exception)
|
||||
{
|
||||
catch (Exception &exception) {
|
||||
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void OCIO_packedImageDescRelease(PackedImageDesc* id)
|
||||
{
|
||||
if(id){
|
||||
delete id;
|
||||
id = 0;
|
||||
}
|
||||
delete id;
|
||||
id = NULL;
|
||||
}
|
||||
|
||||
ExponentTransformRcPtr *OCIO_createExponentTransform(void)
|
||||
@@ -423,7 +392,7 @@ void OCIO_exponentTransformRelease(ExponentTransformRcPtr *et)
|
||||
|
||||
MatrixTransformRcPtr *OCIO_createMatrixTransform(void)
|
||||
{
|
||||
MatrixTransformRcPtr *mt = new MatrixTransformRcPtr();
|
||||
MatrixTransformRcPtr *mt = new MatrixTransformRcPtr();
|
||||
|
||||
*mt = MatrixTransform::Create();
|
||||
|
||||
|
||||
@@ -20,18 +20,19 @@
|
||||
*
|
||||
* Contributor(s): Xavier Thomas
|
||||
* Lukas Toene
|
||||
* Sergey Sharybin
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef OCIO_CAPI_H
|
||||
#define OCIO_CAPI_H
|
||||
#ifndef __OCIO_CAPI_H__
|
||||
#define __OCIO_CAPI_H__
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
using namespace OCIO_NAMESPACE;
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OCIO_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
|
||||
@@ -41,7 +42,7 @@ extern "C" {
|
||||
#define OCIO_ROLE_SCENE_LINEAR "scene_linear"
|
||||
#define OCIO_ROLE_COLOR_PICKING "color_picking"
|
||||
#define OCIO_ROLE_TEXTURE_PAINT "texture_paint"
|
||||
|
||||
|
||||
OCIO_DECLARE_HANDLE(ConstConfigRcPtr);
|
||||
OCIO_DECLARE_HANDLE(ConstColorSpaceRcPtr);
|
||||
OCIO_DECLARE_HANDLE(ConstProcessorRcPtr);
|
||||
@@ -54,54 +55,54 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
extern ConstConfigRcPtr* OCIO_getCurrentConfig(void);
|
||||
extern void OCIO_setCurrentConfig(const ConstConfigRcPtr* config);
|
||||
ConstConfigRcPtr *OCIO_getCurrentConfig(void);
|
||||
void OCIO_setCurrentConfig(const ConstConfigRcPtr *config);
|
||||
|
||||
extern ConstConfigRcPtr* OCIO_configCreateFromEnv(void);
|
||||
extern ConstConfigRcPtr* OCIO_configCreateFromFile(const char* filename);
|
||||
ConstConfigRcPtr *OCIO_configCreateFromEnv(void);
|
||||
ConstConfigRcPtr *OCIO_configCreateFromFile(const char* filename);
|
||||
|
||||
extern void OCIO_configRelease(ConstConfigRcPtr* config);
|
||||
void OCIO_configRelease(ConstConfigRcPtr *config);
|
||||
|
||||
extern int OCIO_configGetNumColorSpaces(ConstConfigRcPtr* config);
|
||||
extern const char* OCIO_configGetColorSpaceNameByIndex(ConstConfigRcPtr* config, int index);
|
||||
extern ConstColorSpaceRcPtr* OCIO_configGetColorSpace(ConstConfigRcPtr* config, const char* name);
|
||||
extern int OCIO_configGetIndexForColorSpace(ConstConfigRcPtr* config, const char* name);
|
||||
int OCIO_configGetNumColorSpaces(ConstConfigRcPtr *config);
|
||||
const char *OCIO_configGetColorSpaceNameByIndex(ConstConfigRcPtr *config, int index);
|
||||
ConstColorSpaceRcPtr *OCIO_configGetColorSpace(ConstConfigRcPtr *config, const char *name);
|
||||
int OCIO_configGetIndexForColorSpace(ConstConfigRcPtr *config, const char *name);
|
||||
|
||||
extern void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr* cs);
|
||||
void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr *cs);
|
||||
|
||||
extern const char* OCIO_configGetDefaultDisplay(ConstConfigRcPtr* config);
|
||||
extern int OCIO_configGetNumDisplays(ConstConfigRcPtr* config);
|
||||
extern const char* OCIO_configGetDisplay(ConstConfigRcPtr* config, int index);
|
||||
extern const char* OCIO_configGetDefaultView(ConstConfigRcPtr* config, const char* display);
|
||||
extern int OCIO_configGetNumViews(ConstConfigRcPtr* config, const char* display);
|
||||
extern const char* OCIO_configGetView(ConstConfigRcPtr* config, const char* display, int index);
|
||||
extern const char* OCIO_configGetDisplayColorSpaceName(ConstConfigRcPtr* config, const char* display, const char* view);
|
||||
const char *OCIO_configGetDefaultDisplay(ConstConfigRcPtr *config);
|
||||
int OCIO_configGetNumDisplays(ConstConfigRcPtr *config);
|
||||
const char *OCIO_configGetDisplay(ConstConfigRcPtr *config, int index);
|
||||
const char *OCIO_configGetDefaultView(ConstConfigRcPtr *config, const char *display);
|
||||
int OCIO_configGetNumViews(ConstConfigRcPtr *config, const char *display);
|
||||
const char *OCIO_configGetView(ConstConfigRcPtr *config, const char *display, int index);
|
||||
const char *OCIO_configGetDisplayColorSpaceName(ConstConfigRcPtr *config, const char *display, const char *view);
|
||||
|
||||
extern ConstProcessorRcPtr* OCIO_configGetProcessorWithNames(ConstConfigRcPtr* config, const char* srcName, const char* dstName);
|
||||
extern ConstProcessorRcPtr* OCIO_configGetProcessor(ConstConfigRcPtr* config, ConstTransformRcPtr* transform);
|
||||
ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(ConstConfigRcPtr *config, const char *srcName, const char *dstName);
|
||||
ConstProcessorRcPtr *OCIO_configGetProcessor(ConstConfigRcPtr *config, ConstTransformRcPtr *transform);
|
||||
|
||||
extern void OCIO_processorApply(ConstProcessorRcPtr* processor, PackedImageDesc* img);
|
||||
extern void OCIO_processorApplyRGB(ConstProcessorRcPtr* processor, float* pixel);
|
||||
extern void OCIO_processorApplyRGBA(ConstProcessorRcPtr* processor, float* pixel);
|
||||
void OCIO_processorApply(ConstProcessorRcPtr *processor, PackedImageDesc *img);
|
||||
void OCIO_processorApplyRGB(ConstProcessorRcPtr *processor, float *pixel);
|
||||
void OCIO_processorApplyRGBA(ConstProcessorRcPtr *processor, float *pixel);
|
||||
|
||||
extern void OCIO_processorRelease(ConstProcessorRcPtr* p);
|
||||
void OCIO_processorRelease(ConstProcessorRcPtr *p);
|
||||
|
||||
|
||||
extern const char* OCIO_colorSpaceGetName(ConstColorSpaceRcPtr* cs);
|
||||
extern const char* OCIO_colorSpaceGetFamily(ConstColorSpaceRcPtr* cs);
|
||||
const char *OCIO_colorSpaceGetName(ConstColorSpaceRcPtr *cs);
|
||||
const char *OCIO_colorSpaceGetFamily(ConstColorSpaceRcPtr *cs);
|
||||
|
||||
extern DisplayTransformRcPtr* OCIO_createDisplayTransform(void);
|
||||
extern void OCIO_displayTransformSetInputColorSpaceName(DisplayTransformRcPtr* dt, const char * name);
|
||||
extern void OCIO_displayTransformSetDisplay(DisplayTransformRcPtr* dt, const char * name);
|
||||
extern void OCIO_displayTransformSetView(DisplayTransformRcPtr* dt, const char * name);
|
||||
extern void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *et);
|
||||
extern void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *et);
|
||||
extern void OCIO_displayTransformRelease(DisplayTransformRcPtr* dt);
|
||||
DisplayTransformRcPtr *OCIO_createDisplayTransform(void);
|
||||
void OCIO_displayTransformSetInputColorSpaceName(DisplayTransformRcPtr *dt, const char *name);
|
||||
void OCIO_displayTransformSetDisplay(DisplayTransformRcPtr *dt, const char *name);
|
||||
void OCIO_displayTransformSetView(DisplayTransformRcPtr *dt, const char *name);
|
||||
void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *et);
|
||||
void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *et);
|
||||
void OCIO_displayTransformRelease(DisplayTransformRcPtr *dt);
|
||||
|
||||
PackedImageDesc* OCIO_createPackedImageDesc(float * data, long width, long height, long numChannels,
|
||||
PackedImageDesc *OCIO_createPackedImageDesc(float *data, long width, long height, long numChannels,
|
||||
long chanStrideBytes, long xStrideBytes, long yStrideBytes);
|
||||
|
||||
extern void OCIO_packedImageDescRelease(PackedImageDesc* p);
|
||||
void OCIO_packedImageDescRelease(PackedImageDesc *p);
|
||||
|
||||
ExponentTransformRcPtr *OCIO_createExponentTransform(void);
|
||||
void OCIO_exponentTransformSetValue(ExponentTransformRcPtr *et, const float *exponent);
|
||||
|
||||
@@ -73,6 +73,7 @@ static ListBase global_displays = {NULL};
|
||||
static ListBase global_views = {NULL};
|
||||
|
||||
static int global_tot_display = 0;
|
||||
static int global_tot_view = 0;
|
||||
|
||||
/*********************** Color managed cache *************************/
|
||||
|
||||
@@ -448,8 +449,8 @@ void IMB_colormanagement_init(void)
|
||||
#ifdef WITH_OCIO
|
||||
const char *ocio_env;
|
||||
const char *configdir;
|
||||
char configfile[FILE_MAXDIR+FILE_MAXFILE];
|
||||
ConstConfigRcPtr* config;
|
||||
char configfile[FILE_MAX];
|
||||
ConstConfigRcPtr *config = NULL;
|
||||
|
||||
ocio_env = getenv("OCIO");
|
||||
|
||||
@@ -461,9 +462,9 @@ void IMB_colormanagement_init(void)
|
||||
|
||||
if (configdir) {
|
||||
BLI_join_dirfile(configfile, sizeof(configfile), configdir, BCM_CONFIG_FILE);
|
||||
}
|
||||
|
||||
config = OCIO_configCreateFromFile(configfile);
|
||||
config = OCIO_configCreateFromFile(configfile);
|
||||
}
|
||||
}
|
||||
|
||||
if (config) {
|
||||
@@ -618,7 +619,7 @@ static ConstProcessorRcPtr *create_display_buffer_processor(const char *view_tra
|
||||
float exposure, float gamma)
|
||||
{
|
||||
ConstConfigRcPtr *config = OCIO_getCurrentConfig();
|
||||
DisplayTransformRcPtr *dt = OCIO_createDisplayTransform();
|
||||
DisplayTransformRcPtr *dt;
|
||||
ExponentTransformRcPtr *et;
|
||||
MatrixTransformRcPtr *mt;
|
||||
ConstProcessorRcPtr *processor;
|
||||
@@ -630,6 +631,14 @@ static ConstProcessorRcPtr *create_display_buffer_processor(const char *view_tra
|
||||
const float scale4f[] = {gain, gain, gain, gain};
|
||||
float m44[16], offset4[4];
|
||||
|
||||
if (!config) {
|
||||
/* there's no valid OCIO configuration, can't create processor */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dt = OCIO_createDisplayTransform();
|
||||
|
||||
/* OCIO_TODO: get rid of hardcoded input and display spaces */
|
||||
OCIO_displayTransformSetInputColorSpaceName(dt, "aces");
|
||||
|
||||
@@ -683,6 +692,9 @@ static void display_buffer_apply_ocio(ImBuf *ibuf, unsigned char *display_buffer
|
||||
|
||||
void IMB_colormanage_flags_allocate(ImBuf *ibuf)
|
||||
{
|
||||
if (global_tot_display == 0)
|
||||
return;
|
||||
|
||||
ibuf->display_buffer_flags = MEM_callocN(sizeof(unsigned int) * global_tot_display, "imbuf display_buffer_flags");
|
||||
}
|
||||
|
||||
@@ -717,7 +729,11 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSet
|
||||
return NULL;
|
||||
|
||||
/* OCIO_TODO: support colormanaged byte buffers */
|
||||
if (!strcmp(view_transform, "NONE") || !ibuf->rect_float) {
|
||||
if (!strcmp(view_transform, "NONE") ||
|
||||
!ibuf->rect_float ||
|
||||
global_tot_display == 0 ||
|
||||
global_tot_view == 0)
|
||||
{
|
||||
/* currently only view-transformation is allowed, input and display
|
||||
* spaces are hard-coded, so if there's no view transform applying
|
||||
* it's safe to suppose standard byte buffer is used for display
|
||||
@@ -851,8 +867,22 @@ void IMB_colormanagement_check_file_config(Main *bmain)
|
||||
wmWindow *win;
|
||||
bScreen *sc;
|
||||
|
||||
ColorManagedDisplay *default_display = colormanage_display_get_default();
|
||||
ColorManagedView *default_view = colormanage_view_get_default(default_display);
|
||||
ColorManagedDisplay *default_display;
|
||||
ColorManagedView *default_view;
|
||||
|
||||
default_display = colormanage_display_get_default();
|
||||
|
||||
if (!default_display) {
|
||||
/* happens when OCIO configuration is incorrect */
|
||||
return;
|
||||
}
|
||||
|
||||
default_view = colormanage_view_get_default(default_display);
|
||||
|
||||
if (!default_view) {
|
||||
/* happens when OCIO configuration is incorrect */
|
||||
return;
|
||||
}
|
||||
|
||||
if (wm) {
|
||||
for (win = wm->windows.first; win; win = win->next) {
|
||||
@@ -920,7 +950,15 @@ const ColorManagedViewSettings *IMB_view_settings_get_effective(wmWindow *win,
|
||||
ColorManagedDisplay *colormanage_display_get_default(void)
|
||||
{
|
||||
ConstConfigRcPtr *config = OCIO_getCurrentConfig();
|
||||
const char *display = OCIO_configGetDefaultDisplay(config);
|
||||
const char *display;
|
||||
|
||||
if (!config) {
|
||||
/* no valid OCIO configuration, can't get default display */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
display = OCIO_configGetDefaultDisplay(config);
|
||||
|
||||
OCIO_configRelease(config);
|
||||
|
||||
@@ -1003,7 +1041,16 @@ const char *IMB_colormanagement_display_get_indexed_name(int index)
|
||||
ColorManagedView *colormanage_view_get_default(const ColorManagedDisplay *display)
|
||||
{
|
||||
ConstConfigRcPtr *config = OCIO_getCurrentConfig();
|
||||
const char *name = OCIO_configGetDefaultView(config, display->name);
|
||||
const char *name;
|
||||
|
||||
if (!config) {
|
||||
/* no valid OCIO configuration, can't get default view */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
name = OCIO_configGetDefaultView(config, display->name);
|
||||
|
||||
OCIO_configRelease(config);
|
||||
|
||||
if (name[0] == '\0')
|
||||
@@ -1016,13 +1063,7 @@ ColorManagedView *colormanage_view_get_default(const ColorManagedDisplay *displa
|
||||
ColorManagedView *colormanage_view_add(const char *name)
|
||||
{
|
||||
ColorManagedView *view;
|
||||
int index = 0;
|
||||
|
||||
if (global_views.last) {
|
||||
ColorManagedView *last_view = global_views.last;
|
||||
|
||||
index = last_view->index;
|
||||
}
|
||||
int index = global_tot_view;
|
||||
|
||||
view = MEM_callocN(sizeof(ColorManagedView), "ColorManagedView");
|
||||
view->index = index + 1;
|
||||
@@ -1030,6 +1071,8 @@ ColorManagedView *colormanage_view_add(const char *name)
|
||||
|
||||
BLI_addtail(&global_views, view);
|
||||
|
||||
global_tot_view++;
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user