1 /*
2  * Copyright © 2007 Novell, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software
5  * and its documentation for any purpose is hereby granted without
6  * fee, provided that the above copyright notice appear in all copies
7  * and that both that copyright notice and this permission notice
8  * appear in supporting documentation, and that the name of
9  * Novell, Inc. not be used in advertising or publicity pertaining to
10  * distribution of the software without specific, written prior permission.
11  * Novell, Inc. makes no representations about the suitability of this
12  * software for any purpose. It is provided "as is" without express or
13  * implied warranty.
14  *
15  * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17  * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Author: David Reveman <davidr@novell.com>
24  */
25 
26 #ifndef _COMPIZ_CUBE_H
27 #define _COMPIZ_CUBE_H
28 
29 #include <compiz-core.h>
30 
31 COMPIZ_BEGIN_DECLS
32 
33 #define CUBE_ABIVERSION 20080424
34 
35 typedef struct _CubeCore {
36     SetOptionForPluginProc setOptionForPlugin;
37 } CubeCore;
38 
39 #define CUBE_MOMODE_AUTO  0
40 #define CUBE_MOMODE_MULTI 1
41 #define CUBE_MOMODE_ONE   2
42 #define CUBE_MOMODE_LAST  CUBE_MOMODE_ONE
43 
44 #define CUBE_DISPLAY_OPTION_ABI        0
45 #define CUBE_DISPLAY_OPTION_INDEX      1
46 #define CUBE_DISPLAY_OPTION_UNFOLD_KEY 2
47 #define CUBE_DISPLAY_OPTION_NEXT_KEY   3
48 #define CUBE_DISPLAY_OPTION_PREV_KEY   4
49 #define CUBE_DISPLAY_OPTION_NUM        5
50 
51 typedef struct _CubeDisplay {
52     int	screenPrivateIndex;
53 
54     CompOption opt[CUBE_DISPLAY_OPTION_NUM];
55 } CubeDisplay;
56 
57 #define CUBE_SCREEN_OPTION_COLOR	           0
58 #define CUBE_SCREEN_OPTION_IN		           1
59 #define CUBE_SCREEN_OPTION_SCALE_IMAGE	           2
60 #define CUBE_SCREEN_OPTION_IMAGES	           3
61 #define CUBE_SCREEN_OPTION_SKYDOME	           4
62 #define CUBE_SCREEN_OPTION_SKYDOME_IMG	           5
63 #define CUBE_SCREEN_OPTION_SKYDOME_ANIM	           6
64 #define CUBE_SCREEN_OPTION_SKYDOME_GRAD_START      7
65 #define CUBE_SCREEN_OPTION_SKYDOME_GRAD_END        8
66 #define CUBE_SCREEN_OPTION_ACCELERATION	           9
67 #define CUBE_SCREEN_OPTION_SPEED	           10
68 #define CUBE_SCREEN_OPTION_TIMESTEP	           11
69 #define CUBE_SCREEN_OPTION_MIPMAP	           12
70 #define CUBE_SCREEN_OPTION_ADJUST_IMAGE	           13
71 #define CUBE_SCREEN_OPTION_ACTIVE_OPACITY          14
72 #define CUBE_SCREEN_OPTION_INACTIVE_OPACITY        15
73 #define CUBE_SCREEN_OPTION_TRANSPARENT_MANUAL_ONLY 16
74 #define CUBE_SCREEN_OPTION_MULTIOUTPUT_MODE        17
75 #define CUBE_SCREEN_OPTION_NUM                     18
76 
77 typedef enum _PaintOrder {
78     BTF = 0,
79     FTB
80 } PaintOrder;
81 
82 typedef enum _RotationState {
83     RotationNone = 0,
84     RotationChange,
85     RotationManual
86 } RotationState;
87 
88 typedef void (*CubeGetRotationProc) (CompScreen *s,
89 				     float      *x,
90 				     float      *v,
91 				     float      *progress);
92 
93 typedef void (*CubeClearTargetOutputProc) (CompScreen *s,
94 					   float      xRotate,
95 					   float      vRotate);
96 
97 typedef void (*CubePaintTopProc) (CompScreen			*s,
98 				  const ScreenPaintAttrib	*sAttrib,
99 				  const CompTransform		*transform,
100 				  CompOutput			*output,
101 				  int				size);
102 
103 typedef void (*CubePaintBottomProc) (CompScreen			*s,
104 				     const ScreenPaintAttrib	*sAttrib,
105 				     const CompTransform	*transform,
106 				     CompOutput			*output,
107 				     int			size);
108 
109 typedef void (*CubePaintInsideProc) (CompScreen			*s,
110 				     const ScreenPaintAttrib	*sAttrib,
111 				     const CompTransform	*transform,
112 				     CompOutput			*output,
113 				     int			size);
114 
115 typedef Bool (*CubeCheckOrientationProc) (CompScreen              *s,
116 					  const ScreenPaintAttrib *sAttrib,
117 					  const CompTransform     *transform,
118 					  CompOutput              *output,
119 					  CompVector              *points);
120 
121 typedef void (*CubePaintViewportProc) (CompScreen              *s,
122 				       const ScreenPaintAttrib *sAttrib,
123 				       const CompTransform     *transform,
124 				       Region                  region,
125 				       CompOutput              *output,
126 				       unsigned int            mask);
127 
128 typedef Bool (*CubeShouldPaintViewportProc) (CompScreen              *s,
129 					     const ScreenPaintAttrib *sAttrib,
130 					     const CompTransform     *transform,
131 					     CompOutput              *output,
132 					     PaintOrder              order);
133 
134 typedef struct _CubeScreen {
135     PreparePaintScreenProc       preparePaintScreen;
136     DonePaintScreenProc	         donePaintScreen;
137     PaintScreenProc		 paintScreen;
138     PaintOutputProc	         paintOutput;
139     PaintTransformedOutputProc   paintTransformedOutput;
140     EnableOutputClippingProc     enableOutputClipping;
141     PaintWindowProc              paintWindow;
142     ApplyScreenTransformProc     applyScreenTransform;
143     OutputChangeNotifyProc       outputChangeNotify;
144     InitWindowWalkerProc         initWindowWalker;
145 
146     CubeGetRotationProc	         getRotation;
147     CubeClearTargetOutputProc    clearTargetOutput;
148     CubePaintTopProc             paintTop;
149     CubePaintBottomProc          paintBottom;
150     CubePaintInsideProc          paintInside;
151     CubeCheckOrientationProc     checkOrientation;
152     CubePaintViewportProc        paintViewport;
153     CubeShouldPaintViewportProc  shouldPaintViewport;
154 
155     CompOption opt[CUBE_SCREEN_OPTION_NUM];
156 
157     int       invert;
158     int       xRotations;
159     PaintOrder paintOrder;
160 
161     RotationState rotationState;
162 
163     Bool paintAllViewports;
164 
165     GLfloat  distance;
166     GLushort color[3];
167     GLfloat  tc[12];
168 
169     int grabIndex;
170 
171     int srcOutput;
172 
173     Bool    unfolded;
174     GLfloat unfold, unfoldVelocity;
175 
176     GLfloat  *vertices;
177     int      nVertices;
178 
179     GLuint skyListId;
180 
181     int		 pw, ph;
182     unsigned int skyW, skyH;
183     CompTexture  texture, sky;
184 
185     int	imgCurFile;
186 
187     int nOutput;
188     int output[64];
189     int outputMask[64];
190 
191     Bool cleared[64];
192 
193     Bool capsPainted[64];
194 
195     Bool fullscreenOutput;
196 
197     float outputXScale;
198     float outputYScale;
199     float outputXOffset;
200     float outputYOffset;
201 
202     float desktopOpacity;
203     float toOpacity;
204     int   lastOpacityIndex;
205 
206     int  moMode;
207     Bool recalcOutput;
208 } CubeScreen;
209 
210 #define GET_CUBE_CORE(c)					\
211     ((CubeCore *) (c)->base.privates[cubeCorePrivateIndex].ptr)
212 
213 #define CUBE_CORE(c)		     \
214     CubeCore *cc = GET_CUBE_CORE (c)
215 
216 #define GET_CUBE_DISPLAY(d)					      \
217     ((CubeDisplay *) (d)->base.privates[cubeDisplayPrivateIndex].ptr)
218 
219 #define CUBE_DISPLAY(d)			   \
220     CubeDisplay *cd = GET_CUBE_DISPLAY (d)
221 
222 #define GET_CUBE_SCREEN(s, cd)					      \
223     ((CubeScreen *) (s)->base.privates[(cd)->screenPrivateIndex].ptr)
224 
225 #define CUBE_SCREEN(s)							\
226     CubeScreen *cs = GET_CUBE_SCREEN (s, GET_CUBE_DISPLAY (s->display))
227 
228 COMPIZ_END_DECLS
229 
230 #endif
231