]> code.delx.au - gnu-emacs/blobdiff - src/nsimage.m
Update copyright year to 2015
[gnu-emacs] / src / nsimage.m
index 370cf832c7c3c68c70315faffbd0ca92394952b5..2da22f239f3ee7a4051a305f247541c1183c4df1 100644 (file)
@@ -1,6 +1,6 @@
 /* Image support for the NeXT/Open/GNUstep and MacOSX window system.
-   Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2012
-     Free Software Foundation, Inc.
+   Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2015 Free Software
+   Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -160,25 +160,11 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
 
 @implementation EmacsImage
 
-static EmacsImage *ImageList = nil;
-
 + allocInitFromFile: (Lisp_Object)file
 {
-  EmacsImage *image = ImageList;
   NSImageRep *imgRep;
   Lisp_Object found;
-
-  /* look for an existing image of the same name */
-  while (image != nil &&
-         [[image name] compare: [NSString stringWithUTF8String: SSDATA (file)]]
-             != NSOrderedSame)
-    image = [image imageListNext];
-
-  if (image != nil)
-    {
-      [image reference];
-      return image;
-    }
+  EmacsImage *image;
 
   /* Search bitmap-file-path for the file, if appropriate.  */
   found = x_find_image_file (file);
@@ -188,7 +174,8 @@ static EmacsImage *ImageList = nil;
   image = [[EmacsImage alloc] initByReferencingFile:
                      [NSString stringWithUTF8String: SSDATA (found)]];
 
-#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+  image->bmRep = nil;
+#ifdef NS_IMPL_COCOA
   imgRep = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]];
 #else
   imgRep = [image bestRepresentationForDevice: nil];
@@ -205,54 +192,15 @@ static EmacsImage *ImageList = nil;
   [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])];
 
   [image setName: [NSString stringWithUTF8String: SSDATA (file)]];
-  [image reference];
-  ImageList = [image imageListSetNext: ImageList];
 
   return image;
 }
 
 
-- reference
-{
-  refCount++;
-  return self;
-}
-
-
-- imageListSetNext: (id)arg
-{
-  imageListNext = arg;
-  return self;
-}
-
-
-- imageListNext
-{
-  return imageListNext;
-}
-
-
 - (void)dealloc
 {
-  id list = ImageList;
-
-  if (refCount > 1)
-    {
-      refCount--;
-      return;
-    }
-
   [stippleMask release];
-
-  if (list == self)
-    ImageList = imageListNext;
-  else
-    {
-      while (list != nil && [list imageListNext] != self)
-        list = [list imageListNext];
-      [list imageListSetNext: imageListNext];
-    }
-
+  [bmRep release];
   [super dealloc];
 }
 
@@ -299,6 +247,7 @@ static EmacsImage *ImageList = nil;
               if (s >= bits + length)
                 {
                   [bmRep release];
+                  bmRep = nil;
                   return nil;
                 }
 #define hexchar(x) ('0' <= (x) && (x) <= '9' ? (x) - '0' : (x) - 'a' + 10)
@@ -334,7 +283,7 @@ static EmacsImage *ImageList = nil;
 {
   NSSize s = [self size];
   unsigned char *planes[5];
-  CGFloat r, g, b, a;
+  EmacsCGFloat r, g, b, a;
   NSColor *rgbColor;
 
   if (bmRep == nil || color == nil)
@@ -402,16 +351,15 @@ static EmacsImage *ImageList = nil;
     {
       if ([rep respondsToSelector: @selector (getBitmapDataPlanes:)])
         {
-          bmRep = (NSBitmapImageRep *) rep;
-          onTiger = [bmRep respondsToSelector: @selector (colorAtX:y:)];
+          NSBitmapImageRep *bmr = (NSBitmapImageRep *) rep;
 
-          if ([bmRep numberOfPlanes] >= 3)
-              [bmRep getBitmapDataPlanes: pixmapData];
+          if ([bmr numberOfPlanes] >= 3)
+              [bmr getBitmapDataPlanes: pixmapData];
 
           /* The next two lines cause the DPI of the image to be ignored.
              This seems to be the behavior users expect. */
           [self setScalesWhenResized: YES];
-          [self setSize: NSMakeSize([bmRep pixelsWide], [bmRep pixelsHigh])];
+          [self setSize: NSMakeSize([bmr pixelsWide], [bmr pixelsHigh])];
 
           break;
         }
@@ -435,17 +383,16 @@ static EmacsImage *ImageList = nil;
        | (pixmapData[0][loc] << 16) | (pixmapData[1][loc] << 8)
        | (pixmapData[2][loc]);
     }
-  else if (onTiger)
+  else
     {
       NSColor *color = [bmRep colorAtX: x y: y];
-      CGFloat r, g, b, a;
+      EmacsCGFloat r, g, b, a;
       [color getRed: &r green: &g blue: &b alpha: &a];
       return ((int)(a * 255.0) << 24)
         | ((int)(r * 255.0) << 16) | ((int)(g * 255.0) << 8)
         | ((int)(b * 255.0));
 
     }
-  return 0;
 }
 
 - (void) setPixelAtX: (int)x Y: (int)y toRed: (unsigned char)r
@@ -463,7 +410,7 @@ static EmacsImage *ImageList = nil;
       pixmapData[2][loc] = b;
       pixmapData[3][loc] = a;
     }
-  else if (onTiger)
+  else
     {
       [bmRep setColor:
                [NSColor colorWithCalibratedRed: (r/255.0) green: (g/255.0)
@@ -483,7 +430,7 @@ static EmacsImage *ImageList = nil;
 
       pixmapData[3][loc] = a;
     }
-  else if (onTiger)
+  else
     {
       NSColor *color = [bmRep colorAtX: x y: y];
       color = [color colorWithAlphaComponent: (a / 255.0)];