2 * $Id: pluginapi.c 8449 2006-09-06 19:13:23Z blendix $
4 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version. The Blender
10 * Foundation also sells licenses for use in proprietary software under
11 * the Blender License. See http://www.blender.org/BL/ for information
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24 * All rights reserved.
26 * The Original Code is: all of this file.
28 * Contributor(s): none yet.
30 * ***** END GPL/BL DUAL LICENSE BLOCK *****
31 * Wrappers for the plugin api. This api is up for removal.
34 /* There are four headers making up the plugin api:
35 * - floatpatch.h : Wraps math functions for mips platforms, no code
37 * - iff.h : Defines, macros and functions for dealing
38 * with image buffer things.
39 * - plugin.h : Wraps some plugin handling types, accesses noise
41 * - util.h : Useful defines, memory management.
44 #define PLUGIN_INTERN /* This tells the LIBEXPORT macro to compile with
45 dll export set on windows */
48 #include "blenpluginapi/util.h"
50 #include "blenpluginapi/util.h"
54 #include "MEM_guardedalloc.h"
56 #include "BLI_blenlib.h" /* util and noise functions */
57 #include "BLI_threads.h" /* For threadsfe guardedalloc malloc/calloc/free */
58 #include "IMB_imbuf.h" /* image buffer stuff */
59 #define GET_INT_FROM_POINTER(i) ((int)(long)(i)) /* should use BKE_utildefines.h */
61 /* -------------------------------------------------------------------------- */
62 /* stuff from util.h */
63 /* -------------------------------------------------------------------------- */
65 LIBEXPORT
void *mallocN(int len
, char *str
)
67 return MEM_mallocN(len
, str
);
70 LIBEXPORT
void *callocN(int len
, char *str
)
72 return MEM_callocN(len
, str
);
75 LIBEXPORT
short freeN(void *vmemh
)
77 return MEM_freeN(vmemh
);
80 /* these are not needed anymore, mallocN/callocN/freeN is now threadsafe */
81 LIBEXPORT
void *mallocT(int len
, char *str
)
83 return MEM_mallocN(len
, str
);
86 LIBEXPORT
void *callocT(int len
, char *str
)
88 return MEM_callocN(len
, str
);
91 LIBEXPORT
void freeT(void *vmemh
)
98 /* -------------------------------------------------------------------------- */
99 /* stuff from iff.h */
100 /* -------------------------------------------------------------------------- */
102 LIBEXPORT
struct ImBuf
*allocImBuf(short x
,
108 return IMB_allocImBuf(x
, y
, d
, flags
, bitmap
);
112 LIBEXPORT
struct ImBuf
*dupImBuf(struct ImBuf
*ib
)
114 return IMB_dupImBuf(ib
);
117 LIBEXPORT
void freeImBuf(struct ImBuf
* ib
)
122 LIBEXPORT
short converttocmap(struct ImBuf
* ibuf
)
124 return IMB_converttocmap(ibuf
);
127 LIBEXPORT
short saveiff(struct ImBuf
*ib
,
131 return IMB_saveiff(ib
, c
, i
);
134 LIBEXPORT
struct ImBuf
*loadiffmem(int *mem
,int flags
)
136 return IMB_loadiffmem(mem
, flags
);
139 LIBEXPORT
struct ImBuf
*loadifffile(int a
,
142 return IMB_loadifffile(a
, b
);
145 LIBEXPORT
struct ImBuf
*loadiffname(char *n
,
148 return IMB_loadiffname(n
, flags
);
151 LIBEXPORT
struct ImBuf
*testiffname(char *n
,
154 return IMB_testiffname(n
, flags
);
157 LIBEXPORT
struct ImBuf
*onehalf(struct ImBuf
*ib
)
159 return IMB_onehalf(ib
);
162 LIBEXPORT
struct ImBuf
*onethird(struct ImBuf
*ib
)
164 return IMB_onethird(ib
);
167 LIBEXPORT
struct ImBuf
*halflace(struct ImBuf
*ib
)
169 return IMB_halflace(ib
);
172 LIBEXPORT
struct ImBuf
*half_x(struct ImBuf
*ib
)
174 return IMB_half_x(ib
);
177 LIBEXPORT
struct ImBuf
*half_y(struct ImBuf
*ib
)
179 return IMB_half_y(ib
);
182 LIBEXPORT
struct ImBuf
*double_x(struct ImBuf
*ib
)
184 return IMB_double_x(ib
);
187 LIBEXPORT
struct ImBuf
*double_y(struct ImBuf
*ib
)
189 return IMB_double_y(ib
);
192 LIBEXPORT
struct ImBuf
*double_fast_x(struct ImBuf
*ib
)
194 return IMB_double_fast_x(ib
);
197 LIBEXPORT
struct ImBuf
*double_fast_y(struct ImBuf
*ib
)
199 return IMB_double_fast_y(ib
);
202 LIBEXPORT
int ispic(char * name
)
204 return IMB_ispic(name
);
207 LIBEXPORT
void dit2(struct ImBuf
*ib
,
214 LIBEXPORT
void dit0(struct ImBuf
*ib
,
221 /* still the same name */
222 /* void (*ditherfunc)(struct ImBuf *, short, short){} */
224 LIBEXPORT
struct ImBuf
*scaleImBuf(struct ImBuf
*ib
,
228 return IMB_scaleImBuf(ib
, nx
, ny
);
231 LIBEXPORT
struct ImBuf
*scalefastImBuf(struct ImBuf
*ib
,
235 return IMB_scalefastImBuf(ib
, x
, y
);
239 LIBEXPORT
struct ImBuf
*scalefieldImBuf(struct ImBuf
*ib
,
243 return IMB_scalefieldImBuf(ib
, x
, y
);
246 LIBEXPORT
struct ImBuf
*scalefastfieldImBuf(struct ImBuf
*ib
,
250 return IMB_scalefastfieldImBuf(ib
, x
, y
);
253 /* Extra ones that some NaN (read Ton) plugins use,
254 * even though they aren't in the header
257 LIBEXPORT
void interlace(struct ImBuf
*ibuf
)
262 LIBEXPORT
void gamwarp(struct ImBuf
*ibuf
, double gamma
)
264 IMB_gamwarp(ibuf
,gamma
);
267 LIBEXPORT
void de_interlace(struct ImBuf
*ib
)
269 IMB_de_interlace(ib
);
272 /* -------------------------------------------------------------------------- */
273 /* stuff from plugin.h */
274 /* -------------------------------------------------------------------------- */
276 /* These three need to be defined in the plugion itself. The plugin
277 * loader looks for these functions to check whether it can use the
278 * plugin. For sequences, something similar exists. */
279 /* int plugin_tex_getversion(void); */
280 /* int plugin_seq_getversion(void); */
281 /* void plugin_getinfo(PluginInfo *); */
283 LIBEXPORT
float hnoise(float noisesize
,
288 return BLI_hnoise(noisesize
, x
, y
, z
);
291 LIBEXPORT
float hnoisep(float noisesize
,
296 return BLI_hnoisep(noisesize
, x
, y
, z
);
299 LIBEXPORT
float turbulence(float noisesize
,
305 return BLI_turbulence(noisesize
, x
, y
, z
, depth
);
308 LIBEXPORT
float turbulence1(float noisesize
,
314 return BLI_turbulence1(noisesize
, x
, y
, z
, depth
);
317 /* -------------------------------------------------------------------------- */
319 /* Stupid hack - force the inclusion of all of the
320 * above functions in the binary by 'using' each one...
321 * Otherwise they will not be imported from the archive
322 * library on Unix. -zr
324 int pluginapi_force_ref(void);
326 int pluginapi_force_ref(void)
329 GET_INT_FROM_POINTER( mallocN
) +
330 GET_INT_FROM_POINTER( callocN
) +
331 GET_INT_FROM_POINTER( freeN
) +
332 GET_INT_FROM_POINTER( mallocT
) +
333 GET_INT_FROM_POINTER( callocT
) +
334 GET_INT_FROM_POINTER( freeT
) +
335 GET_INT_FROM_POINTER( allocImBuf
) +
336 GET_INT_FROM_POINTER( dupImBuf
) +
337 GET_INT_FROM_POINTER( freeImBuf
) +
338 GET_INT_FROM_POINTER( converttocmap
) +
339 GET_INT_FROM_POINTER( saveiff
) +
340 GET_INT_FROM_POINTER( loadiffmem
) +
341 GET_INT_FROM_POINTER( loadifffile
) +
342 GET_INT_FROM_POINTER( loadiffname
) +
343 GET_INT_FROM_POINTER( testiffname
) +
344 GET_INT_FROM_POINTER( onehalf
) +
345 GET_INT_FROM_POINTER( onethird
) +
346 GET_INT_FROM_POINTER( halflace
) +
347 GET_INT_FROM_POINTER( half_x
) +
348 GET_INT_FROM_POINTER( half_y
) +
349 GET_INT_FROM_POINTER( double_x
) +
350 GET_INT_FROM_POINTER( double_y
) +
351 GET_INT_FROM_POINTER( double_fast_x
) +
352 GET_INT_FROM_POINTER( double_fast_y
) +
353 GET_INT_FROM_POINTER( ispic
) +
354 GET_INT_FROM_POINTER( dit2
) +
355 GET_INT_FROM_POINTER( dit0
) +
356 GET_INT_FROM_POINTER( scaleImBuf
) +
357 GET_INT_FROM_POINTER( scalefastImBuf
) +
358 GET_INT_FROM_POINTER( scalefieldImBuf
) +
359 GET_INT_FROM_POINTER( scalefastfieldImBuf
) +
360 GET_INT_FROM_POINTER( hnoise
) +
361 GET_INT_FROM_POINTER( hnoisep
) +
362 GET_INT_FROM_POINTER( turbulence
) +
363 GET_INT_FROM_POINTER( turbulence1
) +
364 GET_INT_FROM_POINTER( de_interlace
) +
365 GET_INT_FROM_POINTER( interlace
) +
366 GET_INT_FROM_POINTER( gamwarp
);