From d3a98cf6cbc3bd0b9efc570f58e8812c03931c18 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 16 Oct 2018 10:08:48 +0200 Subject: Original 5.40 --- jwxyz/jwxyz-cocoa.h | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 jwxyz/jwxyz-cocoa.h (limited to 'jwxyz/jwxyz-cocoa.h') diff --git a/jwxyz/jwxyz-cocoa.h b/jwxyz/jwxyz-cocoa.h new file mode 100644 index 0000000..5f2f61c --- /dev/null +++ b/jwxyz/jwxyz-cocoa.h @@ -0,0 +1,98 @@ +/* xscreensaver, Copyright (c) 1991-2015 Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#ifndef __JWXYZ_COCOA_H__ +#define __JWXYZ_COCOA_H__ + +#import "XScreenSaverView.h" + +#ifdef USE_IPHONE +# import +# define NSView UIView +# define NSOpenGLContext EAGLContext +#endif + +#ifdef JWXYZ_QUARTZ + +struct jwxyz_Drawable { + enum { WINDOW, PIXMAP } type; + CGContextRef cgc; + CGImageRef cgi; + XRectangle frame; + union { + struct { + XScreenSaverView *view; + int last_mouse_x, last_mouse_y; + } window; + struct { + int depth; + void *cgc_buffer; // the bits to which CGContextRef renders + } pixmap; + }; +}; + +#elif defined JWXYZ_GL + +struct jwxyz_Drawable { + enum { WINDOW, PIXMAP } type; + /* OS X: Contexts are unique for each pixmap, 'cause life is hectic. (OS X + appears to dislike it when you attach different pbuffers to the + same context one after the other, apparently.) The Window has this + CFRetained because of garbage collection. For both Pixmaps and + Windows, CFRelease this when done. + iOS: ogl_ctx here is set to either XScreenSaverView.ogl_ctx or + XRootWindow()->window.ogl_ctx_pixmap. No garbage collection antics + here, so no need to CFRetain anything. Plus, if a screenhack leaks + a Pixmap (and they do that all the time), ogl_ctx_pixmap will also + get leaked if a Pixmap CFRetains this. + */ + NSOpenGLContext *ogl_ctx; // OpenGL rendering context (OS X) +# ifdef USE_IPHONE + // TODO: Also on OS X as extensions. + GLuint gl_framebuffer, gl_renderbuffer; +# endif // USE_IPHONE + CGImageRef cgi; + XRectangle frame; + union { + struct { + XScreenSaverView *view; + int last_mouse_x, last_mouse_y; + struct jwxyz_Drawable *current_drawable; +# ifndef USE_IPHONE + NSOpenGLPixelFormat *pixfmt; + GLint virtual_screen; +# else // USE_IPHONE + NSOpenGLContext *ogl_ctx_pixmap; +# endif + } window; + struct { + int depth; +# ifndef USE_IPHONE + NSOpenGLPixelBuffer *gl_pbuffer; + // GLuint blit_texture; // TODO: For blitting from Pbuffers +# endif + } pixmap; + }; +}; + +#endif // JWXYZ_GL + +extern NSString *nsstring_from(const char *str, size_t len, int utf8_p); + +#ifdef USE_IPHONE +extern void create_framebuffer (GLuint *gl_framebuffer, + GLuint *gl_renderbuffer); +extern void check_framebuffer_status (void); +#endif // USE_IPHONE + +#define jwxyz_window_view(w) ((w)->window.view) + +#endif -- cgit v1.2.3-55-g7522