//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-video")]
#[cfg(target_vendor = "apple")]
use objc2_core_video::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-quartz-core")]
#[cfg(target_vendor = "apple")]
use objc2_quartz_core::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsopengllayer?language=objc)
    #[unsafe(super(CAOpenGLLayer, CALayer, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2-quartz-core")]
    #[cfg(target_vendor = "apple")]
    #[deprecated = "Please use CAMetalLayer instead."]
    pub struct NSOpenGLLayer;
);

#[cfg(feature = "objc2-quartz-core")]
#[cfg(target_vendor = "apple")]
extern_conformance!(
    unsafe impl CAMediaTiming for NSOpenGLLayer {}
);

#[cfg(feature = "objc2-quartz-core")]
#[cfg(target_vendor = "apple")]
extern_conformance!(
    unsafe impl NSCoding for NSOpenGLLayer {}
);

#[cfg(feature = "objc2-quartz-core")]
#[cfg(target_vendor = "apple")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSOpenGLLayer {}
);

#[cfg(feature = "objc2-quartz-core")]
#[cfg(target_vendor = "apple")]
extern_conformance!(
    unsafe impl NSSecureCoding for NSOpenGLLayer {}
);

#[cfg(feature = "objc2-quartz-core")]
#[cfg(target_vendor = "apple")]
impl NSOpenGLLayer {
    extern_methods!(
        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[unsafe(method(view))]
        #[unsafe(method_family = none)]
        pub fn view(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        /// Setter for [`view`][Self::view].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setView:))]
        #[unsafe(method_family = none)]
        pub fn setView(&self, view: Option<&NSView>);

        #[cfg(feature = "NSOpenGL")]
        #[unsafe(method(openGLPixelFormat))]
        #[unsafe(method_family = none)]
        pub fn openGLPixelFormat(&self) -> Option<Retained<NSOpenGLPixelFormat>>;

        #[cfg(feature = "NSOpenGL")]
        /// Setter for [`openGLPixelFormat`][Self::openGLPixelFormat].
        #[unsafe(method(setOpenGLPixelFormat:))]
        #[unsafe(method_family = none)]
        pub fn setOpenGLPixelFormat(&self, open_gl_pixel_format: Option<&NSOpenGLPixelFormat>);

        #[cfg(feature = "NSOpenGL")]
        #[unsafe(method(openGLContext))]
        #[unsafe(method_family = none)]
        pub fn openGLContext(&self) -> Option<Retained<NSOpenGLContext>>;

        #[cfg(feature = "NSOpenGL")]
        /// Setter for [`openGLContext`][Self::openGLContext].
        #[unsafe(method(setOpenGLContext:))]
        #[unsafe(method_family = none)]
        pub fn setOpenGLContext(&self, open_gl_context: Option<&NSOpenGLContext>);

        #[cfg(feature = "NSOpenGL")]
        #[unsafe(method(openGLPixelFormatForDisplayMask:))]
        #[unsafe(method_family = none)]
        pub fn openGLPixelFormatForDisplayMask(&self, mask: u32) -> Retained<NSOpenGLPixelFormat>;

        #[cfg(feature = "NSOpenGL")]
        #[unsafe(method(openGLContextForPixelFormat:))]
        #[unsafe(method_family = none)]
        pub fn openGLContextForPixelFormat(
            &self,
            pixel_format: &NSOpenGLPixelFormat,
        ) -> Retained<NSOpenGLContext>;

        #[cfg(all(
            feature = "NSOpenGL",
            feature = "objc2-core-foundation",
            feature = "objc2-core-video"
        ))]
        /// # Safety
        ///
        /// `ts` must be a valid pointer.
        #[unsafe(method(canDrawInOpenGLContext:pixelFormat:forLayerTime:displayTime:))]
        #[unsafe(method_family = none)]
        pub unsafe fn canDrawInOpenGLContext_pixelFormat_forLayerTime_displayTime(
            &self,
            context: &NSOpenGLContext,
            pixel_format: &NSOpenGLPixelFormat,
            t: CFTimeInterval,
            ts: NonNull<CVTimeStamp>,
        ) -> bool;

        #[cfg(all(
            feature = "NSOpenGL",
            feature = "objc2-core-foundation",
            feature = "objc2-core-video"
        ))]
        /// # Safety
        ///
        /// `ts` must be a valid pointer.
        #[unsafe(method(drawInOpenGLContext:pixelFormat:forLayerTime:displayTime:))]
        #[unsafe(method_family = none)]
        pub unsafe fn drawInOpenGLContext_pixelFormat_forLayerTime_displayTime(
            &self,
            context: &NSOpenGLContext,
            pixel_format: &NSOpenGLPixelFormat,
            t: CFTimeInterval,
            ts: NonNull<CVTimeStamp>,
        );
    );
}

/// Methods declared on superclass `CALayer`.
#[cfg(feature = "objc2-quartz-core")]
#[cfg(target_vendor = "apple")]
impl NSOpenGLLayer {
    extern_methods!(
        /// Layer creation and initialization. *
        #[unsafe(method(layer))]
        #[unsafe(method_family = none)]
        pub fn layer() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        /// # Safety
        ///
        /// `layer` should be of the correct type.
        #[unsafe(method(initWithLayer:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLayer(this: Allocated<Self>, layer: &AnyObject) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2-quartz-core")]
#[cfg(target_vendor = "apple")]
impl NSOpenGLLayer {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

#[cfg(feature = "objc2-quartz-core")]
#[cfg(target_vendor = "apple")]
impl DefaultRetained for NSOpenGLLayer {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}
