]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sun, 20 Sep 2009 02:31:52 +0000 (02:31 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sun, 20 Sep 2009 02:31:52 +0000 (02:31 +0000)
coders/tile.c
magick/composite.c

index fa6c4f1a624ad240b85cbf86af755fa8cf62df7e..3983688406b542269b9b3a19feabc2bbf6bb5a2e 100644 (file)
@@ -74,7 +74,8 @@
 %
 %  The format of the ReadTILEImage method is:
 %
-%      Image *ReadTILEImage(const ImageInfo *image_info,ExceptionInfo *exception)
+%      Image *ReadTILEImage(const ImageInfo *image_info,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
index 62919524937ccb48d3410b853b56f714d561a9bb..47505acae3dcc8fdeae2e5d017141dc1f0a1cf4d 100644 (file)
@@ -2399,13 +2399,17 @@ MagickExport MagickBooleanType TextureImage(Image *image,const Image *texture)
 {
 #define TextureImageTag  "Texture/Image"
 
+  CacheView
+    *image_view,
+    *texture_view;
+
   ExceptionInfo
     *exception;
 
   long
     y;
 
-  MagickStatusType
+  MagickBooleanType
     status;
 
   assert(image != (Image *) NULL);
@@ -2416,29 +2420,131 @@ MagickExport MagickBooleanType TextureImage(Image *image,const Image *texture)
     return(MagickFalse);
   if (SetImageStorageClass(image,DirectClass) == MagickFalse)
     return(MagickFalse);
+  status=MagickTrue;
+  if ((image->compose != CopyCompositeOp) &&
+      ((image->compose != OverCompositeOp) || (image->matte != MagickFalse)))
+    {
+      /*
+        Tile texture onto the image background.
+      */
+#if defined(_OPENMP) && (_OPENMP >= 200203)
+  #pragma omp parallel for schedule(static,1) shared(status)
+#endif
+      for (y=0; y < (long) image->rows; y+=texture->rows)
+      {
+        register long
+          x;
+    
+        if (status == MagickFalse)
+          continue;
+        for (x=0; x < (long) image->columns; x+=texture->columns)
+        {
+          MagickBooleanType
+            thread_status;
+    
+          thread_status=CompositeImage(image,image->compose,texture,x+
+            texture->tile_offset.x,y+texture->tile_offset.y);
+          if (thread_status == MagickFalse)
+            {
+              status=thread_status;
+              break;
+            }
+        }
+        if (image->progress_monitor != (MagickProgressMonitor) NULL)
+          {
+            MagickBooleanType
+              proceed;
+    
+#if defined(_OPENMP) && (_OPENMP >= 200203)
+  #pragma omp critical (MagickCore_TextureImage)
+#endif
+            proceed=SetImageProgress(image,TextureImageTag,y,image->rows);
+            if (proceed == MagickFalse)
+              status=MagickFalse;
+          }
+      }
+      (void) SetImageProgress(image,TextureImageTag,(MagickOffsetType)
+        image->rows,image->rows);
+      return(status);
+    }
   /*
-    Tile texture onto the image background.
+    Tile texture onto the image background (optimized).
   */
   status=MagickTrue;
   exception=(&image->exception);
-  for (y=0; y < (long) image->rows; y+=texture->rows)
+  image_view=AcquireCacheView(image);
+  texture_view=AcquireCacheView(texture);
+#if defined(_OPENMP) && (_OPENMP >= 200203)
+#pragma omp parallel for schedule(static,1) shared(status)
+#endif
+  for (y=0; y < (long) image->rows; y++)
   {
+    MagickBooleanType
+      sync;
+
+    register const IndexPacket
+      *texture_indexes;
+
+    register const PixelPacket
+      *p;
+
+    register IndexPacket
+      *indexes;
+
     register long
       x;
 
+    register PixelPacket
+      *q;
+
+    unsigned long
+      width;
+
+    if (status == MagickFalse)
+      continue;
+    p=GetCacheViewVirtualPixels(texture_view,0,y % texture->rows,
+      texture->columns,1,exception);
+    q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
+      exception);
+    if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
+      {
+        status=MagickFalse;
+        continue;
+      }
+    texture_indexes=GetCacheViewVirtualIndexQueue(texture_view);
+    indexes=GetCacheViewAuthenticIndexQueue(image_view);
     for (x=0; x < (long) image->columns; x+=texture->columns)
-      status|=CompositeImage(image,image->compose,texture,x+
-        texture->tile_offset.x,y+texture->tile_offset.y);
+    {
+      width=texture->columns;
+      if ((x+width) > (long) image->columns)
+        width=image->columns-x;
+      (void) CopyMagickMemory(q,p,width*sizeof(*p));
+      if ((indexes != (IndexPacket *) NULL) &&
+          (texture_indexes != (const IndexPacket *) NULL))
+        {
+          (void) CopyMagickMemory(indexes,texture_indexes,width*
+            sizeof(*indexes));
+          indexes+=width;
+        }
+      q+=width;
+    }
+    sync=SyncCacheViewAuthenticPixels(image_view,exception);
+    if (sync == MagickFalse)
+      status=MagickFalse;
     if (image->progress_monitor != (MagickProgressMonitor) NULL)
       {
         MagickBooleanType
           proceed;
 
+#if defined(_OPENMP) && (_OPENMP >= 200203)
+#pragma omp critical (MagickCore_TextureImage)
+#endif
         proceed=SetImageProgress(image,TextureImageTag,y,image->rows);
         if (proceed == MagickFalse)
           status=MagickFalse;
       }
   }
-  (void) SetImageProgress(image,TextureImageTag,image->rows,image->rows);
-  return(status != 0 ? MagickTrue : MagickFalse);
+  texture_view=DestroyCacheView(texture_view);
+  image_view=DestroyCacheView(image_view);
+  return(status);
 }