Start fixing up gpui2
This commit is contained in:
parent
86facbbe4a
commit
7d420edb84
3 changed files with 97 additions and 98 deletions
|
@ -1896,7 +1896,6 @@ impl Into<Corners<Pixels>> for Pixels {
|
||||||
Div,
|
Div,
|
||||||
DivAssign,
|
DivAssign,
|
||||||
PartialEq,
|
PartialEq,
|
||||||
PartialOrd,
|
|
||||||
Serialize,
|
Serialize,
|
||||||
Deserialize,
|
Deserialize,
|
||||||
)]
|
)]
|
||||||
|
@ -2039,9 +2038,15 @@ impl Mul<Pixels> for Pixels {
|
||||||
|
|
||||||
impl Eq 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 {
|
impl Ord for Pixels {
|
||||||
fn cmp(&self, other: &Self) -> cmp::Ordering {
|
fn cmp(&self, other: &Self) -> cmp::Ordering {
|
||||||
self.0.partial_cmp(&other.0).unwrap()
|
self.partial_cmp(other).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ impl MetalRenderer {
|
||||||
unit_vertices,
|
unit_vertices,
|
||||||
instances,
|
instances,
|
||||||
sprite_atlas,
|
sprite_atlas,
|
||||||
core_video_texture_cache: CVMetalTextureCache::new(device.as_ptr()).unwrap(),
|
core_video_texture_cache: unsafe { CVMetalTextureCache::new(device.as_ptr()).unwrap() },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,8 +849,8 @@ impl MetalRenderer {
|
||||||
media::core_video::kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
|
media::core_video::kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
|
||||||
);
|
);
|
||||||
|
|
||||||
let y_texture = self
|
let y_texture = unsafe {
|
||||||
.core_video_texture_cache
|
self.core_video_texture_cache
|
||||||
.create_texture_from_image(
|
.create_texture_from_image(
|
||||||
surface.image_buffer.as_concrete_TypeRef(),
|
surface.image_buffer.as_concrete_TypeRef(),
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
|
@ -859,9 +859,10 @@ impl MetalRenderer {
|
||||||
surface.image_buffer.plane_height(0),
|
surface.image_buffer.plane_height(0),
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap()
|
||||||
let cb_cr_texture = self
|
};
|
||||||
.core_video_texture_cache
|
let cb_cr_texture = unsafe {
|
||||||
|
self.core_video_texture_cache
|
||||||
.create_texture_from_image(
|
.create_texture_from_image(
|
||||||
surface.image_buffer.as_concrete_TypeRef(),
|
surface.image_buffer.as_concrete_TypeRef(),
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
|
@ -870,7 +871,8 @@ impl MetalRenderer {
|
||||||
surface.image_buffer.plane_height(1),
|
surface.image_buffer.plane_height(1),
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
align_offset(offset);
|
align_offset(offset);
|
||||||
let next_offset = *offset + mem::size_of::<Surface>();
|
let next_offset = *offset + mem::size_of::<Surface>();
|
||||||
|
|
|
@ -108,8 +108,7 @@ pub mod core_video {
|
||||||
impl_CFTypeDescription!(CVMetalTextureCache);
|
impl_CFTypeDescription!(CVMetalTextureCache);
|
||||||
|
|
||||||
impl CVMetalTextureCache {
|
impl CVMetalTextureCache {
|
||||||
pub fn new(metal_device: *mut MTLDevice) -> Result<Self> {
|
pub unsafe fn new(metal_device: *mut MTLDevice) -> Result<Self> {
|
||||||
unsafe {
|
|
||||||
let mut this = ptr::null();
|
let mut this = ptr::null();
|
||||||
let result = CVMetalTextureCacheCreate(
|
let result = CVMetalTextureCacheCreate(
|
||||||
kCFAllocatorDefault,
|
kCFAllocatorDefault,
|
||||||
|
@ -124,9 +123,8 @@ pub mod core_video {
|
||||||
Err(anyhow!("could not create texture cache, code: {}", result))
|
Err(anyhow!("could not create texture cache, code: {}", result))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub fn create_texture_from_image(
|
pub unsafe fn create_texture_from_image(
|
||||||
&self,
|
&self,
|
||||||
source: CVImageBufferRef,
|
source: CVImageBufferRef,
|
||||||
texture_attributes: CFDictionaryRef,
|
texture_attributes: CFDictionaryRef,
|
||||||
|
@ -135,7 +133,6 @@ pub mod core_video {
|
||||||
height: usize,
|
height: usize,
|
||||||
plane_index: usize,
|
plane_index: usize,
|
||||||
) -> Result<CVMetalTexture> {
|
) -> Result<CVMetalTexture> {
|
||||||
unsafe {
|
|
||||||
let mut this = ptr::null();
|
let mut this = ptr::null();
|
||||||
let result = CVMetalTextureCacheCreateTextureFromImage(
|
let result = CVMetalTextureCacheCreateTextureFromImage(
|
||||||
kCFAllocatorDefault,
|
kCFAllocatorDefault,
|
||||||
|
@ -155,7 +152,6 @@ pub mod core_video {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[link(name = "CoreVideo", kind = "framework")]
|
#[link(name = "CoreVideo", kind = "framework")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -438,14 +434,13 @@ pub mod video_toolbox {
|
||||||
impl_CFTypeDescription!(VTCompressionSession);
|
impl_CFTypeDescription!(VTCompressionSession);
|
||||||
|
|
||||||
impl VTCompressionSession {
|
impl VTCompressionSession {
|
||||||
pub fn new(
|
pub unsafe fn new(
|
||||||
width: usize,
|
width: usize,
|
||||||
height: usize,
|
height: usize,
|
||||||
codec: CMVideoCodecType,
|
codec: CMVideoCodecType,
|
||||||
callback: VTCompressionOutputCallback,
|
callback: VTCompressionOutputCallback,
|
||||||
callback_data: *const c_void,
|
callback_data: *const c_void,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
unsafe {
|
|
||||||
let mut this = ptr::null();
|
let mut this = ptr::null();
|
||||||
let result = VTCompressionSessionCreate(
|
let result = VTCompressionSessionCreate(
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
|
@ -469,15 +464,13 @@ pub mod video_toolbox {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub fn encode_frame(
|
pub unsafe fn encode_frame(
|
||||||
&self,
|
&self,
|
||||||
buffer: CVImageBufferRef,
|
buffer: CVImageBufferRef,
|
||||||
presentation_timestamp: CMTime,
|
presentation_timestamp: CMTime,
|
||||||
duration: CMTime,
|
duration: CMTime,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
unsafe {
|
|
||||||
let result = VTCompressionSessionEncodeFrame(
|
let result = VTCompressionSessionEncodeFrame(
|
||||||
self.as_concrete_TypeRef(),
|
self.as_concrete_TypeRef(),
|
||||||
buffer,
|
buffer,
|
||||||
|
@ -494,7 +487,6 @@ pub mod video_toolbox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
type VTCompressionOutputCallback = Option<
|
type VTCompressionOutputCallback = Option<
|
||||||
unsafe extern "C" fn(
|
unsafe extern "C" fn(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue