Changeset 11599
- Timestamp:
- 07/09/08 09:37:30 (7 weeks ago)
- Location:
- ImageMagick/trunk/magick
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
ImageMagick/trunk/magick/cache.c
r11579 r11599 579 579 } 580 580 } 581 if (p == (const PixelPacket *) NULL)581 if (p == (const PixelPacket *) NULL) 582 582 break; 583 583 *q++=(*p); … … 1210 1210 % 1211 1211 % MagickBooleanType CloneCacheNexus(CacheInfo *destination, 1212 % CacheInfo *source ,const unsigned long nexus)1212 % CacheInfo *source) 1213 1213 % 1214 1214 % A description of each parameter follows: … … 1217 1217 % 1218 1218 % o source: the source cache nexus. 1219 %1220 % o nexus: specifies which cache nexus to clone.1221 1219 % 1222 1220 */ … … 1243 1241 1244 1242 static MagickBooleanType CloneCacheNexus(CacheInfo *destination, 1245 CacheInfo *source ,const unsigned long nexus)1243 CacheInfo *source) 1246 1244 { 1247 1245 MagickSizeType … … 1285 1283 q->indexes=(IndexPacket *) NULL; 1286 1284 number_pixels=(MagickSizeType) q->columns*q->rows; 1287 if ((destination->storage_class == PseudoClass) || 1288 (destination->colorspace == CMYKColorspace)) 1285 if (p->indexes != (IndexPacket *) NULL) 1289 1286 q->indexes=(IndexPacket *) (q->pixels+number_pixels); 1290 1287 } 1288 if (0) 1289 DestroyCacheNexus(source,id); 1291 1290 } 1292 if (nexus != 0)1293 DestroyCacheNexus(source,nexus);1294 1291 return(MagickTrue); 1295 1292 } … … 3346 3343 % The format of the ModifyCache method is: 3347 3344 % 3348 % MagickBooleanType ModifyCache(Image *image ,const unsigned long nexus)3345 % MagickBooleanType ModifyCache(Image *image) 3349 3346 % 3350 3347 % A description of each parameter follows: … … 3352 3349 % o image: the image. 3353 3350 % 3354 % o nexus: specifies which cache nexus to acquire. 3355 % 3356 */ 3357 static MagickBooleanType ModifyCache(Image *image,const unsigned long nexus) 3351 */ 3352 static MagickBooleanType ModifyCache(Image *image) 3358 3353 { 3359 3354 CacheInfo … … 3364 3359 clone_image; 3365 3360 3366 Magick StatusType3361 MagickBooleanType 3367 3362 status; 3368 3363 … … 3380 3375 (void) GetCacheInfo(&image->cache); 3381 3376 (void) SetCacheVirtualPixelMethod(image,clone_info->virtual_pixel_method); 3382 status=OpenCache(image,IOMode,&image->exception); 3377 cache_info=(CacheInfo *) image->cache; 3378 status=CloneCacheNexus(cache_info,clone_info); 3383 3379 if (status != MagickFalse) 3384 3380 { 3385 cache_info=(CacheInfo *) image->cache;3386 status=CloneCacheNexus(cache_info,clone_info,nexus);3387 status|=ClonePixelCache(cache_info,clone_info,&image->exception);3388 } 3389 return(status != 0 ? MagickTrue : MagickFalse);3381 status=OpenCache(image,IOMode,&image->exception); 3382 if (status != MagickFalse) 3383 status=ClonePixelCache(cache_info,clone_info,&image->exception); 3384 } 3385 return(status); 3390 3386 } 3391 3387 … … 3714 3710 pagesize; 3715 3711 3716 Magick StatusType3712 MagickBooleanType 3717 3713 status; 3718 3714 … … 3787 3783 cache_info->type=DiskCache; 3788 3784 cache_info->offset=(*offset); 3789 status=OpenCache(image,IOMode,exception); 3785 cache_info=(CacheInfo *) image->cache; 3786 status=CloneCacheNexus(cache_info,clone_info); 3790 3787 if (status != MagickFalse) 3791 3788 { 3792 cache_info=(CacheInfo *) image->cache;3793 status=CloneCacheNexus(cache_info,clone_info,0);3794 status|=ClonePixelCache(cache_info,clone_info,&image->exception);3789 status=OpenCache(image,IOMode,exception); 3790 if (status != MagickFalse) 3791 status=ClonePixelCache(cache_info,clone_info,&image->exception); 3795 3792 } 3796 3793 *offset+=cache_info->length+pagesize-(cache_info->length % pagesize); 3797 3794 clone_info=(CacheInfo *) DestroyCacheInfo(clone_info); 3798 return(status != 0 ? MagickTrue : MagickFalse);3795 return(status); 3799 3796 } 3800 3797 … … 4211 4208 % 4212 4209 */ 4213 4214 static inline MagickBooleanType IsCacheSynchronized(const Image *image)4215 {4216 CacheInfo4217 *cache_info;4218 4219 MagickBooleanType4220 status;4221 4222 cache_info=(CacheInfo *) image->cache;4223 status=(image->storage_class == cache_info->storage_class) &&4224 (image->colorspace == cache_info->colorspace) &&4225 (image->columns == cache_info->columns) &&4226 (image->rows == cache_info->rows) &&4227 (cache_info->number_views != 0) ? MagickTrue : MagickFalse;4228 return(status);4229 }4230 4231 4210 MagickExport PixelPacket *SetCacheNexus(Image *image,const long x,const long y, 4232 4211 const unsigned long columns,const unsigned long rows, … … 4245 4224 region; 4246 4225 4247 assert(image != (Image *) NULL);4248 assert(image->signature == MagickSignature);4249 if (image->debug != MagickFalse)4250 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);4251 assert(image->cache != (Cache) NULL);4252 cache_info=(CacheInfo *) image->cache;4253 if ((cache_info->reference_count > 1) ||4254 (IsCacheSynchronized(image) == MagickFalse))4255 {4256 AcquireSemaphoreInfo(&cache_info->semaphore);4257 if (ModifyCache(image,nexus) == MagickFalse)4258 {4259 RelinquishSemaphoreInfo(cache_info->semaphore);4260 return((PixelPacket *) NULL);4261 }4262 if (SyncCache(image) == MagickFalse)4263 {4264 RelinquishSemaphoreInfo(cache_info->semaphore);4265 return((PixelPacket *) NULL);4266 }4267 RelinquishSemaphoreInfo(cache_info->semaphore);4268 }4269 4226 /* 4270 4227 Validate pixel cache geometry. 4271 4228 */ 4229 if (SyncImagePixelCache(image) == MagickFalse) 4230 return((PixelPacket *) NULL); 4272 4231 cache_info=(CacheInfo *) image->cache; 4273 4232 offset=(MagickOffsetType) y*cache_info->columns+x; … … 4334 4293 cache_info->virtual_pixel_method=virtual_pixel_method; 4335 4294 return(method); 4295 } 4296 4297 /* 4298 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4299 % % 4300 % % 4301 % % 4302 % S y n c I m a g e P i x e l C a c h e % 4303 % % 4304 % % 4305 % % 4306 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4307 % 4308 % SyncImagePixelCache() ensures that the pixel cache morphology matches that 4309 % of the image, in particular, the image storage class, colorspace, width, 4310 % and height. 4311 % 4312 % The format of the SetPixelCache() method is: 4313 % 4314 % MagickBooleanType SyncImagePixelCache(Image *image) 4315 % 4316 % A description of each parameter follows: 4317 % 4318 % o image: the image. 4319 % 4320 */ 4321 4322 static inline MagickBooleanType IsCacheSynchronized(const Image *image) 4323 { 4324 CacheInfo 4325 *cache_info; 4326 4327 MagickBooleanType 4328 status; 4329 4330 cache_info=(CacheInfo *) image->cache; 4331 status=(image->storage_class == cache_info->storage_class) && 4332 (image->colorspace == cache_info->colorspace) && 4333 (image->columns == cache_info->columns) && 4334 (image->rows == cache_info->rows) && 4335 (cache_info->number_views != 0) ? MagickTrue : MagickFalse; 4336 return(status); 4337 } 4338 4339 MagickExport MagickBooleanType SyncImagePixelCache(Image *image) 4340 { 4341 CacheInfo 4342 *cache_info; 4343 4344 MagickBooleanType 4345 status; 4346 4347 assert(image != (Image *) NULL); 4348 assert(image->signature == MagickSignature); 4349 if (image->debug != MagickFalse) 4350 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 4351 assert(image->cache != (Cache) NULL); 4352 status=MagickTrue; 4353 cache_info=(CacheInfo *) image->cache; 4354 if ((cache_info->reference_count > 1) || 4355 (IsCacheSynchronized(image) == MagickFalse)) 4356 { 4357 AcquireSemaphoreInfo(&cache_info->semaphore); 4358 if ((cache_info->reference_count > 1) || 4359 (IsCacheSynchronized(image) == MagickFalse)) 4360 { 4361 status=ModifyCache(image); 4362 if (status != MagickFalse) 4363 status=SyncCache(image); 4364 } 4365 RelinquishSemaphoreInfo(cache_info->semaphore); 4366 } 4367 return(status); 4336 4368 } 4337 4369 … … 4594 4626 *cache_info; 4595 4627 4628 MagickBooleanType 4629 status; 4630 4596 4631 assert(image != (Image *) NULL); 4597 4632 assert(image->signature == MagickSignature); … … 4603 4638 if (IsCacheSynchronized(image) != MagickFalse) 4604 4639 return(MagickTrue); 4605 return(OpenCache(image,IOMode,&image->exception)); 4640 status=OpenCache(image,IOMode,&image->exception); 4641 if (status != MagickFalse) 4642 { 4643 RectangleInfo 4644 region; 4645 4646 region.x=0; 4647 region.y=0; 4648 region.width=image->columns; 4649 region.height=1; 4650 status=SetNexus(image,®ion,0) != (PixelPacket *) NULL ? 4651 MagickTrue : MagickFalse; 4652 } 4653 return(status); 4606 4654 } 4607 4655 -
ImageMagick/trunk/magick/cache.h
r11161 r11599 36 36 PersistCache(Image *,const char *,const MagickBooleanType,MagickOffsetType *, 37 37 ExceptionInfo *), 38 SyncCacheNexus(Image *,const unsigned long); 38 SyncCacheNexus(Image *,const unsigned long), 39 SyncImagePixelCache(Image *); 39 40 40 41 extern MagickExport PixelPacket -
ImageMagick/trunk/magick/image.c
r11591 r11599 1159 1159 clone_image->next->previous=clone_image; 1160 1160 } 1161 (void) SetImageExtent(clone_image,columns,rows); 1161 1162 if (((columns == 0) && (rows == 0)) || 1162 1163 ((columns == image->columns) && (rows == image->rows))) … … 1173 1174 return(clone_image); 1174 1175 } 1175 clone_image->columns=columns;1176 clone_image->rows=rows;1177 1176 scale=(MagickRealType) clone_image->columns/(MagickRealType) image->columns; 1178 1177 clone_image->page.width=(unsigned long) (scale*image->page.width+0.5); … … 3283 3282 { 3284 3283 image->storage_class=storage_class; 3285 return(S etImageExtent(image,0,0));3284 return(SyncImagePixelCache(image)); 3286 3285 } 3287 3286 … … 3367 3366 const unsigned long columns,const unsigned long rows) 3368 3367 { 3369 PixelPacket3370 *p;3371 3372 3368 if ((columns != 0) || (rows != 0)) 3373 3369 { … … 3375 3371 image->rows=rows; 3376 3372 } 3377 p=SetImagePixels(image,0,0,image->columns,1); 3378 return(p != (PixelPacket *) NULL ? MagickTrue : MagickFalse); 3373 return(SyncImagePixelCache(image)); 3379 3374 } 3380 3375 … … 3578 3573 format_type=ExplicitFormatType; 3579 3574 i=0; 3580 while ((format_type != MagickFalse) &&3575 while ((format_type != UndefinedFormatType) && 3581 3576 (format_type_formats[i] != (char *) NULL)) 3582 3577 { -
ImageMagick/trunk/magick/resize.c
r11565 r11599 1697 1697 #define ResizeImageTag "Resize/Image" 1698 1698 1699 ClassType 1700 storage_class; 1701 1699 1702 ContributionInfo 1700 1703 **contribution; … … 1722 1725 scale=MagickMax(1.0/x_factor,1.0); 1723 1726 support=scale*GetResizeFilterSupport(resize_filter); 1724 resize_image->storage_class=image->storage_class; 1725 if (support > 0.5) 1726 { 1727 if (SetImageStorageClass(resize_image,DirectClass) == MagickFalse) 1728 { 1729 InheritException(exception,&resize_image->exception); 1730 return(MagickFalse); 1731 } 1732 } 1733 else 1727 storage_class=support > 0.5 ? DirectClass : image->storage_class; 1728 if (SetImageStorageClass(resize_image,storage_class) == MagickFalse) 1729 { 1730 InheritException(exception,&resize_image->exception); 1731 return(MagickFalse); 1732 } 1733 if (support < 0.5) 1734 1734 { 1735 1735 /* … … 1925 1925 const MagickSizeType span,MagickOffsetType *quantum,ExceptionInfo *exception) 1926 1926 { 1927 ClassType 1928 storage_class; 1929 1927 1930 ContributionInfo 1928 1931 **contribution; … … 1951 1954 scale=MagickMax(1.0/y_factor,1.0); 1952 1955 support=scale*GetResizeFilterSupport(resize_filter); 1953 resize_image->storage_class=image->storage_class; 1954 if (support > 0.5) 1955 { 1956 if (SetImageStorageClass(resize_image,DirectClass) == MagickFalse) 1957 { 1958 InheritException(exception,&resize_image->exception); 1959 return(MagickFalse); 1960 } 1961 } 1962 else 1956 storage_class=support > 0.5 ? DirectClass : image->storage_class; 1957 if (SetImageStorageClass(resize_image,storage_class) == MagickFalse) 1958 { 1959 InheritException(exception,&resize_image->exception); 1960 return(MagickFalse); 1961 } 1962 if (support < 0.5) 1963 1963 { 1964 1964 /* -
ImageMagick/trunk/magick/shear.c
r11586 r11599 994 994 if (rotate_image == (Image *) NULL) 995 995 return((Image *) NULL); 996 if (SetImageExtent(rotate_image,0,0) == MagickFalse)997 return(DestroyImage(rotate_image));998 996 /* 999 997 Integral rotate the image.
