~mc-return/compiz/compiz.merge-src-screen.cpp-improvements

« back to all changes in this revision

Viewing changes to plugins/composite/include/composite/composite.h

  • Committer: Dennis kasprzyk
  • Author(s): Dennis Kasprzyk
  • Date: 2009-03-15 05:09:18 UTC
  • Revision ID: git-v1:163f6b6f3c3b7764987cbdf8e03cc355edeaa499
New generalized build system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
 
 
4
/*
 
5
 * Copyright © 2008 Dennis Kasprzyk
 
6
 * Copyright © 2007 Novell, Inc.
 
7
 *
 
8
 * Permission to use, copy, modify, distribute, and sell this software
 
9
 * and its documentation for any purpose is hereby granted without
 
10
 * fee, provided that the above copyright notice appear in all copies
 
11
 * and that both that copyright notice and this permission notice
 
12
 * appear in supporting documentation, and that the name of
 
13
 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
 
14
 * distribution of the software without specific, written prior permission.
 
15
 * Dennis Kasprzyk makes no representations about the suitability of this
 
16
 * software for any purpose. It is provided "as is" without express or
 
17
 * implied warranty.
 
18
 *
 
19
 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
20
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
21
 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
22
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
23
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
24
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
25
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
26
 *
 
27
 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
 
28
 *          David Reveman <davidr@novell.com>
 
29
 */
 
30
 
 
31
#ifndef _COMPIZ_COMPOSITE_H
 
32
#define _COMPIZ_COMPOSITE_H
 
33
 
 
34
#include <X11/extensions/Xcomposite.h>
 
35
 
 
36
#define COMPIZ_COMPOSITE_ABI 1
 
37
 
 
38
#include <core/privatehandler.h>
 
39
#include <core/timer.h>
 
40
#include <core/core.h>
 
41
 
 
42
#define COMPOSITE_SCREEN_DAMAGE_PENDING_MASK (1 << 0)
 
43
#define COMPOSITE_SCREEN_DAMAGE_REGION_MASK  (1 << 1)
 
44
#define COMPOSITE_SCREEN_DAMAGE_ALL_MASK     (1 << 2)
 
45
 
 
46
#define OPAQUE 0xffff
 
47
#define COLOR  0xffff
 
48
#define BRIGHT 0xffff
 
49
 
 
50
#define PAINT_SCREEN_REGION_MASK                   (1 << 0)
 
51
#define PAINT_SCREEN_FULL_MASK                     (1 << 1)
 
52
#define PAINT_SCREEN_TRANSFORMED_MASK              (1 << 2)
 
53
#define PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK (1 << 3)
 
54
#define PAINT_SCREEN_CLEAR_MASK                    (1 << 4)
 
55
#define PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK   (1 << 5)
 
56
#define PAINT_SCREEN_NO_BACKGROUND_MASK            (1 << 6)
 
57
 
 
58
 
 
59
 
 
60
class PrivateCompositeScreen;
 
61
class PrivateCompositeWindow;
 
62
class CompositeScreen;
 
63
class CompositeWindow;
 
64
 
 
65
class CompositeScreenInterface :
 
66
    public WrapableInterface<CompositeScreen, CompositeScreenInterface>
 
67
{
 
68
    public:
 
69
 
 
70
        virtual void preparePaint (int);
 
71
        virtual void donePaint ();
 
72
        virtual void paint (CompOutput::ptrList &outputs, unsigned int);
 
73
 
 
74
        virtual CompWindowList getWindowPaintList ();
 
75
};
 
76
 
 
77
 
 
78
class CompositeScreen :
 
79
    public WrapableHandler<CompositeScreenInterface, 4>,
 
80
    public PrivateHandler<CompositeScreen, CompScreen, COMPIZ_COMPOSITE_ABI>
 
81
{
 
82
    public:
 
83
 
 
84
        class PaintHandler {
 
85
            public:
 
86
                virtual ~PaintHandler () {};
 
87
 
 
88
                virtual void paintOutputs (CompOutput::ptrList &outputs,
 
89
                                           unsigned int        mask,
 
90
                                           const CompRegion    &region) = 0;
 
91
 
 
92
                virtual bool hasVSync () { return false; };
 
93
 
 
94
                virtual void prepareDrawing () {};
 
95
        };
 
96
 
 
97
    public:
 
98
        CompositeScreen (CompScreen *s);
 
99
        ~CompositeScreen ();
 
100
 
 
101
        CompOption::Vector & getOptions ();
 
102
        bool setOption (const char *name, CompOption::Value &value);
 
103
        CompOption * getOption (const char *name);
 
104
 
 
105
        bool registerPaintHandler (PaintHandler *pHnd);
 
106
        void unregisterPaintHandler ();
 
107
 
 
108
        bool compositingActive ();
 
109
 
 
110
        int damageEvent ();
 
111
        
 
112
        void damageScreen ();
 
113
        void damageRegion (const CompRegion &);
 
114
        void damagePending ();
 
115
        unsigned int damageMask ();
 
116
        const CompRegion & currentDamage () const;
 
117
 
 
118
        void showOutputWindow ();
 
119
        void hideOutputWindow ();
 
120
        void updateOutputWindow ();
 
121
 
 
122
        Window overlay ();
 
123
        Window output ();
 
124
 
 
125
        int & overlayWindowCount ();
 
126
 
 
127
        void setWindowPaintOffset (int x, int y);
 
128
        CompPoint windowPaintOffset ();
 
129
 
 
130
 
 
131
        void detectRefreshRate ();
 
132
        int getTimeToNextRedraw (struct timeval *tv);
 
133
 
 
134
        int redrawTime ();
 
135
        
 
136
        bool handlePaintTimeout ();
 
137
 
 
138
        WRAPABLE_HND (0, CompositeScreenInterface, void, preparePaint, int);
 
139
        WRAPABLE_HND (1, CompositeScreenInterface, void, donePaint);
 
140
        WRAPABLE_HND (2, CompositeScreenInterface, void, paint,
 
141
                      CompOutput::ptrList &outputs, unsigned int);
 
142
 
 
143
        WRAPABLE_HND (3, CompositeScreenInterface, CompWindowList,
 
144
                      getWindowPaintList);
 
145
 
 
146
        friend class PrivateCompositeDisplay;
 
147
 
 
148
    private:
 
149
        PrivateCompositeScreen *priv;
 
150
 
 
151
    public:
 
152
        static bool toggleSlowAnimations (CompAction         *action,
 
153
                                          CompAction::State  state,
 
154
                                          CompOption::Vector &options);
 
155
};
 
156
 
 
157
/*
 
158
  window paint flags
 
159
 
 
160
  bit 1-16 are used for read-only flags and they provide
 
161
  information that describe the screen rendering pass
 
162
  currently in process.
 
163
 
 
164
  bit 17-32 are writable flags and they provide information
 
165
  that is used to optimize rendering.
 
166
*/
 
167
 
 
168
/*
 
169
  this flag is present when window is being painted
 
170
  on a transformed screen.
 
171
*/
 
172
#define PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK (1 << 0)
 
173
 
 
174
/*
 
175
  this flag is present when window is being tested
 
176
  for occlusion of other windows.
 
177
*/
 
178
#define PAINT_WINDOW_OCCLUSION_DETECTION_MASK   (1 << 1)
 
179
 
 
180
/*
 
181
  this flag indicates that the window ist painted with
 
182
  an offset
 
183
*/
 
184
#define PAINT_WINDOW_WITH_OFFSET_MASK           (1 << 2)
 
185
 
 
186
/*
 
187
  flag indicate that window is translucent.
 
188
*/
 
189
#define PAINT_WINDOW_TRANSLUCENT_MASK           (1 << 16)
 
190
 
 
191
/*
 
192
  flag indicate that window is transformed.
 
193
*/
 
194
#define PAINT_WINDOW_TRANSFORMED_MASK           (1 << 17)
 
195
 
 
196
/*
 
197
  flag indicate that core PaintWindow function should
 
198
  not draw this window.
 
199
*/
 
200
#define PAINT_WINDOW_NO_CORE_INSTANCE_MASK      (1 << 18)
 
201
 
 
202
/*
 
203
  flag indicate that blending is required.
 
204
*/
 
205
#define PAINT_WINDOW_BLEND_MASK                 (1 << 19)
 
206
 
 
207
class CompositeWindowInterface :
 
208
    public WrapableInterface<CompositeWindow, CompositeWindowInterface>
 
209
{
 
210
    public:
 
211
        virtual bool damageRect (bool, const CompRect &);
 
212
};
 
213
 
 
214
class CompositeWindow :
 
215
    public WrapableHandler<CompositeWindowInterface, 1>,
 
216
    public PrivateHandler<CompositeWindow, CompWindow, COMPIZ_COMPOSITE_ABI>
 
217
{
 
218
    public:
 
219
 
 
220
        CompositeWindow (CompWindow *w);
 
221
        ~CompositeWindow ();
 
222
 
 
223
        bool bind ();
 
224
        void release ();
 
225
        Pixmap pixmap ();
 
226
 
 
227
        void redirect ();
 
228
        void unredirect ();
 
229
        bool redirected ();
 
230
        bool overlayWindow ();
 
231
        
 
232
        void damageTransformedRect (float          xScale,
 
233
                                    float          yScale,
 
234
                                    float          xTranslate,
 
235
                                    float          yTranslate,
 
236
                                    const CompRect &rect);
 
237
 
 
238
        void damageOutputExtents ();
 
239
        void addDamageRect (const CompRect &);
 
240
        void addDamage (bool force = false);
 
241
 
 
242
        bool damaged ();
 
243
 
 
244
        void processDamage (XDamageNotifyEvent *de);
 
245
 
 
246
        void updateOpacity ();
 
247
        void updateBrightness ();
 
248
        void updateSaturation ();
 
249
 
 
250
        unsigned short opacity ();
 
251
        unsigned short brightness ();
 
252
        unsigned short saturation ();
 
253
 
 
254
        WRAPABLE_HND (0, CompositeWindowInterface, bool, damageRect,
 
255
                      bool, const CompRect &);
 
256
 
 
257
        friend class PrivateCompositeWindow;
 
258
        friend class CompositeScreen;
 
259
        
 
260
    private:
 
261
        PrivateCompositeWindow *priv;
 
262
};
 
263
 
 
264
#endif