1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

macOS: Renamed the CoreGraphicsImage class to avoid a symbol resolution issue in Pro Tools

This commit is contained in:
Tom Poole 2020-01-27 10:06:23 +00:00
parent 5623dcda09
commit 9798f672c4

View file

@ -28,10 +28,13 @@ namespace juce
{
//==============================================================================
class CoreGraphicsImage : public ImagePixelData
// This class has been renamed from CoreGraphicsImage to avoid a symbol
// collision in Pro Tools 2019.12 and possibly 2020 depending on the Pro Tools
// release schedule.
class CoreGraphicsPixelData : public ImagePixelData
{
public:
CoreGraphicsImage (const Image::PixelFormat format, int w, int h, bool clearImage)
CoreGraphicsPixelData (const Image::PixelFormat format, int w, int h, bool clearImage)
: ImagePixelData (format, w, h)
{
pixelStride = format == Image::RGB ? 3 : ((format == Image::ARGB) ? 4 : 1);
@ -57,7 +60,7 @@ public:
CGColorSpaceRelease (colourSpace);
}
~CoreGraphicsImage() override
~CoreGraphicsPixelData() override
{
freeCachedImageRef();
CGContextRelease (context);
@ -86,7 +89,7 @@ public:
ImagePixelData::Ptr clone() override
{
auto im = new CoreGraphicsImage (pixelFormat, width, height, false);
auto im = new CoreGraphicsPixelData (pixelFormat, width, height, false);
memcpy (im->imageDataHolder->data, imageDataHolder->data, (size_t) (lineStride * height));
return *im;
}
@ -96,7 +99,7 @@ public:
//==============================================================================
static CGImageRef getCachedImageRef (const Image& juceImage, CGColorSpaceRef colourSpace)
{
auto cgim = dynamic_cast<CoreGraphicsImage*> (juceImage.getPixelData());
auto cgim = dynamic_cast<CoreGraphicsPixelData*> (juceImage.getPixelData());
if (cgim != nullptr && cgim->cachedImageRef != nullptr)
{
@ -127,7 +130,7 @@ public:
{
auto* imageDataContainer = [](const Image& img) -> HeapBlockContainer::Ptr*
{
if (auto* cgim = dynamic_cast<CoreGraphicsImage*> (img.getPixelData()))
if (auto* cgim = dynamic_cast<CoreGraphicsPixelData*> (img.getPixelData()))
return new HeapBlockContainer::Ptr (cgim->imageDataHolder);
return nullptr;
@ -183,12 +186,12 @@ private:
#endif
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsImage)
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsPixelData)
};
ImagePixelData::Ptr NativeImageType::create (Image::PixelFormat format, int width, int height, bool clearImage) const
{
return *new CoreGraphicsImage (format == Image::RGB ? Image::ARGB : format, width, height, clearImage);
return *new CoreGraphicsPixelData (format == Image::RGB ? Image::ARGB : format, width, height, clearImage);
}
//==============================================================================
@ -326,7 +329,7 @@ void CoreGraphicsContext::clipToImageAlpha (const Image& sourceImage, const Affi
if (sourceImage.getFormat() != Image::SingleChannel)
singleChannelImage = sourceImage.convertedToFormat (Image::SingleChannel);
CGImageRef image = CoreGraphicsImage::createImage (singleChannelImage, greyColourSpace, true);
CGImageRef image = CoreGraphicsPixelData::createImage (singleChannelImage, greyColourSpace, true);
flip();
auto t = AffineTransform::verticalFlip (sourceImage.getHeight()).followedBy (transform);
@ -524,7 +527,7 @@ void CoreGraphicsContext::drawImage (const Image& sourceImage, const AffineTrans
auto colourSpace = sourceImage.getFormat() == Image::PixelFormat::SingleChannel ? greyColourSpace
: rgbColourSpace;
CGImageRef image = CoreGraphicsImage::getCachedImageRef (sourceImage, colourSpace);
CGImageRef image = CoreGraphicsPixelData::getCachedImageRef (sourceImage, colourSpace);
CGContextSaveGState (context);
CGContextSetAlpha (context, state->fillType.getOpacity());
@ -887,8 +890,8 @@ Image juce_loadWithCoreImage (InputStream& input)
(int) CGImageGetHeight (loadedImage),
hasAlphaChan));
auto cgImage = dynamic_cast<CoreGraphicsImage*> (image.getPixelData());
jassert (cgImage != nullptr); // if USE_COREGRAPHICS_RENDERING is set, the CoreGraphicsImage class should have been used.
auto cgImage = dynamic_cast<CoreGraphicsPixelData*> (image.getPixelData());
jassert (cgImage != nullptr); // if USE_COREGRAPHICS_RENDERING is set, the CoreGraphicsPixelData class should have been used.
CGContextDrawImage (cgImage->context, convertToCGRect (image.getBounds()), loadedImage);
CGContextFlush (cgImage->context);
@ -912,7 +915,7 @@ Image juce_loadWithCoreImage (InputStream& input)
Image juce_createImageFromCIImage (CIImage*, int, int);
Image juce_createImageFromCIImage (CIImage* im, int w, int h)
{
auto cgImage = new CoreGraphicsImage (Image::ARGB, w, h, false);
auto cgImage = new CoreGraphicsPixelData (Image::ARGB, w, h, false);
CIContext* cic = [CIContext contextWithCGContext: cgImage->context options: nil];
[cic drawImage: im inRect: CGRectMake (0, 0, w, h) fromRect: CGRectMake (0, 0, w, h)];
@ -924,12 +927,12 @@ Image juce_createImageFromCIImage (CIImage* im, int w, int h)
CGImageRef juce_createCoreGraphicsImage (const Image& juceImage, CGColorSpaceRef colourSpace,
const bool mustOutliveSource)
{
return CoreGraphicsImage::createImage (juceImage, colourSpace, mustOutliveSource);
return CoreGraphicsPixelData::createImage (juceImage, colourSpace, mustOutliveSource);
}
CGContextRef juce_getImageContext (const Image& image)
{
if (auto cgi = dynamic_cast<CoreGraphicsImage*> (image.getPixelData()))
if (auto cgi = dynamic_cast<CoreGraphicsPixelData*> (image.getPixelData()))
return cgi->context;
jassertfalse;