diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/imbuf/intern/oiio/openimageio_api.cpp | 5 | ||||
-rw-r--r-- | source/blender/imbuf/intern/oiio/openimageio_api.h | 4 | ||||
-rw-r--r-- | source/blender/python/SConscript | 7 | ||||
-rw-r--r-- | source/blender/python/intern/CMakeLists.txt | 12 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app.c | 6 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app_ocio.c | 109 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app_ocio.h | 32 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app_oiio.c | 109 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app_oiio.h | 32 |
9 files changed, 315 insertions, 1 deletions
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp index fe74b8f7cce..ec9c8fdbb4d 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp +++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp @@ -275,6 +275,11 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac } } +int OIIO_getVersionHex(void) +{ + return openimageio_version(); +} + } // export "C" diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.h b/source/blender/imbuf/intern/oiio/openimageio_api.h index ad11f4bcfe3..df1122584bd 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.h +++ b/source/blender/imbuf/intern/oiio/openimageio_api.h @@ -39,12 +39,16 @@ extern "C" { #include <stdio.h> +struct ImBuf; + int imb_is_a_photoshop (const char *name); int imb_save_photoshop (struct ImBuf *ibuf, const char *name, int flags); struct ImBuf *imb_load_photoshop (const char *name, int flags, char *colorspace); +int OIIO_getVersionHex(void); + #ifdef __cplusplus } diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index 0ac0285031e..3378c43f1f6 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -183,8 +183,13 @@ if env['WITH_BF_SMOKE']: if env['WITH_BF_COLLADA']: defs.append('WITH_COLLADA') -if env['WITH_BF_OIIO']: +if env['WITH_BF_OCIO']: defs.append('WITH_OCIO') + incs += ' ' + '#/intern/opencolorio' + +if env['WITH_BF_OIIO']: + defs.append('WITH_OPENIMAGEIO') + incs += ' ../../imbuf/intern/oiio' if env['WITH_BF_PLAYER']: defs.append('WITH_PLAYER') diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt index ef5d26dccdc..0605f408348 100644 --- a/source/blender/python/intern/CMakeLists.txt +++ b/source/blender/python/intern/CMakeLists.txt @@ -35,6 +35,7 @@ set(INC ../../makesrna ../../windowmanager ../../../../intern/cycles/blender + ../../../../intern/opencolorio ../../../../intern/guardedalloc ) @@ -49,6 +50,8 @@ set(SRC bpy_app_ffmpeg.c bpy_app_build_options.c bpy_app_handlers.c + bpy_app_ocio.c + bpy_app_oiio.c bpy_app_translations.c bpy_driver.c bpy_interface.c @@ -73,6 +76,8 @@ set(SRC bpy_app_ffmpeg.h bpy_app_build_options.h bpy_app_handlers.h + bpy_app_ocio.h + bpy_app_oiio.h bpy_app_translations.h bpy_driver.h bpy_intern_string.h @@ -242,6 +247,13 @@ if(WITH_OPENCOLORIO) add_definitions(-DWITH_OCIO) endif() +if(WITH_OPENIMAGEIO) + add_definitions(-DWITH_OPENIMAGEIO) + list(APPEND INC + ../../imbuf/intern/oiio + ) +endif() + if(WITH_PLAYER) add_definitions(-DWITH_PLAYER) endif() diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 21767196e11..795015c42a0 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -34,6 +34,8 @@ #include "bpy_app.h" #include "bpy_app_ffmpeg.h" +#include "bpy_app_ocio.h" +#include "bpy_app_oiio.h" #include "bpy_app_build_options.h" #include "bpy_app_translations.h" @@ -93,6 +95,8 @@ static PyStructSequence_Field app_info_fields[] = { /* submodules */ {(char *)"ffmpeg", (char *)"FFmpeg library information backend"}, + {(char *)"ocio", (char *)"OpenColorIO library information backend"}, + {(char *)"oiio", (char *)"OpenImageIO library information backend"}, {(char *)"build_options", (char *)"A set containing most important enabled optional build features"}, {(char *)"handlers", (char *)"Application handler callbacks"}, {(char *)"translations", (char *)"Application and addons internationalization API"}, @@ -167,6 +171,8 @@ static PyObject *make_app_info(void) #endif SetObjItem(BPY_app_ffmpeg_struct()); + SetObjItem(BPY_app_ocio_struct()); + SetObjItem(BPY_app_oiio_struct()); SetObjItem(BPY_app_build_options_struct()); SetObjItem(BPY_app_handlers_struct()); SetObjItem(BPY_app_translations_struct()); diff --git a/source/blender/python/intern/bpy_app_ocio.c b/source/blender/python/intern/bpy_app_ocio.c new file mode 100644 index 00000000000..dfcbfe94ead --- /dev/null +++ b/source/blender/python/intern/bpy_app_ocio.c @@ -0,0 +1,109 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/intern/bpy_app_ocio.c + * \ingroup pythonintern + */ + +#include <Python.h> +#include "BLI_utildefines.h" + +#include "bpy_app_ocio.h" + +#ifdef WITH_OCIO +# include "ocio_capi.h" +#endif + +static PyTypeObject BlenderAppOCIOType; + +static PyStructSequence_Field app_ocio_info_fields[] = { + {(char *)"supported", (char *)("Boolean, True when Blender is built with OpenColorIO support")}, + {(char *)("version"), (char *)("The OpenColorIO version as a tuple of 3 numbers")}, + {(char *)("version_string"), (char *)("The OpenColorIO version formatted as a string")}, + {NULL} +}; + +static PyStructSequence_Desc app_ocio_info_desc = { + (char *)"bpy.app.ocio", /* name */ + (char *)"This module contains information about OpenColorIO blender is linked against", /* doc */ + app_ocio_info_fields, /* fields */ + (sizeof(app_ocio_info_fields) / sizeof(PyStructSequence_Field)) - 1 +}; + +static PyObject *make_ocio_info(void) +{ + PyObject *ocio_info; + int pos = 0; + +#ifdef WITH_OCIO + int curversion; +#endif + + ocio_info = PyStructSequence_New(&BlenderAppOCIOType); + if (ocio_info == NULL) { + return NULL; + } + +#define SetStrItem(str) \ + PyStructSequence_SET_ITEM(ocio_info, pos++, PyUnicode_FromString(str)) +#define SetObjItem(obj) \ + PyStructSequence_SET_ITEM(ocio_info, pos++, obj) + +#ifdef WITH_OCIO + curversion = OCIO_getVersionHex(); + SetObjItem(PyBool_FromLong(1)); + SetObjItem(Py_BuildValue("(iii)", + curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256)); + SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d", + curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256)); +#else + SetObjItem(PyBool_FromLong(0)); + SetStrItem("Unknown"); + SetStrItem("Unknown"); +#endif + + if (PyErr_Occurred()) { + Py_CLEAR(ocio_info); + return NULL; + } + +#undef SetStrItem +#undef SetObjItem + + return ocio_info; +} + +PyObject *BPY_app_ocio_struct(void) +{ + PyObject *ret; + + PyStructSequence_InitType(&BlenderAppOCIOType, &app_ocio_info_desc); + + ret = make_ocio_info(); + + /* prevent user from creating new instances */ + BlenderAppOCIOType.tp_init = NULL; + BlenderAppOCIOType.tp_new = NULL; + BlenderAppOCIOType.tp_hash = (hashfunc)_Py_HashPointer; /* without this we can't do set(sys.modules) [#29635] */ + + return ret; +} diff --git a/source/blender/python/intern/bpy_app_ocio.h b/source/blender/python/intern/bpy_app_ocio.h new file mode 100644 index 00000000000..ff230b4ba66 --- /dev/null +++ b/source/blender/python/intern/bpy_app_ocio.h @@ -0,0 +1,32 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/intern/bpy_app_ocio.h + * \ingroup pythonintern + */ + +#ifndef __BPY_APP_OCIO_H__ +#define __BPY_APP_OCIO_H__ + +PyObject *BPY_app_ocio_struct(void); + +#endif /* __BPY_APP_OCIO_H__ */ diff --git a/source/blender/python/intern/bpy_app_oiio.c b/source/blender/python/intern/bpy_app_oiio.c new file mode 100644 index 00000000000..db6df9288bb --- /dev/null +++ b/source/blender/python/intern/bpy_app_oiio.c @@ -0,0 +1,109 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/intern/bpy_app_oiio.c + * \ingroup pythonintern + */ + +#include <Python.h> +#include "BLI_utildefines.h" + +#include "bpy_app_oiio.h" + +#ifdef WITH_OPENIMAGEIO +# include "openimageio_api.h" +#endif + +static PyTypeObject BlenderAppOIIOType; + +static PyStructSequence_Field app_oiio_info_fields[] = { + {(char *)"supported", (char *)("Boolean, True when Blender is built with OpenImageIO support")}, + {(char *)("version"), (char *)("The OpenImageIO version as a tuple of 3 numbers")}, + {(char *)("version_string"), (char *)("The OpenImageIO version formatted as a string")}, + {NULL} +}; + +static PyStructSequence_Desc app_oiio_info_desc = { + (char *)"bpy.app.oiio", /* name */ + (char *)"This module contains information about OpeImageIO blender is linked against", /* doc */ + app_oiio_info_fields, /* fields */ + (sizeof(app_oiio_info_fields) / sizeof(PyStructSequence_Field)) - 1 +}; + +static PyObject *make_oiio_info(void) +{ + PyObject *oiio_info; + int pos = 0; + +#ifdef WITH_OPENIMAGEIO + int curversion; +#endif + + oiio_info = PyStructSequence_New(&BlenderAppOIIOType); + if (oiio_info == NULL) { + return NULL; + } + +#define SetStrItem(str) \ + PyStructSequence_SET_ITEM(oiio_info, pos++, PyUnicode_FromString(str)) +#define SetObjItem(obj) \ + PyStructSequence_SET_ITEM(oiio_info, pos++, obj) + +#ifdef WITH_OPENIMAGEIO + curversion = OIIO_getVersionHex(); + SetObjItem(PyBool_FromLong(1)); + SetObjItem(Py_BuildValue("(iii)", + curversion / 10000, (curversion / 100) % 100, curversion % 100)); + SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d", + curversion / 10000, (curversion / 100) % 100, curversion % 100)); +#else + SetObjItem(PyBool_FromLong(0)); + SetStrItem("Unknown"); + SetStrItem("Unknown"); +#endif + + if (PyErr_Occurred()) { + Py_CLEAR(oiio_info); + return NULL; + } + +#undef SetStrItem +#undef SetObjItem + + return oiio_info; +} + +PyObject *BPY_app_oiio_struct(void) +{ + PyObject *ret; + + PyStructSequence_InitType(&BlenderAppOIIOType, &app_oiio_info_desc); + + ret = make_oiio_info(); + + /* prevent user from creating new instances */ + BlenderAppOIIOType.tp_init = NULL; + BlenderAppOIIOType.tp_new = NULL; + BlenderAppOIIOType.tp_hash = (hashfunc)_Py_HashPointer; /* without this we can't do set(sys.modules) [#29635] */ + + return ret; +} diff --git a/source/blender/python/intern/bpy_app_oiio.h b/source/blender/python/intern/bpy_app_oiio.h new file mode 100644 index 00000000000..775fed237f2 --- /dev/null +++ b/source/blender/python/intern/bpy_app_oiio.h @@ -0,0 +1,32 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/intern/bpy_app_oiio.h + * \ingroup pythonintern + */ + +#ifndef __BPY_APP_OIIO_H__ +#define __BPY_APP_OIIO_H__ + +PyObject *BPY_app_oiio_struct(void); + +#endif /* __BPY_APP_OIIO_H__ */ |