Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Start fixing up gpui2
Piotr Osiewicz7d420edb843b
diff --git a/crates/gpui2/src/geometry.rs b/crates/gpui2/src/geometry.rsindex 6b4d9ae807b..292b0f4aa99 100644--- a/crates/gpui2/src/geometry.rs+++ b/crates/gpui2/src/geometry.rs@@ -1896,7 +1896,6 @@ impl Into<Corners<Pixels>> for Pixels {Div,DivAssign,PartialEq,- PartialOrd,Serialize,Deserialize,)]@@ -2039,9 +2038,15 @@ impl Mul<Pixels> for Pixels {impl Eq for Pixels {}+impl PartialOrd for Pixels {+ fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {+ self.0.partial_cmp(&other.0)+ }+}+impl Ord for Pixels {fn cmp(&self, other: &Self) -> cmp::Ordering {- self.0.partial_cmp(&other.0).unwrap()+ self.partial_cmp(other).unwrap()}}diff --git a/crates/gpui2/src/platform/mac/metal_renderer.rs b/crates/gpui2/src/platform/mac/metal_renderer.rsindex 68768521ee4..7812eebf01b 100644--- a/crates/gpui2/src/platform/mac/metal_renderer.rs+++ b/crates/gpui2/src/platform/mac/metal_renderer.rs@@ -174,7 +174,7 @@ impl MetalRenderer {unit_vertices,instances,sprite_atlas,- core_video_texture_cache: CVMetalTextureCache::new(device.as_ptr()).unwrap(),+ core_video_texture_cache: unsafe { CVMetalTextureCache::new(device.as_ptr()).unwrap() },}}@@ -849,28 +849,30 @@ impl MetalRenderer {media::core_video::kCVPixelFormatType_420YpCbCr8BiPlanarFullRange);- let y_texture = self- .core_video_texture_cache- .create_texture_from_image(- surface.image_buffer.as_concrete_TypeRef(),- ptr::null(),- MTLPixelFormat::R8Unorm,- surface.image_buffer.plane_width(0),- surface.image_buffer.plane_height(0),- 0,- )- .unwrap();- let cb_cr_texture = self- .core_video_texture_cache- .create_texture_from_image(- surface.image_buffer.as_concrete_TypeRef(),- ptr::null(),- MTLPixelFormat::RG8Unorm,- surface.image_buffer.plane_width(1),- surface.image_buffer.plane_height(1),- 1,- )- .unwrap();+ let y_texture = unsafe {+ self.core_video_texture_cache+ .create_texture_from_image(+ surface.image_buffer.as_concrete_TypeRef(),+ ptr::null(),+ MTLPixelFormat::R8Unorm,+ surface.image_buffer.plane_width(0),+ surface.image_buffer.plane_height(0),+ 0,+ )+ .unwrap()+ };+ let cb_cr_texture = unsafe {+ self.core_video_texture_cache+ .create_texture_from_image(+ surface.image_buffer.as_concrete_TypeRef(),+ ptr::null(),+ MTLPixelFormat::RG8Unorm,+ surface.image_buffer.plane_width(1),+ surface.image_buffer.plane_height(1),+ 1,+ )+ .unwrap()+ };align_offset(offset);let next_offset = *offset + mem::size_of::<Surface>();diff --git a/crates/media/src/media.rs b/crates/media/src/media.rsindex 1c76e6befbf..650af06c37d 100644--- a/crates/media/src/media.rs+++ b/crates/media/src/media.rs@@ -108,25 +108,23 @@ pub mod core_video {impl_CFTypeDescription!(CVMetalTextureCache);impl CVMetalTextureCache {- pub fn new(metal_device: *mut MTLDevice) -> Result<Self> {- unsafe {- let mut this = ptr::null();- let result = CVMetalTextureCacheCreate(- kCFAllocatorDefault,- ptr::null(),- metal_device,- ptr::null(),- &mut this,- );- if result == kCVReturnSuccess {- Ok(CVMetalTextureCache::wrap_under_create_rule(this))- } else {- Err(anyhow!("could not create texture cache, code: {}", result))- }+ pub unsafe fn new(metal_device: *mut MTLDevice) -> Result<Self> {+ let mut this = ptr::null();+ let result = CVMetalTextureCacheCreate(+ kCFAllocatorDefault,+ ptr::null(),+ metal_device,+ ptr::null(),+ &mut this,+ );+ if result == kCVReturnSuccess {+ Ok(CVMetalTextureCache::wrap_under_create_rule(this))+ } else {+ Err(anyhow!("could not create texture cache, code: {}", result))}}- pub fn create_texture_from_image(+ pub unsafe fn create_texture_from_image(&self,source: CVImageBufferRef,texture_attributes: CFDictionaryRef,@@ -135,24 +133,22 @@ pub mod core_video {height: usize,plane_index: usize,) -> Result<CVMetalTexture> {- unsafe {- let mut this = ptr::null();- let result = CVMetalTextureCacheCreateTextureFromImage(- kCFAllocatorDefault,- self.as_concrete_TypeRef(),- source,- texture_attributes,- pixel_format,- width,- height,- plane_index,- &mut this,- );- if result == kCVReturnSuccess {- Ok(CVMetalTexture::wrap_under_create_rule(this))- } else {- Err(anyhow!("could not create texture, code: {}", result))- }+ let mut this = ptr::null();+ let result = CVMetalTextureCacheCreateTextureFromImage(+ kCFAllocatorDefault,+ self.as_concrete_TypeRef(),+ source,+ texture_attributes,+ pixel_format,+ width,+ height,+ plane_index,+ &mut this,+ );+ if result == kCVReturnSuccess {+ Ok(CVMetalTexture::wrap_under_create_rule(this))+ } else {+ Err(anyhow!("could not create texture, code: {}", result))}}}@@ -438,60 +434,56 @@ pub mod video_toolbox {impl_CFTypeDescription!(VTCompressionSession);impl VTCompressionSession {- pub fn new(+ pub unsafe fn new(width: usize,height: usize,codec: CMVideoCodecType,callback: VTCompressionOutputCallback,callback_data: *const c_void,) -> Result<Self> {- unsafe {- let mut this = ptr::null();- let result = VTCompressionSessionCreate(- ptr::null(),- width as i32,- height as i32,- codec,- ptr::null(),- ptr::null(),- ptr::null(),- callback,- callback_data,- &mut this,- );-- if result == 0 {- Ok(Self::wrap_under_create_rule(this))- } else {- Err(anyhow!(- "error creating compression session, code {}",- result- ))- }+ let mut this = ptr::null();+ let result = VTCompressionSessionCreate(+ ptr::null(),+ width as i32,+ height as i32,+ codec,+ ptr::null(),+ ptr::null(),+ ptr::null(),+ callback,+ callback_data,+ &mut this,+ );++ if result == 0 {+ Ok(Self::wrap_under_create_rule(this))+ } else {+ Err(anyhow!(+ "error creating compression session, code {}",+ result+ ))}}- pub fn encode_frame(+ pub unsafe fn encode_frame(&self,buffer: CVImageBufferRef,presentation_timestamp: CMTime,duration: CMTime,) -> Result<()> {- unsafe {- let result = VTCompressionSessionEncodeFrame(- self.as_concrete_TypeRef(),- buffer,- presentation_timestamp,- duration,- ptr::null(),- ptr::null(),- ptr::null_mut(),- );- if result == 0 {- Ok(())- } else {- Err(anyhow!("error encoding frame, code {}", result))- }+ let result = VTCompressionSessionEncodeFrame(+ self.as_concrete_TypeRef(),+ buffer,+ presentation_timestamp,+ duration,+ ptr::null(),+ ptr::null(),+ ptr::null_mut(),+ );+ if result == 0 {+ Ok(())+ } else {+ Err(anyhow!("error encoding frame, code {}", result))}}}