mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-29 21:49:33 +00:00
Add logging when atlas allocator fails to allocate
This commit is contained in:
parent
7abd3a98a8
commit
0ca4c9946a
4 changed files with 16 additions and 4 deletions
|
@ -4,6 +4,7 @@ use crate::geometry::{
|
|||
};
|
||||
use etagere::BucketedAtlasAllocator;
|
||||
use foreign_types::ForeignType;
|
||||
use log::warn;
|
||||
use metal::{Device, TextureDescriptor};
|
||||
use objc::{msg_send, sel, sel_impl};
|
||||
|
||||
|
@ -41,7 +42,7 @@ impl AtlasAllocator {
|
|||
}
|
||||
|
||||
pub fn allocate(&mut self, requested_size: Vector2I) -> Option<(AllocId, Vector2I)> {
|
||||
let (alloc_id, origin) = self
|
||||
let allocation = self
|
||||
.atlases
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
|
@ -51,7 +52,16 @@ impl AtlasAllocator {
|
|||
let (id, origin) = atlas.allocate(requested_size)?;
|
||||
self.atlases.push(atlas);
|
||||
Some((id, origin))
|
||||
})?;
|
||||
});
|
||||
|
||||
if allocation.is_none() {
|
||||
warn!(
|
||||
"allocation of size {:?} could not be created",
|
||||
requested_size,
|
||||
);
|
||||
}
|
||||
|
||||
let (alloc_id, origin) = allocation?;
|
||||
|
||||
let id = AllocId {
|
||||
atlas_id: self.atlases.len() - 1,
|
||||
|
|
|
@ -33,7 +33,7 @@ impl ImageCache {
|
|||
.remove(&image.id)
|
||||
.or_else(|| self.curr_frame.get(&image.id).copied())
|
||||
.or_else(|| self.atlases.upload(image.size(), image.as_bytes()))
|
||||
.ok_or_else(|| anyhow!("Could not upload image of size {:?}", image.size()))
|
||||
.ok_or_else(|| anyhow!("could not upload image of size {:?}", image.size()))
|
||||
.unwrap();
|
||||
self.curr_frame.insert(image.id, (alloc_id, atlas_bounds));
|
||||
(alloc_id, atlas_bounds)
|
||||
|
|
|
@ -9,6 +9,7 @@ use crate::{
|
|||
scene::{Glyph, Icon, Image, Layer, Quad, Scene, Shadow, Underline},
|
||||
};
|
||||
use cocoa::foundation::NSUInteger;
|
||||
use log::warn;
|
||||
use metal::{MTLPixelFormat, MTLResourceOptions, NSRange};
|
||||
use shaders::ToFloat2 as _;
|
||||
use std::{collections::HashMap, ffi::c_void, iter::Peekable, mem, sync::Arc, vec};
|
||||
|
@ -176,6 +177,7 @@ impl Renderer {
|
|||
let path_allocation = self.path_atlases.allocate(size.to_i32());
|
||||
if path_allocation.is_none() {
|
||||
// Path size was likely zero.
|
||||
warn!("could not allocate path texture of size {:?}", size);
|
||||
continue;
|
||||
}
|
||||
let (alloc_id, atlas_origin) = path_allocation.unwrap();
|
||||
|
|
|
@ -117,7 +117,7 @@ impl SpriteCache {
|
|||
|
||||
let (alloc_id, atlas_bounds) = atlases
|
||||
.upload(glyph_bounds.size(), &mask)
|
||||
.expect("Could not upload glyph");
|
||||
.expect("could not upload glyph");
|
||||
Some(GlyphSprite {
|
||||
atlas_id: alloc_id.atlas_id,
|
||||
atlas_origin: atlas_bounds.origin(),
|
||||
|
|
Loading…
Reference in a new issue