Subversion Repositories filter_foundry

Rev

Rev 555 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.     This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
  3.     Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.net
  4.     Copyright (C) 2018-2023 Daniel Marschall, ViaThinkSoft
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; either version 2 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19. */
  20.  
  21. #ifndef FF_H_
  22. #define FF_H_
  23.  
  24. #include "world.h"
  25.  
  26. #include "PIFilter.h"
  27.  
  28. #include "entry.h"
  29.  
  30. #include "choosefile.h"
  31. #include "ui.h"
  32. #include "file_compat.h"
  33. #include "symtab.h"
  34. #include "PARM.h"
  35. #include "preview.h"
  36. #include "ff_misc.h"
  37. #include "language.h"
  38.  
  39. #define HOSTSIG_GIMP 'PMIG' // sic: NOT 'GIMP'
  40. #define HOSTSIG_IRFANVIEW 'UP20'
  41. #define HOSTSIG_PHOTOSHOP '8BIM'
  42. //#define HOSTSIG_PLUGINCOMMANDER '8BIM' // illegal usage of signature
  43. //#define HOSTSIG_SERIF_PHOTOPLUS '8BIM' // illegal usage of signature
  44. #define HOSTSIG_JASC_PAINTSHOP_PRO_X 'PSP9'
  45. #define HOSTSIG_PAINT_NET 'NDP.'
  46. #define HOSTSIG_ADOBE_PREMIERE '8B)M'/*sic*/
  47.  
  48. // see also PiPL.rc
  49. #define kViaThinkSoftSignature 'ViaT' // 0x56696154 (inofficial creator code)
  50. #define PIOIDProperty          'ObId' // 0x4f624964
  51.  
  52. #define TEXT_FILETYPE 'TEXT'
  53. #define SIG_SIMPLETEXT 'ttxt'
  54. #define PS_FILTER_FILETYPE '8BFM'
  55.  
  56. #define CHUNK_ROWS 64
  57.  
  58. enum{
  59.         TAB = 011,
  60.         LF  = 012,
  61.         CR  = 015,
  62. };
  63.  
  64. #ifdef _WIN32
  65. typedef struct none_slider_info_ {
  66.         BOOL initialized;
  67. } none_slider_info;
  68.  
  69. typedef struct comctl_slider_info_ {
  70.         BOOL initialized;
  71.         HMODULE hLib;
  72. } comctl_slider_info;
  73.  
  74. typedef struct plugin_dll_slider_info_ {
  75.         BOOL initialized;
  76.         HMODULE hLib;
  77.         DWORD messageId;
  78. } plugin_dll_slider_info;
  79. #endif
  80.  
  81. // The "gdata" structure contains all values which MUST be kept between filter invocations.
  82. // All other working-data (which automatically gets calculated etc.) are NOT part of this structure.
  83. // To increase performance, the lookup tables *tantab and *costab have been included here, so that
  84. // they only need to be calculated once.
  85. // size: 0x2098 (8344 Bytes) for 32-bit
  86. // size: 0x20AC (8364 Bytes) for 64-bit
  87. typedef struct globals_t_ {
  88.         PARM_T parm;
  89.         Boolean obfusc;
  90.         // (padding of 3 bytes here)
  91.         OSType lastKnownBufferVersion;
  92.         OSType lastKnownHandleVersion;
  93.         double* tantab;
  94.         double* costab;
  95. #ifdef _WIN32
  96.         HWND hWndMainDlg;
  97.         none_slider_info noneSliderInfo;
  98.         comctl_slider_info comctlSliderInfo;
  99.         plugin_dll_slider_info pluginDllSliderInfo;
  100. #endif /* _WIN32 */
  101. } globals_t;
  102.  
  103. extern globals_t *gdata;
  104.  
  105. #define NUM_CELLS 0x100
  106.  
  107. extern struct node *tree[4];
  108. extern TCHAR *err[4];
  109. extern int errpos[4],errstart[4];//,nplanes;
  110. extern value_type cell[NUM_CELLS];
  111.  
  112. extern int tokpos,tokstart,varused[];
  113. extern TCHAR *errstr;
  114.  
  115. // FFLoadingResult = 0 : Success
  116. // FFLoadingResult > 0 : Error, message ID as described in language.h
  117. #define LOADING_OK 0
  118. typedef int FFLoadingResult;
  119. #define SAVING_OK 0
  120. typedef int FFSavingResult;
  121.  
  122. //#define DEBUG
  123.  
  124. typedef struct InternalState_ {
  125.         PARM_T bak_parm;
  126.         Boolean bak_obfusc;
  127. } InternalState;
  128.  
  129. // from main.c
  130. void DoPrepare(FilterRecordPtr epb);
  131. void DoStart(FilterRecordPtr epb);
  132. OSErr DoContinue(FilterRecordPtr epb);
  133. void DoFinish(FilterRecordPtr epb);
  134. void RequestNext(FilterRecordPtr epb);
  135. InternalState saveInternalState(void);
  136. void restoreInternalState(InternalState state);
  137. unsigned long parm_hash(PARM_T* parm);
  138. void parm_reset(Boolean resetMetadata, Boolean resetSliderValues, Boolean resetSliderNames, Boolean resetFormulas);
  139. void parm_cleanup();
  140.  
  141. // from read.c
  142. FFLoadingResult readparams_afs_pff(Handle h, Boolean premiereOrder);
  143. void convert_premiere_to_photoshop(PARM_T* photoshop, PARM_T_PREMIERE* premiere);
  144. FFLoadingResult readfile_8bf(StandardFileReply *sfr);
  145. Handle readfileintohandle(FILEREF r);
  146. FFLoadingResult readfile_afs_pff(StandardFileReply* sfr);
  147. FFLoadingResult readfile_ffl(StandardFileReply* sfr);
  148. FFLoadingResult readfile_ffx(StandardFileReply* sfr);
  149. FFLoadingResult readfile_picotxt_or_ffdecomp(StandardFileReply* sfr);
  150. FFLoadingResult readfile_guf(StandardFileReply* sfr);
  151. FFLoadingResult readPARM(PARM_T* parm,Ptr h);
  152.  
  153. // from save.c
  154. OSErr saveparams_afs_pff(Handle h, Boolean premiereOrder);
  155. OSErr saveparams_picotxt(Handle h);
  156. OSErr savehandleintofile(Handle h,FILEREF r);
  157. FFSavingResult savefile_afs_pff_picotxt_guf(StandardFileReply *sfr);
  158.  
  159. // from make_*.c
  160. OSErr make_standalone(StandardFileReply *sfr);
  161.  
  162. // from process.c
  163. Boolean setup(FilterRecordPtr pb);
  164. void evalpixel(unsigned char *outp,unsigned char *inp);
  165.  
  166. // from make.c
  167. unsigned long printablehash(unsigned long hash);
  168. size_t fixpipl(PIPropertyList *pipl,size_t origsize,char* title, char* component, char* category, long *event_id);
  169. size_t aete_generate(void* aeteptr, PARM_T *pparm, long event_id);
  170.  
  171. // from obfusc.c
  172. #ifdef _MSC_VER
  173. __declspec(noinline)
  174. #endif
  175. uint64_t GetObfuscSeed(void);
  176. #ifdef _MSC_VER
  177. __declspec(noinline)
  178. #endif
  179. uint64_t GetObfuscSeed2(void);
  180. #ifdef WIN_ENV
  181. Boolean obfusc_seed_replace(FSSpec* dst, uint64_t search1, uint64_t search2, uint64_t replace1, uint64_t replace2, int maxamount1, int maxamount2);
  182. #endif
  183. int obfuscation_version(PARM_T* pparm);
  184. void obfusc(PARM_T* pparm, uint64_t* out_initial_seed, uint64_t* out_initial_seed2);
  185. void deobfusc(PARM_T* pparm);
  186.  
  187. // from loadfile_*.c
  188. FFLoadingResult loadfile(StandardFileReply *sfr);
  189. FFLoadingResult readPARMresource(HMODULE hm);
  190.  
  191. // from main.c
  192. int64_t maxspace(void);
  193. Boolean maxspace_available(void);
  194. Boolean host_preserves_parameters(void);
  195.  
  196. // from parser.y
  197. struct node *parseexpr(char *s);
  198.  
  199. // Useful macros
  200.  
  201. // Note: "bigDocumentData->PluginUsing32BitCoordinates" will be set by filterSelectorStart, if HAS_BIG_DOC(pb) is true
  202. #define HAS_BIG_DOC(x) ((x)->bigDocumentData != NULL)
  203.  
  204. #define BIGDOC_IMAGE_SIZE(x) ((x)->bigDocumentData->imageSize32)
  205. #define IMAGE_SIZE(x) ((x)->imageSize)
  206.  
  207. #define BIGDOC_FILTER_RECT(x) ((x)->bigDocumentData->filterRect32)
  208. #define FILTER_RECT(x) ((x)->filterRect)
  209.  
  210. #define BIGDOC_IN_RECT(x) ((x)->bigDocumentData->inRect32)
  211. #define IN_RECT(x) ((x)->inRect)
  212.  
  213. #define BIGDOC_OUT_RECT(x) ((x)->bigDocumentData->outRect32)
  214. #define OUT_RECT(x) ((x)->outRect)
  215.  
  216. #define BIGDOC_MASK_RECT(x) ((x)->bigDocumentData->maskRect32)
  217. #define MASK_RECT(x) ((x)->maskRect)
  218.  
  219. #define BIGDOC_FLOAT_COORD(x) ((x)->bigDocumentData->floatCoord32)
  220. #define FLOAT_COORD(x) ((x)->floatCoord)
  221.  
  222. #define BIGDOC_WHOLE_SIZE(x) ((x)->bigDocumentData->wholeSize32)
  223. #define WHOLE_SIZE(x) ((x)->wholeSize)
  224.  
  225. #endif
  226.