Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 * Wrappers for the plugin api. This api is up for removal. 00027 */ 00028 00034 /* There are four headers making up the plugin api: 00035 * - floatpatch.h : Wraps math functions for mips platforms, no code 00036 * required. 00037 * - iff.h : Defines, macros and functions for dealing 00038 * with image buffer things. 00039 * - plugin.h : Wraps some plugin handling types, accesses noise 00040 * functions. 00041 * - util.h : Useful defines, memory management. 00042 */ 00043 00044 #define PLUGIN_INTERN /* This tells the LIBEXPORT macro to compile with 00045 dll export set on windows */ 00046 00047 #ifdef WIN32 00048 #include "blenpluginapi/util.h" 00049 #else 00050 #include "blenpluginapi/util.h" 00051 #endif 00052 #include "iff.h" 00053 #include "plugin.h" 00054 #include "MEM_guardedalloc.h" 00055 00056 #include "BLO_sys_types.h" // needed for intptr_t 00057 00058 #include "BLI_blenlib.h" /* util and noise functions */ 00059 #include "BLI_threads.h" /* For threadsfe guardedalloc malloc/calloc/free */ 00060 #include "IMB_imbuf.h" /* image buffer stuff */ 00061 #define GET_INT_FROM_POINTER(i) ((int)(intptr_t)(i)) /* should use BKE_utildefines.h */ 00062 00063 /* -------------------------------------------------------------------------- */ 00064 /* stuff from util.h */ 00065 /* -------------------------------------------------------------------------- */ 00066 00067 LIBEXPORT void *mallocN(int len, char *str) 00068 { 00069 return MEM_mallocN(len, str); 00070 } 00071 00072 LIBEXPORT void *callocN(int len, char *str) 00073 { 00074 return MEM_callocN(len, str); 00075 } 00076 00077 LIBEXPORT short freeN(void *vmemh) 00078 { 00079 return MEM_freeN(vmemh); 00080 } 00081 00082 /* these are not needed anymore, mallocN/callocN/freeN is now threadsafe */ 00083 LIBEXPORT void *mallocT(int len, char *str) 00084 { 00085 return MEM_mallocN(len, str); 00086 } 00087 00088 LIBEXPORT void *callocT(int len, char *str) 00089 { 00090 return MEM_callocN(len, str); 00091 } 00092 00093 LIBEXPORT void freeT(void *vmemh) 00094 { 00095 MEM_freeN(vmemh); 00096 return; 00097 } 00098 00099 00100 /* -------------------------------------------------------------------------- */ 00101 /* stuff from iff.h */ 00102 /* -------------------------------------------------------------------------- */ 00103 00104 LIBEXPORT struct ImBuf *allocImBuf(short x, 00105 short y, 00106 uchar d, 00107 uint flags) 00108 { 00109 return IMB_allocImBuf(x, y, d, flags); 00110 } 00111 00112 00113 LIBEXPORT struct ImBuf *dupImBuf(struct ImBuf *ib) 00114 { 00115 return IMB_dupImBuf(ib); 00116 } 00117 00118 LIBEXPORT void freeImBuf(struct ImBuf* ib) 00119 { 00120 IMB_freeImBuf(ib); 00121 } 00122 00123 LIBEXPORT short saveiff(struct ImBuf *ib, 00124 char *c, 00125 int i) 00126 { 00127 return IMB_saveiff(ib, c, i); 00128 } 00129 00130 LIBEXPORT struct ImBuf *loadifffile(int a, 00131 int b) 00132 { 00133 return IMB_loadifffile(a, b, "loadifffile"); 00134 } 00135 00136 LIBEXPORT struct ImBuf *loadiffname(char *n, 00137 int flags) 00138 { 00139 return IMB_loadiffname(n, flags); 00140 } 00141 00142 LIBEXPORT struct ImBuf *testiffname(char *n, 00143 int flags) 00144 { 00145 return IMB_testiffname(n, flags); 00146 } 00147 00148 LIBEXPORT struct ImBuf *onehalf(struct ImBuf *ib) 00149 { 00150 return IMB_onehalf(ib); 00151 } 00152 00153 LIBEXPORT struct ImBuf *half_x(struct ImBuf *ib) 00154 { 00155 return IMB_half_x(ib); 00156 } 00157 00158 LIBEXPORT struct ImBuf *half_y(struct ImBuf *ib) 00159 { 00160 return IMB_half_y(ib); 00161 } 00162 00163 LIBEXPORT struct ImBuf *double_x(struct ImBuf *ib) 00164 { 00165 return IMB_double_x(ib); 00166 } 00167 00168 LIBEXPORT struct ImBuf *double_y(struct ImBuf *ib) 00169 { 00170 return IMB_double_y(ib); 00171 } 00172 00173 LIBEXPORT struct ImBuf *double_fast_x(struct ImBuf *ib) 00174 { 00175 return IMB_double_fast_x(ib); 00176 } 00177 00178 LIBEXPORT struct ImBuf *double_fast_y(struct ImBuf *ib) 00179 { 00180 return IMB_double_fast_y(ib); 00181 } 00182 00183 LIBEXPORT int ispic(char * name) 00184 { 00185 return IMB_ispic(name); 00186 } 00187 00188 /* still the same name */ 00189 /* void (*ditherfunc)(struct ImBuf *, short, short){} */ 00190 00191 LIBEXPORT struct ImBuf *scaleImBuf(struct ImBuf *ib, 00192 short nx, 00193 short ny) 00194 { 00195 return IMB_scaleImBuf(ib, nx, ny); 00196 } 00197 00198 LIBEXPORT struct ImBuf *scalefastImBuf(struct ImBuf *ib, 00199 short x, 00200 short y) 00201 { 00202 return IMB_scalefastImBuf(ib, x, y); 00203 } 00204 00205 /* Extra ones that some NaN (read Ton) plugins use, 00206 * even though they aren't in the header 00207 */ 00208 00209 LIBEXPORT void interlace(struct ImBuf *ibuf) 00210 { 00211 IMB_interlace(ibuf); 00212 } 00213 00214 LIBEXPORT void de_interlace(struct ImBuf *ib) 00215 { 00216 IMB_de_interlace(ib); 00217 } 00218 00219 /* -------------------------------------------------------------------------- */ 00220 /* stuff from plugin.h */ 00221 /* -------------------------------------------------------------------------- */ 00222 00223 /* These three need to be defined in the plugion itself. The plugin 00224 * loader looks for these functions to check whether it can use the 00225 * plugin. For sequences, something similar exists. */ 00226 /* int plugin_tex_getversion(void); */ 00227 /* int plugin_seq_getversion(void); */ 00228 /* void plugin_getinfo(PluginInfo *); */ 00229 00230 LIBEXPORT float hnoise(float noisesize, 00231 float x, 00232 float y, 00233 float z) 00234 { 00235 return BLI_hnoise(noisesize, x, y, z); 00236 } 00237 00238 LIBEXPORT float hnoisep(float noisesize, 00239 float x, 00240 float y, 00241 float z) 00242 { 00243 return BLI_hnoisep(noisesize, x, y, z); 00244 } 00245 00246 LIBEXPORT float turbulence(float noisesize, 00247 float x, 00248 float y, 00249 float z, 00250 int depth) 00251 { 00252 return BLI_turbulence(noisesize, x, y, z, depth); 00253 } 00254 00255 LIBEXPORT float turbulence1(float noisesize, 00256 float x, 00257 float y, 00258 float z, 00259 int depth) 00260 { 00261 return BLI_turbulence1(noisesize, x, y, z, depth); 00262 } 00263 00264 /* -------------------------------------------------------------------------- */ 00265 00266 /* Stupid hack - force the inclusion of all of the 00267 * above functions in the binary by 'using' each one... 00268 * Otherwise they will not be imported from the archive 00269 * library on Unix. -zr 00270 */ 00271 int pluginapi_force_ref(void); 00272 00273 int pluginapi_force_ref(void) 00274 { 00275 return 00276 GET_INT_FROM_POINTER( mallocN ) + 00277 GET_INT_FROM_POINTER( callocN ) + 00278 GET_INT_FROM_POINTER( freeN ) + 00279 GET_INT_FROM_POINTER( mallocT ) + 00280 GET_INT_FROM_POINTER( callocT ) + 00281 GET_INT_FROM_POINTER( freeT ) + 00282 GET_INT_FROM_POINTER( allocImBuf ) + 00283 GET_INT_FROM_POINTER( dupImBuf ) + 00284 GET_INT_FROM_POINTER( freeImBuf ) + 00285 GET_INT_FROM_POINTER( saveiff ) + 00286 GET_INT_FROM_POINTER( loadifffile ) + 00287 GET_INT_FROM_POINTER( loadiffname ) + 00288 GET_INT_FROM_POINTER( testiffname ) + 00289 GET_INT_FROM_POINTER( onehalf ) + 00290 GET_INT_FROM_POINTER( half_x ) + 00291 GET_INT_FROM_POINTER( half_y ) + 00292 GET_INT_FROM_POINTER( double_x ) + 00293 GET_INT_FROM_POINTER( double_y ) + 00294 GET_INT_FROM_POINTER( double_fast_x ) + 00295 GET_INT_FROM_POINTER( double_fast_y ) + 00296 GET_INT_FROM_POINTER( ispic ) + 00297 GET_INT_FROM_POINTER( scaleImBuf ) + 00298 GET_INT_FROM_POINTER( scalefastImBuf ) + 00299 GET_INT_FROM_POINTER( hnoise ) + 00300 GET_INT_FROM_POINTER( hnoisep ) + 00301 GET_INT_FROM_POINTER( turbulence ) + 00302 GET_INT_FROM_POINTER( turbulence1 ) + 00303 GET_INT_FROM_POINTER( de_interlace ) + 00304 GET_INT_FROM_POINTER( interlace ); 00305 }