1 /* xscreensaver, Copyright (c) 1991-2016 Jamie Zawinski <jwz@jwz.org>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
19 #define Assert(C, ...) do { if (!(C)) jwxyz_abort (__VA_ARGS__); } while(0)
21 /* OSX/jwxyz.m, utils/jwxyz-gl.c */
22 extern Display *jwxyz_make_display (Window w);
23 extern void jwxyz_free_display (Display *);
24 extern void jwxyz_window_resized (Display *);
25 extern uint32_t jwxyz_alloc_color (Display *dpy, uint16_t r, uint16_t g,
26 uint16_t b, uint16_t a);
27 extern void jwxyz_query_color (Display *dpy, unsigned long pixel,
29 extern unsigned long jwxyz_window_background (Display *);
30 extern int jwxyz_draw_arc (Display *dpy, Drawable d, GC gc, int x, int y,
31 unsigned int width, unsigned int height,
32 int angle1, int angle2, Bool fill_p);
33 extern void jwxyz_fill_rects (Display *dpy, Drawable d, GC gc,
34 const XRectangle *rectangles,
37 extern XGCValues *jwxyz_gc_gcv (GC gc);
38 extern unsigned int jwxyz_gc_depth (GC gc);
40 /* OSX/jwxyz-cocoa.m, android/jwxyz-android.c */
41 extern const XRectangle *jwxyz_frame (Drawable d); /* XGetGeometry sux. */
42 extern unsigned int jwxyz_drawable_depth (Drawable d);
43 extern void jwxyz_get_pos (Window w, XPoint *vpos, XPoint *p);
44 extern void jwxyz_copy_area (Display *dpy, Drawable src, Drawable dst, GC gc,
46 unsigned int width, unsigned int height,
47 int dst_x, int dst_y);
48 #ifndef current_device_rotation
49 extern double current_device_rotation (void);
50 extern Bool ignore_rotation_p (Display *);
53 /* utils/jwxyz-common.c */
54 extern void jwxyz_validate_pixel (Display *dpy, unsigned long pixel,
55 unsigned int depth, Bool alpha_allowed_p);
56 extern Bool jwxyz_dumb_drawing_mode(Display *dpy, Drawable d, GC gc,
58 unsigned width, unsigned height);
59 extern void jwxyz_fill_rect (Display *, Drawable, GC,
61 unsigned int width, unsigned int height,
63 extern void jwxyz_gcv_defaults (Display *dpy, XGCValues *gcv, int depth);
65 # if defined JWXYZ_QUARTZ
67 # include <CoreGraphics/CGGeometry.h>
68 # include <CoreGraphics/CGContext.h>
70 extern void jwxyz_flush_context (Display *);
72 # define jwxyz_assert_display(dpy)
73 # define jwxyz_assert_drawable(main_window, d)
74 # define jwxyz_assert_gl()
76 /* jwxyz-cocoa.m needs these from jwxyz.m for XCopyArea. */
77 extern void invalidate_drawable_cache (Drawable d);
78 extern void set_color (Display *dpy, CGContextRef cgc, unsigned long argb,
79 unsigned int depth, Bool alpha_allowed_p, Bool fill_p);
80 extern void push_gc (Drawable d, GC gc);
81 extern void push_color_gc (Display *dpy, Drawable d, GC gc,
83 Bool antialias_p, Bool fill_p);
84 extern CGPoint map_point (Drawable d, int x, int y);
86 #define seek_xy(dst, dst_pitch, x, y) \
87 ((void *)((char *)dst + dst_pitch * y + x * 4))
89 #define pop_gc(d,gc) CGContextRestoreGState (d->cgc)
91 # elif defined JWXYZ_GL
93 /* utils/jwxyz-gl.c */
94 extern void jwxyz_prepare_context (Display *dpy);
95 extern void jwxyz_set_matrices (Display *dpy, unsigned width, unsigned height,
98 /* Only works if both drawables share OpenGL objects. OpenGL context sharing
99 works on OS X, iOS, and some (but not all!) EGL implementations. This would
100 also work with FBOs and one context for everything. Surprisingly slow and
103 extern void jwxyz_gl_copy_area_copy_tex_image (Display *dpy, Drawable src,
105 int src_x, int src_y,
108 int dst_x, int dst_y);
110 /* glReadPixels followed by glTexImage2D. This is terrible, so only use this
111 if nothing else works.
113 extern void jwxyz_gl_copy_area_read_pixels (Display *dpy, Drawable src,
115 int src_x, int src_y,
118 int dst_x, int dst_y);
120 /* Platform-specific */
121 extern void jwxyz_bind_drawable (Display *dpy, Window w, Drawable d);
122 extern void jwxyz_assert_display (Display *);
123 extern void jwxyz_assert_drawable (Window main_window, Drawable d);
124 extern void jwxyz_assert_gl (void);
126 extern void *jwxyz_load_native_font (Display *, const char *name,
127 char **native_name_ret, float *size_ret,
128 int *ascent_ret, int *descent_ret);
129 extern void jwxyz_release_native_font (Display *, void *native_font);
130 extern void jwxyz_render_text (Display *, void *native_font,
131 const char *str, size_t len, int utf8_p,
132 XCharStruct *cs_ret, char **pixmap_ret);
134 # endif /* JWXYZ_GL */