2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
* Wrappers for the plugin api. This api is up for removal.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:32:12 +00:00
|
|
|
/** \file blender/blenpluginapi/intern/pluginapi.c
|
|
|
|
|
* \ingroup blenpluginapi
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* There are four headers making up the plugin api:
|
|
|
|
|
* - floatpatch.h : Wraps math functions for mips platforms, no code
|
|
|
|
|
* required.
|
|
|
|
|
* - iff.h : Defines, macros and functions for dealing
|
|
|
|
|
* with image buffer things.
|
|
|
|
|
* - plugin.h : Wraps some plugin handling types, accesses noise
|
|
|
|
|
* functions.
|
|
|
|
|
* - util.h : Useful defines, memory management.
|
|
|
|
|
*/
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
#define PLUGIN_INTERN /* This tells the LIBEXPORT macro to compile with
|
2012-03-09 18:28:30 +00:00
|
|
|
* dll export set on windows */
|
2006-06-16 20:00:00 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef WIN32
|
2006-03-13 11:42:49 +00:00
|
|
|
#include "blenpluginapi/util.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#else
|
2005-03-09 19:45:59 +00:00
|
|
|
#include "blenpluginapi/util.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
|
|
|
|
#include "iff.h"
|
|
|
|
|
#include "plugin.h"
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2008-08-17 17:08:00 +00:00
|
|
|
#include "BLO_sys_types.h" // needed for intptr_t
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BLI_blenlib.h" /* util and noise functions */
|
2006-06-16 20:00:00 +00:00
|
|
|
#include "BLI_threads.h" /* For threadsfe guardedalloc malloc/calloc/free */
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "IMB_imbuf.h" /* image buffer stuff */
|
2008-08-17 17:08:00 +00:00
|
|
|
#define GET_INT_FROM_POINTER(i) ((int)(intptr_t)(i)) /* should use BKE_utildefines.h */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
/* stuff from util.h */
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void *mallocN(int len, char *str)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return MEM_mallocN(len, str);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void *callocN(int len, char *str)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return MEM_callocN(len, str);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT short freeN(void *vmemh)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return MEM_freeN(vmemh);
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-06 19:13:23 +00:00
|
|
|
/* these are not needed anymore, mallocN/callocN/freeN is now threadsafe */
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void *mallocT(int len, char *str)
|
|
|
|
|
{
|
2006-09-06 19:13:23 +00:00
|
|
|
return MEM_mallocN(len, str);
|
2006-06-16 20:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBEXPORT void *callocT(int len, char *str)
|
|
|
|
|
{
|
2006-09-06 19:13:23 +00:00
|
|
|
return MEM_callocN(len, str);
|
2006-06-16 20:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBEXPORT void freeT(void *vmemh)
|
|
|
|
|
{
|
2006-09-06 19:13:23 +00:00
|
|
|
MEM_freeN(vmemh);
|
|
|
|
|
return;
|
2006-06-16 20:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
/* stuff from iff.h */
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *allocImBuf(short x,
|
2002-10-12 11:37:38 +00:00
|
|
|
short y,
|
|
|
|
|
uchar d,
|
2010-10-16 14:32:17 +00:00
|
|
|
uint flags)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2010-10-16 14:32:17 +00:00
|
|
|
return IMB_allocImBuf(x, y, d, flags);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *dupImBuf(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_dupImBuf(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void freeImBuf(struct ImBuf* ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
IMB_freeImBuf(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT short saveiff(struct ImBuf *ib,
|
2002-10-12 11:37:38 +00:00
|
|
|
char *c,
|
|
|
|
|
int i)
|
|
|
|
|
{
|
|
|
|
|
return IMB_saveiff(ib, c, i);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *loadifffile(int a,
|
2002-10-12 11:37:38 +00:00
|
|
|
int b)
|
|
|
|
|
{
|
2011-10-27 04:24:34 +00:00
|
|
|
return IMB_loadifffile(a, b, "loadifffile");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *loadiffname(char *n,
|
2002-10-12 11:37:38 +00:00
|
|
|
int flags)
|
|
|
|
|
{
|
|
|
|
|
return IMB_loadiffname(n, flags);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *testiffname(char *n,
|
2002-10-12 11:37:38 +00:00
|
|
|
int flags)
|
|
|
|
|
{
|
|
|
|
|
return IMB_testiffname(n, flags);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *onehalf(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_onehalf(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *half_x(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_half_x(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *half_y(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_half_y(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *double_x(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_double_x(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *double_y(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_double_y(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *double_fast_x(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_double_fast_x(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *double_fast_y(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_double_fast_y(ib);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT int ispic(char * name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return IMB_ispic(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* still the same name */
|
|
|
|
|
/* void (*ditherfunc)(struct ImBuf *, short, short){} */
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *scaleImBuf(struct ImBuf *ib,
|
2002-10-12 11:37:38 +00:00
|
|
|
short nx,
|
|
|
|
|
short ny)
|
|
|
|
|
{
|
|
|
|
|
return IMB_scaleImBuf(ib, nx, ny);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT struct ImBuf *scalefastImBuf(struct ImBuf *ib,
|
2002-10-12 11:37:38 +00:00
|
|
|
short x,
|
|
|
|
|
short y)
|
|
|
|
|
{
|
|
|
|
|
return IMB_scalefastImBuf(ib, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Extra ones that some NaN (read Ton) plugins use,
|
|
|
|
|
* even though they aren't in the header
|
|
|
|
|
*/
|
2003-04-30 18:38:50 +00:00
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void interlace(struct ImBuf *ibuf)
|
2003-04-30 18:38:50 +00:00
|
|
|
{
|
|
|
|
|
IMB_interlace(ibuf);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT void de_interlace(struct ImBuf *ib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
IMB_de_interlace(ib);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
/* stuff from plugin.h */
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* These three need to be defined in the plugin itself. The plugin
|
2002-10-12 11:37:38 +00:00
|
|
|
* loader looks for these functions to check whether it can use the
|
|
|
|
|
* plugin. For sequences, something similar exists. */
|
|
|
|
|
/* int plugin_tex_getversion(void); */
|
|
|
|
|
/* int plugin_seq_getversion(void); */
|
|
|
|
|
/* void plugin_getinfo(PluginInfo *); */
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT float hnoise(float noisesize,
|
2002-10-12 11:37:38 +00:00
|
|
|
float x,
|
|
|
|
|
float y,
|
|
|
|
|
float z)
|
|
|
|
|
{
|
|
|
|
|
return BLI_hnoise(noisesize, x, y, z);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT float hnoisep(float noisesize,
|
2002-10-12 11:37:38 +00:00
|
|
|
float x,
|
|
|
|
|
float y,
|
|
|
|
|
float z)
|
|
|
|
|
{
|
|
|
|
|
return BLI_hnoisep(noisesize, x, y, z);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT float turbulence(float noisesize,
|
2002-10-12 11:37:38 +00:00
|
|
|
float x,
|
|
|
|
|
float y,
|
|
|
|
|
float z,
|
|
|
|
|
int depth)
|
|
|
|
|
{
|
|
|
|
|
return BLI_turbulence(noisesize, x, y, z, depth);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-16 20:00:00 +00:00
|
|
|
LIBEXPORT float turbulence1(float noisesize,
|
2002-10-12 11:37:38 +00:00
|
|
|
float x,
|
|
|
|
|
float y,
|
|
|
|
|
float z,
|
|
|
|
|
int depth)
|
|
|
|
|
{
|
|
|
|
|
return BLI_turbulence1(noisesize, x, y, z, depth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/* Stupid hack - force the inclusion of all of the
|
|
|
|
|
* above functions in the binary by 'using' each one...
|
|
|
|
|
* Otherwise they will not be imported from the archive
|
|
|
|
|
* library on Unix. -zr
|
|
|
|
|
*/
|
2005-03-09 19:45:59 +00:00
|
|
|
int pluginapi_force_ref(void);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
int pluginapi_force_ref(void)
|
|
|
|
|
{
|
2008-04-29 08:24:33 +00:00
|
|
|
return
|
|
|
|
|
GET_INT_FROM_POINTER( mallocN ) +
|
|
|
|
|
GET_INT_FROM_POINTER( callocN ) +
|
|
|
|
|
GET_INT_FROM_POINTER( freeN ) +
|
|
|
|
|
GET_INT_FROM_POINTER( mallocT ) +
|
|
|
|
|
GET_INT_FROM_POINTER( callocT ) +
|
|
|
|
|
GET_INT_FROM_POINTER( freeT ) +
|
|
|
|
|
GET_INT_FROM_POINTER( allocImBuf ) +
|
|
|
|
|
GET_INT_FROM_POINTER( dupImBuf ) +
|
|
|
|
|
GET_INT_FROM_POINTER( freeImBuf ) +
|
|
|
|
|
GET_INT_FROM_POINTER( saveiff ) +
|
|
|
|
|
GET_INT_FROM_POINTER( loadifffile ) +
|
|
|
|
|
GET_INT_FROM_POINTER( loadiffname ) +
|
|
|
|
|
GET_INT_FROM_POINTER( testiffname ) +
|
|
|
|
|
GET_INT_FROM_POINTER( onehalf ) +
|
|
|
|
|
GET_INT_FROM_POINTER( half_x ) +
|
|
|
|
|
GET_INT_FROM_POINTER( half_y ) +
|
|
|
|
|
GET_INT_FROM_POINTER( double_x ) +
|
|
|
|
|
GET_INT_FROM_POINTER( double_y ) +
|
|
|
|
|
GET_INT_FROM_POINTER( double_fast_x ) +
|
|
|
|
|
GET_INT_FROM_POINTER( double_fast_y ) +
|
|
|
|
|
GET_INT_FROM_POINTER( ispic ) +
|
|
|
|
|
GET_INT_FROM_POINTER( scaleImBuf ) +
|
|
|
|
|
GET_INT_FROM_POINTER( scalefastImBuf ) +
|
|
|
|
|
GET_INT_FROM_POINTER( hnoise ) +
|
|
|
|
|
GET_INT_FROM_POINTER( hnoisep ) +
|
|
|
|
|
GET_INT_FROM_POINTER( turbulence ) +
|
|
|
|
|
GET_INT_FROM_POINTER( turbulence1 ) +
|
|
|
|
|
GET_INT_FROM_POINTER( de_interlace ) +
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
GET_INT_FROM_POINTER( interlace );
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|