зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1679751 - Use a shelf packing allocator for the image atlas. r=gw.
Differential Revision: https://phabricator.services.mozilla.com/D98658
This commit is contained in:
Родитель
d1d6af0ee7
Коммит
3f1f2756c3
|
@ -9,6 +9,7 @@ use smallvec::SmallVec;
|
|||
|
||||
pub use etagere::AllocatorOptions as ShelfAllocatorOptions;
|
||||
pub use etagere::BucketedAtlasAllocator as BucketedShelfAllocator;
|
||||
pub use etagere::AtlasAllocator as ShelfAllocator;
|
||||
|
||||
/// ID of an allocation within a given allocator.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
|
@ -241,3 +242,33 @@ impl AtlasAllocator for BucketedShelfAllocator {
|
|||
self.dump_into_svg(Some(&rect.to_i32().cast_unit()), output)
|
||||
}
|
||||
}
|
||||
|
||||
impl AtlasAllocator for ShelfAllocator {
|
||||
type Parameters = ShelfAllocatorOptions;
|
||||
|
||||
fn new(size: i32, options: &Self::Parameters) -> Self {
|
||||
ShelfAllocator::with_options(size2(size, size), options)
|
||||
}
|
||||
|
||||
fn allocate(&mut self, size: DeviceIntSize) -> Option<(AllocId, DeviceIntRect)> {
|
||||
self.allocate(size.to_untyped()).map(|alloc| {
|
||||
(AllocId(alloc.id.serialize()), alloc.rectangle.to_rect().cast_unit())
|
||||
})
|
||||
}
|
||||
|
||||
fn deallocate(&mut self, id: AllocId) {
|
||||
self.deallocate(etagere::AllocId::deserialize(id.0));
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
self.is_empty()
|
||||
}
|
||||
|
||||
fn allocated_space(&self) -> i32 {
|
||||
self.allocated_space()
|
||||
}
|
||||
|
||||
fn dump_into_svg(&self, rect: &Box2D<f32>, output: &mut dyn std::io::Write) -> std::io::Result<()> {
|
||||
self.dump_into_svg(Some(&rect.to_i32().cast_unit()), output)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ struct SharedTextures {
|
|||
color8_nearest: AllocatorList<SlabAllocator, TextureParameters>,
|
||||
alpha8_linear: AllocatorList<SlabAllocator, TextureParameters>,
|
||||
alpha16_linear: AllocatorList<SlabAllocator, TextureParameters>,
|
||||
color8_linear: AllocatorList<SlabAllocator, TextureParameters>,
|
||||
color8_linear: AllocatorList<ShelfAllocator, TextureParameters>,
|
||||
color8_glyphs: AllocatorList<BucketedShelfAllocator, TextureParameters>,
|
||||
}
|
||||
|
||||
|
@ -274,8 +274,10 @@ impl SharedTextures {
|
|||
// The primary cache for images, etc.
|
||||
color8_linear: AllocatorList::new(
|
||||
2048,
|
||||
SlabAllocatorParameters {
|
||||
region_size: TEXTURE_REGION_DIMENSIONS,
|
||||
ShelfAllocatorOptions {
|
||||
num_columns: 2,
|
||||
alignment: size2(16, 16),
|
||||
.. ShelfAllocatorOptions::default()
|
||||
},
|
||||
TextureParameters {
|
||||
formats: color_formats.clone(),
|
||||
|
|
Загрузка…
Ссылка в новой задаче