Rev 488 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
484 | daniel-mar | 1 | /* |
486 | daniel-mar | 2 | This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop |
3 | Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au |
||
4 | Copyright (C) 2018-2022 Daniel Marschall, ViaThinkSoft |
||
484 | daniel-mar | 5 | |
486 | daniel-mar | 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. |
||
484 | daniel-mar | 10 | |
486 | daniel-mar | 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. |
||
484 | daniel-mar | 15 | |
486 | daniel-mar | 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 |
||
484 | daniel-mar | 19 | */ |
20 | |||
21 | #include "ff.h" |
||
22 | |||
485 | daniel-mar | 23 | #include "PIBufferSuite.h" |
486 | daniel-mar | 24 | #include "PIHandleSuite.h" |
485 | daniel-mar | 25 | |
486 | daniel-mar | 26 | void newHandle(FFHandle* hdl, size_t nBytes) { |
27 | PSHandleSuite1* pSHandleSuite1 = NULL; |
||
28 | PSHandleSuite2* pSHandleSuite2 = NULL; |
||
485 | daniel-mar | 29 | |
486 | daniel-mar | 30 | if ((gpb->sSPBasic != 0) && |
31 | (gpb->sSPBasic->AcquireSuite(kPIHandleSuite, kPSHandleSuiteVersion2, (const void**)&pSHandleSuite2) == noErr) && |
||
32 | (pSHandleSuite2 != NULL) && |
||
488 | daniel-mar | 33 | (pSHandleSuite2 != (PSHandleSuite2*)gpb->handleProcs /* Just to be sure (although no bug is known) */) |
486 | daniel-mar | 34 | ) |
35 | { |
||
36 | // PICA Handle Suite 2.0 |
||
37 | hdl->signature = HDLVERSION_SUITE2; |
||
487 | daniel-mar | 38 | if (gdata) gdata->lastKnownHandleVersion = hdl->signature; |
505 | daniel-mar | 39 | hdl->handle = pSHandleSuite2->New((int32)nBytes); |
486 | daniel-mar | 40 | gpb->sSPBasic->ReleaseSuite(kPIHandleSuite, kPSHandleSuiteVersion2); |
41 | } |
||
42 | else if ((gpb->sSPBasic != 0) && |
||
43 | (gpb->sSPBasic->AcquireSuite(kPIHandleSuite, kPSHandleSuiteVersion1, (const void**)&pSHandleSuite1) == noErr) && |
||
488 | daniel-mar | 44 | (pSHandleSuite1 != NULL) && |
45 | (pSHandleSuite1 != (PSHandleSuite1*)gpb->handleProcs /* Just to be sure (although no bug is known) */) |
||
486 | daniel-mar | 46 | ) |
47 | { |
||
48 | // PICA Handle Suite 1.0 |
||
49 | hdl->signature = HDLVERSION_SUITE1; |
||
487 | daniel-mar | 50 | if (gdata) gdata->lastKnownHandleVersion = hdl->signature; |
505 | daniel-mar | 51 | hdl->handle = pSHandleSuite1->New((int32)nBytes); |
486 | daniel-mar | 52 | gpb->sSPBasic->ReleaseSuite(kPIHandleSuite, kPSHandleSuiteVersion1); |
53 | } |
||
54 | else { |
||
55 | // Standard Handle Suite (deprecated) |
||
56 | hdl->signature = HDLVERSION_STANDARD; |
||
487 | daniel-mar | 57 | if (gdata) gdata->lastKnownHandleVersion = hdl->signature; |
505 | daniel-mar | 58 | hdl->handle = gpb->handleProcs->newProc((int32)nBytes); |
486 | daniel-mar | 59 | } |
60 | } |
||
61 | |||
62 | void disposeHandle(FFHandle* hdl) { |
||
63 | if (hdl->signature == HDLVERSION_SUITE2) { |
||
64 | PSHandleSuite2* pSHandleSuite2 = NULL; |
||
65 | if ((gpb->sSPBasic != 0) && |
||
66 | (gpb->sSPBasic->AcquireSuite(kPIHandleSuite, kPSHandleSuiteVersion2, (const void**)&pSHandleSuite2) == noErr) && |
||
67 | (pSHandleSuite2 != NULL) && |
||
488 | daniel-mar | 68 | (pSHandleSuite2 != (PSHandleSuite2*)gpb->handleProcs /* Just to be sure (although no bug is known) */) |
486 | daniel-mar | 69 | ) |
70 | { |
||
71 | // PICA Handle Suite 2.0 |
||
72 | pSHandleSuite2->Dispose(hdl->handle); |
||
73 | gpb->sSPBasic->ReleaseSuite(kPIHandleSuite, kPSHandleSuiteVersion2); |
||
74 | } |
||
75 | } |
||
76 | else if (hdl->signature == HDLVERSION_SUITE1) { |
||
77 | PSHandleSuite1* pSHandleSuite1 = NULL; |
||
78 | if ((gpb->sSPBasic != 0) && |
||
79 | (gpb->sSPBasic->AcquireSuite(kPIHandleSuite, kPSHandleSuiteVersion1, (const void**)&pSHandleSuite1) == noErr) && |
||
488 | daniel-mar | 80 | (pSHandleSuite1 != NULL) && |
81 | (pSHandleSuite1 != (PSHandleSuite1*)gpb->handleProcs /* Just to be sure (although no bug is known) */) |
||
486 | daniel-mar | 82 | ) |
83 | { |
||
84 | // PICA Handle Suite 1.0 |
||
85 | pSHandleSuite1->Dispose(hdl->handle); |
||
86 | gpb->sSPBasic->ReleaseSuite(kPIHandleSuite, kPSHandleSuiteVersion1); |
||
87 | } |
||
88 | } |
||
89 | else if (hdl->signature == HDLVERSION_STANDARD) { |
||
90 | // Standard Handle Suite (deprecated) |
||
91 | gpb->handleProcs->disposeProc(hdl->handle); |
||
92 | } |
||
93 | hdl->signature = HDLVERSION_NULL; |
||
94 | } |
||
95 | |||
96 | size_t getHandleSize(FFHandle* hdl) { |
||
97 | if (hdl->signature == HDLVERSION_SUITE2) { |
||
98 | PSHandleSuite2* pSHandleSuite2 = NULL; |
||
99 | if ((gpb->sSPBasic != 0) && |
||
100 | (gpb->sSPBasic->AcquireSuite(kPIHandleSuite, kPSHandleSuiteVersion2, (const void**)&pSHandleSuite2) == noErr) && |
||
101 | (pSHandleSuite2 != NULL) && |
||
488 | daniel-mar | 102 | (pSHandleSuite2 != (PSHandleSuite2*)gpb->handleProcs /* Just to be sure (although no bug is known) */) |
486 | daniel-mar | 103 | ) |
104 | { |
||
105 | // PICA Handle Suite 2.0 |
||
106 | int32 size = pSHandleSuite2->GetSize(hdl->handle); |
||
107 | gpb->sSPBasic->ReleaseSuite(kPIHandleSuite, kPSHandleSuiteVersion2); |
||
108 | return (size_t)size; |
||
109 | } |
||
110 | } |
||
111 | else if (hdl->signature == HDLVERSION_SUITE1) { |
||
112 | PSHandleSuite1* pSHandleSuite1 = NULL; |
||
113 | if ((gpb->sSPBasic != 0) && |
||
114 | (gpb->sSPBasic->AcquireSuite(kPIHandleSuite, kPSHandleSuiteVersion1, (const void**)&pSHandleSuite1) == noErr) && |
||
488 | daniel-mar | 115 | (pSHandleSuite1 != NULL) && |
116 | (pSHandleSuite1 != (PSHandleSuite1*)gpb->handleProcs /* Just to be sure (although no bug is known) */) |
||
486 | daniel-mar | 117 | ) |
118 | { |
||
119 | // PICA Handle Suite 1.0 |
||
120 | int32 size = pSHandleSuite1->GetSize(hdl->handle); |
||
121 | gpb->sSPBasic->ReleaseSuite(kPIHandleSuite, kPSHandleSuiteVersion1); |
||
122 | return (size_t)size; |
||
123 | } |
||
124 | } |
||
125 | else if (hdl->signature == HDLVERSION_STANDARD) { |
||
126 | // Standard Handle Suite (deprecated) |
||
127 | return gpb->handleProcs->getSizeProc(hdl->handle); |
||
128 | } |
||
129 | return 0; |
||
130 | } |
||
131 | |||
132 | OSErr setHandleSize(FFHandle* hdl, size_t nBytes) { |
||
133 | if (hdl->signature == HDLVERSION_SUITE2) { |
||
134 | PSHandleSuite2* pSHandleSuite2 = NULL; |
||
135 | if ((gpb->sSPBasic != 0) && |
||
136 | (gpb->sSPBasic->AcquireSuite(kPIHandleSuite, kPSHandleSuiteVersion2, (const void**)&pSHandleSuite2) == noErr) && |
||
137 | (pSHandleSuite2 != NULL) && |
||
488 | daniel-mar | 138 | (pSHandleSuite2 != (PSHandleSuite2*)gpb->handleProcs /* Just to be sure (although no bug is known) */) |
486 | daniel-mar | 139 | ) |
140 | { |
||
141 | // PICA Handle Suite 2.0 |
||
505 | daniel-mar | 142 | OSErr ret = pSHandleSuite2->SetSize(hdl->handle, (int32)nBytes); |
486 | daniel-mar | 143 | gpb->sSPBasic->ReleaseSuite(kPIHandleSuite, kPSHandleSuiteVersion2); |
144 | return ret; |
||
145 | } |
||
146 | } |
||
147 | else if (hdl->signature == HDLVERSION_SUITE1) { |
||
148 | PSHandleSuite1* pSHandleSuite1 = NULL; |
||
149 | if ((gpb->sSPBasic != 0) && |
||
150 | (gpb->sSPBasic->AcquireSuite(kPIHandleSuite, kPSHandleSuiteVersion1, (const void**)&pSHandleSuite1) == noErr) && |
||
488 | daniel-mar | 151 | (pSHandleSuite1 != NULL) && |
152 | (pSHandleSuite1 != (PSHandleSuite1*)gpb->handleProcs /* Just to be sure (although no bug is known) */) |
||
486 | daniel-mar | 153 | ) |
154 | { |
||
155 | // PICA Handle Suite 1.0 |
||
505 | daniel-mar | 156 | OSErr ret = pSHandleSuite1->SetSize(hdl->handle, (int32)nBytes); |
486 | daniel-mar | 157 | gpb->sSPBasic->ReleaseSuite(kPIHandleSuite, kPSHandleSuiteVersion1); |
158 | return ret; |
||
159 | } |
||
160 | } |
||
161 | else if (hdl->signature == HDLVERSION_STANDARD) { |
||
162 | // Standard Handle Suite (deprecated) |
||
505 | daniel-mar | 163 | return gpb->handleProcs->setSizeProc(hdl->handle, (int32)nBytes); |
486 | daniel-mar | 164 | } |
165 | return errMissingParameter; |
||
166 | } |
||
167 | |||
168 | Ptr lockHandle(FFHandle* hdl) { |
||
169 | if (hdl->signature == HDLVERSION_SUITE2) { |
||
170 | PSHandleSuite2* pSHandleSuite2 = NULL; |
||
171 | if ((gpb->sSPBasic != 0) && |
||
172 | (gpb->sSPBasic->AcquireSuite(kPIHandleSuite, kPSHandleSuiteVersion2, (const void**)&pSHandleSuite2) == noErr) && |
||
173 | (pSHandleSuite2 != NULL) && |
||
488 | daniel-mar | 174 | (pSHandleSuite2 != (PSHandleSuite2*)gpb->handleProcs /* Just to be sure (although no bug is known) */) |
486 | daniel-mar | 175 | ) |
176 | { |
||
177 | // PICA Handle Suite 2.0 |
||
178 | Ptr address; |
||
179 | Boolean oldLock; |
||
180 | pSHandleSuite2->SetLock(hdl->handle, true, &address, &oldLock); |
||
181 | gpb->sSPBasic->ReleaseSuite(kPIHandleSuite, kPSHandleSuiteVersion2); |
||
182 | return address; |
||
183 | } |
||
184 | } |
||
185 | else if (hdl->signature == HDLVERSION_SUITE1) { |
||
186 | PSHandleSuite1* pSHandleSuite1 = NULL; |
||
187 | if ((gpb->sSPBasic != 0) && |
||
188 | (gpb->sSPBasic->AcquireSuite(kPIHandleSuite, kPSHandleSuiteVersion1, (const void**)&pSHandleSuite1) == noErr) && |
||
488 | daniel-mar | 189 | (pSHandleSuite1 != NULL) && |
190 | (pSHandleSuite1 != (PSHandleSuite1*)gpb->handleProcs /* Just to be sure (although no bug is known) */) |
||
486 | daniel-mar | 191 | ) |
192 | { |
||
193 | // PICA Handle Suite 1.0 |
||
194 | Ptr address; |
||
195 | Boolean oldLock; |
||
196 | pSHandleSuite1->SetLock(hdl->handle, true, &address, &oldLock); |
||
197 | gpb->sSPBasic->ReleaseSuite(kPIHandleSuite, kPSHandleSuiteVersion1); |
||
198 | return address; |
||
199 | } |
||
200 | } |
||
201 | else if (hdl->signature == HDLVERSION_STANDARD) { |
||
202 | // Standard Handle Suite (deprecated) |
||
203 | return gpb->handleProcs->lockProc(hdl->handle, true); |
||
204 | } |
||
205 | return NULL; |
||
206 | } |
||
207 | |||
208 | void unlockHandle(FFHandle* hdl) { |
||
209 | if (hdl->signature == HDLVERSION_SUITE2) { |
||
210 | PSHandleSuite2* pSHandleSuite2 = NULL; |
||
211 | if ((gpb->sSPBasic != 0) && |
||
212 | (gpb->sSPBasic->AcquireSuite(kPIHandleSuite, kPSHandleSuiteVersion2, (const void**)&pSHandleSuite2) == noErr) && |
||
213 | (pSHandleSuite2 != NULL) && |
||
488 | daniel-mar | 214 | (pSHandleSuite2 != (PSHandleSuite2*)gpb->handleProcs /* Just to be sure (although no bug is known) */) |
486 | daniel-mar | 215 | ) |
216 | { |
||
217 | // PICA Handle Suite 2.0 |
||
218 | Ptr address; |
||
219 | Boolean oldLock; |
||
220 | pSHandleSuite2->SetLock(hdl->handle, false, &address, &oldLock); |
||
221 | gpb->sSPBasic->ReleaseSuite(kPIHandleSuite, kPSHandleSuiteVersion2); |
||
222 | } |
||
223 | } |
||
224 | else if (hdl->signature == HDLVERSION_SUITE1) { |
||
225 | PSHandleSuite1* pSHandleSuite1 = NULL; |
||
226 | if ((gpb->sSPBasic != 0) && |
||
227 | (gpb->sSPBasic->AcquireSuite(kPIHandleSuite, kPSHandleSuiteVersion1, (const void**)&pSHandleSuite1) == noErr) && |
||
488 | daniel-mar | 228 | (pSHandleSuite1 != NULL) && |
229 | (pSHandleSuite1 != (PSHandleSuite1*)gpb->handleProcs /* Just to be sure (although no bug is known) */) |
||
486 | daniel-mar | 230 | ) |
231 | { |
||
232 | // PICA Handle Suite 1.0 |
||
233 | Ptr address; |
||
234 | Boolean oldLock; |
||
235 | pSHandleSuite1->SetLock(hdl->handle, false, &address, &oldLock); |
||
236 | gpb->sSPBasic->ReleaseSuite(kPIHandleSuite, kPSHandleSuiteVersion1); |
||
237 | } |
||
238 | } |
||
239 | else if (hdl->signature == HDLVERSION_STANDARD) { |
||
240 | // Standard Handle Suite (deprecated) |
||
241 | gpb->handleProcs->unlockProc(hdl->handle); |
||
242 | } |
||
243 | } |
||
244 | |||
245 | // ----------------------------------------------------------------------------------- |
||
246 | // These functions are for code backwards compatibility: |
||
247 | |||
248 | Handle PINEWHANDLE(int32 size) { |
||
249 | FFHandle fh; |
||
250 | newHandle(&fh, size); |
||
251 | // Note: newHandle() set gdata->lastKnownHandleVersion, so that |
||
252 | // the other functions like PILOCKHANDLE can use it. This is safe, |
||
253 | // as we can assume that the version is always the same for all handles from this host. |
||
254 | return fh.handle; |
||
255 | } |
||
256 | |||
257 | void PIDISPOSEHANDLE(Handle h) { |
||
258 | FFHandle fh; |
||
259 | fh.signature = gdata->lastKnownHandleVersion; |
||
260 | fh.handle = h; |
||
261 | disposeHandle(&fh); |
||
262 | } |
||
263 | |||
505 | daniel-mar | 264 | size_t PIGETHANDLESIZE(Handle h) { |
486 | daniel-mar | 265 | FFHandle fh; |
266 | fh.signature = gdata->lastKnownHandleVersion; |
||
267 | fh.handle = h; |
||
268 | return getHandleSize(&fh); |
||
269 | } |
||
270 | |||
271 | OSErr PISETHANDLESIZE(Handle h, int32 newSize) { |
||
272 | FFHandle fh; |
||
273 | fh.signature = gdata->lastKnownHandleVersion; |
||
274 | fh.handle = h; |
||
275 | return setHandleSize(&fh, newSize); |
||
276 | } |
||
277 | |||
278 | Ptr PILOCKHANDLE(Handle h, Boolean moveHigh) { |
||
279 | FFHandle fh; |
||
488 | daniel-mar | 280 | UNREFERENCED_PARAMETER(moveHigh); |
486 | daniel-mar | 281 | fh.signature = gdata->lastKnownHandleVersion; |
282 | fh.handle = h; |
||
283 | return lockHandle(&fh); |
||
284 | } |
||
285 | |||
286 | void PIUNLOCKHANDLE(Handle h) { |
||
287 | FFHandle fh; |
||
288 | fh.signature = gdata->lastKnownHandleVersion; |
||
289 | fh.handle = h; |
||
290 | unlockHandle(&fh); |
||
291 | } |
||
292 | |||
293 | // ----------------------------------------------------------------------------------- |
||
294 | |||
295 | void newBuffer(FFBuffer* buf, size_t nBytes) { |
||
485 | daniel-mar | 296 | PSBufferSuite1* pSBufferSuite32 = NULL; |
297 | PSBufferSuite2* pSBufferSuite64 = NULL; |
||
298 | |||
299 | if ((gpb->sSPBasic != 0) && |
||
300 | (gpb->sSPBasic->AcquireSuite(kPSBufferSuite, kPSBufferSuiteVersion2, (const void**)&pSBufferSuite64) == noErr) && |
||
301 | (pSBufferSuite64 != NULL) && |
||
302 | (pSBufferSuite64 != (PSBufferSuite2*)gpb->bufferProcs /*Implementation mistake in old Photoshop versions! (see note below)*/) |
||
303 | ) |
||
304 | { |
||
305 | // PICA Buffer Suite 2.0 (64 bit) |
||
306 | // |
||
307 | // Note: Windows Photoshop 7 and CS 2 (Other Photoshop versions were not tested) accept |
||
308 | // kPSBufferSuiteVersion2, but dont't correctly implement it: |
||
309 | // Instead of returning a pointer to a PSBufferSuite2 structure, |
||
310 | // they return the pointer RecordPtr->bufferProcs (structure BufferProcs)! |
||
311 | // |
||
487 | daniel-mar | 312 | // Side note: 64-bit support for Windows was established in Photoshop CS 4, |
313 | // PSBufferSuite2 was first documented in SDK CS 6, |
||
314 | // pb->bufferProcs->allocateProc64 and spaceProc64 were documented in SDK CS 6, |
||
315 | // pb->bufferSpace64 and pb->maxSpace64 were documented in SDK CC 2017. |
||
505 | daniel-mar | 316 | unsigned32 siz = (unsigned32)nBytes; |
486 | daniel-mar | 317 | buf->signature = BUFVERSION_SUITE64; |
487 | daniel-mar | 318 | if (gdata) gdata->lastKnownBufferVersion = buf->signature; |
486 | daniel-mar | 319 | buf->suite = (Ptr)pSBufferSuite64->New(&siz, siz); |
485 | daniel-mar | 320 | if (siz < nBytes) { |
486 | daniel-mar | 321 | buf->signature = BUFVERSION_NULL; |
322 | buf->suite = NULL; |
||
485 | daniel-mar | 323 | } |
324 | gpb->sSPBasic->ReleaseSuite(kPSBufferSuite, kPSBufferSuiteVersion2); |
||
484 | daniel-mar | 325 | } |
485 | daniel-mar | 326 | else if ((gpb->sSPBasic != 0) && |
327 | (gpb->sSPBasic->AcquireSuite(kPSBufferSuite, kPSBufferSuiteVersion1, (const void**)&pSBufferSuite32) == noErr) && |
||
488 | daniel-mar | 328 | (pSBufferSuite32 != NULL) && |
329 | (pSBufferSuite32 != (PSBufferSuite1*)gpb->bufferProcs /* Just to be sure (although no bug is known) */) |
||
330 | ) |
||
485 | daniel-mar | 331 | { |
332 | // PICA Buffer Suite 1.0 (32 bit) |
||
505 | daniel-mar | 333 | unsigned32 siz = (unsigned32)nBytes; |
486 | daniel-mar | 334 | buf->signature = BUFVERSION_SUITE32; |
487 | daniel-mar | 335 | if (gdata) gdata->lastKnownBufferVersion = buf->signature; |
486 | daniel-mar | 336 | buf->suite = (Ptr)pSBufferSuite32->New(&siz, siz); |
485 | daniel-mar | 337 | if (siz < nBytes) { |
486 | daniel-mar | 338 | buf->signature = BUFVERSION_NULL; |
339 | buf->suite = NULL; |
||
485 | daniel-mar | 340 | } |
341 | gpb->sSPBasic->ReleaseSuite(kPSBufferSuite, kPSBufferSuiteVersion1); |
||
484 | daniel-mar | 342 | } |
485 | daniel-mar | 343 | else if (gpb->bufferProcs->numBufferProcs >= 8) |
344 | { |
||
345 | // Standard Buffer Suite 64 bit (deprecated) |
||
486 | daniel-mar | 346 | buf->signature = BUFVERSION_STD64; |
487 | daniel-mar | 347 | if (gdata) gdata->lastKnownBufferVersion = buf->signature; |
486 | daniel-mar | 348 | if (gpb->bufferProcs->allocateProc64(nBytes, &buf->standard) != noErr) { |
349 | buf->signature = BUFVERSION_NULL; |
||
350 | buf->standard = NULL; |
||
485 | daniel-mar | 351 | } |
352 | } |
||
353 | else |
||
354 | { |
||
355 | // Standard Buffer Suite 32 bit (deprecated) |
||
486 | daniel-mar | 356 | buf->signature = BUFVERSION_STD32; |
487 | daniel-mar | 357 | if (gdata) gdata->lastKnownBufferVersion = buf->signature; |
505 | daniel-mar | 358 | if (gpb->bufferProcs->allocateProc((int32)nBytes, &buf->standard) != noErr) { |
486 | daniel-mar | 359 | buf->signature = BUFVERSION_NULL; |
360 | buf->standard = NULL; |
||
485 | daniel-mar | 361 | } |
362 | } |
||
484 | daniel-mar | 363 | } |
364 | |||
486 | daniel-mar | 365 | Ptr lockBuffer(FFBuffer* buf) { |
488 | daniel-mar | 366 | const Boolean moveHigh = false; // Under the Mac OS, the moveHigh flag indicates whether you want the memory blocked moved |
367 | // to the high end of memory to avoid fragmentation. The moveHigh flag has no effect with Windows |
||
486 | daniel-mar | 368 | if (buf->signature == BUFVERSION_SUITE64) { |
369 | return buf->suite; |
||
485 | daniel-mar | 370 | } |
486 | daniel-mar | 371 | else if (buf->signature == BUFVERSION_SUITE32) { |
372 | return buf->suite; |
||
485 | daniel-mar | 373 | } |
486 | daniel-mar | 374 | else if (buf->signature == BUFVERSION_STD64) { |
488 | daniel-mar | 375 | return gpb->bufferProcs->lockProc(buf->standard, moveHigh); |
485 | daniel-mar | 376 | } |
486 | daniel-mar | 377 | else if (buf->signature == BUFVERSION_STD32) { |
488 | daniel-mar | 378 | return gpb->bufferProcs->lockProc(buf->standard, moveHigh); |
485 | daniel-mar | 379 | } |
380 | else { |
||
381 | return NULL; |
||
382 | } |
||
484 | daniel-mar | 383 | } |
384 | |||
486 | daniel-mar | 385 | void unlockBuffer(FFBuffer* buf) { |
386 | if (buf->signature == BUFVERSION_STD64) { |
||
387 | gpb->bufferProcs->unlockProc(buf->standard); |
||
485 | daniel-mar | 388 | } |
486 | daniel-mar | 389 | else if (buf->signature == BUFVERSION_STD32) { |
390 | gpb->bufferProcs->unlockProc(buf->standard); |
||
485 | daniel-mar | 391 | } |
484 | daniel-mar | 392 | } |
393 | |||
486 | daniel-mar | 394 | void disposeBuffer(FFBuffer* buf) { |
395 | if (buf->signature == BUFVERSION_SUITE64) { |
||
485 | daniel-mar | 396 | PSBufferSuite2* pSBufferSuite64 = NULL; |
397 | if ((gpb->sSPBasic != 0) && |
||
398 | (gpb->sSPBasic->AcquireSuite(kPSBufferSuite, kPSBufferSuiteVersion2, (const void**)&pSBufferSuite64) == noErr) && |
||
486 | daniel-mar | 399 | (pSBufferSuite64 != NULL) && |
400 | (pSBufferSuite64 != (PSBufferSuite2*)gpb->bufferProcs /*Implementation mistake in old Photoshop versions! (see note below)*/) |
||
401 | ) |
||
485 | daniel-mar | 402 | { |
403 | // PICA Buffer Suite 2.0 (64 bit) |
||
486 | daniel-mar | 404 | pSBufferSuite64->Dispose(&buf->suite); |
485 | daniel-mar | 405 | gpb->sSPBasic->ReleaseSuite(kPSBufferSuite, kPSBufferSuiteVersion2); |
406 | } |
||
407 | } |
||
486 | daniel-mar | 408 | else if (buf->signature == BUFVERSION_SUITE32) { |
485 | daniel-mar | 409 | PSBufferSuite1* pSBufferSuite32 = NULL; |
410 | if ((gpb->sSPBasic != 0) && |
||
411 | (gpb->sSPBasic->AcquireSuite(kPSBufferSuite, kPSBufferSuiteVersion1, (const void**)&pSBufferSuite32) == noErr) && |
||
412 | (pSBufferSuite32 != NULL)) |
||
413 | { |
||
414 | // PICA Buffer Suite 1.0 (32 bit) |
||
486 | daniel-mar | 415 | pSBufferSuite32->Dispose(&buf->suite); |
485 | daniel-mar | 416 | gpb->sSPBasic->ReleaseSuite(kPSBufferSuite, kPSBufferSuiteVersion1); |
417 | } |
||
418 | } |
||
486 | daniel-mar | 419 | else if (buf->signature == BUFVERSION_STD64) { |
420 | gpb->bufferProcs->freeProc(buf->standard); |
||
485 | daniel-mar | 421 | } |
486 | daniel-mar | 422 | else if (buf->signature == BUFVERSION_STD32) { |
423 | gpb->bufferProcs->freeProc(buf->standard); |
||
485 | daniel-mar | 424 | } |
486 | daniel-mar | 425 | buf->signature = BUFVERSION_NULL; |
484 | daniel-mar | 426 | } |