Merge lp:~compiz-team/compiz-core/compiz-core.fix_874854 into lp:compiz-core/0.9.5
- compiz-core.fix_874854
- Merge into 0.9.5
Proposed by
Sam Spilsbury
Status: | Merged |
---|---|
Merged at revision: | 2883 |
Proposed branch: | lp:~compiz-team/compiz-core/compiz-core.fix_874854 |
Merge into: | lp:compiz-core/0.9.5 |
Diff against target: |
1084 lines (+391/-254) 11 files modified
plugins/composite/include/composite/composite.h (+39/-20) plugins/composite/src/privates.h (+1/-2) plugins/composite/src/screen.cpp (+27/-11) plugins/decor/src/decor.cpp (+62/-13) plugins/decor/src/decor.h (+5/-0) plugins/move/src/move.cpp (+20/-3) plugins/move/src/move.h (+6/-0) plugins/opengl/include/opengl/opengl.h (+10/-7) plugins/opengl/src/paint.cpp (+5/-5) plugins/opengl/src/privates.h (+4/-1) plugins/opengl/src/screen.cpp (+212/-192) |
To merge this branch: | bzr merge lp:~compiz-team/compiz-core/compiz-core.fix_874854 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Compiz Maintainers | Pending | ||
Review via email: mp+79467@code.launchpad.net |
Commit message
Description of the change
Fix bug 874854
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'plugins/composite/include/composite/composite.h' |
2 | --- plugins/composite/include/composite/composite.h 2011-03-11 12:15:30 +0000 |
3 | +++ plugins/composite/include/composite/composite.h 2011-10-15 11:23:26 +0000 |
4 | @@ -30,7 +30,7 @@ |
5 | |
6 | #include <X11/extensions/Xcomposite.h> |
7 | |
8 | -#define COMPIZ_COMPOSITE_ABI 2 |
9 | +#define COMPIZ_COMPOSITE_ABI 3 |
10 | |
11 | #include <core/pluginclasshandler.h> |
12 | #include <core/timer.h> |
13 | @@ -91,6 +91,26 @@ |
14 | class CompositeScreen; |
15 | class CompositeWindow; |
16 | |
17 | +namespace compiz |
18 | +{ |
19 | +namespace composite |
20 | +{ |
21 | +class PaintHandler { |
22 | +public: |
23 | + virtual ~PaintHandler () {}; |
24 | + |
25 | + virtual void paintOutputs (CompOutput::ptrList &outputs, |
26 | + unsigned int mask, |
27 | + const CompRegion ®ion) = 0; |
28 | + |
29 | + virtual bool hasVSync () { return false; }; |
30 | + |
31 | + virtual void prepareDrawing () {}; |
32 | + virtual bool compositingActive () { return false; }; |
33 | +}; |
34 | +} |
35 | +} |
36 | + |
37 | /** |
38 | * Wrapable function interface for CompositeScreen |
39 | */ |
40 | @@ -129,28 +149,30 @@ |
41 | * evaluated for repainting |
42 | */ |
43 | virtual const CompWindowList & getWindowPaintList (); |
44 | + |
45 | + /** |
46 | + * Hookable function to register a new paint handler, overload |
47 | + * and insert your own paint handler if you want to prevent |
48 | + * another one from being loaded |
49 | + */ |
50 | + virtual bool registerPaintHandler (compiz::composite::PaintHandler *pHnd); |
51 | + |
52 | + /** |
53 | + * Hookable function to notify unregistration of a paint handler |
54 | + * |
55 | + */ |
56 | + virtual void unregisterPaintHandler (); |
57 | }; |
58 | |
59 | |
60 | class CompositeScreen : |
61 | - public WrapableHandler<CompositeScreenInterface, 4>, |
62 | + public WrapableHandler<CompositeScreenInterface, 6>, |
63 | public PluginClassHandler<CompositeScreen, CompScreen, COMPIZ_COMPOSITE_ABI>, |
64 | public CompOption::Class |
65 | { |
66 | public: |
67 | |
68 | - class PaintHandler { |
69 | - public: |
70 | - virtual ~PaintHandler () {}; |
71 | - |
72 | - virtual void paintOutputs (CompOutput::ptrList &outputs, |
73 | - unsigned int mask, |
74 | - const CompRegion ®ion) = 0; |
75 | - |
76 | - virtual bool hasVSync () { return false; }; |
77 | - |
78 | - virtual void prepareDrawing () {}; |
79 | - }; |
80 | + |
81 | |
82 | public: |
83 | CompositeScreen (CompScreen *s); |
84 | @@ -159,12 +181,6 @@ |
85 | CompOption::Vector & getOptions (); |
86 | bool setOption (const CompString &name, CompOption::Value &value); |
87 | |
88 | - /** |
89 | - * Register a dispatch PaintHandler for a rendering plugin |
90 | - */ |
91 | - bool registerPaintHandler (PaintHandler *pHnd); |
92 | - void unregisterPaintHandler (); |
93 | - |
94 | bool compositingActive (); |
95 | |
96 | /** |
97 | @@ -220,6 +236,9 @@ |
98 | WRAPABLE_HND (3, CompositeScreenInterface, const CompWindowList &, |
99 | getWindowPaintList); |
100 | |
101 | + WRAPABLE_HND (4, CompositeScreenInterface, bool, registerPaintHandler, compiz::composite::PaintHandler *); |
102 | + WRAPABLE_HND (5, CompositeScreenInterface, void, unregisterPaintHandler); |
103 | + |
104 | friend class PrivateCompositeDisplay; |
105 | |
106 | private: |
107 | |
108 | === modified file 'plugins/composite/src/privates.h' |
109 | --- plugins/composite/src/privates.h 2011-10-13 14:28:30 +0000 |
110 | +++ plugins/composite/src/privates.h 2011-10-15 11:23:26 +0000 |
111 | @@ -107,8 +107,7 @@ |
112 | |
113 | CompTimer paintTimer; |
114 | |
115 | - bool active; |
116 | - CompositeScreen::PaintHandler *pHnd; |
117 | + compiz::composite::PaintHandler *pHnd; |
118 | |
119 | CompositeFPSLimiterMode FPSLimiterMode; |
120 | int frameTimeAccumulator; |
121 | |
122 | === modified file 'plugins/composite/src/screen.cpp' |
123 | --- plugins/composite/src/screen.cpp 2011-10-13 14:28:30 +0000 |
124 | +++ plugins/composite/src/screen.cpp 2011-10-15 11:23:26 +0000 |
125 | @@ -285,7 +285,6 @@ |
126 | idle (true), |
127 | timeLeft (0), |
128 | slowAnimations (false), |
129 | - active (false), |
130 | pHnd (NULL), |
131 | FPSLimiterMode (CompositeFPSLimiterModeDefault), |
132 | frameTimeAccumulator (0), |
133 | @@ -383,11 +382,15 @@ |
134 | |
135 | |
136 | bool |
137 | -CompositeScreen::registerPaintHandler (PaintHandler *pHnd) |
138 | +CompositeScreen::registerPaintHandler (compiz::composite::PaintHandler *pHnd) |
139 | { |
140 | - Display *dpy = screen->dpy (); |
141 | - |
142 | - if (priv->active) |
143 | + Display *dpy; |
144 | + |
145 | + WRAPABLE_HND_FUNC_RETURN (4, bool, registerPaintHandler, pHnd); |
146 | + |
147 | + dpy = screen->dpy (); |
148 | + |
149 | + if (priv->pHnd) |
150 | return false; |
151 | |
152 | CompScreen::checkForError (dpy); |
153 | @@ -414,7 +417,6 @@ |
154 | } |
155 | |
156 | priv->pHnd = pHnd; |
157 | - priv->active = true; |
158 | |
159 | showOutputWindow (); |
160 | |
161 | @@ -428,7 +430,11 @@ |
162 | void |
163 | CompositeScreen::unregisterPaintHandler () |
164 | { |
165 | - Display *dpy = screen->dpy (); |
166 | + Display *dpy; |
167 | + |
168 | + WRAPABLE_HND_FUNC (5, unregisterPaintHandler) |
169 | + |
170 | + dpy = screen->dpy (); |
171 | |
172 | foreach (CompWindow *w, screen->windows ()) |
173 | { |
174 | @@ -444,7 +450,6 @@ |
175 | CompositeRedirectManual); |
176 | |
177 | priv->pHnd = NULL; |
178 | - priv->active = false; |
179 | priv->paintTimer.stop (); |
180 | |
181 | hideOutputWindow (); |
182 | @@ -453,7 +458,10 @@ |
183 | bool |
184 | CompositeScreen::compositingActive () |
185 | { |
186 | - return priv->active; |
187 | + if (priv->pHnd) |
188 | + return priv->pHnd->compositingActive (); |
189 | + |
190 | + return false; |
191 | } |
192 | |
193 | void |
194 | @@ -506,7 +514,7 @@ |
195 | CompositeScreen::showOutputWindow () |
196 | { |
197 | #ifdef USE_COW |
198 | - if (useCow && priv->active) |
199 | + if (useCow && priv->pHnd) |
200 | { |
201 | Display *dpy = screen->dpy (); |
202 | XserverRegion region; |
203 | @@ -556,7 +564,7 @@ |
204 | CompositeScreen::updateOutputWindow () |
205 | { |
206 | #ifdef USE_COW |
207 | - if (useCow && priv->active) |
208 | + if (useCow && priv->pHnd) |
209 | { |
210 | Display *dpy = screen->dpy (); |
211 | XserverRegion region; |
212 | @@ -1023,6 +1031,14 @@ |
213 | CompositeScreenInterface::getWindowPaintList () |
214 | WRAPABLE_DEF (getWindowPaintList) |
215 | |
216 | +bool |
217 | +CompositeScreenInterface::registerPaintHandler (compiz::composite::PaintHandler *pHnd) |
218 | + WRAPABLE_DEF (registerPaintHandler, pHnd); |
219 | + |
220 | +void |
221 | +CompositeScreenInterface::unregisterPaintHandler () |
222 | + WRAPABLE_DEF (unregisterPaintHandler); |
223 | + |
224 | const CompRegion & |
225 | CompositeScreen::currentDamage () const |
226 | { |
227 | |
228 | === modified file 'plugins/decor/src/decor.cpp' |
229 | --- plugins/decor/src/decor.cpp 2011-10-11 14:55:47 +0000 |
230 | +++ plugins/decor/src/decor.cpp 2011-10-15 11:23:26 +0000 |
231 | @@ -2840,6 +2840,27 @@ |
232 | atoms.push_back (requestFrameExtentsAtom); |
233 | } |
234 | |
235 | +void |
236 | +DecorWindow::updateHandlers () |
237 | +{ |
238 | + if (dScreen->cmActive) |
239 | + { |
240 | + gWindow = GLWindow::get (window); |
241 | + cWindow = CompositeWindow::get (window); |
242 | + |
243 | + CompositeWindowInterface::setHandler (cWindow); |
244 | + GLWindowInterface::setHandler (gWindow); |
245 | + } |
246 | + else |
247 | + { |
248 | + CompositeWindowInterface::setHandler (cWindow, false); |
249 | + GLWindowInterface::setHandler (gWindow, false); |
250 | + |
251 | + gWindow = NULL; |
252 | + cWindow = NULL; |
253 | + } |
254 | +} |
255 | + |
256 | /* |
257 | * DecorScreen::decoratorStartTimeout |
258 | * |
259 | @@ -2852,9 +2873,39 @@ |
260 | if (!dmWin) |
261 | screen->runCommand (optionGetCommand ()); |
262 | |
263 | + /* Update all the windows */ |
264 | + foreach (CompWindow *w, screen->windows ()) |
265 | + { |
266 | + DECOR_WINDOW (w); |
267 | + |
268 | + dw->updateHandlers (); |
269 | + |
270 | + dw->updateSwitcher (); |
271 | + |
272 | + if (!w->overrideRedirect () || dw->isSwitcher) |
273 | + dw->updateDecoration (); |
274 | + |
275 | + if (w->shaded () || w->isViewable ()) |
276 | + dw->update (true); |
277 | + } |
278 | + |
279 | return false; |
280 | } |
281 | |
282 | +bool |
283 | +DecorScreen::registerPaintHandler (compiz::composite::PaintHandler *p) |
284 | +{ |
285 | + cmActive = true; |
286 | + return cScreen->registerPaintHandler (p); |
287 | +} |
288 | + |
289 | +void |
290 | +DecorScreen::unregisterPaintHandler () |
291 | +{ |
292 | + cmActive = false; |
293 | + return cScreen->unregisterPaintHandler (); |
294 | +} |
295 | + |
296 | /* |
297 | * DecorScreen::DecorScreen |
298 | * |
299 | @@ -2927,6 +2978,7 @@ |
300 | 0); |
301 | |
302 | ScreenInterface::setHandler (s); |
303 | + CompositeScreenInterface::setHandler (cScreen); |
304 | screen->updateSupportedWmHints (); |
305 | } |
306 | |
307 | @@ -2975,22 +3027,19 @@ |
308 | |
309 | window->resizeNotifySetEnabled (this, false); |
310 | |
311 | - if (dScreen->cmActive) |
312 | + if (!dScreen->decoratorStart.active ()) |
313 | { |
314 | - gWindow = GLWindow::get (w); |
315 | - cWindow = CompositeWindow::get (w); |
316 | - CompositeWindowInterface::setHandler (cWindow); |
317 | - GLWindowInterface::setHandler (gWindow); |
318 | + updateHandlers (); |
319 | + |
320 | + updateSwitcher (); |
321 | + |
322 | + if (!w->overrideRedirect () || isSwitcher) |
323 | + updateDecoration (); |
324 | + |
325 | + if (w->shaded () || w->isViewable ()) |
326 | + update (true); |
327 | } |
328 | |
329 | - updateSwitcher (); |
330 | - |
331 | - if (!w->overrideRedirect () || isSwitcher) |
332 | - updateDecoration (); |
333 | - |
334 | - if (w->shaded () || w->isViewable ()) |
335 | - update (true); |
336 | - |
337 | window->resizeNotifySetEnabled (this, true); |
338 | } |
339 | |
340 | |
341 | === modified file 'plugins/decor/src/decor.h' |
342 | --- plugins/decor/src/decor.h 2011-09-09 15:20:10 +0000 |
343 | +++ plugins/decor/src/decor.h 2011-10-15 11:23:26 +0000 |
344 | @@ -130,6 +130,7 @@ |
345 | |
346 | class DecorScreen : |
347 | public ScreenInterface, |
348 | + public CompositeScreenInterface, |
349 | public PluginClassHandler<DecorScreen,CompScreen>, |
350 | public DecorOptions |
351 | { |
352 | @@ -151,6 +152,9 @@ |
353 | |
354 | void updateDefaultShadowProperty (); |
355 | |
356 | + bool registerPaintHandler (compiz::composite::PaintHandler *pHnd); |
357 | + void unregisterPaintHandler (); |
358 | + |
359 | public: |
360 | |
361 | CompositeScreen *cScreen; |
362 | @@ -231,6 +235,7 @@ |
363 | bool resizeTimeout (); |
364 | |
365 | void updateSwitcher (); |
366 | + void updateHandlers (); |
367 | |
368 | static bool matchType (CompWindow *w, unsigned int decorType); |
369 | static bool matchState (CompWindow *w, unsigned int decorState); |
370 | |
371 | === modified file 'plugins/move/src/move.cpp' |
372 | --- plugins/move/src/move.cpp 2011-10-11 09:36:19 +0000 |
373 | +++ plugins/move/src/move.cpp 2011-10-15 11:23:26 +0000 |
374 | @@ -703,8 +703,23 @@ |
375 | moveOpacity = (optionGetOpacity () * OPAQUE) / 100; |
376 | } |
377 | |
378 | +bool |
379 | +MoveScreen::registerPaintHandler(compiz::composite::PaintHandler *pHnd) |
380 | +{ |
381 | + hasCompositing = true; |
382 | + cScreen->registerPaintHandler (pHnd); |
383 | +} |
384 | + |
385 | +void |
386 | +MoveScreen::unregisterPaintHandler() |
387 | +{ |
388 | + hasCompositing = false; |
389 | + cScreen->unregisterPaintHandler (); |
390 | +} |
391 | + |
392 | MoveScreen::MoveScreen (CompScreen *screen) : |
393 | PluginClassHandler<MoveScreen,CompScreen> (screen), |
394 | + cScreen (CompositeScreen::get (screen)), |
395 | w (0), |
396 | region (NULL), |
397 | status (RectangleOut), |
398 | @@ -713,7 +728,6 @@ |
399 | hasCompositing (false), |
400 | yConstrained (false) |
401 | { |
402 | - |
403 | updateOpacity (); |
404 | |
405 | for (unsigned int i = 0; i < NUM_KEYS; i++) |
406 | @@ -721,9 +735,12 @@ |
407 | XStringToKeysym (mKeys[i].name)); |
408 | |
409 | moveCursor = XCreateFontCursor (screen->dpy (), XC_fleur); |
410 | - if (CompositeScreen::get (screen)) |
411 | + if (cScreen) |
412 | + { |
413 | + CompositeScreenInterface::setHandler (cScreen); |
414 | hasCompositing = |
415 | - CompositeScreen::get (screen)->compositingActive (); |
416 | + cScreen->compositingActive (); |
417 | + } |
418 | |
419 | optionSetOpacityNotify (boost::bind (&MoveScreen::updateOpacity, this)); |
420 | |
421 | |
422 | === modified file 'plugins/move/src/move.h' |
423 | --- plugins/move/src/move.h 2011-09-29 03:29:41 +0000 |
424 | +++ plugins/move/src/move.h 2011-10-15 11:23:26 +0000 |
425 | @@ -51,6 +51,7 @@ |
426 | |
427 | class MoveScreen : |
428 | public ScreenInterface, |
429 | + public CompositeScreenInterface, |
430 | public PluginClassHandler<MoveScreen,CompScreen>, |
431 | public MoveOptions |
432 | { |
433 | @@ -58,6 +59,8 @@ |
434 | MoveScreen (CompScreen *screen); |
435 | ~MoveScreen (); |
436 | |
437 | + CompositeScreen *cScreen; |
438 | + |
439 | void updateOpacity (); |
440 | |
441 | void handleEvent (XEvent *); |
442 | @@ -65,6 +68,9 @@ |
443 | const char *event, |
444 | CompOption::Vector &options); |
445 | |
446 | + bool registerPaintHandler (compiz::composite::PaintHandler *pHnd); |
447 | + void unregisterPaintHandler (); |
448 | + |
449 | CompWindow *w; |
450 | int savedX; |
451 | int savedY; |
452 | |
453 | === modified file 'plugins/opengl/include/opengl/opengl.h' |
454 | --- plugins/opengl/include/opengl/opengl.h 2011-09-19 12:35:49 +0000 |
455 | +++ plugins/opengl/include/opengl/opengl.h 2011-10-15 11:23:26 +0000 |
456 | @@ -35,7 +35,7 @@ |
457 | #include <opengl/texture.h> |
458 | #include <opengl/fragment.h> |
459 | |
460 | -#define COMPIZ_OPENGL_ABI 3 |
461 | +#define COMPIZ_OPENGL_ABI 4 |
462 | |
463 | #include <core/pluginclasshandler.h> |
464 | |
465 | @@ -239,6 +239,8 @@ |
466 | { |
467 | public: |
468 | |
469 | + virtual bool glInitContext (XVisualInfo *); |
470 | + |
471 | /** |
472 | * Hookable function used for plugins to use openGL to draw on an output |
473 | * |
474 | @@ -303,7 +305,7 @@ |
475 | |
476 | |
477 | class GLScreen : |
478 | - public WrapableHandler<GLScreenInterface, 5>, |
479 | + public WrapableHandler<GLScreenInterface, 6>, |
480 | public PluginClassHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI>, |
481 | public CompOption::Class |
482 | { |
483 | @@ -383,19 +385,20 @@ |
484 | */ |
485 | const float * projectionMatrix (); |
486 | |
487 | - WRAPABLE_HND (0, GLScreenInterface, bool, glPaintOutput, |
488 | + WRAPABLE_HND (0, GLScreenInterface, bool, glInitContext, XVisualInfo *); |
489 | + WRAPABLE_HND (1, GLScreenInterface, bool, glPaintOutput, |
490 | const GLScreenPaintAttrib &, const GLMatrix &, |
491 | const CompRegion &, CompOutput *, unsigned int); |
492 | - WRAPABLE_HND (1, GLScreenInterface, void, glPaintTransformedOutput, |
493 | + WRAPABLE_HND (2, GLScreenInterface, void, glPaintTransformedOutput, |
494 | const GLScreenPaintAttrib &, |
495 | const GLMatrix &, const CompRegion &, CompOutput *, |
496 | unsigned int); |
497 | - WRAPABLE_HND (2, GLScreenInterface, void, glApplyTransform, |
498 | + WRAPABLE_HND (3, GLScreenInterface, void, glApplyTransform, |
499 | const GLScreenPaintAttrib &, CompOutput *, GLMatrix *); |
500 | |
501 | - WRAPABLE_HND (3, GLScreenInterface, void, glEnableOutputClipping, |
502 | + WRAPABLE_HND (4, GLScreenInterface, void, glEnableOutputClipping, |
503 | const GLMatrix &, const CompRegion &, CompOutput *); |
504 | - WRAPABLE_HND (4, GLScreenInterface, void, glDisableOutputClipping); |
505 | + WRAPABLE_HND (5, GLScreenInterface, void, glDisableOutputClipping); |
506 | |
507 | friend class GLTexture; |
508 | |
509 | |
510 | === modified file 'plugins/opengl/src/paint.cpp' |
511 | --- plugins/opengl/src/paint.cpp 2011-09-29 03:29:41 +0000 |
512 | +++ plugins/opengl/src/paint.cpp 2011-10-15 11:23:26 +0000 |
513 | @@ -362,7 +362,7 @@ |
514 | const CompRegion ®ion, |
515 | CompOutput *output) |
516 | { |
517 | - WRAPABLE_HND_FUNC (3, glEnableOutputClipping, transform, region, output) |
518 | + WRAPABLE_HND_FUNC (4, glEnableOutputClipping, transform, region, output) |
519 | |
520 | GLdouble h = screen->height (); |
521 | |
522 | @@ -419,7 +419,7 @@ |
523 | CompOutput *output, |
524 | unsigned int mask) |
525 | { |
526 | - WRAPABLE_HND_FUNC (1, glPaintTransformedOutput, sAttrib, transform, |
527 | + WRAPABLE_HND_FUNC (2, glPaintTransformedOutput, sAttrib, transform, |
528 | region, output, mask) |
529 | |
530 | GLMatrix sTransform = transform; |
531 | @@ -466,7 +466,7 @@ |
532 | CompOutput *output, |
533 | unsigned int mask) |
534 | { |
535 | - WRAPABLE_HND_FUNC_RETURN (0, bool, glPaintOutput, sAttrib, transform, |
536 | + WRAPABLE_HND_FUNC_RETURN (1, bool, glPaintOutput, sAttrib, transform, |
537 | region, output, mask) |
538 | |
539 | GLMatrix sTransform = transform; |
540 | @@ -591,7 +591,7 @@ |
541 | void |
542 | GLWindow::glDrawGeometry () |
543 | { |
544 | - WRAPABLE_HND_FUNC (4, glDrawGeometry) |
545 | + WRAPABLE_HND_FUNC (5, glDrawGeometry) |
546 | |
547 | int texUnit = priv->geometry.texUnits; |
548 | int currentTexUnit = 0; |
549 | @@ -716,7 +716,7 @@ |
550 | unsigned int maxGridWidth, |
551 | unsigned int maxGridHeight) |
552 | { |
553 | - WRAPABLE_HND_FUNC (2, glAddGeometry, matrix, region, clip) |
554 | + WRAPABLE_HND_FUNC (3, glAddGeometry, matrix, region, clip) |
555 | |
556 | BoxRec full; |
557 | int nMatrix = matrix.size (); |
558 | |
559 | === modified file 'plugins/opengl/src/privates.h' |
560 | --- plugins/opengl/src/privates.h 2011-09-16 00:51:33 +0000 |
561 | +++ plugins/opengl/src/privates.h 2011-10-15 11:23:26 +0000 |
562 | @@ -49,7 +49,7 @@ |
563 | |
564 | class PrivateGLScreen : |
565 | public ScreenInterface, |
566 | - public CompositeScreen::PaintHandler, |
567 | + public compiz::composite::PaintHandler, |
568 | public OpenglOptions |
569 | { |
570 | public: |
571 | @@ -70,6 +70,8 @@ |
572 | |
573 | void prepareDrawing (); |
574 | |
575 | + bool compositingActive (); |
576 | + |
577 | void controlSwapVideoSync (); |
578 | void waitForVideoSync (); |
579 | |
580 | @@ -122,6 +124,7 @@ |
581 | bool hasCompositing; |
582 | |
583 | GLIcon defaultIcon; |
584 | + CompTimer initContext; |
585 | }; |
586 | |
587 | class PrivateGLWindow : |
588 | |
589 | === modified file 'plugins/opengl/src/screen.cpp' |
590 | --- plugins/opengl/src/screen.cpp 2011-09-16 06:51:02 +0000 |
591 | +++ plugins/opengl/src/screen.cpp 2011-10-15 11:23:26 +0000 |
592 | @@ -82,73 +82,18 @@ |
593 | |
594 | CompOutput *targetOutput = NULL; |
595 | |
596 | -GLScreen::GLScreen (CompScreen *s) : |
597 | - PluginClassHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI> (s), |
598 | - priv (new PrivateGLScreen (this)) |
599 | +bool |
600 | +GLScreen::glInitContext (XVisualInfo *visinfo) |
601 | { |
602 | - Display *dpy = s->dpy (); |
603 | - XVisualInfo templ; |
604 | - XVisualInfo *visinfo; |
605 | - GLXFBConfig *fbConfigs; |
606 | - int defaultDepth, nvisinfo, nElements, value, i; |
607 | - const char *glxExtensions, *glExtensions; |
608 | + Display *dpy = screen->dpy (); |
609 | + const char *glExtensions; |
610 | GLfloat globalAmbient[] = { 0.1f, 0.1f, 0.1f, 0.1f }; |
611 | GLfloat ambientLight[] = { 0.0f, 0.0f, 0.0f, 0.0f }; |
612 | GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 0.9f }; |
613 | GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f }; |
614 | - XWindowAttributes attr; |
615 | const char *glRenderer; |
616 | CompOption::Vector o (0); |
617 | - |
618 | - if (indirectRendering) |
619 | - { |
620 | - /* force Mesa libGL into indirect rendering mode, because |
621 | - glXQueryExtensionsString is context-independant */ |
622 | - setenv ("LIBGL_ALWAYS_INDIRECT", "1", True); |
623 | - } |
624 | - |
625 | - if (!XGetWindowAttributes (dpy, s->root (), &attr)) |
626 | - { |
627 | - screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
628 | - setFailed (); |
629 | - return; |
630 | - } |
631 | - |
632 | - templ.visualid = XVisualIDFromVisual (attr.visual); |
633 | - |
634 | - visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo); |
635 | - if (!nvisinfo) |
636 | - { |
637 | - compLogMessage ("opengl", CompLogLevelFatal, |
638 | - "Couldn't get visual info for default visual"); |
639 | - screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
640 | - setFailed (); |
641 | - return; |
642 | - } |
643 | - |
644 | - defaultDepth = visinfo->depth; |
645 | - |
646 | - glXGetConfig (dpy, visinfo, GLX_USE_GL, &value); |
647 | - if (!value) |
648 | - { |
649 | - compLogMessage ("opengl", CompLogLevelFatal, |
650 | - "Root visual is not a GL visual"); |
651 | - XFree (visinfo); |
652 | - screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
653 | - setFailed (); |
654 | - return; |
655 | - } |
656 | - |
657 | - glXGetConfig (dpy, visinfo, GLX_DOUBLEBUFFER, &value); |
658 | - if (!value) |
659 | - { |
660 | - compLogMessage ("opengl", CompLogLevelFatal, |
661 | - "Root visual is not a double buffered GL visual"); |
662 | - XFree (visinfo); |
663 | - screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
664 | - setFailed (); |
665 | - return; |
666 | - } |
667 | + WRAPABLE_HND_FUNC_RETURN (0, bool, glInitContext, visinfo); |
668 | |
669 | priv->ctx = glXCreateContext (dpy, visinfo, NULL, !indirectRendering); |
670 | if (!priv->ctx) |
671 | @@ -158,82 +103,12 @@ |
672 | XFree (visinfo); |
673 | |
674 | screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
675 | - setFailed (); |
676 | - return; |
677 | + return false; |
678 | } |
679 | |
680 | XFree (visinfo); |
681 | - glxExtensions = glXQueryExtensionsString (dpy, s->screenNum ()); |
682 | - |
683 | - if (!strstr (glxExtensions, "GLX_SGIX_fbconfig")) |
684 | - { |
685 | - compLogMessage ("opengl", CompLogLevelFatal, |
686 | - "GLX_SGIX_fbconfig is missing"); |
687 | - screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
688 | - setFailed (); |
689 | - return; |
690 | - } |
691 | - |
692 | - priv->getProcAddress = (GL::GLXGetProcAddressProc) |
693 | - getProcAddress ("glXGetProcAddressARB"); |
694 | - GL::bindTexImage = (GL::GLXBindTexImageProc) |
695 | - getProcAddress ("glXBindTexImageEXT"); |
696 | - GL::releaseTexImage = (GL::GLXReleaseTexImageProc) |
697 | - getProcAddress ("glXReleaseTexImageEXT"); |
698 | - GL::queryDrawable = (GL::GLXQueryDrawableProc) |
699 | - getProcAddress ("glXQueryDrawable"); |
700 | - GL::getFBConfigs = (GL::GLXGetFBConfigsProc) |
701 | - getProcAddress ("glXGetFBConfigs"); |
702 | - GL::getFBConfigAttrib = (GL::GLXGetFBConfigAttribProc) |
703 | - getProcAddress ("glXGetFBConfigAttrib"); |
704 | - GL::createPixmap = (GL::GLXCreatePixmapProc) |
705 | - getProcAddress ("glXCreatePixmap"); |
706 | - GL::destroyPixmap = (GL::GLXDestroyPixmapProc) |
707 | - getProcAddress ("glXDestroyPixmap"); |
708 | - |
709 | - if (!strstr (glxExtensions, "GLX_EXT_texture_from_pixmap") || |
710 | - !GL::bindTexImage || !GL::releaseTexImage) |
711 | - { |
712 | - compLogMessage ("opengl", CompLogLevelFatal, |
713 | - "GLX_EXT_texture_from_pixmap is missing"); |
714 | - GL::textureFromPixmap = false; |
715 | - } |
716 | - else |
717 | - GL::textureFromPixmap = true; |
718 | - |
719 | - if (!GL::queryDrawable || |
720 | - !GL::getFBConfigs || |
721 | - !GL::getFBConfigAttrib || |
722 | - !GL::createPixmap || |
723 | - !GL::destroyPixmap) |
724 | - { |
725 | - compLogMessage ("opengl", CompLogLevelFatal, |
726 | - "fbconfig functions missing"); |
727 | - screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
728 | - setFailed (); |
729 | - return; |
730 | - } |
731 | - |
732 | - if (strstr (glxExtensions, "GLX_MESA_copy_sub_buffer")) |
733 | - GL::copySubBuffer = (GL::GLXCopySubBufferProc) |
734 | - getProcAddress ("glXCopySubBufferMESA"); |
735 | - |
736 | - if (strstr (glxExtensions, "GLX_SGI_video_sync")) |
737 | - { |
738 | - GL::getVideoSync = (GL::GLXGetVideoSyncProc) |
739 | - getProcAddress ("glXGetVideoSyncSGI"); |
740 | - |
741 | - GL::waitVideoSync = (GL::GLXWaitVideoSyncProc) |
742 | - getProcAddress ("glXWaitVideoSyncSGI"); |
743 | - } |
744 | - |
745 | - if (strstr (glxExtensions, "GLX_SGI_swap_control")) |
746 | - { |
747 | - GL::swapInterval = (GL::GLXSwapIntervalProc) |
748 | - getProcAddress ("glXSwapIntervalSGI"); |
749 | - } |
750 | - |
751 | - glXMakeCurrent (dpy, CompositeScreen::get (s)->output (), priv->ctx); |
752 | + |
753 | + glXMakeCurrent (dpy, CompositeScreen::get (screen)->output (), priv->ctx); |
754 | |
755 | glExtensions = (const char *) glGetString (GL_EXTENSIONS); |
756 | if (!glExtensions) |
757 | @@ -241,8 +116,7 @@ |
758 | compLogMessage ("opengl", CompLogLevelFatal, |
759 | "No valid GL extensions string found."); |
760 | screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
761 | - setFailed (); |
762 | - return; |
763 | + return false; |
764 | } |
765 | |
766 | glRenderer = (const char *) glGetString (GL_RENDERER); |
767 | @@ -254,11 +128,10 @@ |
768 | CompLogLevelFatal, |
769 | "Software rendering detected"); |
770 | screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
771 | - setFailed (); |
772 | - return; |
773 | + return false; |
774 | } |
775 | |
776 | - if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two")) |
777 | + if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two")) |
778 | GL::textureNonPowerOfTwo = true; |
779 | |
780 | glGetIntegerv (GL_MAX_TEXTURE_SIZE, &GL::maxTextureSize); |
781 | @@ -284,8 +157,7 @@ |
782 | compLogMessage ("opengl", CompLogLevelFatal, |
783 | "Support for non power of two textures missing"); |
784 | screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
785 | - setFailed (); |
786 | - return; |
787 | + return false; |
788 | } |
789 | |
790 | if (strstr (glExtensions, "GL_ARB_texture_env_combine")) |
791 | @@ -371,6 +243,182 @@ |
792 | if (strstr (glExtensions, "GL_ARB_texture_compression")) |
793 | GL::textureCompression = true; |
794 | |
795 | + glClearColor (0.0, 0.0, 0.0, 1.0); |
796 | + glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
797 | + glEnable (GL_CULL_FACE); |
798 | + glDisable (GL_BLEND); |
799 | + glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
800 | + glColor4usv (defaultColor); |
801 | + glEnableClientState (GL_VERTEX_ARRAY); |
802 | + glEnableClientState (GL_TEXTURE_COORD_ARRAY); |
803 | + |
804 | + if (GL::textureEnvCombine && GL::maxTextureUnits >= 2) |
805 | + { |
806 | + GL::canDoSaturated = true; |
807 | + if (GL::textureEnvCrossbar && GL::maxTextureUnits >= 4) |
808 | + GL::canDoSlightlySaturated = true; |
809 | + } |
810 | + |
811 | + priv->updateView (); |
812 | + |
813 | + glLightModelfv (GL_LIGHT_MODEL_AMBIENT, globalAmbient); |
814 | + |
815 | + glEnable (GL_LIGHT0); |
816 | + glLightfv (GL_LIGHT0, GL_AMBIENT, ambientLight); |
817 | + glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuseLight); |
818 | + glLightfv (GL_LIGHT0, GL_POSITION, light0Position); |
819 | + |
820 | + glColorMaterial (GL_FRONT, GL_AMBIENT_AND_DIFFUSE); |
821 | + |
822 | + glNormal3f (0.0f, 0.0f, -1.0f); |
823 | + |
824 | + priv->lighting = false; |
825 | + |
826 | + |
827 | + priv->filter[NOTHING_TRANS_FILTER] = GLTexture::Fast; |
828 | + priv->filter[SCREEN_TRANS_FILTER] = GLTexture::Good; |
829 | + priv->filter[WINDOW_TRANS_FILTER] = GLTexture::Good; |
830 | + |
831 | + if (GL::textureFromPixmap) |
832 | + registerBindPixmap (TfpTexture::bindPixmapToTexture); |
833 | + |
834 | + return false; |
835 | +} |
836 | + |
837 | + |
838 | +GLScreen::GLScreen (CompScreen *s) : |
839 | + PluginClassHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI> (s), |
840 | + priv (new PrivateGLScreen (this)) |
841 | +{ |
842 | + Display *dpy = s->dpy (); |
843 | + XVisualInfo templ; |
844 | + XVisualInfo *visinfo; |
845 | + GLXFBConfig *fbConfigs; |
846 | + int defaultDepth, nvisinfo, nElements, value, i; |
847 | + const char *glxExtensions; |
848 | + XWindowAttributes attr; |
849 | + CompOption::Vector o (0); |
850 | + |
851 | + if (indirectRendering) |
852 | + { |
853 | + /* force Mesa libGL into indirect rendering mode, because |
854 | + glXQueryExtensionsString is context-independant */ |
855 | + setenv ("LIBGL_ALWAYS_INDIRECT", "1", True); |
856 | + } |
857 | + |
858 | + if (!XGetWindowAttributes (dpy, s->root (), &attr)) |
859 | + { |
860 | + screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
861 | + setFailed (); |
862 | + return; |
863 | + } |
864 | + |
865 | + templ.visualid = XVisualIDFromVisual (attr.visual); |
866 | + |
867 | + visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo); |
868 | + if (!nvisinfo) |
869 | + { |
870 | + compLogMessage ("opengl", CompLogLevelFatal, |
871 | + "Couldn't get visual info for default visual"); |
872 | + screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
873 | + setFailed (); |
874 | + return; |
875 | + } |
876 | + |
877 | + defaultDepth = visinfo->depth; |
878 | + |
879 | + glXGetConfig (dpy, visinfo, GLX_USE_GL, &value); |
880 | + if (!value) |
881 | + { |
882 | + compLogMessage ("opengl", CompLogLevelFatal, |
883 | + "Root visual is not a GL visual"); |
884 | + XFree (visinfo); |
885 | + screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
886 | + setFailed (); |
887 | + return; |
888 | + } |
889 | + |
890 | + glXGetConfig (dpy, visinfo, GLX_DOUBLEBUFFER, &value); |
891 | + if (!value) |
892 | + { |
893 | + compLogMessage ("opengl", CompLogLevelFatal, |
894 | + "Root visual is not a double buffered GL visual"); |
895 | + XFree (visinfo); |
896 | + screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
897 | + setFailed (); |
898 | + return; |
899 | + } |
900 | + |
901 | + glxExtensions = glXQueryExtensionsString (dpy, s->screenNum ()); |
902 | + |
903 | + if (!strstr (glxExtensions, "GLX_SGIX_fbconfig")) |
904 | + { |
905 | + compLogMessage ("opengl", CompLogLevelFatal, |
906 | + "GLX_SGIX_fbconfig is missing"); |
907 | + screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
908 | + setFailed (); |
909 | + return; |
910 | + } |
911 | + |
912 | + priv->getProcAddress = (GL::GLXGetProcAddressProc) |
913 | + getProcAddress ("glXGetProcAddressARB"); |
914 | + GL::bindTexImage = (GL::GLXBindTexImageProc) |
915 | + getProcAddress ("glXBindTexImageEXT"); |
916 | + GL::releaseTexImage = (GL::GLXReleaseTexImageProc) |
917 | + getProcAddress ("glXReleaseTexImageEXT"); |
918 | + GL::queryDrawable = (GL::GLXQueryDrawableProc) |
919 | + getProcAddress ("glXQueryDrawable"); |
920 | + GL::getFBConfigs = (GL::GLXGetFBConfigsProc) |
921 | + getProcAddress ("glXGetFBConfigs"); |
922 | + GL::getFBConfigAttrib = (GL::GLXGetFBConfigAttribProc) |
923 | + getProcAddress ("glXGetFBConfigAttrib"); |
924 | + GL::createPixmap = (GL::GLXCreatePixmapProc) |
925 | + getProcAddress ("glXCreatePixmap"); |
926 | + GL::destroyPixmap = (GL::GLXDestroyPixmapProc) |
927 | + getProcAddress ("glXDestroyPixmap"); |
928 | + |
929 | + if (!strstr (glxExtensions, "GLX_EXT_texture_from_pixmap") || |
930 | + !GL::bindTexImage || !GL::releaseTexImage) |
931 | + { |
932 | + compLogMessage ("opengl", CompLogLevelFatal, |
933 | + "GLX_EXT_texture_from_pixmap is missing"); |
934 | + GL::textureFromPixmap = false; |
935 | + } |
936 | + else |
937 | + GL::textureFromPixmap = true; |
938 | + |
939 | + if (!GL::queryDrawable || |
940 | + !GL::getFBConfigs || |
941 | + !GL::getFBConfigAttrib || |
942 | + !GL::createPixmap || |
943 | + !GL::destroyPixmap) |
944 | + { |
945 | + compLogMessage ("opengl", CompLogLevelFatal, |
946 | + "fbconfig functions missing"); |
947 | + screen->handleCompizEvent ("opengl", "fatal_fallback", o); |
948 | + setFailed (); |
949 | + return; |
950 | + } |
951 | + |
952 | + if (strstr (glxExtensions, "GLX_MESA_copy_sub_buffer")) |
953 | + GL::copySubBuffer = (GL::GLXCopySubBufferProc) |
954 | + getProcAddress ("glXCopySubBufferMESA"); |
955 | + |
956 | + if (strstr (glxExtensions, "GLX_SGI_video_sync")) |
957 | + { |
958 | + GL::getVideoSync = (GL::GLXGetVideoSyncProc) |
959 | + getProcAddress ("glXGetVideoSyncSGI"); |
960 | + |
961 | + GL::waitVideoSync = (GL::GLXWaitVideoSyncProc) |
962 | + getProcAddress ("glXWaitVideoSyncSGI"); |
963 | + } |
964 | + |
965 | + if (strstr (glxExtensions, "GLX_SGI_swap_control")) |
966 | + { |
967 | + GL::swapInterval = (GL::GLXSwapIntervalProc) |
968 | + getProcAddress ("glXSwapIntervalSGI"); |
969 | + } |
970 | + |
971 | fbConfigs = (*GL::getFBConfigs) (dpy, s->screenNum (), &nElements); |
972 | |
973 | for (i = 0; i <= MAX_DEPTH; i++) |
974 | @@ -501,45 +549,7 @@ |
975 | return; |
976 | } |
977 | |
978 | - glClearColor (0.0, 0.0, 0.0, 1.0); |
979 | - glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
980 | - glEnable (GL_CULL_FACE); |
981 | - glDisable (GL_BLEND); |
982 | - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
983 | - glColor4usv (defaultColor); |
984 | - glEnableClientState (GL_VERTEX_ARRAY); |
985 | - glEnableClientState (GL_TEXTURE_COORD_ARRAY); |
986 | - |
987 | - if (GL::textureEnvCombine && GL::maxTextureUnits >= 2) |
988 | - { |
989 | - GL::canDoSaturated = true; |
990 | - if (GL::textureEnvCrossbar && GL::maxTextureUnits >= 4) |
991 | - GL::canDoSlightlySaturated = true; |
992 | - } |
993 | - |
994 | - priv->updateView (); |
995 | - |
996 | - glLightModelfv (GL_LIGHT_MODEL_AMBIENT, globalAmbient); |
997 | - |
998 | - glEnable (GL_LIGHT0); |
999 | - glLightfv (GL_LIGHT0, GL_AMBIENT, ambientLight); |
1000 | - glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuseLight); |
1001 | - glLightfv (GL_LIGHT0, GL_POSITION, light0Position); |
1002 | - |
1003 | - glColorMaterial (GL_FRONT, GL_AMBIENT_AND_DIFFUSE); |
1004 | - |
1005 | - glNormal3f (0.0f, 0.0f, -1.0f); |
1006 | - |
1007 | - priv->lighting = false; |
1008 | - |
1009 | - |
1010 | - priv->filter[NOTHING_TRANS_FILTER] = GLTexture::Fast; |
1011 | - priv->filter[SCREEN_TRANS_FILTER] = GLTexture::Good; |
1012 | - priv->filter[WINDOW_TRANS_FILTER] = GLTexture::Good; |
1013 | - |
1014 | - if (GL::textureFromPixmap) |
1015 | - registerBindPixmap (TfpTexture::bindPixmapToTexture); |
1016 | - |
1017 | + priv->initContext.start (boost::bind (&GLScreen::glInitContext, this, visinfo), 0, 0); |
1018 | } |
1019 | |
1020 | GLScreen::~GLScreen () |
1021 | @@ -877,6 +887,10 @@ |
1022 | } |
1023 | |
1024 | bool |
1025 | +GLScreenInterface::glInitContext (XVisualInfo *visinfo) |
1026 | + WRAPABLE_DEF (glInitContext, visinfo); |
1027 | + |
1028 | +bool |
1029 | GLScreenInterface::glPaintOutput (const GLScreenPaintAttrib &sAttrib, |
1030 | const GLMatrix &transform, |
1031 | const CompRegion ®ion, |
1032 | @@ -1102,20 +1116,20 @@ |
1033 | |
1034 | glFlush (); |
1035 | |
1036 | - // |
1037 | - // FIXME: Actually fix the composite plugin to be more efficient; |
1038 | - // If GL::swapInterval == NULL && GL::waitVideoSync != NULL then the |
1039 | - // composite plugin should not be imposing any framerate restriction |
1040 | - // (ie. blocking the CPU) at all. Because the framerate will be controlled |
1041 | - // and optimized here: |
1042 | - // |
1043 | + /* |
1044 | + * FIXME: Actually fix the composite plugin to be more efficient; |
1045 | + * If GL::swapInterval == NULL && GL::waitVideoSync != NULL then the |
1046 | + * composite plugin should not be imposing any framerate restriction |
1047 | + * (ie. blocking the CPU) at all. Because the framerate will be controlled |
1048 | + * and optimized here: |
1049 | + */ |
1050 | if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) |
1051 | { |
1052 | - // |
1053 | - // controlSwapVideoSync is much faster than waitForVideoSync because |
1054 | - // it won't block the CPU. The waiting is offloaded to the GPU. |
1055 | - // Unfortunately it only works with glXSwapBuffers in most drivers. |
1056 | - // |
1057 | + /* |
1058 | + * controlSwapVideoSync is much faster than waitForVideoSync because |
1059 | + * it won't block the CPU. The waiting is offloaded to the GPU. |
1060 | + * Unfortunately it only works with glXSwapBuffers in most drivers. |
1061 | + */ |
1062 | GL::controlSwapVideoSync (optionGetSyncToVblank ()); |
1063 | glXSwapBuffers (screen->dpy (), cScreen->output ()); |
1064 | } |
1065 | @@ -1183,12 +1197,18 @@ |
1066 | return (GL::waitVideoSync && optionGetSyncToVblank ()); |
1067 | } |
1068 | |
1069 | +bool |
1070 | +PrivateGLScreen::compositingActive () |
1071 | +{ |
1072 | + return true; |
1073 | +} |
1074 | + |
1075 | void |
1076 | PrivateGLScreen::prepareDrawing () |
1077 | { |
1078 | if (pendingCommands) |
1079 | { |
1080 | - // glFlush! glFinish would block the CPU, which is bad. |
1081 | + /* glFlush! glFinish would block the CPU, which is bad. */ |
1082 | glFlush (); |
1083 | pendingCommands = false; |
1084 | } |