summaryrefslogtreecommitdiffstats
path: root/jwxyz
diff options
context:
space:
mode:
authorSimon Rettberg2022-01-20 13:33:11 +0100
committerSimon Rettberg2022-01-20 13:33:11 +0100
commit3d748ebe7d900e96670ff3d455896998dfba6191 (patch)
treee8bbaf6531897a2292da2158a46e9dce3df96baf /jwxyz
parentRe-sync dpms settings on unblank (diff)
downloadxscreensaver-29r1.tar.gz
xscreensaver-29r1.tar.xz
xscreensaver-29r1.zip
Diffstat (limited to 'jwxyz')
-rw-r--r--jwxyz/jwxyz-cocoa.h16
-rw-r--r--jwxyz/jwxyz-cocoa.m56
-rw-r--r--jwxyz/jwxyz-gl.c6
-rw-r--r--jwxyz/jwxyz.m30
-rw-r--r--jwxyz/jwxyzI.h2
-rw-r--r--jwxyz/jwzgles.c2
-rw-r--r--jwxyz/jwzgles.h1
7 files changed, 56 insertions, 57 deletions
diff --git a/jwxyz/jwxyz-cocoa.h b/jwxyz/jwxyz-cocoa.h
index 5f2f61c..28f08b7 100644
--- a/jwxyz/jwxyz-cocoa.h
+++ b/jwxyz/jwxyz-cocoa.h
@@ -14,7 +14,7 @@
#import "XScreenSaverView.h"
-#ifdef USE_IPHONE
+#ifdef HAVE_IPHONE
# import <UIKit/UIKit.h>
# define NSView UIView
# define NSOpenGLContext EAGLContext
@@ -55,10 +55,10 @@ struct jwxyz_Drawable {
get leaked if a Pixmap CFRetains this.
*/
NSOpenGLContext *ogl_ctx; // OpenGL rendering context (OS X)
-# ifdef USE_IPHONE
+# ifdef HAVE_IPHONE
// TODO: Also on OS X as extensions.
GLuint gl_framebuffer, gl_renderbuffer;
-# endif // USE_IPHONE
+# endif // HAVE_IPHONE
CGImageRef cgi;
XRectangle frame;
union {
@@ -66,16 +66,16 @@ struct jwxyz_Drawable {
XScreenSaverView *view;
int last_mouse_x, last_mouse_y;
struct jwxyz_Drawable *current_drawable;
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
NSOpenGLPixelFormat *pixfmt;
GLint virtual_screen;
-# else // USE_IPHONE
+# else // HAVE_IPHONE
NSOpenGLContext *ogl_ctx_pixmap;
# endif
} window;
struct {
int depth;
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
NSOpenGLPixelBuffer *gl_pbuffer;
// GLuint blit_texture; // TODO: For blitting from Pbuffers
# endif
@@ -87,11 +87,11 @@ struct jwxyz_Drawable {
extern NSString *nsstring_from(const char *str, size_t len, int utf8_p);
-#ifdef USE_IPHONE
+#ifdef HAVE_IPHONE
extern void create_framebuffer (GLuint *gl_framebuffer,
GLuint *gl_renderbuffer);
extern void check_framebuffer_status (void);
-#endif // USE_IPHONE
+#endif // HAVE_IPHONE
#define jwxyz_window_view(w) ((w)->window.view)
diff --git a/jwxyz/jwxyz-cocoa.m b/jwxyz/jwxyz-cocoa.m
index 13666e7..32a3dba 100644
--- a/jwxyz/jwxyz-cocoa.m
+++ b/jwxyz/jwxyz-cocoa.m
@@ -24,7 +24,7 @@
#include <stdarg.h>
-#ifdef USE_IPHONE
+#ifdef HAVE_IPHONE
# import <OpenGLES/ES1/gl.h>
# import <OpenGLES/ES1/glext.h>
# define NSOpenGLContext EAGLContext
@@ -99,7 +99,7 @@ jwxyz_scale_1 (Window main_window, BOOL fonts_p)
{
float scale = 1;
-# ifdef USE_IPHONE
+# ifdef HAVE_IPHONE
/* Since iOS screens are physically smaller than desktop screens, scale up
the fonts to make them more readable.
@@ -112,12 +112,12 @@ jwxyz_scale_1 (Window main_window, BOOL fonts_p)
if (scale < 1) // iPad Pro magnifies the backbuffer by 3x, which makes text
scale = 1; // excessively blurry in BSOD.
-# else // !USE_IPHONE
+# else // !HAVE_IPHONE
/* Desktop retina displays also need fonts doubled. */
scale = [main_window->window.view hackedContentScaleFactor:fonts_p];
-# endif // !USE_IPHONE
+# endif // !HAVE_IPHONE
return scale;
}
@@ -193,7 +193,7 @@ utf8_metrics (Display *dpy, NSFont *nsfont, NSString *nsstr, XCharStruct *cs)
CGFloat advancement =
CTRunGetTypographicBounds (run, r, &ascent, &descent, &leading);
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
// Only necessary for when LCD smoothing is enabled, which iOS doesn't do.
bbox.origin.x -= 2.0/3.0;
bbox.size.width += 4.0/3.0;
@@ -234,7 +234,7 @@ utf8_metrics (Display *dpy, NSFont *nsfont, NSString *nsstr, XCharStruct *cs)
static NSArray *
font_family_members (NSString *family_name)
{
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
return [[NSFontManager sharedFontManager]
availableMembersOfFontFamily:family_name];
# else
@@ -275,7 +275,7 @@ try_font (NSFontTraitMask traits, NSFontTraitMask mask,
traits & NSFixedPitchFontMask ? JWXYZ_STYLE_MONOSPACE : 0)]);
}
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
for (unsigned k = 0; k != family_members.count; ++k) {
NSArray *member = [family_members objectAtIndex:k];
@@ -308,7 +308,7 @@ try_font (NSFontTraitMask traits, NSFontTraitMask mask,
return f;
}
}
-# else // USE_IPHONE
+# else // HAVE_IPHONE
// This trick needs iOS 3.1, see "Using SDK-Based Development".
Class has_font_descriptor = [UIFontDescriptor class];
@@ -370,7 +370,7 @@ static NSFont *
random_font (NSFontTraitMask traits, NSFontTraitMask mask, float size)
{
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
// Providing Unbold or Unitalic in the mask for availableFontNamesWithTraits
// returns an empty list, at least on a system with default fonts only.
NSArray *families = [[NSFontManager sharedFontManager]
@@ -395,7 +395,7 @@ random_font (NSFontTraitMask traits, NSFontTraitMask mask, float size)
families = new_families;
}
-# endif // USE_IPHONE
+# endif // HAVE_IPHONE
long n = [families count];
if (n <= 0) return 0;
@@ -563,7 +563,7 @@ jwxyz_render_text (Display *dpy, void *native_font,
void
jwxyz_get_pos (Window w, XPoint *xvpos, XPoint *xp)
{
-# ifdef USE_IPHONE
+# ifdef HAVE_IPHONE
xvpos->x = 0;
xvpos->y = 0;
@@ -573,7 +573,7 @@ jwxyz_get_pos (Window w, XPoint *xvpos, XPoint *xp)
xp->y = w->window.last_mouse_y;
}
-# else // !USE_IPHONE
+# else // !HAVE_IPHONE
NSWindow *nsw = [w->window.view window];
@@ -631,11 +631,11 @@ jwxyz_get_pos (Window w, XPoint *xvpos, XPoint *xp)
xp->y = (int) p.y;
}
-# endif // !USE_IPHONE
+# endif // !HAVE_IPHONE
}
-#ifdef USE_IPHONE
+#ifdef HAVE_IPHONE
void
check_framebuffer_status (void)
@@ -693,7 +693,7 @@ create_framebuffer (GLuint *gl_framebuffer, GLuint *gl_renderbuffer)
glBindRenderbufferOES (GL_RENDERBUFFER_OES, *gl_renderbuffer);
}
-#endif // USE_IPHONE
+#endif // HAVE_IPHONE
#if defined JWXYZ_QUARTZ
@@ -841,7 +841,7 @@ jwxyz_copy_area (Display *dpy, Drawable src, Drawable dst, GC gc,
/* Strange and ugly flickering when going the glCopyTexImage2D route on
OS X. (Early 2009 Mac mini, OS X 10.10)
*/
-# ifdef USE_IPHONE
+# ifdef HAVE_IPHONE
/* TODO: This might not still work. */
jwxyz_bind_drawable (dpy, dpy->main_window, src);
@@ -850,10 +850,10 @@ jwxyz_copy_area (Display *dpy, Drawable src, Drawable dst, GC gc,
jwxyz_bind_drawable (dpy, dpy->main_window, dst);
jwxyz_gl_copy_area_write_tex_image (dpy, gc, src_x, src_y,
width, height, dst_x, dst_y);
-# else // !USE_IPHONE
+# else // !HAVE_IPHONE
jwxyz_gl_copy_area_read_pixels (dpy, src, dst, gc,
src_x, src_y, width, height, dst_x, dst_y);
-# endif // !USE_IPHONE
+# endif // !HAVE_IPHONE
jwxyz_assert_gl ();
}
@@ -877,7 +877,7 @@ jwxyz_assert_gl ()
void
jwxyz_assert_drawable (Window main_window, Drawable d)
{
-#if !defined USE_IPHONE && !defined __OPTIMIZE__
+#if !defined HAVE_IPHONE && !defined __OPTIMIZE__
XScreenSaverView *view = main_window->window.view;
NSOpenGLContext *ogl_ctx = [view oglContext];
@@ -896,7 +896,7 @@ jwxyz_assert_drawable (Window main_window, Drawable d)
perror([[exception reason] UTF8String]);
jwxyz_abort();
}
-#endif // !USE_IPHONE && !__OPTIMIZE__
+#endif // !HAVE_IPHONE && !__OPTIMIZE__
}
@@ -925,7 +925,7 @@ jwxyz_bind_drawable (Window main_window, Drawable d)
jwxyz_assert_gl ();
jwxyz_assert_drawable (main_window, d);
-#if defined USE_IPHONE && !defined __OPTIMIZE__
+#if defined HAVE_IPHONE && !defined __OPTIMIZE__
Drawable current_drawable = main_window->window.current_drawable;
Assert (!current_drawable
|| current_drawable->ogl_ctx == [EAGLContext currentContext],
@@ -942,7 +942,7 @@ jwxyz_bind_drawable (Window main_window, Drawable d)
main_window->window.current_drawable = d;
/* Doing this repeatedly is probably not OK performance-wise. Probably. */
-#ifndef USE_IPHONE
+#ifndef HAVE_IPHONE
[d->ogl_ctx makeCurrentContext];
#else
[EAGLContext setCurrentContext:d->ogl_ctx];
@@ -973,7 +973,7 @@ XCreatePixmap (Display *dpy, Drawable d,
/* TODO: If Pixel buffers are not supported, do something about it. */
Window w = XRootWindow (dpy, 0);
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
p->ogl_ctx = [[NSOpenGLContext alloc]
initWithFormat:w->window.pixfmt
@@ -997,7 +997,7 @@ XCreatePixmap (Display *dpy, Drawable d,
mipMapLevel:0
currentVirtualScreen:w->window.virtual_screen];
-# else // USE_IPHONE
+# else // HAVE_IPHONE
p->ogl_ctx = w->window.ogl_ctx_pixmap;
@@ -1012,7 +1012,7 @@ XCreatePixmap (Display *dpy, Drawable d,
glBindFramebufferOES(GL_FRAMEBUFFER_OES, p->gl_framebuffer);
-# endif // USE_IPHONE
+# endif // HAVE_IPHONE
w->window.current_drawable = p;
glViewport (0, 0, width, height);
@@ -1033,16 +1033,16 @@ XFreePixmap (Display *d, Pixmap p)
Window w = RootWindow (d, 0);
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
CFRelease (p->ogl_ctx);
[p->ogl_ctx release];
CFRelease (p->pixmap.gl_pbuffer);
[p->pixmap.gl_pbuffer release];
-# else // USE_IPHONE
+# else // HAVE_IPHONE
glDeleteRenderbuffersOES (1, &p->gl_renderbuffer);
glDeleteFramebuffersOES (1, &p->gl_framebuffer);
-# endif // USE_IPHONE
+# endif // HAVE_IPHONE
if (w->window.current_drawable == p) {
w->window.current_drawable = NULL;
diff --git a/jwxyz/jwxyz-gl.c b/jwxyz/jwxyz-gl.c
index f1c13da..3d36612 100644
--- a/jwxyz/jwxyz-gl.c
+++ b/jwxyz/jwxyz-gl.c
@@ -77,7 +77,7 @@
#include <wchar.h>
#ifdef HAVE_COCOA
-# ifdef USE_IPHONE
+# ifdef HAVE_IPHONE
# import <QuartzCore/QuartzCore.h>
# include <OpenGLES/ES1/gl.h>
# include <OpenGLES/ES1/glext.h>
@@ -186,7 +186,7 @@ jwxyz_set_matrices (Display *dpy, unsigned width, unsigned height,
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
-# if defined(USE_IPHONE) || defined(HAVE_ANDROID)
+# if defined(HAVE_IPHONE) || defined(HAVE_ANDROID)
if (window_p && ignore_rotation_p(dpy)) {
int o = (int) current_device_rotation();
@@ -917,7 +917,7 @@ jwxyz_gl_copy_area_read_tex_image (Display *dpy, unsigned src_height,
unsigned int width, unsigned int height,
int dst_x, int dst_y)
{
-# if defined HAVE_COCOA && !defined USE_IPHONE
+# if defined HAVE_COCOA && !defined HAVE_IPHONE
/* TODO: Does this help? */
/* glFinish(); */
# endif
diff --git a/jwxyz/jwxyz.m b/jwxyz/jwxyz.m
index c6a7af5..a4352d3 100644
--- a/jwxyz/jwxyz.m
+++ b/jwxyz/jwxyz.m
@@ -26,7 +26,7 @@
#import <stdint.h>
#import <wchar.h>
-#ifdef USE_IPHONE
+#ifdef HAVE_IPHONE
# import <UIKit/UIKit.h>
# import <UIKit/UIScreen.h>
# import <QuartzCore/QuartzCore.h>
@@ -66,7 +66,7 @@ struct jwxyz_Display {
Visual visual;
struct jwxyz_sources_data *timers_data;
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
CGDirectDisplayID cgdpy; /* ...of the one and only Window, main_window.
This can change if the window is dragged to
a different screen. */
@@ -399,7 +399,7 @@ jwxyz_window_resized (Display *dpy)
{
Window w = dpy->main_window;
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
// Figure out which screen the window is currently on.
{
int wx, wy;
@@ -417,7 +417,7 @@ jwxyz_window_resized (Display *dpy)
}
Assert (dpy->cgdpy, "unable to find CGDisplay");
}
-# endif // USE_IPHONE
+# endif // HAVE_IPHONE
/*
{
@@ -1394,9 +1394,9 @@ jwxyz_draw_NSImage_or_CGImage (Display *dpy, Drawable d,
XRectangle *geom_ret, int exif_rotation)
{
CGImageRef cgi;
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
CGImageSourceRef cgsrc;
-# endif // USE_IPHONE
+# endif // HAVE_IPHONE
NSSize imgr;
CGContextRef cgc = d->cgc;
@@ -1406,7 +1406,7 @@ jwxyz_draw_NSImage_or_CGImage (Display *dpy, Drawable d,
NSImage *nsimg = (NSImage *) img_arg;
imgr = [nsimg size];
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
// convert the NSImage to a CGImage via the toll-free-bridging
// of NSData and CFData...
//
@@ -1416,9 +1416,9 @@ jwxyz_draw_NSImage_or_CGImage (Display *dpy, Drawable d,
CFDataRef cfdata = (CFDataRef) nsdata;
cgsrc = CGImageSourceCreateWithData (cfdata, NULL);
cgi = CGImageSourceCreateImageAtIndex (cgsrc, 0, NULL);
-# else // USE_IPHONE
+# else // HAVE_IPHONE
cgi = nsimg.CGImage;
-# endif // USE_IPHONE
+# endif // HAVE_IPHONE
} else {
cgi = (CGImageRef) img_arg;
@@ -1481,12 +1481,12 @@ jwxyz_draw_NSImage_or_CGImage (Display *dpy, Drawable d,
CGContextDrawImage (cgc, dst2, cgi);
CGContextRestoreGState (cgc);
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
if (nsimg_p) {
CFRelease (cgsrc);
CGImageRelease (cgi);
}
-# endif // USE_IPHONE
+# endif // HAVE_IPHONE
if (geom_ret) {
geom_ret->x = dst.origin.x;
@@ -1507,7 +1507,7 @@ jwxyz_png_to_ximage (Display *dpy, Visual *visual,
[NSData dataWithBytes:png_data
length:data_size]];
if (! img) return 0;
-#ifndef USE_IPHONE
+#ifndef HAVE_IPHONE
NSBitmapImageRep *bm = [NSBitmapImageRep
imageRepWithData:
[NSBitmapImageRep
@@ -1525,7 +1525,7 @@ jwxyz_png_to_ximage (Display *dpy, Visual *visual,
convert_mode_t mode = (([bm bitmapFormat] & NSAlphaFirstBitmapFormat)
? CONVERT_MODE_ROTATE_MASK
: 0);
-#else // USE_IPHONE
+#else // HAVE_IPHONE
CGImageRef cgi = [img CGImage];
if (!cgi) {
[img release];
@@ -1547,7 +1547,7 @@ jwxyz_png_to_ximage (Display *dpy, Visual *visual,
convert_mode_t mode = convert_mode_to_rgba (bitmap_info);
-#endif // USE_IPHONE
+#endif // HAVE_IPHONE
XImage *image = XCreateImage (dpy, visual, 32, ZPixmap, 0, 0,
width, height, 8, 0);
@@ -1567,7 +1567,7 @@ jwxyz_png_to_ximage (Display *dpy, Visual *visual,
[img release];
-#ifndef USE_IPHONE
+#ifndef HAVE_IPHONE
// [bm release];
# else
CGContextRelease (cgc);
diff --git a/jwxyz/jwxyzI.h b/jwxyz/jwxyzI.h
index f7560f7..8672d36 100644
--- a/jwxyz/jwxyzI.h
+++ b/jwxyz/jwxyzI.h
@@ -130,7 +130,7 @@ extern void jwxyz_quartz_copy_area (Display *dpy, Drawable src, Drawable dst,
# ifdef JWXYZ_GL
-# if defined(USE_IPHONE)
+# if defined(HAVE_IPHONE)
# include <OpenGLES/ES1/gl.h>
# elif defined(HAVE_COCOA)
# include <OpenGL/gl.h>
diff --git a/jwxyz/jwzgles.c b/jwxyz/jwzgles.c
index b26bc3a..3895adc 100644
--- a/jwxyz/jwzgles.c
+++ b/jwxyz/jwzgles.c
@@ -162,7 +162,7 @@
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
-#if defined(USE_IPHONE)
+#if defined(HAVE_IPHONE)
# include <OpenGLES/ES1/gl.h>
# include <OpenGLES/ES1/glext.h>
#elif defined(HAVE_COCOA)
diff --git a/jwxyz/jwzgles.h b/jwxyz/jwzgles.h
index 9c8d1e2..a41dcbc 100644
--- a/jwxyz/jwzgles.h
+++ b/jwxyz/jwzgles.h
@@ -21,7 +21,6 @@
# error: do not include this without HAVE_JWZGLES
#endif
-
#include "jwzglesI.h"