#include "IntSize.h"
#if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
#ifdef __OBJC__
@class NSImage;
#else
int m_repetitionsComplete; // How many repetitions we've finished.
#if PLATFORM(MAC)
- mutable NSImage* m_nsImage; // A cached NSImage of frame 0. Only built lazily if someone actually queries for one.
- mutable CFDataRef m_tiffRep; // Cached TIFF rep for frame 0. Only built lazily if someone queries for one.
+ mutable RetainPtr<NSImage> m_nsImage; // A cached NSImage of frame 0. Only built lazily if someone actually queries for one.
+ mutable RetainPtr<CFDataRef> m_tiffRep; // Cached TIFF rep for frame 0. Only built lazily if someone queries for one.
#endif
Color m_solidColor; // If we're a 1x1 solid color, this is the color to use to fill.
void BitmapImage::initPlatformData()
{
- m_nsImage = 0;
- m_tiffRep = 0;
}
void BitmapImage::invalidatePlatformData()
if (m_frames.size() != 1)
return;
- if (m_nsImage) {
- CFRelease(m_nsImage);
- m_nsImage = 0;
- }
-
- if (m_tiffRep) {
- CFRelease(m_tiffRep);
- m_tiffRep = 0;
- }
+ m_nsImage = 0;
+ m_tiffRep = 0;
}
Image* Image::loadPlatformResource(const char *name)
CFDataRef BitmapImage::getTIFFRepresentation()
{
if (m_tiffRep)
- return m_tiffRep;
+ return m_tiffRep.get();
unsigned numFrames = frameCount();
unsigned numValidFrames = images.size();
- CFMutableDataRef data = CFDataCreateMutable(0, 0);
+ RetainPtr<CFMutableDataRef> data(AdoptCF, CFDataCreateMutable(0, 0));
// FIXME: Use type kCGImageTypeIdentifierTIFF constant once is becomes available in the API
- CGImageDestinationRef destination = CGImageDestinationCreateWithData(data, CFSTR("public.tiff"), numValidFrames, 0);
+ CGImageDestinationRef destination = CGImageDestinationCreateWithData(data.get(), CFSTR("public.tiff"), numValidFrames, 0);
if (!destination)
return 0;
CFRelease(destination);
m_tiffRep = data;
- return m_tiffRep;
+ return m_tiffRep.get();
}
NSImage* BitmapImage::getNSImage()
{
if (m_nsImage)
- return m_nsImage;
+ return m_nsImage.get();
CFDataRef data = getTIFFRepresentation();
if (!data)
return 0;
- m_nsImage = HardRetainWithNSRelease([[NSImage alloc] initWithData:(NSData*)data]);
- return m_nsImage;
+ m_nsImage.adoptNS([[NSImage alloc] initWithData:(NSData*)data]);
+ return m_nsImage.get();
}
}