Skip to content

Commit

Permalink
Fix comment formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jun 28, 2024
1 parent 9c71664 commit 883d5c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub unsafe fn metal_layer_from_ns_view(view: NonNull<c_void>) -> Layer {
// SAFETY: Caller ensures that the view is valid.
let obj = unsafe { view.cast::<NSObject>().as_ref() };

// Check if the view is a CAMetalLayer
// Check if the view is a `CAMetalLayer`.
if obj.is_kind_of::<CAMetalLayer>() {
// SAFETY: Just checked that the view is a `CAMetalLayer`.
let layer = unsafe { view.cast::<CAMetalLayer>().as_ref() };
Expand All @@ -27,10 +27,10 @@ pub unsafe fn metal_layer_from_ns_view(view: NonNull<c_void>) -> Layer {
pre_existing: true,
};
}
// Otherwise assume the view is `NSView`
// Otherwise assume the view is `NSView`.
let view = unsafe { view.cast::<objc2_app_kit::NSView>().as_ref() };

// Check if the view contains a valid CAMetalLayer
// Check if the view contains a valid `CAMetalLayer`.
let existing = unsafe { view.layer() };
if let Some(existing) = existing {
if existing.is_kind_of::<CAMetalLayer>() {
Expand All @@ -43,7 +43,7 @@ pub unsafe fn metal_layer_from_ns_view(view: NonNull<c_void>) -> Layer {
}
}

// If the layer was not `CAMetalLayer`, allocate a new one for the view
// If the layer was not `CAMetalLayer`, allocate a new one for the view.
let layer = unsafe { CAMetalLayer::new() };
unsafe { view.setLayer(Some(&layer)) };
view.setWantsLayer(true);
Expand Down
12 changes: 6 additions & 6 deletions src/uikit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ pub unsafe fn metal_layer_from_handle(handle: UiKitWindowHandle) -> Layer {

///
pub unsafe fn metal_layer_from_ui_view(view: NonNull<c_void>) -> Layer {
// SAFETY: Caller ensures that the view is a UIView
// SAFETY: Caller ensures that the view is a `UIView`.
let view = unsafe { view.cast::<objc2_ui_kit::UIView>().as_ref() };

let main_layer = view.layer();

// Check if the view's layer is already a CAMetalLayer
// Check if the view's layer is already a `CAMetalLayer`.
let render_layer = if main_layer.is_kind_of::<CAMetalLayer>() {
// SAFETY: Just checked that the layer is a `CAMetalLayer`.
let layer = unsafe { Retained::cast::<CAMetalLayer>(main_layer) };
Expand All @@ -29,11 +29,11 @@ pub unsafe fn metal_layer_from_ui_view(view: NonNull<c_void>) -> Layer {
pre_existing: true,
}
} else {
// If the main layer is not a CAMetalLayer, we create a CAMetalLayer
// sublayer and use it instead.
// If the main layer is not a `CAMetalLayer`, we create a
// `CAMetalLayer` sublayer and use it instead.
//
// Unlike on macOS, we cannot replace the main view as UIView does not
// allow it (when NSView does).
// Unlike on macOS, we cannot replace the main view as `UIView` does
// not allow it (when `NSView` does).
let layer = unsafe { CAMetalLayer::new() };

let bounds = main_layer.bounds();
Expand Down

0 comments on commit 883d5c5

Please sign in to comment.