blob: 83e843e9896a505a0069f575d29a515c6491a94a [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% CCCC AAA CCCC H H EEEEE %
7% C A A C H H E %
8% C AAAAA C HHHHH EEE %
9% C A A C H H E %
10% CCCC A A CCCC H H EEEEE %
11% %
12% V V IIIII EEEEE W W %
13% V V I E W W %
14% V V I EEE W W W %
15% V V I E WW WW %
16% V IIIII EEEEE W W %
17% %
18% %
19% MagickCore Cache View Methods %
20% %
21% Software Design %
22% John Cristy %
23% February 2000 %
24% %
25% %
cristy7e41fe82010-12-04 23:12:08 +000026% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000027% dedicated to making software imaging solutions freely available. %
28% %
29% You may not use this file except in compliance with the License. You may %
30% obtain a copy of the License at %
31% %
32% http://www.imagemagick.org/script/license.php %
33% %
34% Unless required by applicable law or agreed to in writing, software %
35% distributed under the License is distributed on an "AS IS" BASIS, %
36% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37% See the License for the specific language governing permissions and %
38% limitations under the License. %
39% %
40%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41%
42%
43%
44*/
45
46/*
47 Include declarations.
48*/
49#include "magick/studio.h"
50#include "magick/cache.h"
51#include "magick/cache-private.h"
52#include "magick/cache-view.h"
53#include "magick/memory_.h"
54#include "magick/exception.h"
55#include "magick/exception-private.h"
56#include "magick/string_.h"
57#include "magick/thread-private.h"
58
59/*
60 Typedef declarations.
61*/
62struct _CacheView
63{
64 Image
65 *image;
66
67 VirtualPixelMethod
68 virtual_pixel_method;
69
cristybb503372010-05-27 20:51:26 +000070 size_t
cristy3ed852e2009-09-05 21:47:34 +000071 number_threads;
72
73 NexusInfo
74 **nexus_info;
75
76 MagickBooleanType
77 debug;
78
cristybb503372010-05-27 20:51:26 +000079 size_t
cristy3ed852e2009-09-05 21:47:34 +000080 signature;
81};
82
83/*
84%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85% %
86% %
87% %
88% A c q u i r e C a c h e V i e w %
89% %
90% %
91% %
92%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93%
94% AcquireCacheView() acquires a view into the pixel cache, using the
95% VirtualPixelMethod that is defined within the given image itself.
96%
97% The format of the AcquireCacheView method is:
98%
99% CacheView *AcquireCacheView(const Image *image)
100%
101% A description of each parameter follows:
102%
103% o image: the image.
104%
105*/
106MagickExport CacheView *AcquireCacheView(const Image *image)
107{
108 CacheView
109 *cache_view;
110
111 assert(image != (Image *) NULL);
112 assert(image->signature == MagickSignature);
113 if (image->debug != MagickFalse)
114 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
cristy73bd4a52010-10-05 11:24:23 +0000115 cache_view=(CacheView *) AcquireMagickMemory(sizeof(*cache_view));
cristy3ed852e2009-09-05 21:47:34 +0000116 if (cache_view == (CacheView *) NULL)
117 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
118 (void) ResetMagickMemory(cache_view,0,sizeof(*cache_view));
119 cache_view->image=ReferenceImage((Image *) image);
120 cache_view->number_threads=GetOpenMPMaximumThreads();
121 cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
122 cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
123 cache_view->debug=IsEventLogging();
124 cache_view->signature=MagickSignature;
125 if (cache_view->nexus_info == (NexusInfo **) NULL)
126 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
127 return(cache_view);
128}
129
130/*
131%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132% %
133% %
134% %
135% C l o n e C a c h e V i e w %
136% %
137% %
138% %
139%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
140%
141% CloneCacheView() makes an exact copy of the specified cache view.
142%
143% The format of the CloneCacheView method is:
144%
145% CacheView *CloneCacheView(const CacheView *cache_view)
146%
147% A description of each parameter follows:
148%
149% o cache_view: the cache view.
150%
151*/
152MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
153{
154 CacheView
155 *clone_view;
156
157 assert(cache_view != (CacheView *) NULL);
158 assert(cache_view->signature == MagickSignature);
159 if (cache_view->debug != MagickFalse)
160 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
161 cache_view->image->filename);
cristy73bd4a52010-10-05 11:24:23 +0000162 clone_view=(CacheView *) AcquireMagickMemory(sizeof(*clone_view));
cristy3ed852e2009-09-05 21:47:34 +0000163 if (clone_view == (CacheView *) NULL)
164 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
165 (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
166 clone_view->image=ReferenceImage(cache_view->image);
167 clone_view->number_threads=cache_view->number_threads;
168 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
169 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
170 clone_view->debug=cache_view->debug;
171 clone_view->signature=MagickSignature;
172 return(clone_view);
173}
174
175/*
176%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177% %
178% %
179% %
180% D e s t r o y C a c h e V i e w %
181% %
182% %
183% %
184%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
185%
186% DestroyCacheView() destroys the specified view returned by a previous call
187% to AcquireCacheView().
188%
189% The format of the DestroyCacheView method is:
190%
191% CacheView *DestroyCacheView(CacheView *cache_view)
192%
193% A description of each parameter follows:
194%
195% o cache_view: the cache view.
196%
197*/
198MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
199{
200 assert(cache_view != (CacheView *) NULL);
201 assert(cache_view->signature == MagickSignature);
202 if (cache_view->debug != MagickFalse)
203 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
204 cache_view->image->filename);
205 if (cache_view->nexus_info != (NexusInfo **) NULL)
206 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
207 cache_view->number_threads);
208 cache_view->image=DestroyImage(cache_view->image);
209 cache_view->signature=(~MagickSignature);
cristyb41ee102010-10-04 16:46:15 +0000210 cache_view=(CacheView *) RelinquishMagickMemory(cache_view);
cristy3ed852e2009-09-05 21:47:34 +0000211 return(cache_view);
212}
213
214/*
215%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216% %
217% %
218% %
cristy0d267172011-04-25 20:13:48 +0000219% G e t C a c h e V i e w C h a n n e l s %
220% %
221% %
222% %
223%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
224%
225% GetCacheViewChannels() returns the image pixel channels associated with
226% the specified view.
227%
228% The format of the GetCacheViewChannels method is:
229%
230% size_t GetCacheViewChannels(const CacheView *cache_view)
231%
232% A description of each parameter follows:
233%
234% o cache_view: the cache view.
235%
236*/
237MagickExport size_t GetCacheViewChannels(const CacheView *cache_view)
238{
239 assert(cache_view != (CacheView *) NULL);
240 assert(cache_view->signature == MagickSignature);
241 if (cache_view->debug != MagickFalse)
242 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
243 cache_view->image->filename);
244 return(GetPixelCacheChannels(cache_view->image->cache));
245}
246
247/*
248%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
249% %
250% %
251% %
cristy3ed852e2009-09-05 21:47:34 +0000252% G e t C a c h e V i e w C o l o r s p a c e %
253% %
254% %
255% %
256%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
257%
258% GetCacheViewColorspace() returns the image colorspace associated with the
259% specified view.
260%
261% The format of the GetCacheViewColorspace method is:
262%
263% ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
264%
265% A description of each parameter follows:
266%
267% o cache_view: the cache view.
268%
269*/
270MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
271{
272 assert(cache_view != (CacheView *) NULL);
273 assert(cache_view->signature == MagickSignature);
274 if (cache_view->debug != MagickFalse)
275 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
276 cache_view->image->filename);
cristy0d267172011-04-25 20:13:48 +0000277 return(GetPixelCacheColorspace(cache_view->image->cache));
cristy3ed852e2009-09-05 21:47:34 +0000278}
279
280/*
281%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282% %
283% %
284% %
285% G e t C a c h e V i e w E x c e p t i o n %
286% %
287% %
288% %
289%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
290%
291% GetCacheViewException() returns the image exception associated with the
292% specified view.
293%
294% The format of the GetCacheViewException method is:
295%
296% ExceptionInfo GetCacheViewException(const CacheView *cache_view)
297%
298% A description of each parameter follows:
299%
300% o cache_view: the cache view.
301%
302*/
303MagickExport ExceptionInfo *GetCacheViewException(const CacheView *cache_view)
304{
305 assert(cache_view != (CacheView *) NULL);
306 assert(cache_view->signature == MagickSignature);
307 if (cache_view->debug != MagickFalse)
308 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
309 cache_view->image->filename);
310 return(&cache_view->image->exception);
311}
312
313/*
314%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315% %
316% %
317% %
318+ G e t C a c h e V i e w E x t e n t %
319% %
320% %
321% %
322%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
323%
324% GetCacheViewExtent() returns the extent of the pixels associated with the
325% last call to QueueCacheViewAuthenticPixels() or
326% GetCacheViewAuthenticPixels().
327%
328% The format of the GetCacheViewExtent() method is:
329%
330% MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
331%
332% A description of each parameter follows:
333%
334% o cache_view: the cache view.
335%
336*/
337MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
338{
cristy5c9e6f22010-09-17 17:31:01 +0000339 const int
340 id = GetOpenMPThreadId();
cristy4205a3c2010-09-12 20:19:59 +0000341
cristy3ed852e2009-09-05 21:47:34 +0000342 assert(cache_view != (CacheView *) NULL);
343 assert(cache_view->signature == MagickSignature);
344 if (cache_view->debug != MagickFalse)
345 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
346 cache_view->image->filename);
347 assert(cache_view->image->cache != (Cache) NULL);
cristy4205a3c2010-09-12 20:19:59 +0000348 assert(id < (int) cache_view->number_threads);
cristyf54fb572010-09-17 20:08:14 +0000349 return(GetPixelCacheNexusExtent(cache_view->image->cache,
350 cache_view->nexus_info[id]));
cristy3ed852e2009-09-05 21:47:34 +0000351}
352
353/*
354%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
355% %
356% %
357% %
358% G e t C a c h e V i e w S t o r a g e C l a s s %
359% %
360% %
361% %
362%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
363%
364% GetCacheViewStorageClass() returns the image storage class associated with
365% the specified view.
366%
367% The format of the GetCacheViewStorageClass method is:
368%
369% ClassType GetCacheViewStorageClass(const CacheView *cache_view)
370%
371% A description of each parameter follows:
372%
373% o cache_view: the cache view.
374%
375*/
376MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
377{
378 assert(cache_view != (CacheView *) NULL);
379 assert(cache_view->signature == MagickSignature);
380 if (cache_view->debug != MagickFalse)
381 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
382 cache_view->image->filename);
cristy0d267172011-04-25 20:13:48 +0000383 return(GetPixelCacheStorageClass(cache_view->image->cache));
cristy3ed852e2009-09-05 21:47:34 +0000384}
385
386/*
387%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
388% %
389% %
390% %
391% G e t C a c h e V i e w A u t h e n t i c P i x e l s %
392% %
393% %
394% %
395%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
396%
397% GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
398% cache as defined by the geometry parameters. A pointer to the pixels is
399% returned if the pixels are transferred, otherwise a NULL is returned.
400%
401% The format of the GetCacheViewAuthenticPixels method is:
402%
403% PixelPacket *GetCacheViewAuthenticPixels(CacheView *cache_view,
cristybb503372010-05-27 20:51:26 +0000404% const ssize_t x,const ssize_t y,const size_t columns,
405% const size_t rows,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000406%
407% A description of each parameter follows:
408%
409% o cache_view: the cache view.
410%
411% o x,y,columns,rows: These values define the perimeter of a region of
412% pixels.
413%
414*/
415MagickExport PixelPacket *GetCacheViewAuthenticPixels(CacheView *cache_view,
cristy30097232010-07-01 02:16:30 +0000416 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
417 ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000418{
cristy5c9e6f22010-09-17 17:31:01 +0000419 const int
420 id = GetOpenMPThreadId();
cristy4205a3c2010-09-12 20:19:59 +0000421
cristy3ed852e2009-09-05 21:47:34 +0000422 assert(cache_view != (CacheView *) NULL);
423 assert(cache_view->signature == MagickSignature);
cristy4205a3c2010-09-12 20:19:59 +0000424 assert(id < (int) cache_view->number_threads);
cristyf54fb572010-09-17 20:08:14 +0000425 return(GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
426 cache_view->nexus_info[id],exception));
cristy3ed852e2009-09-05 21:47:34 +0000427}
428
429/*
430%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
431% %
432% %
433% %
434% G e t O n e C a c h e V i e w A u t h e n t i c P i x e l %
435% %
436% %
437% %
438%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
439%
440% GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
441% location. The image background color is returned if an error occurs.
442%
443% The format of the GetOneCacheViewAuthenticPixel method is:
444%
445% MagickBooleaNType GetOneCacheViewAuthenticPixel(
cristybb503372010-05-27 20:51:26 +0000446% const CacheView *cache_view,const ssize_t x,const ssize_t y,
cristy3ed852e2009-09-05 21:47:34 +0000447% Pixelpacket *pixel,ExceptionInfo *exception)
448%
449% A description of each parameter follows:
450%
451% o cache_view: the cache view.
452%
453% o x,y: These values define the offset of the pixel.
454%
455% o pixel: return a pixel at the specified (x,y) location.
456%
457% o exception: return any errors or warnings in this structure.
458%
459*/
460MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
cristy30097232010-07-01 02:16:30 +0000461 const CacheView *cache_view,const ssize_t x,const ssize_t y,
462 PixelPacket *pixel,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000463{
cristy5c9e6f22010-09-17 17:31:01 +0000464 const int
465 id = GetOpenMPThreadId();
cristy4205a3c2010-09-12 20:19:59 +0000466
cristy3ed852e2009-09-05 21:47:34 +0000467 PixelPacket
468 *pixels;
469
470 assert(cache_view != (CacheView *) NULL);
471 assert(cache_view->signature == MagickSignature);
cristy3ed852e2009-09-05 21:47:34 +0000472 *pixel=cache_view->image->background_color;
cristy4205a3c2010-09-12 20:19:59 +0000473 assert(id < (int) cache_view->number_threads);
cristy3ed852e2009-09-05 21:47:34 +0000474 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
475 cache_view->nexus_info[id],exception);
476 if (pixels == (const PixelPacket *) NULL)
477 return(MagickFalse);
478 *pixel=(*pixels);
479 return(MagickTrue);
480}
481
482/*
483%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
484% %
485% %
486% %
487% G e t C a c h e V i e w A u t h e n t i c I n d e x Q u e u e %
488% %
489% %
490% %
491%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
492%
493% GetCacheViewAuthenticIndexQueue() returns the indexes associated with the
494% last call to SetCacheViewIndexes() or GetCacheViewAuthenticIndexQueue(). The
495% indexes are authentic and can be updated.
496%
497% The format of the GetCacheViewAuthenticIndexQueue() method is:
498%
499% IndexPacket *GetCacheViewAuthenticIndexQueue(CacheView *cache_view)
500%
501% A description of each parameter follows:
502%
503% o cache_view: the cache view.
504%
505*/
506MagickExport IndexPacket *GetCacheViewAuthenticIndexQueue(CacheView *cache_view)
507{
cristy5c9e6f22010-09-17 17:31:01 +0000508 const int
509 id = GetOpenMPThreadId();
510
cristy3ed852e2009-09-05 21:47:34 +0000511 assert(cache_view != (CacheView *) NULL);
512 assert(cache_view->signature == MagickSignature);
cristy3ed852e2009-09-05 21:47:34 +0000513 assert(cache_view->image->cache != (Cache) NULL);
cristy4205a3c2010-09-12 20:19:59 +0000514 assert(id < (int) cache_view->number_threads);
cristyf54fb572010-09-17 20:08:14 +0000515 return(GetPixelCacheNexusIndexes(cache_view->image->cache,
516 cache_view->nexus_info[id]));
cristy3ed852e2009-09-05 21:47:34 +0000517}
518
519/*
520%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
521% %
522% %
523% %
524% G e t C a c h e V i e w A u t h e n t i c P i x e l Q u e u e %
525% %
526% %
527% %
528%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
529%
530% GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
531% last call to QueueCacheViewAuthenticPixels() or
532% GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
533% updated.
534%
535% The format of the GetCacheViewAuthenticPixelQueue() method is:
536%
537% PixelPacket *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
538%
539% A description of each parameter follows:
540%
541% o cache_view: the cache view.
542%
543*/
544MagickExport PixelPacket *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
545{
cristy5c9e6f22010-09-17 17:31:01 +0000546 const int
547 id = GetOpenMPThreadId();
cristy4205a3c2010-09-12 20:19:59 +0000548
cristy3ed852e2009-09-05 21:47:34 +0000549 assert(cache_view != (CacheView *) NULL);
550 assert(cache_view->signature == MagickSignature);
cristy3ed852e2009-09-05 21:47:34 +0000551 assert(cache_view->image->cache != (Cache) NULL);
cristy4205a3c2010-09-12 20:19:59 +0000552 assert(id < (int) cache_view->number_threads);
cristyf54fb572010-09-17 20:08:14 +0000553 return(GetPixelCacheNexusPixels(cache_view->image->cache,
554 cache_view->nexus_info[id]));
cristy3ed852e2009-09-05 21:47:34 +0000555}
556
557/*
558%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
559% %
560% %
561% %
562% G e t C a c h e V i e w V i r t u a l I n d e x Q u e u e %
563% %
564% %
565% %
566%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
567%
568% GetCacheViewVirtualIndexQueue() returns the indexes associated with the
569% last call to GetCacheViewVirtualIndexQueue(). The indexes are virtual and
570% therefore cannot be updated.
571%
572% The format of the GetCacheViewVirtualIndexQueue() method is:
573%
574% const IndexPacket *GetCacheViewVirtualIndexQueue(
575% const CacheView *cache_view)
576%
577% A description of each parameter follows:
578%
579% o cache_view: the cache view.
580%
581*/
582MagickExport const IndexPacket *GetCacheViewVirtualIndexQueue(
583 const CacheView *cache_view)
584{
cristy5c9e6f22010-09-17 17:31:01 +0000585 const int
586 id = GetOpenMPThreadId();
cristy3ed852e2009-09-05 21:47:34 +0000587
588 assert(cache_view != (const CacheView *) NULL);
589 assert(cache_view->signature == MagickSignature);
cristy3ed852e2009-09-05 21:47:34 +0000590 assert(cache_view->image->cache != (Cache) NULL);
cristy4205a3c2010-09-12 20:19:59 +0000591 assert(id < (int) cache_view->number_threads);
cristyf54fb572010-09-17 20:08:14 +0000592 return(GetVirtualIndexesFromNexus(cache_view->image->cache,
593 cache_view->nexus_info[id]));
cristy3ed852e2009-09-05 21:47:34 +0000594}
595
596/*
597%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598% %
599% %
600% %
601% G e t C a c h e V i e w V i r t u a l P i x e l Q u e u e %
602% %
603% %
604% %
605%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
606%
607% GetCacheViewVirtualPixelQueue() returns the the pixels associated with
608% the last call to GetCacheViewVirtualPixels(). The pixels are virtual
609% and therefore cannot be updated.
610%
611% The format of the GetCacheViewVirtualPixelQueue() method is:
612%
613% const PixelPacket *GetCacheViewVirtualPixelQueue(
614% const CacheView *cache_view)
615%
616% A description of each parameter follows:
617%
618% o cache_view: the cache view.
619%
620*/
621MagickExport const PixelPacket *GetCacheViewVirtualPixelQueue(
622 const CacheView *cache_view)
623{
cristy5c9e6f22010-09-17 17:31:01 +0000624 const int
625 id = GetOpenMPThreadId();
626
cristy3ed852e2009-09-05 21:47:34 +0000627 assert(cache_view != (const CacheView *) NULL);
628 assert(cache_view->signature == MagickSignature);
cristy3ed852e2009-09-05 21:47:34 +0000629 assert(cache_view->image->cache != (Cache) NULL);
cristy4205a3c2010-09-12 20:19:59 +0000630 assert(id < (int) cache_view->number_threads);
cristyf54fb572010-09-17 20:08:14 +0000631 return(GetVirtualPixelsNexus(cache_view->image->cache,
632 cache_view->nexus_info[id]));
cristy3ed852e2009-09-05 21:47:34 +0000633}
634
635/*
636%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
637% %
638% %
639% %
640% G e t C a c h e V i e w V i r t u a l P i x e l s %
641% %
642% %
643% %
644%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
645%
646% GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
647% disk pixel cache as defined by the geometry parameters. A pointer to the
648% pixels is returned if the pixels are transferred, otherwise a NULL is
649% returned.
650%
651% The format of the GetCacheViewVirtualPixels method is:
652%
653% const PixelPacket *GetCacheViewVirtualPixels(
cristybb503372010-05-27 20:51:26 +0000654% const CacheView *cache_view,const ssize_t x,const ssize_t y,
cristye076a6e2010-08-15 19:59:43 +0000655% const size_t columns,const size_t rows,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000656%
657% A description of each parameter follows:
658%
659% o cache_view: the cache view.
660%
661% o x,y,columns,rows: These values define the perimeter of a region of
662% pixels.
663%
664% o exception: return any errors or warnings in this structure.
665%
666*/
667MagickExport const PixelPacket *GetCacheViewVirtualPixels(
cristybb503372010-05-27 20:51:26 +0000668 const CacheView *cache_view,const ssize_t x,const ssize_t y,
669 const size_t columns,const size_t rows,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000670{
cristy5c9e6f22010-09-17 17:31:01 +0000671 const int
672 id = GetOpenMPThreadId();
673
cristy3ed852e2009-09-05 21:47:34 +0000674 assert(cache_view != (CacheView *) NULL);
675 assert(cache_view->signature == MagickSignature);
cristy4205a3c2010-09-12 20:19:59 +0000676 assert(id < (int) cache_view->number_threads);
cristyf54fb572010-09-17 20:08:14 +0000677 return(GetVirtualPixelsFromNexus(cache_view->image,
cristy3ed852e2009-09-05 21:47:34 +0000678 cache_view->virtual_pixel_method,x,y,columns,rows,
cristyf54fb572010-09-17 20:08:14 +0000679 cache_view->nexus_info[id],exception));
cristy3ed852e2009-09-05 21:47:34 +0000680}
681
682/*
683%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
684% %
685% %
686% %
687% G e t O n e C a c h e V i e w V i r t u a l P i x e l %
688% %
689% %
690% %
691%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
692%
693% GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
694% location. The image background color is returned if an error occurs. If
695% you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
696%
697% The format of the GetOneCacheViewVirtualPixel method is:
698%
699% MagickBooleanType GetOneCacheViewVirtualPixel(
cristybb503372010-05-27 20:51:26 +0000700% const CacheView *cache_view,const ssize_t x,const ssize_t y,
cristy3ed852e2009-09-05 21:47:34 +0000701% PixelPacket *pixel,ExceptionInfo *exception)
702%
703% A description of each parameter follows:
704%
705% o cache_view: the cache view.
706%
707% o x,y: These values define the offset of the pixel.
708%
709% o pixel: return a pixel at the specified (x,y) location.
710%
711% o exception: return any errors or warnings in this structure.
712%
713*/
714MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
cristy30097232010-07-01 02:16:30 +0000715 const CacheView *cache_view,const ssize_t x,const ssize_t y,
716 PixelPacket *pixel,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000717{
cristy5c9e6f22010-09-17 17:31:01 +0000718 const int
719 id = GetOpenMPThreadId();
720
cristy3ed852e2009-09-05 21:47:34 +0000721 const PixelPacket
722 *pixels;
723
cristy3ed852e2009-09-05 21:47:34 +0000724 assert(cache_view != (CacheView *) NULL);
725 assert(cache_view->signature == MagickSignature);
cristy3ed852e2009-09-05 21:47:34 +0000726 *pixel=cache_view->image->background_color;
cristy4205a3c2010-09-12 20:19:59 +0000727 assert(id < (int) cache_view->number_threads);
cristy3ed852e2009-09-05 21:47:34 +0000728 pixels=GetVirtualPixelsFromNexus(cache_view->image,
729 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
730 exception);
731 if (pixels == (const PixelPacket *) NULL)
732 return(MagickFalse);
733 *pixel=(*pixels);
734 return(MagickTrue);
735}
736
737/*
738%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
739% %
740% %
741% %
742% G e t O n e C a c h e V i e w V i r t u a l P i x e l %
743% %
744% %
745% %
746%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
747%
748% GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
749% the specified (x,y) location. The image background color is returned if an
750% error occurs. If you plan to modify the pixel, use
751% GetOneCacheViewAuthenticPixel() instead.
752%
753% The format of the GetOneCacheViewVirtualPixel method is:
754%
755% MagickBooleanType GetOneCacheViewVirtualMethodPixel(
756% const CacheView *cache_view,
cristybb503372010-05-27 20:51:26 +0000757% const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
758% const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000759%
760% A description of each parameter follows:
761%
762% o cache_view: the cache view.
763%
764% o virtual_pixel_method: the virtual pixel method.
765%
766% o x,y: These values define the offset of the pixel.
767%
768% o pixel: return a pixel at the specified (x,y) location.
769%
770% o exception: return any errors or warnings in this structure.
771%
772*/
773MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
774 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
cristybb503372010-05-27 20:51:26 +0000775 const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000776{
cristy5c9e6f22010-09-17 17:31:01 +0000777 const int
778 id = GetOpenMPThreadId();
779
cristy3ed852e2009-09-05 21:47:34 +0000780 const PixelPacket
781 *pixels;
782
cristy3ed852e2009-09-05 21:47:34 +0000783 assert(cache_view != (CacheView *) NULL);
784 assert(cache_view->signature == MagickSignature);
cristy3ed852e2009-09-05 21:47:34 +0000785 *pixel=cache_view->image->background_color;
cristy4205a3c2010-09-12 20:19:59 +0000786 assert(id < (int) cache_view->number_threads);
cristy3ed852e2009-09-05 21:47:34 +0000787 pixels=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,
788 1,cache_view->nexus_info[id],exception);
789 if (pixels == (const PixelPacket *) NULL)
790 return(MagickFalse);
791 *pixel=(*pixels);
792 return(MagickTrue);
793}
794
795/*
796%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
797% %
798% %
799% %
800% Q u e u e C a c h e V i e w A u t h e n t i c P i x e l s %
801% %
802% %
803% %
804%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
805%
806% QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
807% disk pixel cache as defined by the geometry parameters. A pointer to the
808% pixels is returned if the pixels are transferred, otherwise a NULL is
809% returned.
810%
811% The format of the QueueCacheViewAuthenticPixels method is:
812%
813% PixelPacket *QueueCacheViewAuthenticPixels(CacheView *cache_view,
cristybb503372010-05-27 20:51:26 +0000814% const ssize_t x,const ssize_t y,const size_t columns,
815% const size_t rows,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000816%
817% A description of each parameter follows:
818%
819% o cache_view: the cache view.
820%
821% o x,y,columns,rows: These values define the perimeter of a region of
822% pixels.
823%
824% o exception: return any errors or warnings in this structure.
825%
826*/
827MagickExport PixelPacket *QueueCacheViewAuthenticPixels(CacheView *cache_view,
cristy30097232010-07-01 02:16:30 +0000828 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
829 ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000830{
cristy5c9e6f22010-09-17 17:31:01 +0000831 const int
832 id = GetOpenMPThreadId();
cristy4205a3c2010-09-12 20:19:59 +0000833
cristy3ed852e2009-09-05 21:47:34 +0000834 assert(cache_view != (CacheView *) NULL);
835 assert(cache_view->signature == MagickSignature);
cristy4205a3c2010-09-12 20:19:59 +0000836 assert(id < (int) cache_view->number_threads);
cristyf54fb572010-09-17 20:08:14 +0000837 return(QueueAuthenticNexus(cache_view->image,x,y,columns,rows,
838 cache_view->nexus_info[id],exception));
cristy3ed852e2009-09-05 21:47:34 +0000839}
840
841/*
842%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
843% %
844% %
845% %
846% S e t C a c h e V i e w S t o r a g e C l a s s %
847% %
848% %
849% %
850%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
851%
852% SetCacheViewStorageClass() sets the image storage class associated with
853% the specified view.
854%
855% The format of the SetCacheViewStorageClass method is:
856%
857% MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
858% const ClassType storage_class)
859%
860% A description of each parameter follows:
861%
862% o cache_view: the cache view.
863%
864% o storage_class: the image storage class: PseudoClass or DirectClass.
865%
866*/
867MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
868 const ClassType storage_class)
869{
870 assert(cache_view != (CacheView *) NULL);
871 assert(cache_view->signature == MagickSignature);
872 if (cache_view->debug != MagickFalse)
873 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
874 cache_view->image->filename);
875 return(SetImageStorageClass(cache_view->image,storage_class));
876}
877
878/*
879%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
880% %
881% %
882% %
883% S e t C a c h e V i e w V i r t u a l P i x e l M e t h o d %
884% %
885% %
886% %
887%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
888%
889% SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
890% with the specified cache view.
891%
892% The format of the SetCacheViewVirtualPixelMethod method is:
893%
894% MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
895% const VirtualPixelMethod virtual_pixel_method)
896%
897% A description of each parameter follows:
898%
899% o cache_view: the cache view.
900%
901% o virtual_pixel_method: the virtual pixel method.
902%
903*/
904MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
905 CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method)
906{
907 assert(cache_view != (CacheView *) NULL);
908 assert(cache_view->signature == MagickSignature);
909 if (cache_view->debug != MagickFalse)
910 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
911 cache_view->image->filename);
912 cache_view->virtual_pixel_method=virtual_pixel_method;
913 return(MagickTrue);
914}
915
916/*
917%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
918% %
919% %
920% %
921% S y n c C a c h e V i e w A u t h e n t i c P i x e l s %
922% %
923% %
924% %
925%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
926%
927% SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
928% or disk cache. It returns MagickTrue if the pixel region is flushed,
929% otherwise MagickFalse.
930%
931% The format of the SyncCacheViewAuthenticPixels method is:
932%
933% MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
934% ExceptionInfo *exception)
935%
936% A description of each parameter follows:
937%
938% o cache_view: the cache view.
939%
940% o exception: return any errors or warnings in this structure.
941%
942*/
943MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
944 CacheView *cache_view,ExceptionInfo *exception)
945{
cristy5c9e6f22010-09-17 17:31:01 +0000946 const int
947 id = GetOpenMPThreadId();
cristy4205a3c2010-09-12 20:19:59 +0000948
cristy3ed852e2009-09-05 21:47:34 +0000949 assert(cache_view != (CacheView *) NULL);
950 assert(cache_view->signature == MagickSignature);
cristy4205a3c2010-09-12 20:19:59 +0000951 assert(id < (int) cache_view->number_threads);
cristyf54fb572010-09-17 20:08:14 +0000952 return(SyncAuthenticPixelCacheNexus(cache_view->image,
953 cache_view->nexus_info[id],exception));
cristy3ed852e2009-09-05 21:47:34 +0000954}