Skip to content

Commit

Permalink
macOS: Renamed the CoreGraphicsImage class to avoid a symbol resoluti…
Browse files Browse the repository at this point in the history
…on issue in Pro Tools
  • Loading branch information
tpoole committed Jan 27, 2020
1 parent 5623dcd commit 9798f67
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm
Expand Up @@ -28,10 +28,13 @@
{

//==============================================================================
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);
Expand All @@ -57,7 +60,7 @@
CGColorSpaceRelease (colourSpace);
}

~CoreGraphicsImage() override
~CoreGraphicsPixelData() override
{
freeCachedImageRef();
CGContextRelease (context);
Expand Down Expand Up @@ -86,7 +89,7 @@ void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::Bitma

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;
}
Expand All @@ -96,7 +99,7 @@ void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::Bitma
//==============================================================================
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)
{
Expand Down Expand Up @@ -127,7 +130,7 @@ static CGImageRef createImage (const Image& juceImage, CGColorSpaceRef colourSpa
{
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;
Expand Down Expand Up @@ -183,12 +186,12 @@ static CGBitmapInfo getCGImageFlags (const Image::PixelFormat& format)
#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);
}

//==============================================================================
Expand Down Expand Up @@ -326,7 +329,7 @@ static CGBitmapInfo getCGImageFlags (const Image::PixelFormat& format)
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);
Expand Down Expand Up @@ -524,7 +527,7 @@ static CGBitmapInfo getCGImageFlags (const Image::PixelFormat& format)

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());
Expand Down Expand Up @@ -887,8 +890,8 @@ Image image (NativeImageType().create (Image::ARGB, // (CoreImage doesn't work w
(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);
Expand All @@ -912,7 +915,7 @@ Image image (NativeImageType().create (Image::ARGB, // (CoreImage doesn't work w
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)];
Expand All @@ -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;
Expand Down

0 comments on commit 9798f67

Please sign in to comment.