summaryrefslogtreecommitdiffstats
path: root/third_party/rust/metal/src/buffer.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /third_party/rust/metal/src/buffer.rs
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/metal/src/buffer.rs')
-rw-r--r--third_party/rust/metal/src/buffer.rs67
1 files changed, 67 insertions, 0 deletions
diff --git a/third_party/rust/metal/src/buffer.rs b/third_party/rust/metal/src/buffer.rs
new file mode 100644
index 0000000000..e334c54e50
--- /dev/null
+++ b/third_party/rust/metal/src/buffer.rs
@@ -0,0 +1,67 @@
+// Copyright 2016 GFX developers
+//
+// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
+// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
+// http://opensource.org/licenses/MIT>, at your option. This file may not be
+// copied, modified, or distributed except according to those terms.
+
+use super::*;
+
+pub enum MTLBuffer {}
+
+foreign_obj_type! {
+ type CType = MTLBuffer;
+ pub struct Buffer;
+ pub struct BufferRef;
+ type ParentType = ResourceRef;
+}
+
+impl BufferRef {
+ pub fn length(&self) -> u64 {
+ unsafe { msg_send![self, length] }
+ }
+
+ pub fn contents(&self) -> *mut std::ffi::c_void {
+ unsafe { msg_send![self, contents] }
+ }
+
+ pub fn did_modify_range(&self, range: crate::NSRange) {
+ unsafe { msg_send![self, didModifyRange: range] }
+ }
+
+ pub fn new_texture_with_descriptor(
+ &self,
+ descriptor: &TextureDescriptorRef,
+ offset: u64,
+ bytes_per_row: u64,
+ ) -> Texture {
+ unsafe {
+ msg_send![self,
+ newTextureWithDescriptor:descriptor
+ offset:offset
+ bytesPerRow:bytes_per_row
+ ]
+ }
+ }
+
+ /// Only available on macos(10.15), NOT available on (ios)
+ pub fn remote_storage_buffer(&self) -> &BufferRef {
+ unsafe { msg_send![self, remoteStorageBuffer] }
+ }
+
+ /// Only available on (macos(10.15), NOT available on (ios)
+ pub fn new_remote_buffer_view_for_device(&self, device: &DeviceRef) -> Buffer {
+ unsafe { msg_send![self, newRemoteBufferViewForDevice: device] }
+ }
+
+ pub fn add_debug_marker(&self, name: &str, range: crate::NSRange) {
+ unsafe {
+ let name = crate::nsstring_from_str(name);
+ msg_send![self, addDebugMarker:name range:range]
+ }
+ }
+
+ pub fn remove_all_debug_markers(&self) {
+ unsafe { msg_send![self, removeAllDebugMarkers] }
+ }
+}