Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(rendering): add create_bgra_texture to IOSurface cache

Richie McIlroy51c31e4aa9cd
diff --git a/crates/rendering/src/iosurface_texture.rs b/crates/rendering/src/iosurface_texture.rs
index 4403146da..f57d7e559 100644
--- a/crates/rendering/src/iosurface_texture.rs
+++ b/crates/rendering/src/iosurface_texture.rs
@@ -84,6 +84,26 @@ impl IOSurfaceTextureCache {
.ok_or(IOSurfaceTextureError::TextureCreationFailed)
}
+ pub fn create_bgra_texture(
+ &self,
+ io_surface: &io::Surf,
+ width: u32,
+ height: u32,
+ ) -> Result<R<mtl::Texture>, IOSurfaceTextureError> {
+ let mut desc = mtl::TextureDesc::new_2d(
+ mtl::PixelFormat::Bgra8UNorm,
+ width as usize,
+ height as usize,
+ false,
+ );
+ desc.set_storage_mode(mtl::StorageMode::Shared);
+ desc.set_usage(mtl::TextureUsage::SHADER_READ);
+
+ self.metal_device
+ .new_texture_with_surf(&desc, io_surface, 0)
+ .ok_or(IOSurfaceTextureError::TextureCreationFailed)
+ }
+
pub fn create_rgba_texture(
&self,
io_surface: &io::Surf,