summaryrefslogtreecommitdiff
path: root/uisimulator
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-03-26 13:41:46 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-03-26 13:41:46 +0000
commit3066991c061dab5224279ab4df988c8f9317f216 (patch)
treebd78cbd455dde7fb4ffd402fd6c1b66421549780 /uisimulator
parent50e23294586bfa8d54aa0f51227a1afac783d8b6 (diff)
downloadrockbox-3066991c061dab5224279ab4df988c8f9317f216.tar.gz
rockbox-3066991c061dab5224279ab4df988c8f9317f216.zip
removed unused code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/Makefile4
-rw-r--r--uisimulator/alpha.c78
-rw-r--r--uisimulator/hsv.c81
3 files changed, 2 insertions, 161 deletions
diff --git a/uisimulator/Makefile b/uisimulator/Makefile
index 8d118589a0..1ad5649eb7 100644
--- a/uisimulator/Makefile
+++ b/uisimulator/Makefile
@@ -28,8 +28,8 @@ LDFLAGS = -lX11 -lm -lXt -lXmu -lsocket -lnsl
28 28
29DEPEND = .depends 29DEPEND = .depends
30 30
31OBJS= alpha.o hsv.o screenhack.o yarandom.o uibasic.o resources.o visual.o\ 31OBJS= alpha.o screenhack.o yarandom.o uibasic.o resources.o visual.o\
32 usleep.o lcd.o lcd-x11.o 32 lcd.o lcd-x11.o
33 33
34SRCS = $(OBJS:%.o=%.c) 34SRCS = $(OBJS:%.o=%.c)
35HDRS = $(OBJS:%.o=%.h) 35HDRS = $(OBJS:%.o=%.h)
diff --git a/uisimulator/alpha.c b/uisimulator/alpha.c
index 22504fcd93..39abd33251 100644
--- a/uisimulator/alpha.c
+++ b/uisimulator/alpha.c
@@ -135,81 +135,3 @@ initialize_transparency_colormap (Display *dpy, Colormap cmap,
135 XFree ((XPointer) all_colors); 135 XFree ((XPointer) all_colors);
136} 136}
137 137
138
139Bool
140allocate_alpha_colors (Screen *screen, Visual *visual, Colormap cmap,
141 int *nplanesP, Bool additive_p,
142 unsigned long **plane_masks,
143 unsigned long *base_pixelP)
144{
145 Display *dpy = DisplayOfScreen (screen);
146 XColor *colors;
147 int nplanes = *nplanesP;
148 int i;
149
150 if (!has_writable_cells (screen, visual))
151 cmap = 0;
152
153 if (!cmap) /* A TrueColor visual, or similar. */
154 {
155 int depth = visual_depth (screen, visual);
156 unsigned long masks;
157 XVisualInfo vi_in, *vi_out;
158
159 /* Find out which bits the R, G, and B components actually occupy
160 on this visual. */
161 vi_in.screen = screen_number (screen);
162 vi_in.visualid = XVisualIDFromVisual (visual);
163 vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask,
164 &vi_in, &i);
165 if (! vi_out) abort ();
166 masks = vi_out[0].red_mask | vi_out[0].green_mask | vi_out[0].blue_mask;
167 XFree ((char *) vi_out);
168
169 if (nplanes > depth)
170 nplanes = depth;
171 *nplanesP = nplanes;
172 *base_pixelP = 0;
173 *plane_masks = (unsigned long *) calloc(sizeof(unsigned long), nplanes);
174
175 /* Pick the planar values randomly, but constrain them to fall within
176 the bit positions of the R, G, and B fields. */
177 for (i = 0; i < nplanes; i++)
178 (*plane_masks)[i] = random() & masks;
179
180 }
181 else /* A PseudoColor visual, or similar. */
182 {
183 if (nplanes > 31) nplanes = 31;
184 *plane_masks = (unsigned long *) malloc(sizeof(unsigned long) * nplanes);
185
186 nplanes = allocate_color_planes (dpy, cmap, nplanes, *plane_masks,
187 base_pixelP);
188 *nplanesP = nplanes;
189
190 if (nplanes <= 1)
191 {
192 free(*plane_masks);
193 *plane_masks = 0;
194 return False;
195 }
196
197 colors = (XColor *) calloc (nplanes, sizeof (XColor));
198 for (i = 0; i < nplanes; i++)
199 {
200 /* pick the base colors. If we are in subtractive mode, pick higher
201 intensities. */
202 hsv_to_rgb (random () % 360,
203 frand (1.0),
204 frand (0.5) + (additive_p ? 0.2 : 0.5),
205 &colors[i].red,
206 &colors[i].green,
207 &colors[i].blue);
208 }
209 initialize_transparency_colormap (dpy, cmap, nplanes,
210 *base_pixelP, *plane_masks, colors,
211 additive_p);
212 XFree ((XPointer) colors);
213 }
214 return True;
215}
diff --git a/uisimulator/hsv.c b/uisimulator/hsv.c
deleted file mode 100644
index cf1cc8d18e..0000000000
--- a/uisimulator/hsv.c
+++ /dev/null
@@ -1,81 +0,0 @@
1/* xscreensaver, Copyright (c) 1992, 1997 Jamie Zawinski <jwz@jwz.org>
2 *
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
9 * implied warranty.
10 */
11
12/* This file contains some utility routines for randomly picking the colors
13 to hack the screen with.
14 */
15
16#include "utils.h"
17#include "hsv.h"
18
19void
20hsv_to_rgb (int h, double s, double v,
21 unsigned short *r, unsigned short *g, unsigned short *b)
22{
23 double H, S, V, R, G, B;
24 double p1, p2, p3;
25 double f;
26 int i;
27
28 if (s < 0) s = 0;
29 if (v < 0) v = 0;
30 if (s > 1) s = 1;
31 if (v > 1) v = 1;
32
33 S = s; V = v;
34 H = (h % 360) / 60.0;
35 i = H;
36 f = H - i;
37 p1 = V * (1 - S);
38 p2 = V * (1 - (S * f));
39 p3 = V * (1 - (S * (1 - f)));
40 if (i == 0) { R = V; G = p3; B = p1; }
41 else if (i == 1) { R = p2; G = V; B = p1; }
42 else if (i == 2) { R = p1; G = V; B = p3; }
43 else if (i == 3) { R = p1; G = p2; B = V; }
44 else if (i == 4) { R = p3; G = p1; B = V; }
45 else { R = V; G = p1; B = p2; }
46 *r = R * 65535;
47 *g = G * 65535;
48 *b = B * 65535;
49}
50
51void
52rgb_to_hsv (unsigned short r, unsigned short g, unsigned short b,
53 int *h, double *s, double *v)
54{
55 double R, G, B, H, S, V;
56 double cmax, cmin;
57 double cmm;
58 int imax;
59 R = ((double) r) / 65535.0;
60 G = ((double) g) / 65535.0;
61 B = ((double) b) / 65535.0;
62 cmax = R; cmin = G; imax = 1;
63 if ( cmax < G ) { cmax = G; cmin = R; imax = 2; }
64 if ( cmax < B ) { cmax = B; imax = 3; }
65 if ( cmin > B ) { cmin = B; }
66 cmm = cmax - cmin;
67 V = cmax;
68 if (cmm == 0)
69 S = H = 0;
70 else
71 {
72 S = cmm / cmax;
73 if (imax == 1) H = (G - B) / cmm;
74 else if (imax == 2) H = 2.0 + (B - R) / cmm;
75 else /*if (imax == 3)*/ H = 4.0 + (R - G) / cmm;
76 if (H < 0) H += 6.0;
77 }
78 *h = (H * 60.0);
79 *s = S;
80 *v = V;
81}