mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-08 04:20:09 +00:00
Fix for duplicateIfShared when image depends on other image via SubsectionImageData
This commit is contained in:
parent
4f28be946c
commit
e83a69560a
2 changed files with 16 additions and 2 deletions
|
|
@ -39,6 +39,11 @@ void ImagePixelData::sendDataChangeMessage()
|
|||
listeners.call (&Listener::imageDataChanged, this);
|
||||
}
|
||||
|
||||
int ImagePixelData::getSharedCount() const noexcept
|
||||
{
|
||||
return getReferenceCount();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
ImageType::ImageType() {}
|
||||
ImageType::~ImageType() {}
|
||||
|
|
@ -179,7 +184,11 @@ public:
|
|||
|
||||
ImageType* createType() const override { return image->createType(); }
|
||||
|
||||
/* as we always hold a reference to image, don't double count */
|
||||
int getSharedCount() const noexcept { return getReferenceCount() + image->getSharedCount() - 1; }
|
||||
|
||||
private:
|
||||
friend class Image;
|
||||
const ImagePixelData::Ptr image;
|
||||
const Rectangle<int> area;
|
||||
|
||||
|
|
@ -246,7 +255,7 @@ Image::~Image()
|
|||
|
||||
const Image Image::null;
|
||||
|
||||
int Image::getReferenceCount() const noexcept { return image == nullptr ? 0 : image->getReferenceCount(); }
|
||||
int Image::getReferenceCount() const noexcept { return image == nullptr ? 0 : image->getSharedCount(); }
|
||||
int Image::getWidth() const noexcept { return image == nullptr ? 0 : image->width; }
|
||||
int Image::getHeight() const noexcept { return image == nullptr ? 0 : image->height; }
|
||||
Rectangle<int> Image::getBounds() const noexcept { return image == nullptr ? Rectangle<int>() : Rectangle<int> (image->width, image->height); }
|
||||
|
|
@ -263,7 +272,7 @@ LowLevelGraphicsContext* Image::createLowLevelContext() const
|
|||
|
||||
void Image::duplicateIfShared()
|
||||
{
|
||||
if (image != nullptr && image->getReferenceCount() > 1)
|
||||
if (getReferenceCount() > 1)
|
||||
image = image->clone();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -443,6 +443,11 @@ public:
|
|||
virtual ImageType* createType() const = 0;
|
||||
/** Initialises a BitmapData object. */
|
||||
virtual void initialiseBitmapData (Image::BitmapData&, int x, int y, Image::BitmapData::ReadWriteMode) = 0;
|
||||
/** Returns the number of Image objects which are currently referring to the same internal
|
||||
shared image data. This is different to the reference count as an instance of ImagePixelData
|
||||
can internally depend on another ImagePixelData via it's member variables. */
|
||||
virtual int getSharedCount() const noexcept;
|
||||
|
||||
|
||||
/** The pixel format of the image data. */
|
||||
const Image::PixelFormat pixelFormat;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue