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

CGMetalLayerRenderer: Fix crash when attempting to render zero-sized components

This commit is contained in:
reuk 2023-04-15 15:09:44 +01:00
parent dcef8b88b2
commit 208be3dd5e
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -86,9 +86,13 @@ public:
{
layer.drawableSize = transformedFrameSize;
resources = std::make_unique<Resources> (device.get(), layer);
dirtyRegions = convertToRectFloat (layer.bounds);
dirtyRegions.clear();
dirtyRegions.add (convertToRectFloat (layer.bounds));
}
if (CGSizeEqualToSize (transformedFrameSize, CGSizeZero))
return dirtyRegions;
auto gpuTexture = resources->getGpuTexture();
if (gpuTexture == nullptr)
@ -209,7 +213,8 @@ private:
GpuTexturePool (id<MTLDevice> metalDevice, MTLTextureDescriptor* descriptor)
{
for (auto& t : textureCache)
t.reset ([metalDevice newTextureWithDescriptor: descriptor]);
t.reset ((descriptor.width != 0 && descriptor.height != 0) ? [metalDevice newTextureWithDescriptor: descriptor]
: nullptr);
}
id<MTLTexture> take() const