Subversion Repositories filter_foundry

Rev

Rev 181 | Rev 183 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 181 Rev 182
Line 74... Line 74...
74
 
74
 
75
        /* Workaround for GIMP/PSPI, to avoid that formulas vanish when you re-open the main window.
75
        /* Workaround for GIMP/PSPI, to avoid that formulas vanish when you re-open the main window.
76
           The reason is a bug in PSPI: The host should preserve the value of pb->parameters, which PSPI does not do.
76
           The reason is a bug in PSPI: The host should preserve the value of pb->parameters, which PSPI does not do.
77
           Also, all global variables are unloaded, so the plugin cannot preserve any data.
77
           Also, all global variables are unloaded, so the plugin cannot preserve any data.
78
           Workaround in FF 1.7: If the host GIMP is detected, the new flag persistent_savestate will be set.
78
           Workaround in FF 1.7: If the host GIMP is detected, the new flag persistent_savestate will be set.
79
           This mode saves the filter data into a temporary file "tmp.afs" and loads it
79
           This mode saves the filter data into a temporary file "FilterFoundryGIMP.afs" and loads it
80
           when the window is opened again. */
80
           when the window is opened again. */
81
#if MAC_ENV
81
 
82
        if (pb->hostSig == 'GIMP') persistent_savestate = true;
82
        // GIMP/PSPI uses the hostSig "GIMP" (string!) which is the Windows OSType 'PMIG'.
83
#else
-
 
-
 
83
        // There are no further steps to do for Mac OS, because PSPI will not be available for Mac OS
84
        if (pb->hostSig == 'PMIG') persistent_savestate = true;
84
        if (pb->hostSig == 'PMIG') persistent_savestate = true;
85
#endif
-
 
86
 
85
 
87
        if(selector != filterSelectorAbout && !*data){
86
        if(selector != filterSelectorAbout && !*data){
88
                BufferID tempId;
87
                BufferID tempId;
89
                if( (*result = PS_BUFFER_ALLOC(sizeof(globals_t), &tempId)) )
88
                if( (*result = PS_BUFFER_ALLOC(sizeof(globals_t), &tempId)) )
90
                        return;
89
                        return;
Line 123... Line 122...
123
 
122
 
124
                /* wantdialog = false means that we never got a Parameters call, so we're not supposed to ask user */
123
                /* wantdialog = false means that we never got a Parameters call, so we're not supposed to ask user */
125
                if( wantdialog && (!gdata->standalone || gdata->parm.popDialog) ){
124
                if( wantdialog && (!gdata->standalone || gdata->parm.popDialog) ){
126
                        if( maindialog(pb) ){
125
                        if( maindialog(pb) ){
127
                                if (persistent_savestate) {
126
                                if (persistent_savestate) {
-
 
127
                                        // GIMP Workaround: Save settings in "FilterFoundryGIMP.afs", becase pb->parameters is not preserved by GIMP/PSPI
-
 
128
                                        char outfilename[255];
-
 
129
                                        char* tempdir;
128
                                        StandardFileReply sfr;
130
                                        StandardFileReply sfr;
129
                                        sfr.sfGood = true;
131
                                        sfr.sfGood = true;
130
                                        sfr.sfReplacing = true;
132
                                        sfr.sfReplacing = true;
131
                                        sfr.sfType = PS_FILTER_FILETYPE;
133
                                        sfr.sfType = PS_FILTER_FILETYPE;
-
 
134
 
-
 
135
                                        tempdir = getenv("TMP");
-
 
136
                                        #ifdef WIN_ENV
-
 
137
                                        if (strlen(tempdir) > 0) strcat(tempdir, "\\");
-
 
138
                                        #else
-
 
139
                                        if (strlen(tempdir) > 0) strcat(tempdir, "/");
-
 
140
                                        #endif
-
 
141
                                        sprintf(outfilename, "%sFilterFoundryGIMP.afs", tempdir);
-
 
142
 
132
                                        myc2pstrcpy(sfr.sfFile.name, "tmp.afs");
143
                                        myc2pstrcpy(sfr.sfFile.name, outfilename);
133
                                        sfr.nFileExtension = 3; // length of "tmp"
144
                                        sfr.nFileExtension = strlen(outfilename)-strlen(".afs");
134
                                        sfr.sfScript = 0; // FIXME: is that ok?
145
                                        sfr.sfScript = 0; // FIXME: is that ok?
135
                                        savefile(&sfr);
146
                                        savefile(&sfr);
136
                                }
147
                                }
137
 
148
 
138
                                /* update stored parameters from new user settings */
149
                                /* update stored parameters from new user settings */
Line 175... Line 186...
175
int checkandinitparams(Handle params){
186
int checkandinitparams(Handle params){
176
        char *reasonstr,*reason;
187
        char *reasonstr,*reason;
177
        int i,f,showdialog;
188
        int i,f,showdialog;
178
 
189
 
179
        if (persistent_savestate) {
190
        if (persistent_savestate) {
-
 
191
                // GIMP Workaround: Load settings in "FilterFoundryGIMP.afs", becase pb->parameters is not preserved by GIMP/PSPI
-
 
192
                char outfilename[255];
-
 
193
                char* tempdir;
180
                StandardFileReply sfr;
194
                StandardFileReply sfr;
181
                sfr.sfGood = true;
195
                sfr.sfGood = true;
182
                sfr.sfReplacing = true;
196
                sfr.sfReplacing = true;
183
                sfr.sfType = PS_FILTER_FILETYPE;
197
                sfr.sfType = PS_FILTER_FILETYPE;
-
 
198
 
-
 
199
                tempdir = getenv("TMP");
-
 
200
                #ifdef WIN_ENV
-
 
201
                if (strlen(tempdir) > 0) strcat(tempdir, "\\");
-
 
202
                #else
-
 
203
                if (strlen(tempdir) > 0) strcat(tempdir, "/");
-
 
204
                #endif
-
 
205
                sprintf(outfilename, "%sFilterFoundryGIMP.afs", tempdir);
-
 
206
 
184
                myc2pstrcpy(sfr.sfFile.name, "tmp.afs");
207
                myc2pstrcpy(sfr.sfFile.name, outfilename);
185
                sfr.nFileExtension = 3; // length of "tmp"
208
                sfr.nFileExtension = strlen(outfilename) - strlen(".afs");
186
                sfr.sfScript = 0; // FIXME: is that ok?
209
                sfr.sfScript = 0; // FIXME: is that ok?
187
                if (loadfile(&sfr, &reason)) return true;
210
                if (loadfile(&sfr, &reason)) return true;
188
        }
211
        }
189
 
212
 
190
        if( (f = !(params && readparams(params,false,&reasonstr))) ){
213
        if( (f = !(params && readparams(params,false,&reasonstr))) ){
Line 221... Line 244...
221
 
244
 
222
        saveparams(params);
245
        saveparams(params);
223
        return f || showdialog;
246
        return f || showdialog;
224
}
247
}
225
 
248
 
226
int64_t MaxSpace(){
249
int64_t maxspace(){
227
        if (gpb->maxSpace64 != 0) {
250
        if (gpb->maxSpace64 != 0) {
228
                // If this is non-zero, the host either support 64-bit OR the host ignored the rule "set reserved fields to 0".
251
                // If this is non-zero, the host either support 64-bit OR the host ignored the rule "set reserved fields to 0".
229
                uint64_t maxSpace64 = gpb->maxSpace64;
252
                uint64_t maxSpace64 = gpb->maxSpace64;
230
                return maxSpace64;
253
                return maxSpace64;
231
        } else {
254
        } else {
Line 234... Line 257...
234
                uint64_t maxSpace64 = maxSpace32;
257
                uint64_t maxSpace64 = maxSpace32;
235
                return maxSpace64;
258
                return maxSpace64;
236
        }
259
        }
237
}
260
}
238
 
261
 
-
 
262
int maxspace_available() {
-
 
263
        // GIMP sets MaxSpace to hardcoded 100 MB
-
 
264
        // GIMP/PSPI uses the hostSig "GIMP" (string!) which is the Windows OSType 'PMIG'.
-
 
265
        // There are no further steps to do for Mac OS, because PSPI will not be available for Mac OS
-
 
266
        if (gpb->hostSig == 'PMIG') return false;
-
 
267
 
-
 
268
        return true;
-
 
269
}
-
 
270
 
239
void DoPrepare(FilterRecordPtr pb){
271
void DoPrepare(FilterRecordPtr pb){
240
        int i;
272
        int i;
241
 
273
 
242
        for(i = 4; i--;){
274
        for(i = 4; i--;){
243
                if(expr[i]||tree[i]) DBG("expr[] or tree[] non-NULL in Prepare!");
275
                if(expr[i]||tree[i]) DBG("expr[] or tree[] non-NULL in Prepare!");
Line 255... Line 287...
255
                maxSpace = space;
287
                maxSpace = space;
256
        pb->maxSpace = maxSpace;
288
        pb->maxSpace = maxSpace;
257
        */
289
        */
258
 
290
 
259
        // New variant:
291
        // New variant:
-
 
292
        if (maxspace_available()) {
260
        pb->maxSpace = (MaxSpace()/10.)*9; // don't ask for more than 90% of available memory
293
                pb->maxSpace = (maxspace()/10.)*9; // don't ask for more than 90% of available memory
-
 
294
        }
261
}
295
}
262
 
296
 
263
void RequestNext(FilterRecordPtr pb,long toprow){
297
void RequestNext(FilterRecordPtr pb,long toprow){
264
        /* Request next block of the image */
298
        /* Request next block of the image */
265
 
299