mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-05 03:50:07 +00:00
Component: Recreate cached images if ideal type changes
This is intended to fix an issue where drawing a component snapshot into a temporary OpenGL image can fail, because the GL context may not be bound.
This commit is contained in:
parent
86732069c7
commit
bf54fb1fe9
1 changed files with 9 additions and 3 deletions
|
|
@ -214,14 +214,20 @@ public:
|
|||
auto scale = g.getInternalContext().getPhysicalPixelScaleFactor();
|
||||
auto scaledBounds = c.getLocalBounds() * scale;
|
||||
|
||||
if (effectImage.getBounds() != scaledBounds)
|
||||
const auto preferredType = g.getInternalContext().getPreferredImageTypeForTemporaryImages();
|
||||
const auto pixelData = effectImage.getPixelData();
|
||||
const auto shouldCreateImage = pixelData == nullptr
|
||||
|| pixelData->width != scaledBounds.getWidth()
|
||||
|| pixelData->height != scaledBounds.getHeight()
|
||||
|| pixelData->createType()->getTypeID() != preferredType->getTypeID();
|
||||
|
||||
if (shouldCreateImage)
|
||||
{
|
||||
auto tempImageType = g.getInternalContext().getPreferredImageTypeForTemporaryImages();
|
||||
effectImage = Image { c.isOpaque() ? Image::RGB : Image::ARGB,
|
||||
scaledBounds.getWidth(),
|
||||
scaledBounds.getHeight(),
|
||||
false,
|
||||
*tempImageType };
|
||||
*preferredType };
|
||||
effectImage.setBackupEnabled (false);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue