Merge lp:~mc-return/compiz/compiz.merge-opengl-cleanup into lp:compiz/0.9.11

Proposed by MC Return
Status: Work in progress
Proposed branch: lp:~mc-return/compiz/compiz.merge-opengl-cleanup
Merge into: lp:compiz/0.9.11
Diff against target: 6177 lines (+1581/-1449)
26 files modified
plugins/opengl/include/opengl/doublebuffer.h (+14/-8)
plugins/opengl/include/opengl/opengl.h (+136/-133)
plugins/opengl/include/opengl/program.h (+38/-16)
plugins/opengl/include/opengl/programcache.h (+2/-1)
plugins/opengl/include/opengl/texture.h (+11/-5)
plugins/opengl/include/opengl/vector.h (+6/-2)
plugins/opengl/src/blacklist/blacklist.cpp (+8/-6)
plugins/opengl/src/blacklist/blacklist.h (+4/-2)
plugins/opengl/src/doublebuffer/src/double-buffer.cpp (+2/-4)
plugins/opengl/src/framebufferobject.cpp (+26/-21)
plugins/opengl/src/fsregion/fsregion.cpp (+9/-11)
plugins/opengl/src/fsregion/fsregion.h (+10/-4)
plugins/opengl/src/matrix.cpp (+24/-22)
plugins/opengl/src/opengl.cpp (+12/-10)
plugins/opengl/src/paint.cpp (+242/-260)
plugins/opengl/src/privates.h (+99/-85)
plugins/opengl/src/privatetexture.h (+17/-6)
plugins/opengl/src/privatevertexbuffer.h (+47/-39)
plugins/opengl/src/program.cpp (+46/-36)
plugins/opengl/src/programcache.cpp (+29/-34)
plugins/opengl/src/screen.cpp (+484/-453)
plugins/opengl/src/shadercache.cpp (+53/-47)
plugins/opengl/src/texture.cpp (+70/-61)
plugins/opengl/src/vector.cpp (+35/-33)
plugins/opengl/src/vertexbuffer.cpp (+108/-106)
plugins/opengl/src/window.cpp (+49/-44)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-opengl-cleanup
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+176724@code.launchpad.net

Commit message

*OpenGL plugin, cleanup:

Bail out of functions ASAP, do not calculate stuff you might not need.
Merged if condition checks.
Use pre- instead of postfix de- and increments.
Declare variables outside of loops.
Declarations and assignment of local variables in one line.
Removed redundant brackets.
Removed and added newlines for better readability.
Fixed indentation.
Fixed a few typos in comments and debug-messages.
Added TODO comment.

*OpenGL plugin, fixes:

framebufferobject.cpp:
Also initialize the non-static struct member "rbStencilId" in the
PrivateGLFramebufferObject::PrivateGLFramebufferObject () constructor
(LP: #1101410)

screen.cpp:
Initialize all the non-static class member fields (glxPixmapFBConfigs,
lastViewport) and members (filter, saveWindow) in the PrivateGLScreen::
PrivateGLScreen (GLScreen *) constructor.
(LP: #1101408)

texture.cpp:
Also initialize the non-static class members "x11Pixmap" and "source" in
the TfpTexture::TfpTexture () ctor.
(LP: #1101594)

vertexbuffer.cpp:
Also initialize the non-static class members "color", "primitiveType" and
"usage" in the PrivateVertexBuffer::PrivateVertexBuffer () constructor
(LP: #1101493)

To post a comment you must log in.

Unmerged revisions

3688. By MC Return

Merged latest lp:compiz

3687. By MC Return

Merged latest lp:compiz and fixed conflict in plugins/opengl/src/paint.cpp

3686. By MC Return

framebufferobject.cpp:
Also initialize the non-static struct member "rbStencilId" in the
PrivateGLFramebufferObject::PrivateGLFramebufferObject () constructor
(LP: #1101410)

Removed alignment in the ctor

3685. By MC Return

screen.cpp:
Initialize all the non-static class member fields (glxPixmapFBConfigs,
lastViewport) and members (filter, saveWindow) in the PrivateGLScreen::
PrivateGLScreen (GLScreen *) constructor
(LP: #1101408)

Reverted alignment in the constructor

3684. By MC Return

Also initialize the non-static class members "color", "primitiveType" and
"usage" in the PrivateVertexBuffer::PrivateVertexBuffer () constructor
(LP: #1101493)

3683. By MC Return

texture.cpp:
Also initialize the non-static class members "x11Pixmap" and "source" in
the TfpTexture::TfpTexture () ctor (LP: #1101594)

3682. By MC Return

Indentation fixes
Re-added "lost" code in paint.cpp

3681. By MC Return

Removed bracket (typo)

3680. By MC Return

Merged latest lp:compiz and fixed conflict in plugins/opengl/src/window.cpp

3679. By MC Return

Added missing " | NoOcclusionDetection"

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/opengl/include/opengl/doublebuffer.h'
--- plugins/opengl/include/opengl/doublebuffer.h 2012-11-08 09:17:39 +0000
+++ plugins/opengl/include/opengl/doublebuffer.h 2013-07-24 16:05:45 +0000
@@ -18,16 +18,17 @@
18class DoubleBuffer18class DoubleBuffer
19{19{
20 public:20 public:
21
21 DoubleBuffer (const impl::GLXSwapIntervalEXTFunc &swapIntervalFunc,22 DoubleBuffer (const impl::GLXSwapIntervalEXTFunc &swapIntervalFunc,
22 const impl::GLXWaitVideoSyncSGIFunc &waitVideoSyncFunc);23 const impl::GLXWaitVideoSyncSGIFunc &waitVideoSyncFunc);
23 virtual ~DoubleBuffer ();24 virtual ~DoubleBuffer ();
2425
25 virtual void swap () const = 0;26 virtual void swap () const = 0;
26 virtual bool blitAvailable () const = 0;27 virtual bool blitAvailable () const = 0;
27 virtual void blit (const CompRegion &region) const = 0;28 virtual void blit (const CompRegion &region) const = 0;
28 virtual bool fallbackBlitAvailable () const = 0;29 virtual bool fallbackBlitAvailable () const = 0;
29 virtual void fallbackBlit (const CompRegion &region) const = 0;30 virtual void fallbackBlit (const CompRegion &region) const = 0;
30 virtual void copyFrontToBack () const = 0;31 virtual void copyFrontToBack () const = 0;
3132
32 typedef enum33 typedef enum
33 {34 {
@@ -56,13 +57,18 @@
56 FrameThrottledInternally57 FrameThrottledInternally
57 } FrameThrottleState;58 } FrameThrottleState;
5859
59 void set (Setting name, bool value);60 void set (Setting name,
60 void render (const CompRegion &region, bool fullscreen);61 bool value);
62
63 void render (const CompRegion &region,
64 bool fullscreen);
65
61 void vsync (FrontbufferRedrawType redrawType);66 void vsync (FrontbufferRedrawType redrawType);
6267
63 bool hardwareVSyncFunctional ();68 bool hardwareVSyncFunctional ();
6469
65 protected:70 protected:
71
66 bool setting[_NSETTINGS];72 bool setting[_NSETTINGS];
6773
68 private:74 private:
@@ -72,7 +78,7 @@
72 virtual bool enableBlockingVideoSync (FrontbufferRedrawType, FrameThrottleState &);78 virtual bool enableBlockingVideoSync (FrontbufferRedrawType, FrameThrottleState &);
73 virtual void disableBlockingVideoSync ();79 virtual void disableBlockingVideoSync ();
7480
75 SyncType syncType;81 SyncType syncType;
7682
77 FrameThrottleState bufferFrameThrottleState;83 FrameThrottleState bufferFrameThrottleState;
78 unsigned int blockingVSyncUnthrottledFrames;84 unsigned int blockingVSyncUnthrottledFrames;
7985
=== modified file 'plugins/opengl/include/opengl/opengl.h'
--- plugins/opengl/include/opengl/opengl.h 2013-04-27 05:54:57 +0000
+++ plugins/opengl/include/opengl/opengl.h 2013-07-24 16:05:45 +0000
@@ -87,77 +87,79 @@
87class PrivateGLScreen;87class PrivateGLScreen;
88class PrivateGLWindow;88class PrivateGLWindow;
8989
90extern GLushort defaultColor[4];90extern GLushort defaultColor[4];
9191
92#ifndef GLX_EXT_texture_from_pixmap92#ifndef GLX_EXT_texture_from_pixmap
93#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D093#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0
94#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D194#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1
95#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D295#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2
96#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D396#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3
97#define GLX_Y_INVERTED_EXT 0x20D497#define GLX_Y_INVERTED_EXT 0x20D4
98#define GLX_TEXTURE_FORMAT_EXT 0x20D598#define GLX_TEXTURE_FORMAT_EXT 0x20D5
99#define GLX_TEXTURE_TARGET_EXT 0x20D699#define GLX_TEXTURE_TARGET_EXT 0x20D6
100#define GLX_MIPMAP_TEXTURE_EXT 0x20D7100#define GLX_MIPMAP_TEXTURE_EXT 0x20D7
101#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8101#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8
102#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9102#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9
103#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA103#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA
104#define GLX_TEXTURE_1D_BIT_EXT 0x00000001104#define GLX_TEXTURE_1D_BIT_EXT 0x00000001
105#define GLX_TEXTURE_2D_BIT_EXT 0x00000002105#define GLX_TEXTURE_2D_BIT_EXT 0x00000002
106#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004106#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
107#define GLX_TEXTURE_1D_EXT 0x20DB107#define GLX_TEXTURE_1D_EXT 0x20DB
108#define GLX_TEXTURE_2D_EXT 0x20DC108#define GLX_TEXTURE_2D_EXT 0x20DC
109#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD109#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD
110#define GLX_FRONT_LEFT_EXT 0x20DE110#define GLX_FRONT_LEFT_EXT 0x20DE
111#endif111#endif
112112
113namespace GL {113namespace GL
114{
114 #ifdef USE_GLES115 #ifdef USE_GLES
115 typedef EGLImageKHR (*EGLCreateImageKHRProc) (EGLDisplay dpy,116typedef EGLImageKHR (*EGLCreateImageKHRProc) (EGLDisplay dpy,
116 EGLContext ctx,117 EGLContext ctx,
117 EGLenum target,118 EGLenum target,
118 EGLClientBuffer buffer,119 EGLClientBuffer buffer,
119 const EGLint *attrib_list);120 const EGLint *attrib_list);
120 typedef EGLBoolean (*EGLDestroyImageKHRProc) (EGLDisplay dpy,121
121 EGLImageKHR image);122typedef EGLBoolean (*EGLDestroyImageKHRProc) (EGLDisplay dpy,
122123 EGLImageKHR image);
123 typedef void (*GLEGLImageTargetTexture2DOESProc) (GLenum target,124
124 GLeglImageOES image);125typedef void (*GLEGLImageTargetTexture2DOESProc) (GLenum target,
125126 GLeglImageOES image);
126 typedef EGLBoolean (*EGLPostSubBufferNVProc) (EGLDisplay dpy,127
127 EGLSurface surface,128typedef EGLBoolean (*EGLPostSubBufferNVProc) (EGLDisplay dpy,
128 EGLint x, EGLint y,129 EGLSurface surface,
129 EGLint width, EGLint height);130 EGLint x,
130131 EGLint y,
132 EGLint width,
133 EGLint height);
131 #else134 #else
132 typedef void (*FuncPtr) (void);135 typedef void (*FuncPtr) (void);
133136
134 typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);137 typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);
135138
136 typedef void (*GLXBindTexImageProc) (Display *display,139typedef void (*GLXBindTexImageProc) (Display *display,
137 GLXDrawable drawable,140 GLXDrawable drawable,
138 int buffer,141 int buffer,
139 int *attribList);142 int *attribList);
140 typedef void (*GLXReleaseTexImageProc) (Display *display,143typedef void (*GLXReleaseTexImageProc) (Display *display,
141 GLXDrawable drawable,144 GLXDrawable drawable,
142 int buffer);145 int buffer);
143 typedef void (*GLXQueryDrawableProc) (Display *display,146typedef void (*GLXQueryDrawableProc) (Display *display,
144 GLXDrawable drawable,147 GLXDrawable drawable,
145 int attribute,148 int attribute,
146 unsigned int *value);149 unsigned int *value);
147150
148 typedef void (*GLXCopySubBufferProc) (Display *display,151typedef void (*GLXCopySubBufferProc) (Display *display,
149 GLXDrawable drawable,152 GLXDrawable drawable,
150 int x,153 int x,
151 int y,154 int y,
152 int width,155 int width,
153 int height);156 int height);
154157
155 typedef int (*GLXGetVideoSyncProc) (unsigned int *count);158typedef int (*GLXGetVideoSyncProc) (unsigned int *count);
156 typedef int (*GLXWaitVideoSyncProc) (int divisor,159typedef int (*GLXWaitVideoSyncProc) (int divisor,
157 int remainder,160 int remainder,
158 unsigned int *count);161 unsigned int *count);
159 typedef int (*GLXSwapIntervalProc) (int interval);162typedef int (*GLXSwapIntervalProc) (int interval);
160
161163
162 #ifndef GLX_VERSION_1_3164 #ifndef GLX_VERSION_1_3
163 typedef struct __GLXFBConfigRec *GLXFBConfig;165 typedef struct __GLXFBConfigRec *GLXFBConfig;
@@ -413,102 +415,102 @@
413 extern GLDisableVertexAttribArrayProc disableVertexAttribArray;415 extern GLDisableVertexAttribArrayProc disableVertexAttribArray;
414 extern GLVertexAttribPointerProc vertexAttribPointer;416 extern GLVertexAttribPointerProc vertexAttribPointer;
415417
416 extern GLGenRenderbuffersProc genRenderbuffers;418 extern GLGenRenderbuffersProc genRenderbuffers;
417 extern GLDeleteRenderbuffersProc deleteRenderbuffers;419 extern GLDeleteRenderbuffersProc deleteRenderbuffers;
418 extern GLBindRenderbufferProc bindRenderbuffer;420 extern GLBindRenderbufferProc bindRenderbuffer;
419 extern GLFramebufferRenderbufferProc framebufferRenderbuffer;421 extern GLFramebufferRenderbufferProc framebufferRenderbuffer;
420 extern GLRenderbufferStorageProc renderbufferStorage;422 extern GLRenderbufferStorageProc renderbufferStorage;
421423
422 #ifndef USE_GLES424 #ifndef USE_GLES
423 extern GLCreateShaderObjectARBProc createShaderObjectARB;425 extern GLCreateShaderObjectARBProc createShaderObjectARB;
424 extern GLCreateProgramObjectARBProc createProgramObjectARB;426 extern GLCreateProgramObjectARBProc createProgramObjectARB;
425 extern GLShaderSourceARBProc shaderSourceARB;427 extern GLShaderSourceARBProc shaderSourceARB;
426 extern GLCompileShaderARBProc compileShaderARB;428 extern GLCompileShaderARBProc compileShaderARB;
427 extern GLValidateProgramARBProc validateProgramARB;429 extern GLValidateProgramARBProc validateProgramARB;
428 extern GLDeleteObjectARBProc deleteObjectARB;430 extern GLDeleteObjectARBProc deleteObjectARB;
429 extern GLAttachObjectARBProc attachObjectARB;431 extern GLAttachObjectARBProc attachObjectARB;
430 extern GLLinkProgramARBProc linkProgramARB;432 extern GLLinkProgramARBProc linkProgramARB;
431 extern GLUseProgramObjectARBProc useProgramObjectARB;433 extern GLUseProgramObjectARBProc useProgramObjectARB;
432 extern GLGetUniformLocationARBProc getUniformLocationARB;434 extern GLGetUniformLocationARBProc getUniformLocationARB;
433 extern GLGetAttribLocationARBProc getAttribLocationARB;435 extern GLGetAttribLocationARBProc getAttribLocationARB;
434436
435 extern GLGetObjectParameterivProc getObjectParameteriv;437 extern GLGetObjectParameterivProc getObjectParameteriv;
436 extern GLGetInfoLogProc getInfoLog;438 extern GLGetInfoLogProc getInfoLog;
437 #endif439 #endif
438440
439#ifdef USE_GLES441#ifdef USE_GLES
440442
441 static const GLenum FRAMEBUFFER_BINDING = GL_FRAMEBUFFER_BINDING;443 static const GLenum FRAMEBUFFER_BINDING = GL_FRAMEBUFFER_BINDING;
442 static const GLenum FRAMEBUFFER = GL_FRAMEBUFFER;444 static const GLenum FRAMEBUFFER = GL_FRAMEBUFFER;
443 static const GLenum RENDERBUFFER = GL_RENDERBUFFER;445 static const GLenum RENDERBUFFER = GL_RENDERBUFFER;
444 static const GLenum COLOR_ATTACHMENT0 = GL_COLOR_ATTACHMENT0;446 static const GLenum COLOR_ATTACHMENT0 = GL_COLOR_ATTACHMENT0;
445 static const GLenum DEPTH_ATTACHMENT = GL_DEPTH_ATTACHMENT;447 static const GLenum DEPTH_ATTACHMENT = GL_DEPTH_ATTACHMENT;
446 static const GLenum STENCIL_ATTACHMENT = GL_STENCIL_ATTACHMENT;448 static const GLenum STENCIL_ATTACHMENT = GL_STENCIL_ATTACHMENT;
447 static const GLenum DEPTH24_STENCIL8 = GL_DEPTH24_STENCIL8_OES;449 static const GLenum DEPTH24_STENCIL8 = GL_DEPTH24_STENCIL8_OES;
448450
449 /* OpenGL|ES does not support different draw/read framebuffers */451 /* OpenGL|ES does not support different draw/read framebuffers */
450 static const GLenum DRAW_FRAMEBUFFER = GL_FRAMEBUFFER;452 static const GLenum DRAW_FRAMEBUFFER = GL_FRAMEBUFFER;
451 static const GLenum READ_FRAMEBUFFER = GL_FRAMEBUFFER;453 static const GLenum READ_FRAMEBUFFER = GL_FRAMEBUFFER;
452 static const GLenum DRAW_FRAMEBUFFER_BINDING = FRAMEBUFFER_BINDING;454 static const GLenum DRAW_FRAMEBUFFER_BINDING = FRAMEBUFFER_BINDING;
453 static const GLenum READ_FRAMEBUFFER_BINDING = FRAMEBUFFER_BINDING;455 static const GLenum READ_FRAMEBUFFER_BINDING = FRAMEBUFFER_BINDING;
454456
455 static const GLenum FRAMEBUFFER_COMPLETE = GL_FRAMEBUFFER_COMPLETE;457 static const GLenum FRAMEBUFFER_COMPLETE = GL_FRAMEBUFFER_COMPLETE;
456 static const GLenum FRAMEBUFFER_UNDEFINED = 0;458 static const GLenum FRAMEBUFFER_UNDEFINED = 0;
457 static const GLenum FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;459 static const GLenum FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
458 static const GLenum FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;460 static const GLenum FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
459 static const GLenum FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = 0;461 static const GLenum FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = 0;
460 static const GLenum FRAMEBUFFER_INCOMPLETE_READ_BUFFER = 0;462 static const GLenum FRAMEBUFFER_INCOMPLETE_READ_BUFFER = 0;
461 static const GLenum FRAMEBUFFER_UNSUPPORTED = GL_FRAMEBUFFER_UNSUPPORTED;463 static const GLenum FRAMEBUFFER_UNSUPPORTED = GL_FRAMEBUFFER_UNSUPPORTED;
462 static const GLenum FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0;464 static const GLenum FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0;
463 static const GLenum FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = 0;465 static const GLenum FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = 0;
464 static const GLenum FRAMEBUFFER_INCOMPLETE_DIMENSIONS = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;466 static const GLenum FRAMEBUFFER_INCOMPLETE_DIMENSIONS = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
465467
466 static const GLenum ARRAY_BUFFER = GL_ARRAY_BUFFER;468 static const GLenum ARRAY_BUFFER = GL_ARRAY_BUFFER;
467 static const GLenum STATIC_DRAW = GL_STATIC_DRAW;469 static const GLenum STATIC_DRAW = GL_STATIC_DRAW;
468 static const GLenum STREAM_DRAW = GL_STREAM_DRAW;470 static const GLenum STREAM_DRAW = GL_STREAM_DRAW;
469 static const GLenum DYNAMIC_DRAW = GL_DYNAMIC_DRAW;471 static const GLenum DYNAMIC_DRAW = GL_DYNAMIC_DRAW;
470472
471 static const GLenum INFO_LOG_LENGTH = GL_INFO_LOG_LENGTH;473 static const GLenum INFO_LOG_LENGTH = GL_INFO_LOG_LENGTH;
472 static const GLenum COMPILE_STATUS = GL_COMPILE_STATUS;474 static const GLenum COMPILE_STATUS = GL_COMPILE_STATUS;
473 static const GLenum LINK_STATUS = GL_LINK_STATUS;475 static const GLenum LINK_STATUS = GL_LINK_STATUS;
474 static const GLenum FRAGMENT_SHADER = GL_FRAGMENT_SHADER;476 static const GLenum FRAGMENT_SHADER = GL_FRAGMENT_SHADER;
475 static const GLenum VERTEX_SHADER = GL_VERTEX_SHADER;477 static const GLenum VERTEX_SHADER = GL_VERTEX_SHADER;
476478
477#else479#else
478480
479 static const GLenum FRAMEBUFFER_BINDING = GL_FRAMEBUFFER_BINDING_EXT;481 static const GLenum FRAMEBUFFER_BINDING = GL_FRAMEBUFFER_BINDING_EXT;
480 static const GLenum FRAMEBUFFER = GL_FRAMEBUFFER_EXT;482 static const GLenum FRAMEBUFFER = GL_FRAMEBUFFER_EXT;
481 static const GLenum RENDERBUFFER = GL_RENDERBUFFER;483 static const GLenum RENDERBUFFER = GL_RENDERBUFFER;
482 static const GLenum COLOR_ATTACHMENT0 = GL_COLOR_ATTACHMENT0_EXT;484 static const GLenum COLOR_ATTACHMENT0 = GL_COLOR_ATTACHMENT0_EXT;
483 static const GLenum DEPTH_ATTACHMENT = GL_DEPTH_ATTACHMENT_EXT;485 static const GLenum DEPTH_ATTACHMENT = GL_DEPTH_ATTACHMENT_EXT;
484 static const GLenum STENCIL_ATTACHMENT = GL_STENCIL_ATTACHMENT_EXT;486 static const GLenum STENCIL_ATTACHMENT = GL_STENCIL_ATTACHMENT_EXT;
485 static const GLenum DEPTH24_STENCIL8 = GL_DEPTH24_STENCIL8_EXT;487 static const GLenum DEPTH24_STENCIL8 = GL_DEPTH24_STENCIL8_EXT;
486488
487 static const GLenum DRAW_FRAMEBUFFER = GL_DRAW_FRAMEBUFFER_EXT;489 static const GLenum DRAW_FRAMEBUFFER = GL_DRAW_FRAMEBUFFER_EXT;
488 static const GLenum READ_FRAMEBUFFER = GL_READ_FRAMEBUFFER_EXT;490 static const GLenum READ_FRAMEBUFFER = GL_READ_FRAMEBUFFER_EXT;
489 static const GLenum DRAW_FRAMEBUFFER_BINDING = GL_DRAW_FRAMEBUFFER_BINDING_EXT;491 static const GLenum DRAW_FRAMEBUFFER_BINDING = GL_DRAW_FRAMEBUFFER_BINDING_EXT;
490 static const GLenum READ_FRAMEBUFFER_BINDING = GL_READ_FRAMEBUFFER_BINDING_EXT;492 static const GLenum READ_FRAMEBUFFER_BINDING = GL_READ_FRAMEBUFFER_BINDING_EXT;
491 static const GLenum FRAMEBUFFER_COMPLETE = GL_FRAMEBUFFER_COMPLETE_EXT;493 static const GLenum FRAMEBUFFER_COMPLETE = GL_FRAMEBUFFER_COMPLETE_EXT;
492 static const GLenum FRAMEBUFFER_UNDEFINED = GL_FRAMEBUFFER_UNDEFINED;494 static const GLenum FRAMEBUFFER_UNDEFINED = GL_FRAMEBUFFER_UNDEFINED;
493 static const GLenum FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;495 static const GLenum FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
494 static const GLenum FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;496 static const GLenum FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
495 static const GLenum FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT;497 static const GLenum FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT;
496 static const GLenum FRAMEBUFFER_INCOMPLETE_READ_BUFFER = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT;498 static const GLenum FRAMEBUFFER_INCOMPLETE_READ_BUFFER = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT;
497 static const GLenum FRAMEBUFFER_UNSUPPORTED = GL_FRAMEBUFFER_UNSUPPORTED_EXT;499 static const GLenum FRAMEBUFFER_UNSUPPORTED = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
498 static const GLenum FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT;500 static const GLenum FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT;
499 static const GLenum FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT;501 static const GLenum FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT;
500 static const GLenum FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0;502 static const GLenum FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0;
501503
502 static const GLenum ARRAY_BUFFER = GL_ARRAY_BUFFER_ARB;504 static const GLenum ARRAY_BUFFER = GL_ARRAY_BUFFER_ARB;
503 static const GLenum STATIC_DRAW = GL_STATIC_DRAW_ARB;505 static const GLenum STATIC_DRAW = GL_STATIC_DRAW_ARB;
504 static const GLenum STREAM_DRAW = GL_STREAM_DRAW_ARB;506 static const GLenum STREAM_DRAW = GL_STREAM_DRAW_ARB;
505 static const GLenum DYNAMIC_DRAW = GL_DYNAMIC_DRAW_ARB;507 static const GLenum DYNAMIC_DRAW = GL_DYNAMIC_DRAW_ARB;
506508
507 static const GLenum INFO_LOG_LENGTH = GL_OBJECT_INFO_LOG_LENGTH_ARB;509 static const GLenum INFO_LOG_LENGTH = GL_OBJECT_INFO_LOG_LENGTH_ARB;
508 static const GLenum COMPILE_STATUS = GL_OBJECT_COMPILE_STATUS_ARB;510 static const GLenum COMPILE_STATUS = GL_OBJECT_COMPILE_STATUS_ARB;
509 static const GLenum LINK_STATUS = GL_OBJECT_LINK_STATUS_ARB;511 static const GLenum LINK_STATUS = GL_OBJECT_LINK_STATUS_ARB;
510 static const GLenum FRAGMENT_SHADER = GL_FRAGMENT_SHADER_ARB;512 static const GLenum FRAGMENT_SHADER = GL_FRAGMENT_SHADER_ARB;
511 static const GLenum VERTEX_SHADER = GL_VERTEX_SHADER_ARB;513 static const GLenum VERTEX_SHADER = GL_VERTEX_SHADER_ARB;
512514
513#endif515#endif
514516
@@ -553,7 +555,8 @@
553#endif555#endif
554};556};
555557
556struct GLScreenPaintAttrib {558struct GLScreenPaintAttrib
559{
557 GLfloat xRotate;560 GLfloat xRotate;
558 GLfloat yRotate;561 GLfloat yRotate;
559 GLfloat vRotate;562 GLfloat vRotate;
@@ -566,7 +569,8 @@
566#define MAX_DEPTH 32569#define MAX_DEPTH 32
567570
568#ifndef USE_GLES571#ifndef USE_GLES
569struct GLFBConfig {572struct GLFBConfig
573{
570 GLXFBConfig fbConfig;574 GLXFBConfig fbConfig;
571 int yInverted;575 int yInverted;
572 int mipmap;576 int mipmap;
@@ -647,9 +651,9 @@
647 CompOutput *output,651 CompOutput *output,
648 GLMatrix *mask);652 GLMatrix *mask);
649653
650 virtual void glEnableOutputClipping (const GLMatrix &,654 virtual void glEnableOutputClipping (const GLMatrix &,
651 const CompRegion &,655 const CompRegion &,
652 CompOutput *);656 CompOutput *);
653 virtual void glDisableOutputClipping ();657 virtual void glDisableOutputClipping ();
654658
655 virtual GLMatrix *projectionMatrix ();659 virtual GLMatrix *projectionMatrix ();
@@ -669,9 +673,9 @@
669 /**673 /**
670 * Hookable function used by plugins to determine stenciling mask674 * Hookable function used by plugins to determine stenciling mask
671 */675 */
672 virtual void glBufferStencil (const GLMatrix &matrix,676 virtual void glBufferStencil (const GLMatrix &matrix,
673 GLVertexBuffer &vertexBuffer,677 GLVertexBuffer &vertexBuffer,
674 CompOutput *output);678 CompOutput *output);
675679
676};680};
677681
@@ -925,7 +929,7 @@
925 const GLTexture::List & textures () const;929 const GLTexture::List & textures () const;
926930
927 /**931 /**
928 * Returns the matrices for the tiled textures for this windwo932 * Returns the matrices for the tiled textures for this window
929 */933 */
930 const GLTexture::MatrixList & matrices () const;934 const GLTexture::MatrixList & matrices () const;
931935
@@ -971,4 +975,3 @@
971};975};
972976
973#endif977#endif
974
975978
=== modified file 'plugins/opengl/include/opengl/program.h'
--- plugins/opengl/include/opengl/program.h 2012-05-17 10:41:21 +0000
+++ plugins/opengl/include/opengl/program.h 2013-07-24 16:05:45 +0000
@@ -40,6 +40,7 @@
40class GLProgram40class GLProgram
41{41{
42 public:42 public:
43
43 GLProgram (CompString &vertexShader, CompString &fragmentShader);44 GLProgram (CompString &vertexShader, CompString &fragmentShader);
44 ~GLProgram ();45 ~GLProgram ();
4546
@@ -47,29 +48,50 @@
47 void bind ();48 void bind ();
48 void unbind ();49 void unbind ();
4950
50 bool setUniform (const char *name, GLfloat value);51 bool setUniform (const char *name,
51 bool setUniform (const char *name, GLint value);52 GLfloat value);
52 bool setUniform (const char *name, const GLMatrix &value);53
53 bool setUniform2f (const char *name, GLfloat x, GLfloat y);54 bool setUniform (const char *name,
54 bool setUniform3f (const char *name, GLfloat x, GLfloat y, GLfloat z);55 GLint value);
56
57 bool setUniform (const char *name,
58 const GLMatrix &value);
59
60 bool setUniform2f (const char *name,
61 GLfloat x,
62 GLfloat y);
63
64 bool setUniform3f (const char *name,
65 GLfloat x,
66 GLfloat y,
67 GLfloat z);
68
55 bool setUniform4f (const char *name,69 bool setUniform4f (const char *name,
56 GLfloat x,70 GLfloat x,
57 GLfloat y,71 GLfloat y,
58 GLfloat z,72 GLfloat z,
59 GLfloat w);73 GLfloat w);
60 bool setUniform2i (const char *name, GLint x, GLint y);74
61 bool setUniform3i (const char *name, GLint x, GLint y, GLint z);75 bool setUniform2i (const char *name,
76 GLint x,
77 GLint y);
78
79 bool setUniform3i (const char *name,
80 GLint x,
81 GLint y,
82 GLint z);
83
62 bool setUniform4i (const char *name,84 bool setUniform4i (const char *name,
63 GLint x,85 GLint x,
64 GLint y,86 GLint y,
65 GLint z,87 GLint z,
66 GLint w);88 GLint w);
6789
68 GLuint attributeLocation (const char *name);90 GLuint attributeLocation (const char *name);
6991
70 private:92 private:
93
71 PrivateProgram *priv;94 PrivateProgram *priv;
72};95};
7396
74#endif // _COMPIZ_GLPROGRAM_H97#endif // _COMPIZ_GLPROGRAM_H
75
7698
=== modified file 'plugins/opengl/include/opengl/programcache.h'
--- plugins/opengl/include/opengl/programcache.h 2012-05-17 10:41:21 +0000
+++ plugins/opengl/include/opengl/programcache.h 2013-07-24 16:05:45 +0000
@@ -38,9 +38,11 @@
38class GLProgramCache38class GLProgramCache
39{39{
40 private:40 private:
41
41 PrivateProgramCache *priv;42 PrivateProgramCache *priv;
4243
43 public:44 public:
45
44 GLProgramCache (size_t);46 GLProgramCache (size_t);
45 ~GLProgramCache ();47 ~GLProgramCache ();
4648
@@ -48,4 +50,3 @@
48};50};
4951
50#endif // _COMPIZ_GLPROGRAMCACHE_H52#endif // _COMPIZ_GLPROGRAMCACHE_H
51
5253
=== modified file 'plugins/opengl/include/opengl/texture.h'
--- plugins/opengl/include/opengl/texture.h 2012-09-18 11:32:20 +0000
+++ plugins/opengl/include/opengl/texture.h 2013-07-24 16:05:45 +0000
@@ -73,15 +73,18 @@
73/**73/**
74 * Class which represents an openGL texture74 * Class which represents an openGL texture
75 */75 */
76class GLTexture : public CompRect {76class GLTexture : public CompRect
77{
77 public:78 public:
7879
79 typedef enum {80 typedef enum
81 {
80 Fast,82 Fast,
81 Good83 Good
82 } Filter;84 } Filter;
8385
84 typedef struct {86 typedef struct
87 {
85 float xx; float yx;88 float xx; float yx;
86 float xy; float yy;89 float xy; float yy;
87 float x0; float y0;90 float x0; float y0;
@@ -93,9 +96,10 @@
93 * Class which represents a list of openGL textures,96 * Class which represents a list of openGL textures,
94 * usually used for texture tiling97 * usually used for texture tiling
95 */98 */
96 class List : public std::vector <GLTexture *> {99 class List : public std::vector <GLTexture *>
97100 {
98 public:101 public:
102
99 List ();103 List ();
100 List (unsigned int);104 List (unsigned int);
101 List (const List &);105 List (const List &);
@@ -224,12 +228,14 @@
224 friend class PrivateTexture;228 friend class PrivateTexture;
225229
226 protected:230 protected:
231
227 GLTexture ();232 GLTexture ();
228 virtual ~GLTexture ();233 virtual ~GLTexture ();
229234
230 void setData (GLenum target, Matrix &m, bool mipmap);235 void setData (GLenum target, Matrix &m, bool mipmap);
231236
232 private:237 private:
238
233 PrivateTexture *priv;239 PrivateTexture *priv;
234};240};
235241
236242
=== modified file 'plugins/opengl/include/opengl/vector.h'
--- plugins/opengl/include/opengl/vector.h 2012-05-17 10:41:21 +0000
+++ plugins/opengl/include/opengl/vector.h 2013-07-24 16:05:45 +0000
@@ -30,9 +30,12 @@
30 * Class which describes a point or vector30 * Class which describes a point or vector
31 * in 3D space31 * in 3D space
32 */32 */
33class GLVector {33class GLVector
34{
34 public:35 public:
35 typedef enum {36
37 typedef enum
38 {
36 x,39 x,
37 y,40 y,
38 z,41 z,
@@ -105,6 +108,7 @@
105 GLVector& homogenize ();108 GLVector& homogenize ();
106109
107 private:110 private:
111
108 friend GLVector operator+ (const GLVector& lhs,112 friend GLVector operator+ (const GLVector& lhs,
109 const GLVector& rhs);113 const GLVector& rhs);
110 friend GLVector operator- (const GLVector& lhs,114 friend GLVector operator- (const GLVector& lhs,
111115
=== modified file 'plugins/opengl/src/blacklist/blacklist.cpp'
--- plugins/opengl/src/blacklist/blacklist.cpp 2012-12-12 07:24:34 +0000
+++ plugins/opengl/src/blacklist/blacklist.cpp 2013-07-24 16:05:45 +0000
@@ -30,8 +30,10 @@
30namespace compiz {30namespace compiz {
31namespace opengl {31namespace opengl {
3232
33bool blacklisted (const char *blacklistRegex, const char *glVendor,33bool blacklisted (const char *blacklistRegex,
34 const char *glRenderer, const char *glVersion)34 const char *glVendor,
35 const char *glRenderer,
36 const char *glVersion)
35{37{
36 bool matches = false;38 bool matches = false;
3739
@@ -42,16 +44,16 @@
42 // Ensure the regex contains something other than spaces, or ignore.44 // Ensure the regex contains something other than spaces, or ignore.
43 const char *p = blacklistRegex;45 const char *p = blacklistRegex;
44 while (*p == ' ')46 while (*p == ' ')
45 p++;47 ++p;
4648
47 if (*p && !regcomp (&re, blacklistRegex, REG_EXTENDED))49 if (*p && !regcomp (&re, blacklistRegex, REG_EXTENDED))
48 {50 {
49 char driver[1024];51 char driver[1024];
5052
51 snprintf (driver, sizeof driver, "%s\n%s\n%s",53 snprintf (driver, sizeof driver, "%s\n%s\n%s",
52 glVendor ? glVendor : "",54 glVendor ? glVendor : "",
53 glRenderer ? glRenderer : "",55 glRenderer ? glRenderer : "",
54 glVersion ? glVersion : "");56 glVersion ? glVersion : "");
5557
56 if (!regexec (&re, driver, 0, NULL, 0))58 if (!regexec (&re, driver, 0, NULL, 0))
57 matches = true;59 matches = true;
5860
=== modified file 'plugins/opengl/src/blacklist/blacklist.h'
--- plugins/opengl/src/blacklist/blacklist.h 2012-12-12 07:24:34 +0000
+++ plugins/opengl/src/blacklist/blacklist.h 2013-07-24 16:05:45 +0000
@@ -29,8 +29,10 @@
29namespace compiz {29namespace compiz {
30namespace opengl {30namespace opengl {
3131
32bool blacklisted (const char *blacklistRegex, const char *glVendor,32bool blacklisted (const char *blacklistRegex,
33 const char *glRenderer, const char *glVersion);33 const char *glVendor,
34 const char *glRenderer,
35 const char *glVersion);
3436
35} // namespace opengl37} // namespace opengl
36} // namespace compiz38} // namespace compiz
3739
=== modified file 'plugins/opengl/src/doublebuffer/src/double-buffer.cpp'
--- plugins/opengl/src/doublebuffer/src/double-buffer.cpp 2012-11-09 06:13:00 +0000
+++ plugins/opengl/src/doublebuffer/src/double-buffer.cpp 2013-07-24 16:05:45 +0000
@@ -66,7 +66,7 @@
6666
67void67void
68DoubleBuffer::render (const CompRegion &region,68DoubleBuffer::render (const CompRegion &region,
69 bool fullscreen)69 bool fullscreen)
70{70{
71 if (fullscreen)71 if (fullscreen)
72 {72 {
@@ -77,9 +77,7 @@
7777
78 if (setting[NEED_PERSISTENT_BACK_BUFFER] &&78 if (setting[NEED_PERSISTENT_BACK_BUFFER] &&
79 !setting[HAVE_PERSISTENT_BACK_BUFFER])79 !setting[HAVE_PERSISTENT_BACK_BUFFER])
80 {
81 copyFrontToBack ();80 copyFrontToBack ();
82 }
83 }81 }
84 else82 else
85 {83 {
@@ -124,7 +122,7 @@
124122
125 /* Accumulate throttle */123 /* Accumulate throttle */
126 if (throttleState == ExternalFrameThrottlingRequired)124 if (throttleState == ExternalFrameThrottlingRequired)
127 blockingVSyncUnthrottledFrames++;125 ++blockingVSyncUnthrottledFrames;
128 else126 else
129 blockingVSyncUnthrottledFrames = 0;127 blockingVSyncUnthrottledFrames = 0;
130128
131129
=== modified file 'plugins/opengl/src/framebufferobject.cpp'
--- plugins/opengl/src/framebufferobject.cpp 2012-08-06 09:44:49 +0000
+++ plugins/opengl/src/framebufferobject.cpp 2013-07-24 16:05:45 +0000
@@ -32,6 +32,7 @@
32 PrivateGLFramebufferObject () :32 PrivateGLFramebufferObject () :
33 fboId (0),33 fboId (0),
34 pushedId (0),34 pushedId (0),
35 rbStencilId (0),
35 glTex (NULL),36 glTex (NULL),
36 status (-1)37 status (-1)
37 {38 {
@@ -40,14 +41,14 @@
40 void pushFBO ();41 void pushFBO ();
41 void popFBO ();42 void popFBO ();
4243
43 GLuint fboId;44 GLuint fboId;
44 GLuint pushedId;45 GLuint pushedId;
45 GLuint rbStencilId;46 GLuint rbStencilId;
46 GLTexture *glTex;47 GLTexture *glTex;
4748
48 GLint status;49 GLint status;
4950
50 static GLuint boundId;51 static GLuint boundId;
51 static std::map<GLuint, GLFramebufferObject *> idMap;52 static std::map<GLuint, GLFramebufferObject *> idMap;
52};53};
5354
@@ -58,6 +59,7 @@
58PrivateGLFramebufferObject::pushFBO ()59PrivateGLFramebufferObject::pushFBO ()
59{60{
60 pushedId = boundId;61 pushedId = boundId;
62
61 if (boundId != fboId)63 if (boundId != fboId)
62 {64 {
63 (*GL::bindFramebuffer) (GL::FRAMEBUFFER, fboId);65 (*GL::bindFramebuffer) (GL::FRAMEBUFFER, fboId);
@@ -94,22 +96,24 @@
94 (*GL::deleteFramebuffers) (1, &priv->fboId);96 (*GL::deleteFramebuffers) (1, &priv->fboId);
95 (*GL::deleteRenderbuffers) (1, &priv->rbStencilId);97 (*GL::deleteRenderbuffers) (1, &priv->rbStencilId);
9698
97
98 delete priv;99 delete priv;
99}100}
100101
101bool102bool
102GLFramebufferObject::allocate (const CompSize &size, const char *image,103GLFramebufferObject::allocate (const CompSize &size,
103 GLenum format, GLenum type)104 const char *image,
105 GLenum format,
106 GLenum type)
104{107{
105 priv->status = -1;108 priv->status = -1;
106109
107 if (!priv->glTex ||110 if (!priv->glTex ||
108 size.width () != priv->glTex->width () ||111 size.width () != priv->glTex->width () ||
109 size.height () != priv->glTex->height ())112 size.height () != priv->glTex->height ())
110 {113 {
111 if (priv->glTex)114 if (priv->glTex)
112 GLTexture::decRef (priv->glTex);115 GLTexture::decRef (priv->glTex);
116
113 priv->glTex = NULL;117 priv->glTex = NULL;
114118
115 GLTexture::List list = GLTexture::imageDataToTexture (image, size,119 GLTexture::List list = GLTexture::imageDataToTexture (image, size,
@@ -130,12 +134,12 @@
130 priv->pushFBO ();134 priv->pushFBO ();
131135
132 (*GL::framebufferTexture2D) (GL::FRAMEBUFFER, GL::COLOR_ATTACHMENT0,136 (*GL::framebufferTexture2D) (GL::FRAMEBUFFER, GL::COLOR_ATTACHMENT0,
133 priv->glTex->target (),137 priv->glTex->target (),
134 priv->glTex->name (), 0);138 priv->glTex->name (), 0);
135139
136 priv->status = (*GL::checkFramebufferStatus) (GL::DRAW_FRAMEBUFFER);140 priv->status = (*GL::checkFramebufferStatus) (GL::DRAW_FRAMEBUFFER);
141 priv->popFBO ();
137142
138 priv->popFBO ();
139 return true;143 return true;
140}144}
141145
@@ -146,8 +150,8 @@
146150
147 if (priv->boundId != 0)151 if (priv->boundId != 0)
148 {152 {
149 std::map<GLuint, GLFramebufferObject *>::iterator it;153 std::map<GLuint, GLFramebufferObject *>::iterator it =
150 it = PrivateGLFramebufferObject::idMap.find (priv->boundId);154 PrivateGLFramebufferObject::idMap.find (priv->boundId);
151155
152 if (it != PrivateGLFramebufferObject::idMap.end ())156 if (it != PrivateGLFramebufferObject::idMap.end ())
153 old = it->second;157 old = it->second;
@@ -209,8 +213,9 @@
209 return true;213 return true;
210214
211 compLogMessage ("opengl", CompLogLevelError,215 compLogMessage ("opengl", CompLogLevelError,
212 "FBO is incomplete: %s (0x%04x)",216 "FBO is incomplete: %s (0x%04x)",
213 getFboErrorString (priv->status), priv->status);217 getFboErrorString (priv->status), priv->status);
218
214 return false;219 return false;
215}220}
216221
217222
=== modified file 'plugins/opengl/src/fsregion/fsregion.cpp'
--- plugins/opengl/src/fsregion/fsregion.cpp 2013-05-08 15:04:46 +0000
+++ plugins/opengl/src/fsregion/fsregion.cpp 2013-07-24 16:05:45 +0000
@@ -29,16 +29,16 @@
29namespace opengl {29namespace opengl {
3030
31FullscreenRegion::FullscreenRegion (const CompRect &output) :31FullscreenRegion::FullscreenRegion (const CompRect &output) :
32 untouched (output),32 untouched (output),
33 orig (output),33 orig (output),
34 allOutputs (output)34 allOutputs (output)
35{35{
36}36}
3737
38FullscreenRegion::FullscreenRegion (const CompRect &output,38FullscreenRegion::FullscreenRegion (const CompRect &output,
39 const CompRegion &all) :39 const CompRegion &all) :
40 untouched (output),40 untouched (output),
41 orig (output),41 orig (output),
42 allOutputs (all)42 allOutputs (all)
43{43{
44}44}
@@ -48,12 +48,10 @@
48{48{
49 bool fullscreen = false;49 bool fullscreen = false;
5050
51 if (!(flags & (Desktop | Alpha | NoOcclusionDetection)) &&51 if (!(flags & (Desktop | Alpha | NoOcclusionDetection)) &&
52 region == untouched &&52 region == untouched &&
53 region == orig)53 region == orig)
54 {
55 fullscreen = true;54 fullscreen = true;
56 }
5755
58 untouched -= region;56 untouched -= region;
5957
6058
=== modified file 'plugins/opengl/src/fsregion/fsregion.h'
--- plugins/opengl/src/fsregion/fsregion.h 2013-05-08 15:04:46 +0000
+++ plugins/opengl/src/fsregion/fsregion.h 2013-07-24 16:05:45 +0000
@@ -34,23 +34,29 @@
34class FullscreenRegion34class FullscreenRegion
35{35{
36public:36public:
37
37 typedef enum38 typedef enum
38 {39 {
39 Desktop = 1,40 Desktop = 1,
40 Alpha = 2,41 Alpha = 2,
41 NoOcclusionDetection = 342 NoOcclusionDetection = 3
42 } WinFlag;43 } WinFlag;
4344
44 typedef unsigned int WinFlags;45 typedef unsigned int WinFlags;
4546
46 FullscreenRegion (const CompRect &output);47 FullscreenRegion (const CompRect &output);
47 FullscreenRegion (const CompRect &output, const CompRegion &all);48
49 FullscreenRegion (const CompRect &output,
50 const CompRegion &all);
4851
49 // isCoveredBy is called for windows from TOP to BOTTOM52 // isCoveredBy is called for windows from TOP to BOTTOM
50 bool isCoveredBy (const CompRegion &region, WinFlags flags = 0);53 bool isCoveredBy (const CompRegion &region,
54 WinFlags flags = 0);
55
51 bool allowRedirection (const CompRegion &region);56 bool allowRedirection (const CompRegion &region);
5257
53private:58private:
59
54 CompRegion untouched;60 CompRegion untouched;
55 CompRegion orig;61 CompRegion orig;
56 CompRegion allOutputs;62 CompRegion allOutputs;
5763
=== modified file 'plugins/opengl/src/matrix.cpp'
--- plugins/opengl/src/matrix.cpp 2012-12-04 15:28:56 +0000
+++ plugins/opengl/src/matrix.cpp 2013-07-24 16:05:45 +0000
@@ -59,7 +59,8 @@
59/**59/**
60 * Identity matrix.60 * Identity matrix.
61 */61 */
62static const float identity[16] = {62static const float identity[16] =
63{
63 1.0, 0.0, 0.0, 0.0,64 1.0, 0.0, 0.0, 0.0,
64 0.0, 1.0, 0.0, 0.0,65 0.0, 1.0, 0.0, 0.0,
65 0.0, 0.0, 1.0, 0.0,66 0.0, 0.0, 1.0, 0.0,
@@ -88,7 +89,7 @@
88 const float *a,89 const float *a,
89 const float *b)90 const float *b)
90{91{
91 for (int i = 0; i < 4; i++)92 for (int i = 0; i < 4; ++i)
92 {93 {
93 const float ai0 = A(i,0), ai1 = A(i,1), ai2 = A(i,2), ai3 = A(i,3);94 const float ai0 = A(i,0), ai1 = A(i,1), ai2 = A(i,2), ai3 = A(i,3);
9495
@@ -144,10 +145,10 @@
144operator* (const GLMatrix& lhs,145operator* (const GLMatrix& lhs,
145 const GLVector& rhs)146 const GLVector& rhs)
146{147{
147 GLVector result;148 GLVector result;
148 const float *a = lhs.m;149 const float *a = lhs.m;
149150
150 for (int i = 0; i < 4; i++)151 for (int i = 0; i < 4; ++i)
151 {152 {
152 result[i] = A(i,0) * rhs[0] + A(i,1) * rhs[1] +153 result[i] = A(i,0) * rhs[0] + A(i,1) * rhs[1] +
153 A(i,2) * rhs[2] + A(i,3) * rhs[3];154 A(i,2) * rhs[2] + A(i,3) * rhs[3];
@@ -202,13 +203,14 @@
202 + m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5];203 + m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5];
203204
204 det = m[0]*inv[0] + m[1]*inv[4] + m[2]*inv[8] + m[3]*inv[12];205 det = m[0]*inv[0] + m[1]*inv[4] + m[2]*inv[8] + m[3]*inv[12];
206
205 if (det == 0)207 if (det == 0)
206 return false;208 return false;
207209
208 det = 1.0f / det;210 det = 1.0f / det;
209211
210 for (int i = 0; i < 16; i++)212 for (int i = 0; i < 16; ++i)
211 m[i] = inv[i] * det;213 m[i] = inv[i] * det;
212214
213 return true;215 return true;
214}216}
@@ -223,20 +225,18 @@
223 */225 */
224void226void
225GLMatrix::rotate (const float angle,227GLMatrix::rotate (const float angle,
226 const float xRot,228 const float xRot,
227 const float yRot,229 const float yRot,
228 const float zRot)230 const float zRot)
229{231{
230 float x = xRot, y = yRot, z = zRot;232 float x = xRot, y = yRot, z = zRot;
231 float s, c;
232 float matrix[16];233 float matrix[16];
233 bool optimized;
234234
235 s = (float) sin (angle * DEG2RAD);235 float s = (float) sin (angle * DEG2RAD);
236 c = (float) cos (angle * DEG2RAD);236 float c = (float) cos (angle * DEG2RAD);
237237
238 memcpy (matrix, identity, sizeof (matrix));238 memcpy (matrix, identity, sizeof (matrix));
239 optimized = false;239 bool optimized = false;
240240
241#define M(row, col) matrix[col * 4 + row]241#define M(row, col) matrix[col * 4 + row]
242242
@@ -250,6 +250,7 @@
250 /* rotate only around z-axis */250 /* rotate only around z-axis */
251 M(0,0) = c;251 M(0,0) = c;
252 M(1,1) = c;252 M(1,1) = c;
253
253 if (z < 0.0f)254 if (z < 0.0f)
254 {255 {
255 M(0,1) = s;256 M(0,1) = s;
@@ -268,6 +269,7 @@
268 /* rotate only around y-axis */269 /* rotate only around y-axis */
269 M(0,0) = c;270 M(0,0) = c;
270 M(2,2) = c;271 M(2,2) = c;
272
271 if (y < 0.0f)273 if (y < 0.0f)
272 {274 {
273 M(0,2) = -s;275 M(0,2) = -s;
@@ -288,6 +290,7 @@
288 /* rotate only around x-axis */290 /* rotate only around x-axis */
289 M(1,1) = c;291 M(1,1) = c;
290 M(2,2) = c;292 M(2,2) = c;
293
291 if (x < 0.0f)294 if (x < 0.0f)
292 {295 {
293 M(1,2) = s;296 M(1,2) = s;
@@ -316,7 +319,6 @@
316 y /= mag;319 y /= mag;
317 z /= mag;320 z /= mag;
318321
319
320 /*322 /*
321 * Arbitrary axis rotation matrix.323 * Arbitrary axis rotation matrix.
322 *324 *
@@ -410,8 +412,8 @@
410}412}
411413
412void414void
413GLMatrix::rotate (const float angle,415GLMatrix::rotate (const float angle,
414 const GLVector& vector)416 const GLVector& vector)
415{417{
416 rotate (angle,418 rotate (angle,
417 vector[GLVector::x],419 vector[GLVector::x],
@@ -431,8 +433,8 @@
431 */433 */
432void434void
433GLMatrix::scale (const float x,435GLMatrix::scale (const float x,
434 const float y,436 const float y,
435 const float z)437 const float z)
436{438{
437 m[0] *= x; m[4] *= y; m[8] *= z;439 m[0] *= x; m[4] *= y; m[8] *= z;
438 m[1] *= x; m[5] *= y; m[9] *= z;440 m[1] *= x; m[5] *= y; m[9] *= z;
@@ -460,8 +462,8 @@
460 */462 */
461void463void
462GLMatrix::translate (const float x,464GLMatrix::translate (const float x,
463 const float y,465 const float y,
464 const float z)466 const float z)
465{467{
466 m[12] = m[0] * x + m[4] * y + m[8] * z + m[12];468 m[12] = m[0] * x + m[4] * y + m[8] * z + m[12];
467 m[13] = m[1] * x + m[5] * y + m[9] * z + m[13];469 m[13] = m[1] * x + m[5] * y + m[9] * z + m[13];
468470
=== modified file 'plugins/opengl/src/opengl.cpp'
--- plugins/opengl/src/opengl.cpp 2013-05-26 06:15:47 +0000
+++ plugins/opengl/src/opengl.cpp 2013-07-24 16:05:45 +0000
@@ -28,15 +28,15 @@
28#include <core/pluginclasshandler.h>28#include <core/pluginclasshandler.h>
29#include "privates.h"29#include "privates.h"
3030
31const float DEFAULT_Z_CAMERA = 0.866025404f;31const float DEFAULT_Z_CAMERA = 0.866025404f;
3232
33const float RED_SATURATION_WEIGHT = 0.30f;33const float RED_SATURATION_WEIGHT = 0.30f;
34const float GREEN_SATURATION_WEIGHT = 0.59f;34const float GREEN_SATURATION_WEIGHT = 0.59f;
35const float BLUE_SATURATION_WEIGHT = 0.11f;35const float BLUE_SATURATION_WEIGHT = 0.11f;
3636
37const unsigned short NOTHING_TRANS_FILTER = 0;37const unsigned short NOTHING_TRANS_FILTER = 0;
38const unsigned short SCREEN_TRANS_FILTER = 1;38const unsigned short SCREEN_TRANS_FILTER = 1;
39const unsigned short WINDOW_TRANS_FILTER = 2;39const unsigned short WINDOW_TRANS_FILTER = 2;
4040
41CompOption::Vector &41CompOption::Vector &
42GLScreen::getOptions ()42GLScreen::getOptions ()
@@ -62,7 +62,8 @@
62 if (!rv || !CompOption::findOption (getOptions (), name, &index))62 if (!rv || !CompOption::findOption (getOptions (), name, &index))
63 return false;63 return false;
6464
65 switch (index) {65 switch (index)
66 {
66 case OpenglOptions::TextureFilter:67 case OpenglOptions::TextureFilter:
67 cScreen->damageScreen ();68 cScreen->damageScreen ();
6869
@@ -71,6 +72,7 @@
71 else72 else
72 textureFilter = GL_LINEAR;73 textureFilter = GL_LINEAR;
73 break;74 break;
75
74 default:76 default:
75 break;77 break;
76 }78 }
7779
=== modified file 'plugins/opengl/src/paint.cpp'
--- plugins/opengl/src/paint.cpp 2013-06-28 01:10:57 +0000
+++ plugins/opengl/src/paint.cpp 2013-07-24 16:05:45 +0000
@@ -45,11 +45,13 @@
4545
46using namespace compiz::opengl;46using namespace compiz::opengl;
4747
48GLScreenPaintAttrib defaultScreenPaintAttrib = {48GLScreenPaintAttrib defaultScreenPaintAttrib =
49{
49 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -DEFAULT_Z_CAMERA50 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -DEFAULT_Z_CAMERA
50};51};
5152
52GLWindowPaintAttrib GLWindow::defaultPaintAttrib = {53GLWindowPaintAttrib GLWindow::defaultPaintAttrib =
54{
53 OPAQUE, BRIGHT, COLOR, 1.0f, 1.0f, 0.0f, 0.0f55 OPAQUE, BRIGHT, COLOR, 1.0f, 1.0f, 0.0f, 0.0f
54};56};
5557
@@ -76,12 +78,7 @@
76 const CompRegion &region,78 const CompRegion &region,
77 bool transformed)79 bool transformed)
78{80{
79 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();81 int nBox = const_cast <Region> (region.handle ())->numRects;
80 GLfloat vertexData[18];
81 GLushort colorData[4];
82
83 BoxPtr pBox = const_cast <Region> (region.handle ())->rects;
84 int n, nBox = const_cast <Region> (region.handle ())->numRects;
8582
86 if (!nBox)83 if (!nBox)
87 return;84 return;
@@ -89,9 +86,7 @@
89 if (screen->desktopWindowCount ())86 if (screen->desktopWindowCount ())
90 {87 {
91 if (!backgroundTextures.empty ())88 if (!backgroundTextures.empty ())
92 {
93 backgroundTextures.clear ();89 backgroundTextures.clear ();
94 }
9590
96 backgroundLoaded = false;91 backgroundLoaded = false;
9792
@@ -105,10 +100,15 @@
105 backgroundLoaded = true;100 backgroundLoaded = true;
106 }101 }
107102
103 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
104 GLfloat vertexData[18];
105 GLushort colorData[4];
106 BoxPtr pBox = const_cast <Region> (region.handle ())->rects;
107 int n = nBox;
108
108 if (backgroundTextures.empty ())109 if (backgroundTextures.empty ())
109 {110 {
110 streamingBuffer->begin (GL_TRIANGLES);111 streamingBuffer->begin (GL_TRIANGLES);
111 n = nBox;
112112
113 while (n--)113 while (n--)
114 {114 {
@@ -134,7 +134,7 @@
134134
135 streamingBuffer->addVertices (6, vertexData);135 streamingBuffer->addVertices (6, vertexData);
136136
137 pBox++;137 ++pBox;
138 }138 }
139139
140 colorData[0] = colorData[1] = colorData[2] = 0;140 colorData[0] = colorData[1] = colorData[2] = 0;
@@ -146,9 +146,7 @@
146 }146 }
147 else147 else
148 {148 {
149 n = nBox;149 for (unsigned int i = 0; i < backgroundTextures.size (); ++i)
150
151 for (unsigned int i = 0; i < backgroundTextures.size (); i++)
152 {150 {
153 GLfloat textureData[12];151 GLfloat textureData[12];
154 GLTexture *bg = backgroundTextures[i];152 GLTexture *bg = backgroundTextures[i];
@@ -208,7 +206,7 @@
208 streamingBuffer->addVertices (6, vertexData);206 streamingBuffer->addVertices (6, vertexData);
209 streamingBuffer->addTexCoords (0, 6, textureData);207 streamingBuffer->addTexCoords (0, 6, textureData);
210208
211 pBox++;209 ++pBox;
212 }210 }
213211
214 streamingBuffer->end ();212 streamingBuffer->end ();
@@ -230,10 +228,10 @@
230228
231229
232/* This function currently always performs occlusion detection to230/* This function currently always performs occlusion detection to
233 minimize paint regions. OpenGL precision requirements are no good231 minimize paint regions. OpenGL precision requirements are not good
234 enough to guarantee that the results from using occlusion detection232 enough to guarantee that the result from using occlusion detection
235 is the same as without. It's likely not possible to see any233 is the same as without. It's likely not possible to see any
236 difference with most hardware but occlusion detection in the234 difference with most hardware, but occlusion detection in the
237 transformed screen case should be made optional for those who do235 transformed screen case should be made optional for those who do
238 see a difference. */236 see a difference. */
239void237void
@@ -242,19 +240,17 @@
242 CompOutput *output,240 CompOutput *output,
243 unsigned int mask)241 unsigned int mask)
244{242{
245 CompRegion tmpRegion (region);243 CompRegion tmpRegion (region);
246 CompWindow *w;244 CompWindow *w;
247 GLWindow *gw;245 GLWindow *gw;
248 int windowMask, odMask;246 int odMask;
249 bool status, unredirectFS;247 int windowMask = 0;
250 bool withOffset = false;248 bool status, unredirectFS;
251 GLMatrix vTransform;249 bool withOffset = false;
252 CompPoint offXY;250 GLMatrix vTransform;
251 CompPoint offXY;
253 std::set<CompWindow*> unredirected;252 std::set<CompWindow*> unredirected;
254253
255 CompWindowList pl;
256 CompWindowList::reverse_iterator rit;
257
258 unredirectFS = CompositeScreen::get (screen)->254 unredirectFS = CompositeScreen::get (screen)->
259 getOption ("unredirect_fullscreen_windows")->value ().b ();255 getOption ("unredirect_fullscreen_windows")->value ().b ();
260256
@@ -267,29 +263,24 @@
267 bool blacklisted = driverIsBlacklisted (blacklist.c_str ());263 bool blacklisted = driverIsBlacklisted (blacklist.c_str ());
268264
269 if (mask & PAINT_SCREEN_TRANSFORMED_MASK)265 if (mask & PAINT_SCREEN_TRANSFORMED_MASK)
270 {266 windowMask = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;
271 windowMask = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;
272 }
273 else
274 {
275 windowMask = 0;
276 }
277267
278 /*268 /*
279 * We need to COPY the PaintList for now because there seem to be some269 * We need to COPY the PaintList for now because there seem to be some
280 * odd cases where the master list might change during the below loops.270 * odd cases where the master list might change during the below loops.
281 * (LP: #958540)271 * (LP: #958540)
282 */272 */
283 pl = cScreen->getWindowPaintList ();273 CompWindowList pl = cScreen->getWindowPaintList ();
284274
285 if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))275 if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))
286 {276 {
287 FullscreenRegion fs (*output, screen->region ());277 FullscreenRegion fs (*output, screen->region ());
288278
289 /* detect occlusions */279 /* detect occlusions */
290 for (rit = pl.rbegin (); rit != pl.rend (); ++rit)280 for (CompWindowList::reverse_iterator rit = pl.rbegin ();
281 rit != pl.rend (); ++rit)
291 {282 {
292 w = (*rit);283 w = (*rit);
293 gw = GLWindow::get (w);284 gw = GLWindow::get (w);
294285
295 if (w->destroyed ())286 if (w->destroyed ())
@@ -305,6 +296,7 @@
305 gw->priv->clip = region;296 gw->priv->clip = region;
306 continue;297 continue;
307 }298 }
299
308 if (!w->isViewable ())300 if (!w->isViewable ())
309 continue;301 continue;
310 }302 }
@@ -319,8 +311,7 @@
319 !w->onAllViewports ())311 !w->onAllViewports ())
320 {312 {
321 withOffset = true;313 withOffset = true;
322314 offXY = w->getMovementForOffset (cScreen->windowPaintOffset ());
323 offXY = w->getMovementForOffset (cScreen->windowPaintOffset ());
324315
325 vTransform = transform;316 vTransform = transform;
326 vTransform.translate (offXY.x (), offXY.y (), 0);317 vTransform.translate (offXY.x (), offXY.y (), 0);
@@ -328,32 +319,32 @@
328 gw->priv->clip.translate (-offXY.x (), -offXY. y ());319 gw->priv->clip.translate (-offXY.x (), -offXY. y ());
329320
330 odMask |= PAINT_WINDOW_WITH_OFFSET_MASK;321 odMask |= PAINT_WINDOW_WITH_OFFSET_MASK;
331 status = gw->glPaint (gw->paintAttrib (), vTransform,322 status = gw->glPaint (gw->paintAttrib (), vTransform,
332 tmpRegion, odMask);323 tmpRegion, odMask);
333 }324 }
334 else325 else
335 {326 {
336 withOffset = false;327 withOffset = false;
337 status = gw->glPaint (gw->paintAttrib (), transform, tmpRegion,328 status = gw->glPaint (gw->paintAttrib (), transform, tmpRegion,
338 odMask);329 odMask);
339 }330 }
340331
341 if (status)332 if (status)
342 {333 {
343 if (withOffset)334 if (withOffset)
344 {
345 tmpRegion -= w->region ().translated (offXY);335 tmpRegion -= w->region ().translated (offXY);
346 }
347 else336 else
348 tmpRegion -= w->region ();337 tmpRegion -= w->region ();
349 }338 }
350339
351 FullscreenRegion::WinFlags flags = 0;340 FullscreenRegion::WinFlags flags = 0;
341
352 if (w->type () & CompWindowTypeDesktopMask)342 if (w->type () & CompWindowTypeDesktopMask)
353 flags |= FullscreenRegion::Desktop;343 flags |= FullscreenRegion::Desktop;
344
354 if (w->alpha ())345 if (w->alpha ())
355 flags |= FullscreenRegion::Alpha;346 flags |= FullscreenRegion::Alpha;
356 347
357 /* Anything which was not occlusion detected is not a suitable348 /* Anything which was not occlusion detected is not a suitable
358 * candidate for unredirection either */349 * candidate for unredirection either */
359 if (!status)350 if (!status)
@@ -373,37 +364,31 @@
373 * take effect until it is un-fullscreened again. But that's better364 * take effect until it is un-fullscreened again. But that's better
374 * than the high price of regex matching on every frame.365 * than the high price of regex matching on every frame.
375 */366 */
376 if (unredirectFS &&367 if (unredirectFS &&
377 !blacklisted &&368 !blacklisted &&
378 !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&369 !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
379 !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&370 !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&
380 fs.isCoveredBy (w->region (), flags) &&371 fs.isCoveredBy (w->region (), flags) &&
381 (!cw->redirected () || unredirectable.evaluate (w)))372 (!cw->redirected () || unredirectable.evaluate (w)))
382 {
383 unredirected.insert (w);373 unredirected.insert (w);
384 }374
385 else375 else if (!cw->redirected ())
386 {376 {
387 if (!cw->redirected ())377 if (fs.allowRedirection (w->region ()))
388 {378 {
389 if (fs.allowRedirection (w->region ()))379 // 1. GLWindow::release to force gw->priv->needsRebind
390 {380 gw->release ();
391 // 1. GLWindow::release to force gw->priv->needsRebind381
392 gw->release ();382 // 2. GLWindow::bind, which redirects the window,
393383 // rebinds the pixmap, and then rebinds the pixmap
394 // 2. GLWindow::bind, which redirects the window,384 // to a texture.
395 // rebinds the pixmap, and then rebinds the pixmap385 gw->bind ();
396 // to a texture.386
397 gw->bind ();387 // 3. Your window is now redirected again with the
398388 // latest pixmap contents.
399 // 3. Your window is now redirected again with the
400 // latest pixmap contents.
401 }
402 else
403 {
404 unredirected.insert (w);
405 }
406 }389 }
390 else
391 unredirected.insert (w);
407 }392 }
408 }393 }
409 }394 }
@@ -414,8 +399,8 @@
414399
415 if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))400 if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
416 paintBackground (transform,401 paintBackground (transform,
417 tmpRegion,402 tmpRegion,
418 (mask & PAINT_SCREEN_TRANSFORMED_MASK));403 (mask & PAINT_SCREEN_TRANSFORMED_MASK));
419404
420 /* paint all windows from bottom to top */405 /* paint all windows from bottom to top */
421 foreach (w, pl)406 foreach (w, pl)
@@ -423,26 +408,25 @@
423 if (w->destroyed ())408 if (w->destroyed ())
424 continue;409 continue;
425410
426 gw = GLWindow::get (w);411 gw = GLWindow::get (w);
427412
428 /* Release any queued ConfigureWindow requests now */413 /* Release any queued ConfigureWindow requests now */
414
429 gw->priv->configureLock->release ();415 gw->priv->configureLock->release ();
430416
431 if (unredirected.find (w) != unredirected.end ())417 if (unredirected.find (w) != unredirected.end ())
432 continue;418 continue;
433419
434 if (!w->shaded ())420 if (!w->shaded () &&
435 {421 !w->isViewable ())
436 if (!w->isViewable ())422 continue;
437 continue;
438 }
439423
440 const CompRegion &clip =424 const CompRegion &clip =
441 (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK)) ?425 (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK)) ?
442 gw->clip () : region;426 gw->clip () : region;
443427
444 if ((cScreen->windowPaintOffset ().x () != 0 ||428 if ((cScreen->windowPaintOffset ().x () != 0 ||
445 cScreen->windowPaintOffset ().y () != 0) &&429 cScreen->windowPaintOffset ().y () != 0 ) &&
446 !w->onAllViewports ())430 !w->onAllViewports ())
447 {431 {
448 offXY = w->getMovementForOffset (cScreen->windowPaintOffset ());432 offXY = w->getMovementForOffset (cScreen->windowPaintOffset ());
@@ -450,12 +434,10 @@
450 vTransform = transform;434 vTransform = transform;
451 vTransform.translate (offXY.x (), offXY.y (), 0);435 vTransform.translate (offXY.x (), offXY.y (), 0);
452 gw->glPaint (gw->paintAttrib (), vTransform, clip,436 gw->glPaint (gw->paintAttrib (), vTransform, clip,
453 windowMask | PAINT_WINDOW_WITH_OFFSET_MASK);437 windowMask | PAINT_WINDOW_WITH_OFFSET_MASK);
454 }438 }
455 else439 else
456 {
457 gw->glPaint (gw->paintAttrib (), transform, clip, windowMask);440 gw->glPaint (gw->paintAttrib (), transform, clip, windowMask);
458 }
459 }441 }
460}442}
461443
@@ -488,20 +470,20 @@
488 WRAPABLE_HND_FUNCTN (glEnableOutputClipping, transform, region, output)470 WRAPABLE_HND_FUNCTN (glEnableOutputClipping, transform, region, output)
489471
490 // Bottom-left corner of the output:472 // Bottom-left corner of the output:
491 const GLint x = output->x1 ();473 const GLint x = output->x1 ();
492 const GLint y = screen->height () - output->y2 ();474 const GLint y = screen->height () - output->y2 ();
493 const GLsizei w = output->width ();475 const GLsizei w = output->width ();
494 const GLsizei h = output->height ();476 const GLsizei h = output->height ();
495477
496 // Transformed (only scale and translation is supported!)478 // Transformed (only scale and translation is supported!)
497 const float *t = transform.getMatrix ();479 const float *t = transform.getMatrix ();
498 const GLfloat scalex = t[0], scaley = t[5], transx = t[12], transy = t[13];480 const GLfloat scalex = t[0], scaley = t[5], transx = t[12], transy = t[13];
499 const GLfloat centrex = x + w / 2.0f;481 const GLfloat centrex = x + w / 2.0f;
500 const GLfloat centrey = y + h / 2.0f;482 const GLfloat centrey = y + h / 2.0f;
501 GLfloat scaledw = fabs (w * scalex);483 GLfloat scaledw = fabs (w * scalex);
502 GLfloat scaledh = fabs (h * scaley);484 GLfloat scaledh = fabs (h * scaley);
503 GLfloat tx = centrex - (scaledw / 2.0f) + transx * w;485 GLfloat tx = centrex - (scaledw / 2.0f) + transx * w;
504 GLfloat ty = centrey - (scaledh / 2.0f) + transy * h;486 GLfloat ty = centrey - (scaledh / 2.0f) + transy * h;
505487
506 glScissor (tx, ty, roundf (scaledw), roundf (scaledh));488 glScissor (tx, ty, roundf (scaledw), roundf (scaledh));
507 glEnable (GL_SCISSOR_TEST);489 glEnable (GL_SCISSOR_TEST);
@@ -516,22 +498,22 @@
516}498}
517499
518void500void
519GLScreen::glBufferStencil (const GLMatrix &matrix,501GLScreen::glBufferStencil (const GLMatrix &matrix,
520 GLVertexBuffer &vertexBuffer,502 GLVertexBuffer &vertexBuffer,
521 CompOutput *output)503 CompOutput *output)
522{504{
523 WRAPABLE_HND_FUNCTN (glBufferStencil, matrix, vertexBuffer, output);505 WRAPABLE_HND_FUNCTN (glBufferStencil, matrix, vertexBuffer, output);
524506
525 GLfloat x = output->x ();507 GLfloat x = output->x ();
526 GLfloat y = screen->height () - output->y2 ();508 GLfloat y = screen->height () - output->y2 ();
527 GLfloat x2 = output->x () + output->width ();509 GLfloat x2 = output->x () + output->width ();
528 GLfloat y2 = screen->height () - output->y2 () + output->height ();510 GLfloat y2 = screen->height () - output->y2 () + output->height ();
529511
530 GLfloat vertices[] =512 GLfloat vertices[] =
531 {513 {
532 x, y, 0,514 x, y, 0,
533 x, y2, 0,515 x, y2, 0,
534 x2, y, 0,516 x2, y, 0,
535 x2, y2, 0517 x2, y2, 0
536 };518 };
537519
@@ -576,8 +558,8 @@
576 priv->paintOutputRegion (sTransform, region, output, mask);558 priv->paintOutputRegion (sTransform, region, output, mask);
577 glDisableOutputClipping ();559 glDisableOutputClipping ();
578 }560 }
579 else if ( (GL::fboEnabled && GL::fboStencilSupported) ||561 else if ((GL::fboEnabled && GL::fboStencilSupported) ||
580 GL::stencilBuffer )562 GL::stencilBuffer )
581 {563 {
582 sTransform.toScreenSpace (output, -sAttrib.zTranslate);564 sTransform.toScreenSpace (output, -sAttrib.zTranslate);
583565
@@ -656,7 +638,7 @@
656 * windows are getting transformed (and so the unredirected window638 * windows are getting transformed (and so the unredirected window
657 * needs to be redirected again).639 * needs to be redirected again).
658 */640 */
659 if (!region.isEmpty () ||641 if (!region.isEmpty () ||
660 (mask & PAINT_SCREEN_FULL_MASK) ||642 (mask & PAINT_SCREEN_FULL_MASK) ||
661 (mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK))643 (mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK))
662 priv->paintOutputRegion (sTransform, region, output, mask);644 priv->paintOutputRegion (sTransform, region, output, mask);
@@ -671,9 +653,7 @@
671 return true;653 return true;
672 }654 }
673 else655 else
674 {
675 return false;656 return false;
676 }
677}657}
678658
679void659void
@@ -683,9 +663,9 @@
683{663{
684 WRAPABLE_HND_FUNCTN (glPaintCompositedOutput, region, fbo, mask)664 WRAPABLE_HND_FUNCTN (glPaintCompositedOutput, region, fbo, mask)
685665
686 GLMatrix sTransform;666 GLMatrix sTransform;
687 const GLTexture::Matrix & texmatrix = fbo->tex ()->matrix ();667 const GLTexture::Matrix &texmatrix = fbo->tex ()->matrix ();
688 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();668 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
689669
690 streamingBuffer->begin (GL_TRIANGLES);670 streamingBuffer->begin (GL_TRIANGLES);
691671
@@ -696,7 +676,8 @@
696 GLfloat ty1 = 1.0 - COMP_TEX_COORD_Y (texmatrix, 0.0f);676 GLfloat ty1 = 1.0 - COMP_TEX_COORD_Y (texmatrix, 0.0f);
697 GLfloat ty2 = 1.0 - COMP_TEX_COORD_Y (texmatrix, screen->height ());677 GLfloat ty2 = 1.0 - COMP_TEX_COORD_Y (texmatrix, screen->height ());
698678
699 const GLfloat vertexData[] = {679 const GLfloat vertexData[] =
680 {
700 0.0f, 0.0f, 0.0f,681 0.0f, 0.0f, 0.0f,
701 0.0f, (float)screen->height (), 0.0f,682 0.0f, (float)screen->height (), 0.0f,
702 (float)screen->width (), 0.0f, 0.0f,683 (float)screen->width (), 0.0f, 0.0f,
@@ -706,7 +687,8 @@
706 (float)screen->width (), 0.0f, 0.0f,687 (float)screen->width (), 0.0f, 0.0f,
707 };688 };
708689
709 const GLfloat textureData[] = {690 const GLfloat textureData[] =
691 {
710 tx1, ty1,692 tx1, ty1,
711 tx1, ty2,693 tx1, ty2,
712 tx2, ty1,694 tx2, ty1,
@@ -721,7 +703,7 @@
721 else703 else
722 {704 {
723 BoxPtr pBox = const_cast <Region> (region.handle ())->rects;705 BoxPtr pBox = const_cast <Region> (region.handle ())->rects;
724 int nBox = const_cast <Region> (region.handle ())->numRects;706 int nBox = const_cast <Region> (region.handle ())->numRects;
725707
726 while (nBox--)708 while (nBox--)
727 {709 {
@@ -730,7 +712,8 @@
730 GLfloat ty1 = 1.0 - COMP_TEX_COORD_Y (texmatrix, pBox->y1);712 GLfloat ty1 = 1.0 - COMP_TEX_COORD_Y (texmatrix, pBox->y1);
731 GLfloat ty2 = 1.0 - COMP_TEX_COORD_Y (texmatrix, pBox->y2);713 GLfloat ty2 = 1.0 - COMP_TEX_COORD_Y (texmatrix, pBox->y2);
732714
733 const GLfloat vertexData[] = {715 const GLfloat vertexData[] =
716 {
734 (float)pBox->x1, (float)pBox->y1, 0.0f,717 (float)pBox->x1, (float)pBox->y1, 0.0f,
735 (float)pBox->x1, (float)pBox->y2, 0.0f,718 (float)pBox->x1, (float)pBox->y2, 0.0f,
736 (float)pBox->x2, (float)pBox->y1, 0.0f,719 (float)pBox->x2, (float)pBox->y1, 0.0f,
@@ -740,7 +723,8 @@
740 (float)pBox->x2, (float)pBox->y1, 0.0f,723 (float)pBox->x2, (float)pBox->y1, 0.0f,
741 };724 };
742725
743 const GLfloat textureData[] = {726 const GLfloat textureData[] =
727 {
744 tx1, ty1,728 tx1, ty1,
745 tx1, ty2,729 tx1, ty2,
746 tx2, ty1,730 tx2, ty1,
@@ -751,7 +735,8 @@
751735
752 streamingBuffer->addVertices (6, &vertexData[0]);736 streamingBuffer->addVertices (6, &vertexData[0]);
753 streamingBuffer->addTexCoords (0, 6, &textureData[0]);737 streamingBuffer->addTexCoords (0, 6, &textureData[0]);
754 pBox++;738
739 ++pBox;
755 }740 }
756 }741 }
757742
@@ -763,16 +748,17 @@
763}748}
764749
765static void750static void
766addSingleQuad (GLVertexBuffer *vertexBuffer,751addSingleQuad (GLVertexBuffer *vertexBuffer,
767 const GLTexture::MatrixList &matrix,752 const GLTexture::MatrixList &matrix,
768 unsigned int nMatrix,753 unsigned int nMatrix,
769 int x1,754 int x1,
770 int y1,755 int y1,
771 int x2,756 int x2,
772 int y2,757 int y2,
773 bool rect)758 bool rect)
774{759{
775 GLfloat vertexData[18] = {760 GLfloat vertexData[18] =
761 {
776 (float)x1, (float)y1, 0.0,762 (float)x1, (float)y1, 0.0,
777 (float)x1, (float)y2, 0.0,763 (float)x1, (float)y2, 0.0,
778 (float)x2, (float)y1, 0.0,764 (float)x2, (float)y1, 0.0,
@@ -780,52 +766,58 @@
780 (float)x1, (float)y2, 0.0,766 (float)x1, (float)y2, 0.0,
781 (float)x2, (float)y2, 0.0767 (float)x2, (float)y2, 0.0
782 };768 };
769
783 vertexBuffer->addVertices (6, vertexData);770 vertexBuffer->addVertices (6, vertexData);
771 unsigned int it;
784772
785 if (rect)773 if (rect)
786 {774 {
787 unsigned int it;775 for (it = 0; it < nMatrix; ++it)
788 for (it = 0; it < nMatrix; it++)776 {
789 {777 GLfloat data[2];
790 GLfloat data[2];778 const GLTexture::Matrix &mat = matrix[it];
791 const GLTexture::Matrix &mat = matrix[it];779 data[0] = COMP_TEX_COORD_X (mat, x1);
792 data[0] = COMP_TEX_COORD_X (mat, x1);780 data[1] = COMP_TEX_COORD_Y (mat, y1);
793 data[1] = COMP_TEX_COORD_Y (mat, y1);781 vertexBuffer->addTexCoords (it, 1, data);
794 vertexBuffer->addTexCoords (it, 1, data);782 }
795 }783
796 for (it = 0; it < nMatrix; it++)784 for (it = 0; it < nMatrix; ++it)
797 {785 {
798 GLfloat data[2];786 GLfloat data[2];
799 const GLTexture::Matrix &mat = matrix[it];787 const GLTexture::Matrix &mat = matrix[it];
800 data[0] = COMP_TEX_COORD_X (mat, x1);788 data[0] = COMP_TEX_COORD_X (mat, x1);
801 data[1] = COMP_TEX_COORD_Y (mat, y2);789 data[1] = COMP_TEX_COORD_Y (mat, y2);
802 vertexBuffer->addTexCoords (it, 1, data);790 vertexBuffer->addTexCoords (it, 1, data);
803 }791 }
804 for (it = 0; it < nMatrix; it++)792
805 {793 for (it = 0; it < nMatrix; ++it)
806 GLfloat data[2];794 {
807 const GLTexture::Matrix &mat = matrix[it];795 GLfloat data[2];
808 data[0] = COMP_TEX_COORD_X (mat, x2);796 const GLTexture::Matrix &mat = matrix[it];
809 data[1] = COMP_TEX_COORD_Y (mat, y1);797 data[0] = COMP_TEX_COORD_X (mat, x2);
810 vertexBuffer->addTexCoords (it, 1, data);798 data[1] = COMP_TEX_COORD_Y (mat, y1);
811 }799 vertexBuffer->addTexCoords (it, 1, data);
812 for (it = 0; it < nMatrix; it++)800 }
813 {801
814 GLfloat data[2];802 for (it = 0; it < nMatrix; ++it)
815 const GLTexture::Matrix &mat = matrix[it];803 {
816 data[0] = COMP_TEX_COORD_X (mat, x2);804 GLfloat data[2];
817 data[1] = COMP_TEX_COORD_Y (mat, y1);805 const GLTexture::Matrix &mat = matrix[it];
818 vertexBuffer->addTexCoords (it, 1, data);806 data[0] = COMP_TEX_COORD_X (mat, x2);
819 }807 data[1] = COMP_TEX_COORD_Y (mat, y1);
820 for (it = 0; it < nMatrix; it++)808 vertexBuffer->addTexCoords (it, 1, data);
821 {809 }
822 GLfloat data[2];810
823 const GLTexture::Matrix &mat = matrix[it];811 for (it = 0; it < nMatrix; ++it)
824 data[0] = COMP_TEX_COORD_X (mat, x1);812 {
825 data[1] = COMP_TEX_COORD_Y (mat, y2);813 GLfloat data[2];
826 vertexBuffer->addTexCoords (it, 1, data);814 const GLTexture::Matrix &mat = matrix[it];
827 }815 data[0] = COMP_TEX_COORD_X (mat, x1);
828 for (it = 0; it < nMatrix; it++)816 data[1] = COMP_TEX_COORD_Y (mat, y2);
817 vertexBuffer->addTexCoords (it, 1, data);
818 }
819
820 for (it = 0; it < nMatrix; ++it)
829 {821 {
830 GLfloat data[2];822 GLfloat data[2];
831 const GLTexture::Matrix &mat = matrix[it];823 const GLTexture::Matrix &mat = matrix[it];
@@ -836,8 +828,7 @@
836 }828 }
837 else829 else
838 {830 {
839 unsigned int it;831 for (it = 0; it < nMatrix; ++it)
840 for (it = 0; it < nMatrix; it++)
841 {832 {
842 GLfloat data[2];833 GLfloat data[2];
843 const GLTexture::Matrix &mat = matrix[it];834 const GLTexture::Matrix &mat = matrix[it];
@@ -845,39 +836,44 @@
845 data[1] = COMP_TEX_COORD_YX (mat, x1, y1);836 data[1] = COMP_TEX_COORD_YX (mat, x1, y1);
846 vertexBuffer->addTexCoords (it, 1, data);837 vertexBuffer->addTexCoords (it, 1, data);
847 }838 }
848 for (it = 0; it < nMatrix; it++)839
849 {840 for (it = 0; it < nMatrix; ++it)
850 GLfloat data[2];841 {
851 const GLTexture::Matrix &mat = matrix[it];842 GLfloat data[2];
852 data[0] = COMP_TEX_COORD_XY (mat, x1, y2);843 const GLTexture::Matrix &mat = matrix[it];
853 data[1] = COMP_TEX_COORD_YX (mat, x1, y2);844 data[0] = COMP_TEX_COORD_XY (mat, x1, y2);
854 vertexBuffer->addTexCoords (it, 1, data);845 data[1] = COMP_TEX_COORD_YX (mat, x1, y2);
855 }846 vertexBuffer->addTexCoords (it, 1, data);
856 for (it = 0; it < nMatrix; it++)847 }
857 {848
858 GLfloat data[2];849 for (it = 0; it < nMatrix; ++it)
859 const GLTexture::Matrix &mat = matrix[it];850 {
860 data[0] = COMP_TEX_COORD_XY (mat, x2, y1);851 GLfloat data[2];
861 data[1] = COMP_TEX_COORD_YX (mat, x2, y1);852 const GLTexture::Matrix &mat = matrix[it];
862 vertexBuffer->addTexCoords (it, 1, data);853 data[0] = COMP_TEX_COORD_XY (mat, x2, y1);
863 }854 data[1] = COMP_TEX_COORD_YX (mat, x2, y1);
864 for (it = 0; it < nMatrix; it++)855 vertexBuffer->addTexCoords (it, 1, data);
865 {856 }
866 GLfloat data[2];857
867 const GLTexture::Matrix &mat = matrix[it];858 for (it = 0; it < nMatrix; ++it)
868 data[0] = COMP_TEX_COORD_XY (mat, x2, y1);859 {
869 data[1] = COMP_TEX_COORD_YX (mat, x2, y1);860 GLfloat data[2];
870 vertexBuffer->addTexCoords (it, 1, data);861 const GLTexture::Matrix &mat = matrix[it];
871 }862 data[0] = COMP_TEX_COORD_XY (mat, x2, y1);
872 for (it = 0; it < nMatrix; it++)863 data[1] = COMP_TEX_COORD_YX (mat, x2, y1);
873 {864 vertexBuffer->addTexCoords (it, 1, data);
874 GLfloat data[2];865 }
875 const GLTexture::Matrix &mat = matrix[it];866
876 data[0] = COMP_TEX_COORD_XY (mat, x1, y2);867 for (it = 0; it < nMatrix; ++it)
877 data[1] = COMP_TEX_COORD_YX (mat, x1, y2);868 {
878 vertexBuffer->addTexCoords (it, 1, data);869 GLfloat data[2];
879 }870 const GLTexture::Matrix &mat = matrix[it];
880 for (it = 0; it < nMatrix; it++)871 data[0] = COMP_TEX_COORD_XY (mat, x1, y2);
872 data[1] = COMP_TEX_COORD_YX (mat, x1, y2);
873 vertexBuffer->addTexCoords (it, 1, data);
874 }
875
876 for (it = 0; it < nMatrix; ++it)
881 {877 {
882 GLfloat data[2];878 GLfloat data[2];
883 const GLTexture::Matrix &mat = matrix[it];879 const GLTexture::Matrix &mat = matrix[it];
@@ -889,16 +885,16 @@
889}885}
890886
891static void887static void
892addQuads (GLVertexBuffer *vertexBuffer,888addQuads (GLVertexBuffer *vertexBuffer,
893 const GLTexture::MatrixList &matrix,889 const GLTexture::MatrixList &matrix,
894 unsigned int nMatrix,890 unsigned int nMatrix,
895 int x1,891 int x1,
896 int y1,892 int y1,
897 int x2,893 int x2,
898 int y2,894 int y2,
899 bool rect,895 bool rect,
900 unsigned int maxGridWidth,896 unsigned int maxGridWidth,
901 unsigned int maxGridHeight)897 unsigned int maxGridHeight)
902{898{
903 if (maxGridWidth == 0 || maxGridHeight == 0)899 if (maxGridWidth == 0 || maxGridHeight == 0)
904 return;900 return;
@@ -909,9 +905,7 @@
909 1 + (y2 - y1 - 1) / (int) maxGridHeight;905 1 + (y2 - y1 - 1) / (int) maxGridHeight;
910906
911 if (nQuadsX == 1 && nQuadsY == 1)907 if (nQuadsX == 1 && nQuadsY == 1)
912 {
913 addSingleQuad (vertexBuffer, matrix, nMatrix, x1, y1, x2, y2, rect);908 addSingleQuad (vertexBuffer, matrix, nMatrix, x1, y1, x2, y2, rect);
914 }
915 else909 else
916 {910 {
917 int quadWidth = 1 + (x2 - x1 - 1) / nQuadsX; // ceil. division911 int quadWidth = 1 + (x2 - x1 - 1) / nQuadsX; // ceil. division
@@ -942,30 +936,30 @@
942{936{
943 WRAPABLE_HND_FUNCTN (glAddGeometry, matrix, region, clip)937 WRAPABLE_HND_FUNCTN (glAddGeometry, matrix, region, clip)
944938
945 BoxRec full;
946 int nMatrix = matrix.size ();939 int nMatrix = matrix.size ();
940 BoxRec full = clip.handle ()->extents;
947941
948 full = clip.handle ()->extents;
949 if (region.handle ()->extents.x1 > full.x1)942 if (region.handle ()->extents.x1 > full.x1)
950 full.x1 = region.handle ()->extents.x1;943 full.x1 = region.handle ()->extents.x1;
944
951 if (region.handle ()->extents.y1 > full.y1)945 if (region.handle ()->extents.y1 > full.y1)
952 full.y1 = region.handle ()->extents.y1;946 full.y1 = region.handle ()->extents.y1;
947
953 if (region.handle ()->extents.x2 < full.x2)948 if (region.handle ()->extents.x2 < full.x2)
954 full.x2 = region.handle ()->extents.x2;949 full.x2 = region.handle ()->extents.x2;
950
955 if (region.handle ()->extents.y2 < full.y2)951 if (region.handle ()->extents.y2 < full.y2)
956 full.y2 = region.handle ()->extents.y2;952 full.y2 = region.handle ()->extents.y2;
957953
958 if (full.x1 < full.x2 && full.y1 < full.y2)954 if (full.x1 < full.x2 && full.y1 < full.y2)
959 {955 {
960 BoxPtr pBox;
961 int nBox;
962 BoxPtr pClip;956 BoxPtr pClip;
963 int nClip;957 int nClip;
964 BoxRec cbox;958 BoxRec cbox;
965 int it, x1, y1, x2, y2;959 int it, x1, y1, x2, y2;
966 bool rect = true;960 bool rect = true;
967961
968 for (it = 0; it < nMatrix; it++)962 for (it = 0; it < nMatrix; ++it)
969 {963 {
970 if (matrix[it].xy != 0.0f || matrix[it].yx != 0.0f)964 if (matrix[it].xy != 0.0f || matrix[it].yx != 0.0f)
971 {965 {
@@ -974,8 +968,8 @@
974 }968 }
975 }969 }
976970
977 pBox = const_cast <Region> (region.handle ())->rects;971 BoxPtr pBox = const_cast <Region> (region.handle ())->rects;
978 nBox = const_cast <Region> (region.handle ())->numRects;972 int nBox = const_cast <Region> (region.handle ())->numRects;
979973
980 while (nBox--)974 while (nBox--)
981 {975 {
@@ -984,7 +978,7 @@
984 x2 = pBox->x2;978 x2 = pBox->x2;
985 y2 = pBox->y2;979 y2 = pBox->y2;
986980
987 pBox++;981 ++pBox;
988982
989 if (x1 < full.x1)983 if (x1 < full.x1)
990 x1 = full.x1;984 x1 = full.x1;
@@ -1014,14 +1008,17 @@
1014 {1008 {
1015 cbox = *pClip;1009 cbox = *pClip;
10161010
1017 pClip++;1011 ++pClip;
10181012
1019 if (cbox.x1 < x1)1013 if (cbox.x1 < x1)
1020 cbox.x1 = x1;1014 cbox.x1 = x1;
1015
1021 if (cbox.y1 < y1)1016 if (cbox.y1 < y1)
1022 cbox.y1 = y1;1017 cbox.y1 = y1;
1018
1023 if (cbox.x2 > x2)1019 if (cbox.x2 > x2)
1024 cbox.x2 = x2;1020 cbox.x2 = x2;
1021
1025 if (cbox.y2 > y2)1022 if (cbox.y2 > y2)
1026 cbox.y2 = y2;1023 cbox.y2 = y2;
10271024
@@ -1157,9 +1154,7 @@
1157 GL::activeTexture (GL_TEXTURE2_ARB);1154 GL::activeTexture (GL_TEXTURE2_ARB);
1158 }1155 }
1159 else1156 else
1160 {
1161 w->vertexBuffer ()->render (transform, attrib);1157 w->vertexBuffer ()->render (transform, attrib);
1162 }
11631158
1164 texture->disable ();1159 texture->disable ();
11651160
@@ -1221,9 +1216,7 @@
1221 gs->setTexEnvMode (GL_REPLACE);1216 gs->setTexEnvMode (GL_REPLACE);
1222 }1217 }
1223 else1218 else
1224 {
1225 w->vertexBuffer ()->render (transform, attrib);1219 w->vertexBuffer ()->render (transform, attrib);
1226 }
1227 }1220 }
1228 else if (attrib.brightness != BRIGHT)1221 else if (attrib.brightness != BRIGHT)
1229 {1222 {
@@ -1237,9 +1230,7 @@
1237 gs->setTexEnvMode (GL_REPLACE);1230 gs->setTexEnvMode (GL_REPLACE);
1238 }1231 }
1239 else1232 else
1240 {
1241 w->vertexBuffer ()->render (transform, attrib);1233 w->vertexBuffer ()->render (transform, attrib);
1242 }
12431234
1244 texture->disable ();1235 texture->disable ();
1245 }1236 }
@@ -1247,10 +1238,10 @@
1247#endif1238#endif
12481239
1249void1240void
1250GLWindow::glDrawTexture (GLTexture *texture,1241GLWindow::glDrawTexture (GLTexture *texture,
1251 const GLMatrix &transform,1242 const GLMatrix &transform,
1252 const GLWindowPaintAttrib &attrib,1243 const GLWindowPaintAttrib &attrib,
1253 unsigned int mask)1244 unsigned int mask)
1254{1245{
1255 WRAPABLE_HND_FUNCTN (glDrawTexture, texture, transform, attrib, mask)1246 WRAPABLE_HND_FUNCTN (glDrawTexture, texture, transform, attrib, mask)
12561247
@@ -1287,21 +1278,19 @@
1287}1278}
12881279
1289bool1280bool
1290GLWindow::glDraw (const GLMatrix &transform,1281GLWindow::glDraw (const GLMatrix &transform,
1291 const GLWindowPaintAttrib &attrib,1282 const GLWindowPaintAttrib &attrib,
1292 const CompRegion &region,1283 const CompRegion &region,
1293 unsigned int mask)1284 unsigned int mask)
1294{1285{
1295 WRAPABLE_HND_FUNCTN_RETURN (bool, glDraw, transform,1286 WRAPABLE_HND_FUNCTN_RETURN (bool, glDraw, transform,
1296 attrib, region, mask)1287 attrib, region, mask)
12971288
1298 const CompRegion &reg = (mask & PAINT_WINDOW_TRANSFORMED_MASK) ?1289 const CompRegion &reg = (mask & PAINT_WINDOW_TRANSFORMED_MASK) ?
1299 infiniteRegion : region;1290 infiniteRegion : region;
13001291
1301 if (reg.isEmpty ())1292 if (reg.isEmpty () ||
1302 return true;1293 !priv->window->isViewable () ||
1303
1304 if (!priv->window->isViewable () ||
1305 !priv->cWindow->damaged ())1294 !priv->cWindow->damaged ())
1306 return true;1295 return true;
13071296
@@ -1327,11 +1316,12 @@
1327 if (priv->updateState & PrivateGLWindow::UpdateRegion)1316 if (priv->updateState & PrivateGLWindow::UpdateRegion)
1328 priv->updateWindowRegions ();1317 priv->updateWindowRegions ();
13291318
1330 for (unsigned int i = 0; i < priv->textures.size (); i++)1319 for (unsigned int i = 0; i < priv->textures.size (); ++i)
1331 {1320 {
1332 ml[0] = priv->matrices[i];1321 ml[0] = priv->matrices[i];
1333 priv->vertexBuffer->begin ();1322 priv->vertexBuffer->begin ();
1334 glAddGeometry (ml, priv->regions[i], reg);1323 glAddGeometry (ml, priv->regions[i], reg);
1324
1335 if (priv->vertexBuffer->end ())1325 if (priv->vertexBuffer->end ())
1336 glDrawTexture (priv->textures[i], transform, attrib, mask);1326 glDrawTexture (priv->textures[i], transform, attrib, mask);
1337 }1327 }
@@ -1347,8 +1337,6 @@
1347{1337{
1348 WRAPABLE_HND_FUNCTN_RETURN (bool, glPaint, attrib, transform, region, mask)1338 WRAPABLE_HND_FUNCTN_RETURN (bool, glPaint, attrib, transform, region, mask)
13491339
1350 bool status;
1351
1352 priv->lastPaint = attrib;1340 priv->lastPaint = attrib;
13531341
1354 if (priv->window->alpha () || attrib.opacity != OPAQUE)1342 if (priv->window->alpha () || attrib.opacity != OPAQUE)
@@ -1358,16 +1346,10 @@
13581346
1359 if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)1347 if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
1360 {1348 {
1361 if (mask & PAINT_WINDOW_TRANSFORMED_MASK)1349 if (mask & PAINT_WINDOW_TRANSFORMED_MASK ||
1362 return false;1350 mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK ||
13631351 mask & PAINT_WINDOW_TRANSLUCENT_MASK ||
1364 if (mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK)1352 priv->window->shaded ())
1365 return false;
1366
1367 if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
1368 return false;
1369
1370 if (priv->window->shaded ())
1371 return false;1353 return false;
13721354
1373 return true;1355 return true;
@@ -1376,7 +1358,7 @@
1376 if (mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK)1358 if (mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK)
1377 return true;1359 return true;
13781360
1379 status = glDraw (transform, attrib, region, mask);1361 bool status = glDraw (transform, attrib, region, mask);
13801362
1381 return status;1363 return status;
1382}1364}
13831365
=== modified file 'plugins/opengl/src/privates.h'
--- plugins/opengl/src/privates.h 2013-01-03 16:05:26 +0000
+++ plugins/opengl/src/privates.h 2013-07-24 16:05:45 +0000
@@ -59,7 +59,7 @@
5959
60 protected:60 protected:
6161
62 Display *mDpy;62 Display *mDpy;
63 const CompSize &mSize;63 const CompSize &mSize;
64};64};
6565
@@ -70,9 +70,9 @@
70{70{
71 public:71 public:
7272
73 GLXDoubleBuffer (Display *,73 GLXDoubleBuffer (Display *,
74 const CompSize &,74 const CompSize &,
75 Window);75 Window );
7676
77 void swap () const;77 void swap () const;
78 bool blitAvailable () const;78 bool blitAvailable () const;
@@ -93,9 +93,9 @@
93{93{
94 public:94 public:
9595
96 EGLDoubleBuffer (Display *,96 EGLDoubleBuffer (Display *,
97 const CompSize &,97 const CompSize &,
98 EGLSurface const &);98 EGLSurface const &);
9999
100 void swap () const;100 void swap () const;
101 bool blitAvailable () const;101 bool blitAvailable () const;
@@ -106,7 +106,7 @@
106106
107 private:107 private:
108108
109 EGLSurface const & mSurface;109 EGLSurface const &mSurface;
110};110};
111111
112#endif112#endif
@@ -114,6 +114,7 @@
114class GLIcon114class GLIcon
115{115{
116 public:116 public:
117
117 GLIcon () : icon (NULL) {}118 GLIcon () : icon (NULL) {}
118119
119 CompIcon *icon;120 CompIcon *icon;
@@ -126,10 +127,12 @@
126 public OpenglOptions127 public OpenglOptions
127{128{
128 public:129 public:
130
129 PrivateGLScreen (GLScreen *gs);131 PrivateGLScreen (GLScreen *gs);
130 ~PrivateGLScreen ();132 ~PrivateGLScreen ();
131133
132 bool setOption (const CompString &name, CompOption::Value &value);134 bool setOption (const CompString &name,
135 CompOption::Value &value);
133136
134 void handleEvent (XEvent *event);137 void handleEvent (XEvent *event);
135138
@@ -149,7 +152,7 @@
149 bool compositingActive ();152 bool compositingActive ();
150153
151 void paintBackground (const GLMatrix &transform,154 void paintBackground (const GLMatrix &transform,
152 const CompRegion &region,155 const CompRegion &region,
153 bool transformed);156 bool transformed);
154157
155 void paintOutputRegion (const GLMatrix &transform,158 void paintOutputRegion (const GLMatrix &transform,
@@ -165,67 +168,69 @@
165168
166 public:169 public:
167170
168 GLScreen *gScreen;171 GLScreen *gScreen;
169 CompositeScreen *cScreen;172 CompositeScreen *cScreen;
170173
171 GLenum textureFilter;174 GLenum textureFilter;
172175
173 #ifndef USE_GLES176 #ifndef USE_GLES
174 GLFBConfig glxPixmapFBConfigs[MAX_DEPTH + 1];177 GLFBConfig glxPixmapFBConfigs[MAX_DEPTH + 1];
175 #endif178 #endif
176179
177 GLTexture::List backgroundTextures;180 GLTexture::List backgroundTextures;
178 bool backgroundLoaded;181 bool backgroundLoaded;
179182
180 GLTexture::Filter filter[3];183 GLTexture::Filter filter[3];
181184
182 CompPoint rasterPos;185 CompPoint rasterPos;
183186
184 GLMatrix *projection;187 GLMatrix *projection;
185188
186 bool clearBuffers;189 bool clearBuffers;
187 bool lighting;190 bool lighting;
188191
189 #ifdef USE_GLES192 #ifdef USE_GLES
190 EGLContext ctx;193 EGLContext ctx;
191 EGLSurface surface;194 EGLSurface surface;
192 EGLDoubleBuffer doubleBuffer;195 EGLDoubleBuffer doubleBuffer;
193 #else196 #else
194 GLXContext ctx;197 GLXContext ctx;
195198
196 GL::GLXGetProcAddressProc getProcAddress;199 GL::GLXGetProcAddressProc getProcAddress;
197 GLXDoubleBuffer doubleBuffer;200 GLXDoubleBuffer doubleBuffer;
198 #endif201 #endif
199202
200 GLFramebufferObject *scratchFbo;203 GLFramebufferObject *scratchFbo;
201 CompRegion outputRegion;204 CompRegion outputRegion;
202205
203 XRectangle lastViewport;206 XRectangle lastViewport;
204 bool refreshSubBuffer;207 bool refreshSubBuffer;
205 unsigned int lastMask;208 unsigned int lastMask;
206209
207 std::vector<GLTexture::BindPixmapProc> bindPixmap;210 std::vector<GLTexture::BindPixmapProc> bindPixmap;
208 bool hasCompositing;211 bool hasCompositing;
209 bool commonFrontbuffer;212 bool commonFrontbuffer;
210 bool incorrectRefreshRate; // hack for NVIDIA specifying an incorrect213 bool incorrectRefreshRate; // hack for NVIDIA specifying an incorrect
211 // refresh rate, causing us to miss vblanks214 // refresh rate, causing us to miss vblanks
212215
213 GLIcon defaultIcon;216 GLIcon defaultIcon;
214217
215 Window saveWindow; // hack for broken applications, see:218 Window saveWindow; // hack for broken applications, see:
216 // https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/807487219 // https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/807487
217220
218 GLProgramCache *programCache;221 GLProgramCache *programCache;
219 GLShaderCache shaderCache;222 GLShaderCache shaderCache;
220 GLVertexBuffer::AutoProgram *autoProgram;223 GLVertexBuffer::AutoProgram *autoProgram;
221224
222 Pixmap rootPixmapCopy;225 Pixmap rootPixmapCopy;
223 CompSize rootPixmapSize;226 CompSize rootPixmapSize;
224227
225 const char *glVendor, *glRenderer, *glVersion;228 const char *glVendor;
226229 const char *glRenderer;
227 mutable CompString prevRegex;230 const char *glVersion;
228 mutable bool prevBlacklisted;231
232 mutable CompString prevRegex;
233 mutable bool prevBlacklisted;
229};234};
230235
231class PrivateGLWindow :236class PrivateGLWindow :
@@ -238,55 +243,64 @@
238 static const unsigned int UpdateMatrix = 1 << 1;243 static const unsigned int UpdateMatrix = 1 << 1;
239244
240 public:245 public:
246
241 PrivateGLWindow (CompWindow *w, GLWindow *gw);247 PrivateGLWindow (CompWindow *w, GLWindow *gw);
242 ~PrivateGLWindow ();248 ~PrivateGLWindow ();
243249
244 void windowNotify (CompWindowNotify n);250 void windowNotify (CompWindowNotify n);
245 void resizeNotify (int dx, int dy, int dwidth, int dheight);251
246 void moveNotify (int dx, int dy, bool now);252 void resizeNotify (int dx,
253 int dy,
254 int dwidth,
255 int dheight);
256
257 void moveNotify (int dx,
258 int dy,
259 bool now);
260
247 void updateFrameRegion (CompRegion &region);261 void updateFrameRegion (CompRegion &region);
248262
249 void setWindowMatrix ();263 void setWindowMatrix ();
264
250 void updateWindowRegions ();265 void updateWindowRegions ();
251266
252 void clearTextures ();267 void clearTextures ();
253268
254 CompWindow *window;269 CompWindow *window;
255 GLWindow *gWindow;270 GLWindow *gWindow;
256 CompositeWindow *cWindow;271 CompositeWindow *cWindow;
257 GLScreen *gScreen;272 GLScreen *gScreen;
258273
259 GLTexture::List textures;274 GLTexture::List textures;
260 GLTexture::MatrixList matrices;275 GLTexture::MatrixList matrices;
261 CompRegion::Vector regions;276 CompRegion::Vector regions;
262 unsigned int updateState;277 unsigned int updateState;
263 bool needsRebind;278 bool needsRebind;
264279
265 CompRegion clip;280 CompRegion clip;
266281
267 bool bindFailed;282 bool bindFailed;
268 bool overlayWindow;283 bool overlayWindow;
269284
270 GLushort opacity;285 GLushort opacity;
271 GLushort brightness;286 GLushort brightness;
272 GLushort saturation;287 GLushort saturation;
273288
274 GLWindowPaintAttrib paint;289 GLWindowPaintAttrib paint;
275 GLWindowPaintAttrib lastPaint;290 GLWindowPaintAttrib lastPaint;
276291
277 unsigned int lastMask;292 unsigned int lastMask;
278293
279 GLVertexBuffer *vertexBuffer;294 GLVertexBuffer *vertexBuffer;
280295
281 // map of shaders, plugin name is key, pair of vertex and fragment296 // map of shaders, plugin name is key, pair of vertex and fragment
282 // shader source code is value297 // shader source code is value
283 std::list<const GLShaderData*> shaders;298 std::list<const GLShaderData*> shaders;
284 GLVertexBuffer::AutoProgram *autoProgram;299 GLVertexBuffer::AutoProgram *autoProgram;
285300
286 std::list<GLIcon> icons;301 std::list<GLIcon> icons;
287302
288 compiz::window::configure_buffers::Releasable::Ptr configureLock;303 compiz::window::configure_buffers::Releasable::Ptr configureLock;
289};304};
290305
291#endif306#endif
292
293307
=== modified file 'plugins/opengl/src/privatetexture.h'
--- plugins/opengl/src/privatetexture.h 2012-09-18 11:32:20 +0000
+++ plugins/opengl/src/privatetexture.h 2013-07-24 16:05:45 +0000
@@ -47,8 +47,10 @@
47class GLScreen;47class GLScreen;
48class GLDisplay;48class GLDisplay;
4949
50class PrivateTexture {50class PrivateTexture
51{
51 public:52 public:
53
52 PrivateTexture (GLTexture *);54 PrivateTexture (GLTexture *);
53 ~PrivateTexture ();55 ~PrivateTexture ();
5456
@@ -59,6 +61,7 @@
59 GLenum type);61 GLenum type);
6062
61 public:63 public:
64
62 GLTexture *texture;65 GLTexture *texture;
63 GLuint name;66 GLuint name;
64 GLenum target;67 GLenum target;
@@ -72,8 +75,10 @@
72};75};
7376
74#ifdef USE_GLES77#ifdef USE_GLES
75class EglTexture : public GLTexture {78class EglTexture : public GLTexture
79{
76 public:80 public:
81
77 EglTexture ();82 EglTexture ();
78 ~EglTexture ();83 ~EglTexture ();
7984
@@ -86,21 +91,26 @@
86 compiz::opengl::PixmapSource source);91 compiz::opengl::PixmapSource source);
8792
88 public:93 public:
89 bool damaged;94
90 Damage damage;95 bool damaged;
91 bool updateMipMap;96 Damage damage;
97 bool updateMipMap;
92};98};
9399
94extern std::map<Damage, EglTexture*> boundPixmapTex;100extern std::map<Damage, EglTexture*> boundPixmapTex;
95#else101#else
96102
97class TfpTexture : public GLTexture {103class TfpTexture : public GLTexture
104{
98 public:105 public:
106
99 TfpTexture ();107 TfpTexture ();
100 ~TfpTexture ();108 ~TfpTexture ();
101109
102 void enable (Filter filter);110 void enable (Filter filter);
111
103 bool bindTexImage (const GLXPixmap &);112 bool bindTexImage (const GLXPixmap &);
113
104 void releaseTexImage ();114 void releaseTexImage ();
105115
106 static List bindPixmapToTexture (Pixmap pixmap,116 static List bindPixmapToTexture (Pixmap pixmap,
@@ -110,6 +120,7 @@
110 compiz::opengl::PixmapSource source);120 compiz::opengl::PixmapSource source);
111121
112 public:122 public:
123
113 Pixmap x11Pixmap;124 Pixmap x11Pixmap;
114 GLXPixmap pixmap;125 GLXPixmap pixmap;
115 bool damaged;126 bool damaged;
116127
=== modified file 'plugins/opengl/src/privatevertexbuffer.h'
--- plugins/opengl/src/privatevertexbuffer.h 2012-07-25 09:46:54 +0000
+++ plugins/opengl/src/privatevertexbuffer.h 2013-07-24 16:05:45 +0000
@@ -41,17 +41,20 @@
41class AbstractUniform41class AbstractUniform
42{42{
43 public:43 public:
44 void virtual set(GLProgram* program) = 0;44
45 void virtual set (GLProgram *program) = 0;
45};46};
4647
47template < typename T, int C >48template < typename T, int C >
48class Uniform: public AbstractUniform49class Uniform: public AbstractUniform
49{50{
50 public:51 public:
51 Uniform(const char *_name, ... );52
52 void set(GLProgram* program);53 Uniform (const char *_name, ... );
54 void set (GLProgram* program);
5355
54 public:56 public:
57
55 T a[C];58 T a[C];
56 std::string name;59 std::string name;
57};60};
@@ -60,15 +63,17 @@
60Uniform< T, C >::Uniform(const char *_name, ... )63Uniform< T, C >::Uniform(const char *_name, ... )
61{64{
62 va_list arg_list;65 va_list arg_list;
63 va_start( arg_list, _name );66 va_start (arg_list, _name);
64 name = _name;67 name = _name;
65 for( int i = 0; i < C; i++ )68
69 for (int i = 0; i < C; ++i)
66 a[i] = va_arg( arg_list, T );70 a[i] = va_arg( arg_list, T );
71
67 va_end( arg_list );72 va_end( arg_list );
68}73}
6974
70template < typename T, int C >75template < typename T, int C >
71void Uniform< T, C >::set(GLProgram* prog)76void Uniform< T, C >::set (GLProgram *prog)
72{77{
73 const char* n = name.c_str();78 const char* n = name.c_str();
7479
@@ -78,24 +83,24 @@
78 {83 {
79 switch (C)84 switch (C)
80 {85 {
81 case 1: prog->setUniform (n, (GLfloat) a[0]); break;86 case 1: prog->setUniform (n, (GLfloat) a[0]); break;
82 case 2: prog->setUniform2f (n, a[0], a[1]); break;87 case 2: prog->setUniform2f (n, a[0], a[1]); break;
83 case 3: prog->setUniform3f (n, a[0], a[1], a[2]); break;88 case 3: prog->setUniform3f (n, a[0], a[1], a[2]); break;
84 case 4: prog->setUniform4f (n, a[0], a[1], a[2], a[3]); break;89 case 4: prog->setUniform4f (n, a[0], a[1], a[2], a[3]); break;
85 }90 }
86 } else if (typeid(a[0]) == typeid(int))91 }
92 else if (typeid(a[0]) == typeid(int))
87 {93 {
88 switch (C)94 switch (C)
89 {95 {
90 case 1: prog->setUniform (n, (GLint) a[0]); break;96 case 1: prog->setUniform (n, (GLint) a[0]); break;
91 case 2: prog->setUniform2i (n, a[0], a[1]); break;97 case 2: prog->setUniform2i (n, a[0], a[1]); break;
92 case 3: prog->setUniform3i (n, a[0], a[1], a[2]); break;98 case 3: prog->setUniform3i (n, a[0], a[1], a[2]); break;
93 case 4: prog->setUniform4i (n, a[0], a[1], a[2], a[3]); break;99 case 4: prog->setUniform4i (n, a[0], a[1], a[2], a[3]); break;
94 }100 }
95 } else101 }
96 {102 else
97 compLogMessage ("opengl", CompLogLevelError, "Unknown uniform type!");103 compLogMessage ("opengl", CompLogLevelError, "Unknown uniform type!");
98 }
99}104}
100105
101class GLVertexBuffer;106class GLVertexBuffer;
@@ -103,47 +108,50 @@
103class PrivateVertexBuffer108class PrivateVertexBuffer
104{109{
105 public:110 public:
111
106 PrivateVertexBuffer ();112 PrivateVertexBuffer ();
107 ~PrivateVertexBuffer ();113 ~PrivateVertexBuffer ();
108114
109 int render (const GLMatrix *projection,115 int render (const GLMatrix *projection,
110 const GLMatrix *modelview,116 const GLMatrix *modelview,
111 const GLWindowPaintAttrib *attrib);117 const GLWindowPaintAttrib *attrib);
118
112 int legacyRender (const GLMatrix &projection,119 int legacyRender (const GLMatrix &projection,
113 const GLMatrix &modelview,120 const GLMatrix &modelview,
114 const GLWindowPaintAttrib &attrib);121 const GLWindowPaintAttrib &attrib);
115122
116 public:123 public:
117 static GLVertexBuffer *streamingBuffer;124
118125 static GLVertexBuffer *streamingBuffer;
119 std::vector<GLfloat> vertexData;126
120 std::vector<GLfloat> normalData;127 std::vector<GLfloat> vertexData;
121 std::vector<GLfloat> colorData;128 std::vector<GLfloat> normalData;
129 std::vector<GLfloat> colorData;
122130
123 enum131 enum
124 {132 {
125 MAX_TEXTURES = 4133 MAX_TEXTURES = 4
126 };134 };
127 std::vector<GLfloat> textureData[MAX_TEXTURES];135
128 GLuint nTextures;136 std::vector<GLfloat> textureData[MAX_TEXTURES];
129137 GLuint nTextures;
130 GLfloat color[4];138
131139 GLfloat color[4];
132 GLuint vertexOffset;140
133 GLint maxVertices;141 GLuint vertexOffset;
134142 GLint maxVertices;
135 GLProgram *program;143
136 GLenum primitiveType;144 GLProgram *program;
137 GLenum usage;145 GLenum primitiveType;
138146 GLenum usage;
139 GLuint vertexBuffer;147
140 GLuint normalBuffer;148 GLuint vertexBuffer;
141 GLuint colorBuffer;149 GLuint normalBuffer;
142 GLuint textureBuffers[4];150 GLuint colorBuffer;
151 GLuint textureBuffers[4];
143 std::vector<AbstractUniform*> uniforms;152 std::vector<AbstractUniform*> uniforms;
144153
145 GLVertexBuffer::AutoProgram *autoProgram;154 GLVertexBuffer::AutoProgram *autoProgram;
146};155};
147156
148#endif //_VERTEXBUFFER_PRIVATE_H157#endif //_VERTEXBUFFER_PRIVATE_H
149
150158
=== modified file 'plugins/opengl/src/program.cpp'
--- plugins/opengl/src/program.cpp 2012-12-04 12:15:34 +0000
+++ plugins/opengl/src/program.cpp 2013-07-24 16:05:45 +0000
@@ -37,15 +37,14 @@
3737
38void printShaderInfoLog (GLuint shader)38void printShaderInfoLog (GLuint shader)
39{39{
40 GLint length = 0;40 GLint length = 0;
41 GLint chars = 0;41 GLint chars = 0;
4242
43 (*GL::getShaderiv) (shader, GL::INFO_LOG_LENGTH, &length);43 (*GL::getShaderiv) (shader, GL::INFO_LOG_LENGTH, &length);
4444
45 if (length > 0)45 if (length > 0)
46 {46 {
47 GLchar *infoLog;47 GLchar *infoLog = new GLchar[length];
48 infoLog = new GLchar[length];
49 (*GL::getShaderInfoLog) (shader, length, &chars, infoLog);48 (*GL::getShaderInfoLog) (shader, length, &chars, infoLog);
50 std::cout << infoLog << std::endl;49 std::cout << infoLog << std::endl;
51 delete[] infoLog;50 delete[] infoLog;
@@ -54,27 +53,26 @@
5453
55void printProgramInfoLog(GLuint program)54void printProgramInfoLog(GLuint program)
56{55{
57 GLint length = 0;56 GLint length = 0;
58 GLint chars = 0;57 GLint chars = 0;
5958
60 (*GL::getProgramiv) (program, GL::INFO_LOG_LENGTH, &length);59 (*GL::getProgramiv) (program, GL::INFO_LOG_LENGTH, &length);
6160
62 if (length > 0)61 if (length > 0)
63 {62 {
64 GLchar *infoLog;63 GLchar *infoLog = new GLchar[length];
65 infoLog = new GLchar[length];
66 (*GL::getProgramInfoLog) (program, length, &chars, infoLog);64 (*GL::getProgramInfoLog) (program, length, &chars, infoLog);
67 std::cout << infoLog << std::endl;65 std::cout << infoLog << std::endl;
68 delete[] infoLog;66 delete[] infoLog;
69 }67 }
70}68}
7169
72static bool compileShader (GLuint *shader, GLenum type, CompString &source)70static bool compileShader (GLuint *shader,
71 GLenum type,
72 CompString &source)
73{73{
74 const GLchar *data;
75 GLint status;74 GLint status;
7675 const GLchar *data = (GLchar *)source.c_str ();
77 data = (GLchar *)source.c_str ();
7876
79 *shader = (*GL::createShader) (type);77 *shader = (*GL::createShader) (type);
80 (*GL::shaderSource) (*shader, 1, &data, NULL);78 (*GL::shaderSource) (*shader, 1, &data, NULL);
@@ -88,9 +86,9 @@
88 priv (new PrivateProgram ())86 priv (new PrivateProgram ())
89{87{
90 GLuint vertex, fragment;88 GLuint vertex, fragment;
91 GLint status;89 GLint status;
9290
93 priv->valid = false;91 priv->valid = false;
94 priv->program = (*GL::createProgram) ();92 priv->program = (*GL::createProgram) ();
9593
96 if (!compileShader (&vertex, GL::VERTEX_SHADER, vertexShader))94 if (!compileShader (&vertex, GL::VERTEX_SHADER, vertexShader))
@@ -114,6 +112,7 @@
114 (*GL::validateProgram) (priv->program);112 (*GL::validateProgram) (priv->program);
115113
116 (*GL::getProgramiv) (priv->program, GL::LINK_STATUS, &status);114 (*GL::getProgramiv) (priv->program, GL::LINK_STATUS, &status);
115
117 if (status == GL_FALSE)116 if (status == GL_FALSE)
118 {117 {
119 printProgramInfoLog (priv->program);118 printProgramInfoLog (priv->program);
@@ -147,9 +146,11 @@
147 (*GL::useProgram) (0);146 (*GL::useProgram) (0);
148}147}
149148
150bool GLProgram::setUniform (const char *name, GLfloat value)149bool GLProgram::setUniform (const char *name,
150 GLfloat value)
151{151{
152 GLint location = (*GL::getUniformLocation) (priv->program, name);152 GLint location = (*GL::getUniformLocation) (priv->program, name);
153
153 if (location == -1)154 if (location == -1)
154 return false;155 return false;
155156
@@ -157,9 +158,11 @@
157 return true;158 return true;
158}159}
159160
160bool GLProgram::setUniform (const char *name, GLint value)161bool GLProgram::setUniform (const char *name,
162 GLint value)
161{163{
162 GLint location = (*GL::getUniformLocation) (priv->program, name);164 GLint location = (*GL::getUniformLocation) (priv->program, name);
165
163 if (location == -1)166 if (location == -1)
164 return false;167 return false;
165168
@@ -167,9 +170,11 @@
167 return true;170 return true;
168}171}
169172
170bool GLProgram::setUniform (const char *name, const GLMatrix &value)173bool GLProgram::setUniform (const char *name,
174 const GLMatrix &value)
171{175{
172 GLint location = (*GL::getUniformLocation) (priv->program, name);176 GLint location = (*GL::getUniformLocation) (priv->program, name);
177
173 if (location == -1)178 if (location == -1)
174 return false;179 return false;
175180
@@ -178,10 +183,11 @@
178}183}
179184
180bool GLProgram::setUniform2f (const char *name,185bool GLProgram::setUniform2f (const char *name,
181 GLfloat x,186 GLfloat x,
182 GLfloat y)187 GLfloat y)
183{188{
184 GLint location = (*GL::getUniformLocation) (priv->program, name);189 GLint location = (*GL::getUniformLocation) (priv->program, name);
190
185 if (location == -1)191 if (location == -1)
186 return false;192 return false;
187193
@@ -190,11 +196,12 @@
190}196}
191197
192bool GLProgram::setUniform3f (const char *name,198bool GLProgram::setUniform3f (const char *name,
193 GLfloat x,199 GLfloat x,
194 GLfloat y,200 GLfloat y,
195 GLfloat z)201 GLfloat z)
196{202{
197 GLint location = (*GL::getUniformLocation) (priv->program, name);203 GLint location = (*GL::getUniformLocation) (priv->program, name);
204
198 if (location == -1)205 if (location == -1)
199 return false;206 return false;
200207
@@ -203,12 +210,13 @@
203}210}
204211
205bool GLProgram::setUniform4f (const char *name,212bool GLProgram::setUniform4f (const char *name,
206 GLfloat x,213 GLfloat x,
207 GLfloat y,214 GLfloat y,
208 GLfloat z,215 GLfloat z,
209 GLfloat w)216 GLfloat w)
210{217{
211 GLint location = (*GL::getUniformLocation) (priv->program, name);218 GLint location = (*GL::getUniformLocation) (priv->program, name);
219
212 if (location == -1)220 if (location == -1)
213 return false;221 return false;
214222
@@ -217,10 +225,11 @@
217}225}
218226
219bool GLProgram::setUniform2i (const char *name,227bool GLProgram::setUniform2i (const char *name,
220 GLint x,228 GLint x,
221 GLint y)229 GLint y)
222{230{
223 GLint location = (*GL::getUniformLocation) (priv->program, name);231 GLint location = (*GL::getUniformLocation) (priv->program, name);
232
224 if (location == -1)233 if (location == -1)
225 return false;234 return false;
226235
@@ -229,11 +238,12 @@
229}238}
230239
231bool GLProgram::setUniform3i (const char *name,240bool GLProgram::setUniform3i (const char *name,
232 GLint x,241 GLint x,
233 GLint y,242 GLint y,
234 GLint z)243 GLint z)
235{244{
236 GLint location = (*GL::getUniformLocation) (priv->program, name);245 GLint location = (*GL::getUniformLocation) (priv->program, name);
246
237 if (location == -1)247 if (location == -1)
238 return false;248 return false;
239249
@@ -242,12 +252,13 @@
242}252}
243253
244bool GLProgram::setUniform4i (const char *name,254bool GLProgram::setUniform4i (const char *name,
245 GLint x,255 GLint x,
246 GLint y,256 GLint y,
247 GLint z,257 GLint z,
248 GLint w)258 GLint w)
249{259{
250 GLint location = (*GL::getUniformLocation) (priv->program, name);260 GLint location = (*GL::getUniformLocation) (priv->program, name);
261
251 if (location == -1)262 if (location == -1)
252 return false;263 return false;
253264
@@ -259,4 +270,3 @@
259{270{
260 return (*GL::getAttribLocation) (priv->program, name);271 return (*GL::getAttribLocation) (priv->program, name);
261}272}
262
263273
=== modified file 'plugins/opengl/src/programcache.cpp'
--- plugins/opengl/src/programcache.cpp 2013-01-10 08:19:56 +0000
+++ plugins/opengl/src/programcache.cpp 2013-07-24 16:05:45 +0000
@@ -31,58 +31,50 @@
31typedef std::pair<boost::shared_ptr<GLProgram>, access_history_t::iterator> value;31typedef std::pair<boost::shared_ptr<GLProgram>, access_history_t::iterator> value;
3232
33static GLProgram *33static GLProgram *
34compileProgram (std::string name, std::list<const GLShaderData*> shaders)34compileProgram (std::string name,
35 std::list<const GLShaderData*> shaders)
35{36{
36 std::list<const GLShaderData*>::const_iterator it;
37 std::string vertex_shader;37 std::string vertex_shader;
38 std::string fragment_shader;38 std::string fragment_shader;
39 std::string vertex_functions = "";39 std::string vertex_functions = "";
40 std::string vertex_function_calls = "";40 std::string vertex_function_calls = "";
41 std::string fragment_functions = "";41 std::string fragment_functions = "";
42 std::string fragment_function_calls = "";42 std::string fragment_function_calls = "";
43 int vpos, vcallpos, fpos, fcallpos;
4443
45 for (it = shaders.begin (); it != shaders.end (); ++it)44 for (std::list<const GLShaderData*>::const_iterator it = shaders.begin ();
45 it != shaders.end (); ++it)
46 {46 {
47 //find the special shaders to put the rest in47 //find the special shaders to put the rest in
48 if ((*it)->vertexShader.find ("@VERTEX_FUNCTIONS@") != std::string::npos)48 if ((*it)->vertexShader.find ("@VERTEX_FUNCTIONS@") != std::string::npos)
49 {
50 vertex_shader = (*it)->vertexShader;49 vertex_shader = (*it)->vertexShader;
51 }50
52 else51 else if ((*it)->vertexShader.length ())
53 {52 {
54 if ((*it)->vertexShader.length ())53 vertex_functions += (*it)->vertexShader;
55 {54 vertex_function_calls += (*it)->name + "_vertex();\n";
56 vertex_functions += (*it)->vertexShader;
57 vertex_function_calls += (*it)->name + "_vertex();\n";
58 }
59 }55 }
6056
61 if ((*it)->fragmentShader.find ("@FRAGMENT_FUNCTIONS@") != std::string::npos)57 if ((*it)->fragmentShader.find ("@FRAGMENT_FUNCTIONS@") != std::string::npos)
62 {
63 fragment_shader = (*it)->fragmentShader;58 fragment_shader = (*it)->fragmentShader;
64 }59
65 else60 else if ((*it)->fragmentShader.length ())
66 {61 {
67 if ((*it)->fragmentShader.length ())62 fragment_functions += (*it)->fragmentShader;
68 {63 fragment_function_calls += (*it)->name + "_fragment();\n";
69 fragment_functions += (*it)->fragmentShader;
70 fragment_function_calls += (*it)->name + "_fragment();\n";
71 }
72 }64 }
73 }65 }
7466
75 // put shader functions and function calls into the main shader67 // put shader functions and function calls into the main shader
76 vpos = vertex_shader.find ("@VERTEX_FUNCTIONS@");68 int vpos = vertex_shader.find ("@VERTEX_FUNCTIONS@");
77 vertex_shader.replace (vpos, 18, vertex_functions);69 vertex_shader.replace (vpos, 18, vertex_functions);
7870
79 vcallpos = vertex_shader.find ("@VERTEX_FUNCTION_CALLS@");71 int vcallpos = vertex_shader.find ("@VERTEX_FUNCTION_CALLS@");
80 vertex_shader.replace (vcallpos, 23, vertex_function_calls);72 vertex_shader.replace (vcallpos, 23, vertex_function_calls);
8173
82 fpos = fragment_shader.find ("@FRAGMENT_FUNCTIONS@");74 int fpos = fragment_shader.find ("@FRAGMENT_FUNCTIONS@");
83 fragment_shader.replace (fpos, 20, fragment_functions);75 fragment_shader.replace (fpos, 20, fragment_functions);
8476
85 fcallpos = fragment_shader.find ("@FRAGMENT_FUNCTION_CALLS@");77 int fcallpos = fragment_shader.find ("@FRAGMENT_FUNCTION_CALLS@");
86 fragment_shader.replace (fcallpos, 25, fragment_function_calls);78 fragment_shader.replace (fcallpos, 25, fragment_function_calls);
8779
88 return new GLProgram (vertex_shader, fragment_shader);80 return new GLProgram (vertex_shader, fragment_shader);
@@ -91,13 +83,16 @@
91class PrivateProgramCache83class PrivateProgramCache
92{84{
93 public:85 public:
86
94 PrivateProgramCache (size_t);87 PrivateProgramCache (size_t);
9588
96 const size_t capacity;89 const size_t capacity;
97 access_history_t access_history;90 access_history_t access_history;
98 std::map<std::string, value> cache;91 std::map<std::string, value> cache;
9992
100 void insert (std::string, GLProgram *);93 void insert (std::string ,
94 GLProgram *);
95
101 void evict ();96 void evict ();
102};97};
10398
@@ -114,10 +109,10 @@
114 109
115GLProgram* GLProgramCache::operator () (std::list<const GLShaderData*> shaders)110GLProgram* GLProgramCache::operator () (std::list<const GLShaderData*> shaders)
116{111{
117 std::list<const GLShaderData*>::const_iterator name_it;
118 std::string name;112 std::string name;
119113
120 for (name_it = shaders.begin(); name_it != shaders.end(); ++name_it)114 for (std::list<const GLShaderData*>::const_iterator name_it = shaders.begin();
115 name_it != shaders.end(); ++name_it)
121 {116 {
122 if (name.length () == 0)117 if (name.length () == 0)
123 name += (*name_it)->name;118 name += (*name_it)->name;
@@ -136,8 +131,8 @@
136 else131 else
137 {132 {
138 priv->access_history.splice (priv->access_history.end (),133 priv->access_history.splice (priv->access_history.end (),
139 priv->access_history,134 priv->access_history,
140 (*it).second.second);135 (*it).second.second);
141 (*it).second.second = priv->access_history.rbegin ().base ();136 (*it).second.second = priv->access_history.rbegin ().base ();
142137
143 return (*it).second.first.get ();138 return (*it).second.first.get ();
@@ -149,7 +144,8 @@
149{144{
150}145}
151146
152void PrivateProgramCache::insert (std::string name, GLProgram *program)147void PrivateProgramCache::insert (std::string name,
148 GLProgram *program)
153{149{
154 assert (cache.find (name) == cache.end ());150 assert (cache.find (name) == cache.end ());
155151
@@ -173,4 +169,3 @@
173 cache.erase (it);169 cache.erase (it);
174 access_history.pop_front ();170 access_history.pop_front ();
175}171}
176
177172
=== modified file 'plugins/opengl/src/screen.cpp'
--- plugins/opengl/src/screen.cpp 2013-05-15 10:47:42 +0000
+++ plugins/opengl/src/screen.cpp 2013-07-24 16:05:45 +0000
@@ -54,18 +54,18 @@
54class DetectionWorkaround54class DetectionWorkaround
55{55{
56 public:56 public:
57 DetectionWorkaround ()57
58 {58 DetectionWorkaround ()
59 program_invocation_short_name[0] = 'C';59 {
60 }60 program_invocation_short_name[0] = 'C';
61 ~DetectionWorkaround ()61 }
62 {62 ~DetectionWorkaround ()
63 program_invocation_short_name[0] = 'c';63 {
64 }64 program_invocation_short_name[0] = 'c';
65 }
65};66};
66#endif67#endif
6768
68
69using namespace compiz::opengl;69using namespace compiz::opengl;
7070
71namespace GL {71namespace GL {
@@ -75,124 +75,124 @@
7575
76 GLEGLImageTargetTexture2DOESProc eglImageTargetTexture;76 GLEGLImageTargetTexture2DOESProc eglImageTargetTexture;
7777
78 EGLPostSubBufferNVProc postSubBuffer = NULL;78 EGLPostSubBufferNVProc postSubBuffer = NULL;
79 #else79 #else
8080
81 typedef int (*GLXSwapIntervalProc) (int interval);81 typedef int (*GLXSwapIntervalProc) (int interval);
8282
83 GLXBindTexImageProc bindTexImage = NULL;83 GLXBindTexImageProc bindTexImage = NULL;
84 GLXReleaseTexImageProc releaseTexImage = NULL;84 GLXReleaseTexImageProc releaseTexImage = NULL;
85 GLXQueryDrawableProc queryDrawable = NULL;85 GLXQueryDrawableProc queryDrawable = NULL;
86 GLXCopySubBufferProc copySubBuffer = NULL;86 GLXCopySubBufferProc copySubBuffer = NULL;
87 GLXGetVideoSyncProc getVideoSync = NULL;87 GLXGetVideoSyncProc getVideoSync = NULL;
88 GLXWaitVideoSyncProc waitVideoSync = NULL;88 GLXWaitVideoSyncProc waitVideoSync = NULL;
89 GLXSwapIntervalProc swapInterval = NULL;89 GLXSwapIntervalProc swapInterval = NULL;
90 GLXGetFBConfigsProc getFBConfigs = NULL;90 GLXGetFBConfigsProc getFBConfigs = NULL;
91 GLXGetFBConfigAttribProc getFBConfigAttrib = NULL;91 GLXGetFBConfigAttribProc getFBConfigAttrib = NULL;
92 GLXCreatePixmapProc createPixmap = NULL;92 GLXCreatePixmapProc createPixmap = NULL;
93 GLXDestroyPixmapProc destroyPixmap = NULL;93 GLXDestroyPixmapProc destroyPixmap = NULL;
94 GLGenProgramsProc genPrograms = NULL;94 GLGenProgramsProc genPrograms = NULL;
95 GLDeleteProgramsProc deletePrograms = NULL;95 GLDeleteProgramsProc deletePrograms = NULL;
96 GLBindProgramProc bindProgram = NULL;96 GLBindProgramProc bindProgram = NULL;
97 GLProgramStringProc programString = NULL;97 GLProgramStringProc programString = NULL;
98 GLProgramParameter4fProc programEnvParameter4f = NULL;98 GLProgramParameter4fProc programEnvParameter4f = NULL;
99 GLProgramParameter4fProc programLocalParameter4f = NULL;99 GLProgramParameter4fProc programLocalParameter4f = NULL;
100 #endif100 #endif
101101
102 GLActiveTextureProc activeTexture = NULL;102 GLActiveTextureProc activeTexture = NULL;
103 GLClientActiveTextureProc clientActiveTexture = NULL;103 GLClientActiveTextureProc clientActiveTexture = NULL;
104 GLMultiTexCoord2fProc multiTexCoord2f = NULL;104 GLMultiTexCoord2fProc multiTexCoord2f = NULL;
105105
106 GLGenFramebuffersProc genFramebuffers = NULL;106 GLGenFramebuffersProc genFramebuffers = NULL;
107 GLDeleteFramebuffersProc deleteFramebuffers = NULL;107 GLDeleteFramebuffersProc deleteFramebuffers = NULL;
108 GLBindFramebufferProc bindFramebuffer = NULL;108 GLBindFramebufferProc bindFramebuffer = NULL;
109 GLCheckFramebufferStatusProc checkFramebufferStatus = NULL;109 GLCheckFramebufferStatusProc checkFramebufferStatus = NULL;
110 GLFramebufferTexture2DProc framebufferTexture2D = NULL;110 GLFramebufferTexture2DProc framebufferTexture2D = NULL;
111 GLGenerateMipmapProc generateMipmap = NULL;111 GLGenerateMipmapProc generateMipmap = NULL;
112112
113 GLBindBufferProc bindBuffer = NULL;113 GLBindBufferProc bindBuffer = NULL;
114 GLDeleteBuffersProc deleteBuffers = NULL;114 GLDeleteBuffersProc deleteBuffers = NULL;
115 GLGenBuffersProc genBuffers = NULL;115 GLGenBuffersProc genBuffers = NULL;
116 GLBufferDataProc bufferData = NULL;116 GLBufferDataProc bufferData = NULL;
117 GLBufferSubDataProc bufferSubData = NULL;117 GLBufferSubDataProc bufferSubData = NULL;
118118
119 GLGetShaderivProc getShaderiv = NULL;119 GLGetShaderivProc getShaderiv = NULL;
120 GLGetShaderInfoLogProc getShaderInfoLog = NULL;120 GLGetShaderInfoLogProc getShaderInfoLog = NULL;
121 GLGetProgramivProc getProgramiv = NULL;121 GLGetProgramivProc getProgramiv = NULL;
122 GLGetProgramInfoLogProc getProgramInfoLog = NULL;122 GLGetProgramInfoLogProc getProgramInfoLog = NULL;
123 GLCreateShaderProc createShader = NULL;123 GLCreateShaderProc createShader = NULL;
124 GLShaderSourceProc shaderSource = NULL;124 GLShaderSourceProc shaderSource = NULL;
125 GLCompileShaderProc compileShader = NULL;125 GLCompileShaderProc compileShader = NULL;
126 GLCreateProgramProc createProgram = NULL;126 GLCreateProgramProc createProgram = NULL;
127 GLAttachShaderProc attachShader = NULL;127 GLAttachShaderProc attachShader = NULL;
128 GLLinkProgramProc linkProgram = NULL;128 GLLinkProgramProc linkProgram = NULL;
129 GLValidateProgramProc validateProgram = NULL;129 GLValidateProgramProc validateProgram = NULL;
130 GLDeleteShaderProc deleteShader = NULL;130 GLDeleteShaderProc deleteShader = NULL;
131 GLDeleteProgramProc deleteProgram = NULL;131 GLDeleteProgramProc deleteProgram = NULL;
132 GLUseProgramProc useProgram = NULL;132 GLUseProgramProc useProgram = NULL;
133 GLGetUniformLocationProc getUniformLocation = NULL;133 GLGetUniformLocationProc getUniformLocation = NULL;
134 GLUniform1fProc uniform1f = NULL;134 GLUniform1fProc uniform1f = NULL;
135 GLUniform1iProc uniform1i = NULL;135 GLUniform1iProc uniform1i = NULL;
136 GLUniform2fProc uniform2f = NULL;136 GLUniform2fProc uniform2f = NULL;
137 GLUniform2iProc uniform2i = NULL;137 GLUniform2iProc uniform2i = NULL;
138 GLUniform3fProc uniform3f = NULL;138 GLUniform3fProc uniform3f = NULL;
139 GLUniform3iProc uniform3i = NULL;139 GLUniform3iProc uniform3i = NULL;
140 GLUniform4fProc uniform4f = NULL;140 GLUniform4fProc uniform4f = NULL;
141 GLUniform4iProc uniform4i = NULL;141 GLUniform4iProc uniform4i = NULL;
142 GLUniformMatrix4fvProc uniformMatrix4fv = NULL;142 GLUniformMatrix4fvProc uniformMatrix4fv = NULL;
143 GLGetAttribLocationProc getAttribLocation = NULL;143 GLGetAttribLocationProc getAttribLocation = NULL;
144144
145#ifndef USE_GLES145#ifndef USE_GLES
146146
147 GLCreateShaderObjectARBProc createShaderObjectARB = NULL;147 GLCreateShaderObjectARBProc createShaderObjectARB = NULL;
148 GLCreateProgramObjectARBProc createProgramObjectARB = NULL;148 GLCreateProgramObjectARBProc createProgramObjectARB = NULL;
149 GLCompileShaderARBProc compileShaderARB = NULL;149 GLCompileShaderARBProc compileShaderARB = NULL;
150 GLShaderSourceARBProc shaderSourceARB = NULL;150 GLShaderSourceARBProc shaderSourceARB = NULL;
151 GLValidateProgramARBProc validateProgramARB = NULL;151 GLValidateProgramARBProc validateProgramARB = NULL;
152 GLDeleteObjectARBProc deleteObjectARB = NULL;152 GLDeleteObjectARBProc deleteObjectARB = NULL;
153 GLAttachObjectARBProc attachObjectARB = NULL;153 GLAttachObjectARBProc attachObjectARB = NULL;
154 GLLinkProgramARBProc linkProgramARB = NULL;154 GLLinkProgramARBProc linkProgramARB = NULL;
155 GLUseProgramObjectARBProc useProgramObjectARB = NULL;155 GLUseProgramObjectARBProc useProgramObjectARB = NULL;
156 GLGetUniformLocationARBProc getUniformLocationARB = NULL;156 GLGetUniformLocationARBProc getUniformLocationARB = NULL;
157 GLGetAttribLocationARBProc getAttribLocationARB = NULL;157 GLGetAttribLocationARBProc getAttribLocationARB = NULL;
158 GLGetObjectParameterivProc getObjectParameteriv = NULL;158 GLGetObjectParameterivProc getObjectParameteriv = NULL;
159 GLGetInfoLogProc getInfoLog = NULL;159 GLGetInfoLogProc getInfoLog = NULL;
160160
161#endif161#endif
162162
163 GLEnableVertexAttribArrayProc enableVertexAttribArray = NULL;163 GLEnableVertexAttribArrayProc enableVertexAttribArray = NULL;
164 GLDisableVertexAttribArrayProc disableVertexAttribArray = NULL;164 GLDisableVertexAttribArrayProc disableVertexAttribArray = NULL;
165 GLVertexAttribPointerProc vertexAttribPointer = NULL;165 GLVertexAttribPointerProc vertexAttribPointer = NULL;
166166
167 GLGenRenderbuffersProc genRenderbuffers = NULL;167 GLGenRenderbuffersProc genRenderbuffers = NULL;
168 GLDeleteRenderbuffersProc deleteRenderbuffers = NULL;168 GLDeleteRenderbuffersProc deleteRenderbuffers = NULL;
169 GLFramebufferRenderbufferProc framebufferRenderbuffer = NULL;169 GLFramebufferRenderbufferProc framebufferRenderbuffer = NULL;
170 GLBindRenderbufferProc bindRenderbuffer = NULL;170 GLBindRenderbufferProc bindRenderbuffer = NULL;
171 GLRenderbufferStorageProc renderbufferStorage = NULL;171 GLRenderbufferStorageProc renderbufferStorage = NULL;
172172
173 bool textureFromPixmap = true;173 bool textureFromPixmap = true;
174 bool textureRectangle = false;174 bool textureRectangle = false;
175 bool textureNonPowerOfTwo = false;175 bool textureNonPowerOfTwo = false;
176 bool textureNonPowerOfTwoMipmap = false;176 bool textureNonPowerOfTwoMipmap = false;
177 bool textureEnvCombine = false;177 bool textureEnvCombine = false;
178 bool textureEnvCrossbar = false;178 bool textureEnvCrossbar = false;
179 bool textureBorderClamp = false;179 bool textureBorderClamp = false;
180 bool textureCompression = false;180 bool textureCompression = false;
181 GLint maxTextureSize = 0;181 GLint maxTextureSize = 0;
182 bool fboSupported = false;182 bool fboSupported = false;
183 bool fboEnabled = false;183 bool fboEnabled = false;
184 bool fboStencilSupported = false;184 bool fboStencilSupported = false;
185 bool vboSupported = false;185 bool vboSupported = false;
186 bool vboEnabled = false;186 bool vboEnabled = false;
187 bool shaders = false;187 bool shaders = false;
188 GLint maxTextureUnits = 1;188 GLint maxTextureUnits = 1;
189189
190 bool canDoSaturated = false;190 bool canDoSaturated = false;
191 bool canDoSlightlySaturated = false;191 bool canDoSlightlySaturated = false;
192192
193 unsigned int vsyncCount = 0;193 unsigned int vsyncCount = 0;
194194
195 bool stencilBuffer = false;195 bool stencilBuffer = false;
196#ifndef USE_GLES196#ifndef USE_GLES
197197
198 GLuint createShaderARBWrapper (GLenum type)198 GLuint createShaderARBWrapper (GLenum type)
@@ -205,7 +205,10 @@
205 return static_cast <GLuint> ((GL::createProgramObjectARB) ());205 return static_cast <GLuint> ((GL::createProgramObjectARB) ());
206 }206 }
207207
208 void shaderSourceARBWrapper (GLuint shader, GLsizei count, const GLchar **string, const GLint *length)208 void shaderSourceARBWrapper (GLuint shader,
209 GLsizei count,
210 const GLchar **string,
211 const GLint *length)
209 {212 {
210 (GL::shaderSourceARB) (static_cast <GLhandleARB> (shader), count, string, length);213 (GL::shaderSourceARB) (static_cast <GLhandleARB> (shader), count, string, length);
211 }214 }
@@ -230,7 +233,8 @@
230 (GL::deleteObjectARB) (static_cast <GLhandleARB> (program));233 (GL::deleteObjectARB) (static_cast <GLhandleARB> (program));
231 }234 }
232235
233 void attachShaderARBWrapper (GLuint program, GLuint shader)236 void attachShaderARBWrapper (GLuint program,
237 GLuint shader)
234 {238 {
235 (GL::attachObjectARB) (static_cast <GLhandleARB> (program), static_cast <GLhandleARB> (shader));239 (GL::attachObjectARB) (static_cast <GLhandleARB> (program), static_cast <GLhandleARB> (shader));
236 }240 }
@@ -245,32 +249,44 @@
245 (GL::useProgramObjectARB) (static_cast <GLhandleARB> (program));249 (GL::useProgramObjectARB) (static_cast <GLhandleARB> (program));
246 }250 }
247251
248 int getUniformLocationARBWrapper (GLuint program, const GLchar *name)252 int getUniformLocationARBWrapper (GLuint program,
253 const GLchar *name)
249 {254 {
250 return (GL::getUniformLocationARB) (static_cast <GLhandleARB> (program), name);255 return (GL::getUniformLocationARB) (static_cast <GLhandleARB> (program), name);
251 }256 }
252257
253 int getAttribLocationARBWrapper (GLuint program, const GLchar *name)258 int getAttribLocationARBWrapper (GLuint program,
259 const GLchar *name)
254 {260 {
255 return (GL::getAttribLocationARB) (static_cast <GLhandleARB> (program), name);261 return (GL::getAttribLocationARB) (static_cast <GLhandleARB> (program), name);
256 }262 }
257263
258 void getProgramInfoLogARBWrapper (GLuint object, int maxLen, int *len, char *log)264 void getProgramInfoLogARBWrapper (GLuint object,
259 {265 int maxLen,
260 (GL::getInfoLog) (static_cast <GLhandleARB> (object), maxLen, len, log);266 int *len,
261 }267 char *log)
262268 {
263 void getShaderInfoLogARBWrapper (GLuint object, int maxLen, int *len, char *log)269 (GL::getInfoLog) (static_cast <GLhandleARB> (object), maxLen, len, log);
264 {270 }
265 (GL::getInfoLog) (static_cast <GLhandleARB> (object), maxLen, len, log);271
266 }272 void getShaderInfoLogARBWrapper (GLuint object,
267273 int maxLen,
268 void getShaderivARBWrapper (GLuint object, GLenum type, int *param)274 int *len,
275 char *log)
276 {
277 (GL::getInfoLog) (static_cast <GLhandleARB> (object), maxLen, len, log);
278 }
279
280 void getShaderivARBWrapper (GLuint object,
281 GLenum type,
282 int *param)
269 {283 {
270 (GL::getObjectParameteriv) (static_cast <GLhandleARB> (object), type, param);284 (GL::getObjectParameteriv) (static_cast <GLhandleARB> (object), type, param);
271 }285 }
272286
273 void getProgramivARBWrapper (GLuint object, GLenum type, int *param)287 void getProgramivARBWrapper (GLuint object,
288 GLenum type,
289 int *param)
274 {290 {
275 (GL::getObjectParameteriv) (static_cast <GLhandleARB> (object), type, param);291 (GL::getObjectParameteriv) (static_cast <GLhandleARB> (object), type, param);
276 }292 }
@@ -286,14 +302,15 @@
286class GLScreenAutoProgram : public GLVertexBuffer::AutoProgram302class GLScreenAutoProgram : public GLVertexBuffer::AutoProgram
287{303{
288public:304public:
305
289 GLScreenAutoProgram (GLScreen *gScreen) : gScreen(gScreen) {}306 GLScreenAutoProgram (GLScreen *gScreen) : gScreen(gScreen) {}
290307
291 GLProgram *getProgram (GLShaderParameters &params)308 GLProgram *getProgram (GLShaderParameters &params)
292 {309 {
293 const GLShaderData *shaderData = gScreen->getShaderData (params);310 const GLShaderData *shaderData = gScreen->getShaderData (params);
294 std::list<const GLShaderData *> tempShaders;311 std::list<const GLShaderData *> tempShaders;
295 tempShaders.push_back (shaderData);312 tempShaders.push_back (shaderData);
296 return gScreen->getProgram (tempShaders);313 return gScreen->getProgram (tempShaders);
297 }314 }
298315
299 GLScreen *gScreen;316 GLScreen *gScreen;
@@ -341,13 +358,14 @@
341{358{
342namespace opengl359namespace opengl
343{360{
344void swapIntervalEGL (Display *display, int interval)361void swapIntervalEGL (Display *display,
362 int interval)
345{363{
346 eglSwapInterval (eglGetDisplay (display), interval);364 eglSwapInterval (eglGetDisplay (display), interval);
347}365}
348366
349int waitVSyncEGL (int wait,367int waitVSyncEGL (int wait,
350 int remainder,368 int remainder,
351 unsigned int *count)369 unsigned int *count)
352{370{
353 /* not supported */371 /* not supported */
@@ -365,37 +383,37 @@
365 DetectionWorkaround workaround;383 DetectionWorkaround workaround;
366#endif384#endif
367385
368 #ifdef USE_GLES386#ifdef USE_GLES
369 Display *xdpy;387 Window overlay;
370 Window overlay;388 EGLint major, minor;
371 EGLDisplay dpy;389 const char *eglExtensions, *glExtensions;
372 EGLConfig config;390 XWindowAttributes attr;
373 EGLint major, minor;391 EGLint count;
374 const char *eglExtensions, *glExtensions;392 EGLConfig configs[1024];
375 XWindowAttributes attr;393 CompOption::Vector o (0);
376 EGLint count, visualid;394
377 EGLConfig configs[1024];395 const EGLint config_attribs[] =
378 CompOption::Vector o (0);396 {
379397 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
380 const EGLint config_attribs[] = {398 EGL_RED_SIZE, 1,
381 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,399 EGL_GREEN_SIZE, 1,
382 EGL_RED_SIZE, 1,400 EGL_BLUE_SIZE, 1,
383 EGL_GREEN_SIZE, 1,401 EGL_ALPHA_SIZE, 0,
384 EGL_BLUE_SIZE, 1,402 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
385 EGL_ALPHA_SIZE, 0,403 EGL_CONFIG_CAVEAT, EGL_NONE,
386 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,404 EGL_STENCIL_SIZE, 1,
387 EGL_CONFIG_CAVEAT, EGL_NONE,405 EGL_NONE
388 EGL_STENCIL_SIZE, 1,406 };
389 EGL_NONE407
390 };408 const EGLint context_attribs[] =
391409 {
392 const EGLint context_attribs[] = {410 EGL_CONTEXT_CLIENT_VERSION, 2,
393 EGL_CONTEXT_CLIENT_VERSION, 2,411 EGL_NONE
394 EGL_NONE412 };
395 };413
396414 Display *xdpy = screen->dpy ();
397 xdpy = screen->dpy ();415 EGLDisplay dpy = eglGetDisplay ((EGLNativeDisplayType)xdpy);
398 dpy = eglGetDisplay ((EGLNativeDisplayType)xdpy);416
399 if (!eglInitialize (dpy, &major, &minor))417 if (!eglInitialize (dpy, &major, &minor))
400 {418 {
401 screen->handleCompizEvent ("opengl", "fatal_fallback", o);419 screen->handleCompizEvent ("opengl", "fatal_fallback", o);
@@ -416,27 +434,30 @@
416 return false;434 return false;
417 }435 }
418436
419 EGLint val;437 EGLint val;
420 int msaaBuffers = MAXSHORT;438 int msaaBuffers = MAXSHORT;
421 int msaaSamples = MAXSHORT;439 int msaaSamples = MAXSHORT;
422 visualid = XVisualIDFromVisual (attr.visual);440 EGLint visualid = XVisualIDFromVisual (attr.visual);
423 config = configs[0];441 EGLConfig config = configs[0];
424442
425 for (int i = 0; i < count; ++i)443 for (int i = 0; i < count; ++i)
426 {444 {
427 eglGetConfigAttrib (dpy, configs[i], EGL_SAMPLE_BUFFERS, &val);445 eglGetConfigAttrib (dpy, configs[i], EGL_SAMPLE_BUFFERS, &val);
446
428 if (val > msaaBuffers)447 if (val > msaaBuffers)
429 continue;448 continue;
430449
431 msaaBuffers = val;450 msaaBuffers = val;
432451
433 eglGetConfigAttrib (dpy, configs[i], EGL_SAMPLES, &val);452 eglGetConfigAttrib (dpy, configs[i], EGL_SAMPLES, &val);
453
434 if (val > msaaSamples)454 if (val > msaaSamples)
435 continue;455 continue;
436456
437 msaaSamples = val;457 msaaSamples = val;
438458
439 eglGetConfigAttrib (dpy, configs[i], EGL_NATIVE_VISUAL_ID, &val);459 eglGetConfigAttrib (dpy, configs[i], EGL_NATIVE_VISUAL_ID, &val);
460
440 if (val != visualid)461 if (val != visualid)
441 continue;462 continue;
442463
@@ -446,10 +467,11 @@
446467
447 overlay = CompositeScreen::get (screen)->overlay ();468 overlay = CompositeScreen::get (screen)->overlay ();
448 priv->surface = eglCreateWindowSurface (dpy, config, overlay, 0);469 priv->surface = eglCreateWindowSurface (dpy, config, overlay, 0);
470
449 if (priv->surface == EGL_NO_SURFACE)471 if (priv->surface == EGL_NO_SURFACE)
450 {472 {
451 compLogMessage ("opengl", CompLogLevelFatal,473 compLogMessage ("opengl", CompLogLevelFatal,
452 "eglCreateWindowSurface failed");474 "eglCreateWindowSurface failed");
453 screen->handleCompizEvent ("opengl", "fatal_fallback", o);475 screen->handleCompizEvent ("opengl", "fatal_fallback", o);
454 return false;476 return false;
455 }477 }
@@ -458,6 +480,7 @@
458 eglSurfaceAttrib (dpy, priv->surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED);480 eglSurfaceAttrib (dpy, priv->surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED);
459481
460 priv->ctx = eglCreateContext (dpy, config, EGL_NO_CONTEXT, context_attribs);482 priv->ctx = eglCreateContext (dpy, config, EGL_NO_CONTEXT, context_attribs);
483
461 if (priv->ctx == EGL_NO_CONTEXT)484 if (priv->ctx == EGL_NO_CONTEXT)
462 {485 {
463 compLogMessage ("opengl", CompLogLevelFatal, "eglCreateContext failed");486 compLogMessage ("opengl", CompLogLevelFatal, "eglCreateContext failed");
@@ -474,7 +497,7 @@
474 }497 }
475498
476 eglExtensions = (const char *) eglQueryString (dpy, EGL_EXTENSIONS);499 eglExtensions = (const char *) eglQueryString (dpy, EGL_EXTENSIONS);
477 glExtensions = (const char *) glGetString (GL_EXTENSIONS);500 glExtensions = (const char *) glGetString (GL_EXTENSIONS);
478501
479 if (!glExtensions || !eglExtensions)502 if (!glExtensions || !eglExtensions)
480 {503 {
@@ -484,15 +507,15 @@
484 return false;507 return false;
485 }508 }
486509
487 GL::textureFromPixmap = true;510 GL::textureFromPixmap = true;
488 GL::textureNonPowerOfTwo = true;511 GL::textureNonPowerOfTwo = true;
489 GL::fboSupported = true;512 GL::fboSupported = true;
490 GL::fboEnabled = true;513 GL::fboEnabled = true;
491 GL::vboSupported = true;514 GL::vboSupported = true;
492 GL::vboEnabled = true;515 GL::vboEnabled = true;
493 GL::shaders = true;516 GL::shaders = true;
494 GL::stencilBuffer = true;517 GL::stencilBuffer = true;
495 GL::maxTextureUnits = 4;518 GL::maxTextureUnits = 4;
496 glGetIntegerv (GL_MAX_TEXTURE_SIZE, &GL::maxTextureSize);519 glGetIntegerv (GL_MAX_TEXTURE_SIZE, &GL::maxTextureSize);
497520
498 GL::createImage = (GL::EGLCreateImageKHRProc)521 GL::createImage = (GL::EGLCreateImageKHRProc)
@@ -503,7 +526,7 @@
503 eglGetProcAddress ("glEGLImageTargetTexture2DOES");526 eglGetProcAddress ("glEGLImageTargetTexture2DOES");
504527
505 if (!strstr (eglExtensions, "EGL_KHR_image_pixmap") ||528 if (!strstr (eglExtensions, "EGL_KHR_image_pixmap") ||
506 !strstr (glExtensions, "GL_OES_EGL_image") ||529 !strstr (glExtensions, "GL_OES_EGL_image") ||
507 !GL::createImage || !GL::destroyImage || !GL::eglImageTargetTexture)530 !GL::createImage || !GL::destroyImage || !GL::eglImageTargetTexture)
508 {531 {
509 compLogMessage ("opengl", CompLogLevelFatal,532 compLogMessage ("opengl", CompLogLevelFatal,
@@ -531,7 +554,7 @@
531 eglGetProcAddress ("eglPostSubBufferNV");554 eglGetProcAddress ("eglPostSubBufferNV");
532555
533 GL::fboStencilSupported = GL::fboSupported &&556 GL::fboStencilSupported = GL::fboSupported &&
534 strstr (glExtensions, "GL_OES_packed_depth_stencil");557 strstr (glExtensions, "GL_OES_packed_depth_stencil");
535558
536 if (!GL::fboSupported &&559 if (!GL::fboSupported &&
537 !GL::postSubBuffer)560 !GL::postSubBuffer)
@@ -542,59 +565,64 @@
542 return false;565 return false;
543 }566 }
544567
545 GL::activeTexture = glActiveTexture;568 GL::activeTexture = glActiveTexture;
546 GL::genFramebuffers = glGenFramebuffers;569 GL::genFramebuffers = glGenFramebuffers;
547 GL::deleteFramebuffers = glDeleteFramebuffers;570 GL::deleteFramebuffers = glDeleteFramebuffers;
548 GL::bindFramebuffer = glBindFramebuffer;571 GL::bindFramebuffer = glBindFramebuffer;
549 GL::checkFramebufferStatus = glCheckFramebufferStatus;572 GL::checkFramebufferStatus = glCheckFramebufferStatus;
550 GL::framebufferTexture2D = glFramebufferTexture2D;573 GL::framebufferTexture2D = glFramebufferTexture2D;
551 GL::generateMipmap = glGenerateMipmap;574 GL::generateMipmap = glGenerateMipmap;
552575
553 GL::bindBuffer = glBindBuffer;576 GL::bindBuffer = glBindBuffer;
554 GL::deleteBuffers = glDeleteBuffers;577 GL::deleteBuffers = glDeleteBuffers;
555 GL::genBuffers = glGenBuffers;578 GL::genBuffers = glGenBuffers;
556 GL::bufferData = glBufferData;579 GL::bufferData = glBufferData;
557 GL::bufferSubData = glBufferSubData;580 GL::bufferSubData = glBufferSubData;
558581
559 GL::getShaderiv = glGetShaderiv;582 GL::getShaderiv = glGetShaderiv;
560 GL::getShaderInfoLog = glGetShaderInfoLog;583 GL::getShaderInfoLog = glGetShaderInfoLog;
561 GL::getProgramiv = glGetProgramiv;584 GL::getProgramiv = glGetProgramiv;
562 GL::getProgramInfoLog = glGetProgramInfoLog;585 GL::getProgramInfoLog = glGetProgramInfoLog;
563 GL::createShader = glCreateShader;586 GL::createShader = glCreateShader;
564 GL::shaderSource = (GL::GLShaderSourceProc) glShaderSource;587 GL::shaderSource = (GL::GLShaderSourceProc) glShaderSource;
565 GL::compileShader = glCompileShader;588 GL::compileShader = glCompileShader;
566 GL::createProgram = glCreateProgram;589 GL::createProgram = glCreateProgram;
567 GL::attachShader = glAttachShader;590 GL::attachShader = glAttachShader;
568 GL::linkProgram = glLinkProgram;591 GL::linkProgram = glLinkProgram;
569 GL::validateProgram = glValidateProgram;592 GL::validateProgram = glValidateProgram;
570 GL::deleteShader = glDeleteShader;593 GL::deleteShader = glDeleteShader;
571 GL::deleteProgram = glDeleteProgram;594 GL::deleteProgram = glDeleteProgram;
572 GL::useProgram = glUseProgram;595 GL::useProgram = glUseProgram;
573 GL::getUniformLocation = glGetUniformLocation;596 GL::getUniformLocation = glGetUniformLocation;
574 GL::uniform1f = glUniform1f;597 GL::uniform1f = glUniform1f;
575 GL::uniform1i = glUniform1i;598 GL::uniform1i = glUniform1i;
576 GL::uniform2f = glUniform2f;599 GL::uniform2f = glUniform2f;
577 GL::uniform2i = glUniform2i;600 GL::uniform2i = glUniform2i;
578 GL::uniform3f = glUniform3f;601 GL::uniform3f = glUniform3f;
579 GL::uniform3i = glUniform3i;602 GL::uniform3i = glUniform3i;
580 GL::uniform4f = glUniform4f;603 GL::uniform4f = glUniform4f;
581 GL::uniform4i = glUniform4i;604 GL::uniform4i = glUniform4i;
582 GL::uniformMatrix4fv = glUniformMatrix4fv;605 GL::uniformMatrix4fv = glUniformMatrix4fv;
583 GL::getAttribLocation = glGetAttribLocation;606 GL::getAttribLocation = glGetAttribLocation;
584607
585 GL::enableVertexAttribArray = glEnableVertexAttribArray;608 GL::enableVertexAttribArray = glEnableVertexAttribArray;
586 GL::disableVertexAttribArray = glDisableVertexAttribArray;609 GL::disableVertexAttribArray = glDisableVertexAttribArray;
587 GL::vertexAttribPointer = glVertexAttribPointer;610 GL::vertexAttribPointer = glVertexAttribPointer;
588611
589 GL::genRenderbuffers = glGenRenderbuffers;612 GL::genRenderbuffers = glGenRenderbuffers;
590 GL::deleteRenderbuffers = glDeleteRenderbuffers;613 GL::deleteRenderbuffers = glDeleteRenderbuffers;
591 GL::bindRenderbuffer = glBindRenderbuffer;614 GL::bindRenderbuffer = glBindRenderbuffer;
592 GL::framebufferRenderbuffer = glFramebufferRenderbuffer;615 GL::framebufferRenderbuffer = glFramebufferRenderbuffer;
593 GL::renderbufferStorage = glRenderbufferStorage;616 GL::renderbufferStorage = glRenderbufferStorage;
594617
595 glClearColor (0.0, 0.0, 0.0, 1.0);618 glClearColor (0.0, 0.0, 0.0, 1.0);
596 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);619 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
597 glEnable (GL_BLEND);620
621 GLboolean glBlendEnabled = glIsEnabled (GL_BLEND);
622
623 if (!glBlendEnabled)
624 glEnable (GL_BLEND);
625
598 glEnable (GL_CULL_FACE);626 glEnable (GL_CULL_FACE);
599627
600 priv->updateView ();628 priv->updateView ();
@@ -612,15 +640,16 @@
612640
613 #else641 #else
614642
615 Display *dpy = screen->dpy ();643 Display *dpy = screen->dpy ();
616 const char *glExtensions;644 const char *glExtensions;
617 GLfloat globalAmbient[] = { 0.1f, 0.1f, 0.1f, 0.1f };645 GLfloat globalAmbient[] = { 0.1f, 0.1f, 0.1f, 0.1f };
618 GLfloat ambientLight[] = { 0.0f, 0.0f, 0.0f, 0.0f };646 GLfloat ambientLight[] = { 0.0f, 0.0f, 0.0f, 0.0f };
619 GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 0.9f };647 GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 0.9f };
620 GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f };648 GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f };
621 CompOption::Vector o (0);649 CompOption::Vector o (0);
622650
623 priv->ctx = glXCreateContext (dpy, visinfo, NULL, True);651 priv->ctx = glXCreateContext (dpy, visinfo, NULL, True);
652
624 if (!priv->ctx)653 if (!priv->ctx)
625 {654 {
626 compLogMessage ("opengl", CompLogLevelWarn,655 compLogMessage ("opengl", CompLogLevelWarn,
@@ -648,6 +677,7 @@
648 glXMakeCurrent (dpy, CompositeScreen::get (screen)->output (), priv->ctx);677 glXMakeCurrent (dpy, CompositeScreen::get (screen)->output (), priv->ctx);
649678
650 glExtensions = (const char *) glGetString (GL_EXTENSIONS);679 glExtensions = (const char *) glGetString (GL_EXTENSIONS);
680
651 if (!glExtensions)681 if (!glExtensions)
652 {682 {
653 compLogMessage ("opengl", CompLogLevelFatal,683 compLogMessage ("opengl", CompLogLevelFatal,
@@ -656,13 +686,13 @@
656 return false;686 return false;
657 }687 }
658688
659 const char *glVendor = (const char *) glGetString (GL_VENDOR);689 const char *glVendor = (const char *) glGetString (GL_VENDOR);
660 const char *glRenderer = (const char *) glGetString (GL_RENDERER);690 const char *glRenderer = (const char *) glGetString (GL_RENDERER);
661 const char *glVersion = (const char *) glGetString (GL_VERSION);691 const char *glVersion = (const char *) glGetString (GL_VERSION);
662692
663 priv->glVendor = glVendor;693 priv->glVendor = glVendor;
664 priv->glRenderer = glRenderer;694 priv->glRenderer = glRenderer;
665 priv->glVersion = glVersion;695 priv->glVersion = glVersion;
666696
667 if (glRenderer != NULL &&697 if (glRenderer != NULL &&
668 (strcmp (glRenderer, "Software Rasterizer") == 0 ||698 (strcmp (glRenderer, "Software Rasterizer") == 0 ||
@@ -675,8 +705,9 @@
675 return false;705 return false;
676 }706 }
677707
678 priv->commonFrontbuffer = true;708 priv->commonFrontbuffer = true;
679 priv->incorrectRefreshRate = false;709 priv->incorrectRefreshRate = false;
710
680 if (glRenderer != NULL && strstr (glRenderer, "on llvmpipe"))711 if (glRenderer != NULL && strstr (glRenderer, "on llvmpipe"))
681 {712 {
682 /*713 /*
@@ -691,7 +722,7 @@
691722
692 if (glVendor != NULL && strstr (glVendor, "NVIDIA"))723 if (glVendor != NULL && strstr (glVendor, "NVIDIA"))
693 {724 {
694 /*725 /* TODO: Check if this is still necessary:
695 * NVIDIA provides an incorrect refresh rate, we need to726 * NVIDIA provides an incorrect refresh rate, we need to
696 * force 60Hz */727 * force 60Hz */
697 priv->incorrectRefreshRate = true;728 priv->incorrectRefreshRate = true;
@@ -699,6 +730,7 @@
699730
700 if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))731 if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))
701 GL::textureNonPowerOfTwo = true;732 GL::textureNonPowerOfTwo = true;
733
702 GL::textureNonPowerOfTwoMipmap = GL::textureNonPowerOfTwo;734 GL::textureNonPowerOfTwoMipmap = GL::textureNonPowerOfTwo;
703735
704 glGetIntegerv (GL_MAX_TEXTURE_SIZE, &GL::maxTextureSize);736 glGetIntegerv (GL_MAX_TEXTURE_SIZE, &GL::maxTextureSize);
@@ -714,6 +746,7 @@
714 GLint maxTextureSize;746 GLint maxTextureSize;
715747
716 glGetIntegerv (GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, &maxTextureSize);748 glGetIntegerv (GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, &maxTextureSize);
749
717 if (maxTextureSize > GL::maxTextureSize)750 if (maxTextureSize > GL::maxTextureSize)
718 GL::maxTextureSize = maxTextureSize;751 GL::maxTextureSize = maxTextureSize;
719 }752 }
@@ -731,7 +764,7 @@
731 {764 {
732 GL::textureEnvCombine = true;765 GL::textureEnvCombine = true;
733766
734 /* XXX: GL_NV_texture_env_combine4 need special code but it seams to767 /* XXX: GL_NV_texture_env_combine4 need special code but it seems to
735 be working anyway for now... */768 be working anyway for now... */
736 if (strstr (glExtensions, "GL_ARB_texture_env_crossbar") ||769 if (strstr (glExtensions, "GL_ARB_texture_env_crossbar") ||
737 strstr (glExtensions, "GL_NV_texture_env_combine4"))770 strstr (glExtensions, "GL_NV_texture_env_combine4"))
@@ -743,6 +776,7 @@
743 GL::textureBorderClamp = true;776 GL::textureBorderClamp = true;
744777
745 GL::maxTextureUnits = 1;778 GL::maxTextureUnits = 1;
779
746 if (strstr (glExtensions, "GL_ARB_multitexture"))780 if (strstr (glExtensions, "GL_ARB_multitexture"))
747 {781 {
748 GL::activeTexture = (GL::GLActiveTextureProc)782 GL::activeTexture = (GL::GLActiveTextureProc)
@@ -781,18 +815,17 @@
781 GL::renderbufferStorage = (GL::GLRenderbufferStorageProc)815 GL::renderbufferStorage = (GL::GLRenderbufferStorageProc)
782 getProcAddress ("glRenderbufferStorageEXT");816 getProcAddress ("glRenderbufferStorageEXT");
783817
784 if (GL::genFramebuffers &&818 if (GL::genFramebuffers &&
785 GL::deleteFramebuffers &&819 GL::deleteFramebuffers &&
786 GL::bindFramebuffer &&820 GL::bindFramebuffer &&
787 GL::checkFramebufferStatus &&821 GL::checkFramebufferStatus &&
788 GL::framebufferTexture2D &&822 GL::framebufferTexture2D &&
789 GL::generateMipmap &&823 GL::generateMipmap &&
790 GL::genRenderbuffers &&824 GL::genRenderbuffers &&
791 GL::deleteRenderbuffers &&825 GL::deleteRenderbuffers &&
792 GL::bindRenderbuffer &&826 GL::bindRenderbuffer &&
793 GL::framebufferRenderbuffer &&827 GL::framebufferRenderbuffer &&
794 GL::renderbufferStorage828 GL::renderbufferStorage)
795 )
796 GL::fboSupported = true;829 GL::fboSupported = true;
797 }830 }
798831
@@ -822,53 +855,53 @@
822855
823 priv->updateRenderMode ();856 priv->updateRenderMode ();
824857
825 if (strstr (glExtensions, "GL_ARB_fragment_shader") &&858 if (strstr (glExtensions, "GL_ARB_fragment_shader") &&
826 strstr (glExtensions, "GL_ARB_vertex_shader") &&859 strstr (glExtensions, "GL_ARB_vertex_shader") &&
827 strstr (glExtensions, "GL_ARB_shader_objects") &&860 strstr (glExtensions, "GL_ARB_shader_objects") &&
828 strstr (glExtensions, "GL_ARB_shading_language_100"))861 strstr (glExtensions, "GL_ARB_shading_language_100"))
829 {862 {
830 GL::getShaderiv = (GL::GLGetShaderivProc) GL::getShaderivARBWrapper;863 GL::getShaderiv = (GL::GLGetShaderivProc) GL::getShaderivARBWrapper;
831 GL::getShaderInfoLog = (GL::GLGetShaderInfoLogProc) GL::getShaderInfoLogARBWrapper;864 GL::getShaderInfoLog = (GL::GLGetShaderInfoLogProc) GL::getShaderInfoLogARBWrapper;
832 GL::getProgramiv = (GL::GLGetProgramivProc) GL::getProgramivARBWrapper;865 GL::getProgramiv = (GL::GLGetProgramivProc) GL::getProgramivARBWrapper;
833 GL::getProgramInfoLog = (GL::GLGetProgramInfoLogProc) GL::getProgramInfoLogARBWrapper;866 GL::getProgramInfoLog = (GL::GLGetProgramInfoLogProc) GL::getProgramInfoLogARBWrapper;
834 GL::getObjectParameteriv = (GL::GLGetObjectParameterivProc) getProcAddress ("glGetObjectParameterivARB");867 GL::getObjectParameteriv = (GL::GLGetObjectParameterivProc) getProcAddress ("glGetObjectParameterivARB");
835 GL::getInfoLog = (GL::GLGetInfoLogProc) getProcAddress ("glGetInfoLogARB");868 GL::getInfoLog = (GL::GLGetInfoLogProc) getProcAddress ("glGetInfoLogARB");
836 GL::createShader = (GL::GLCreateShaderProc) GL::createShaderARBWrapper;869 GL::createShader = (GL::GLCreateShaderProc) GL::createShaderARBWrapper;
837 GL::createShaderObjectARB = (GL::GLCreateShaderObjectARBProc) getProcAddress ("glCreateShaderObjectARB");870 GL::createShaderObjectARB = (GL::GLCreateShaderObjectARBProc) getProcAddress ("glCreateShaderObjectARB");
838 GL::shaderSource = (GL::GLShaderSourceProc) GL::shaderSourceARBWrapper;871 GL::shaderSource = (GL::GLShaderSourceProc) GL::shaderSourceARBWrapper;
839 GL::shaderSourceARB = (GL::GLShaderSourceARBProc) getProcAddress ("glShaderSourceARB");872 GL::shaderSourceARB = (GL::GLShaderSourceARBProc) getProcAddress ("glShaderSourceARB");
840 GL::compileShader = (GL::GLCompileShaderProc) GL::compileShaderARBWrapper;873 GL::compileShader = (GL::GLCompileShaderProc) GL::compileShaderARBWrapper;
841 GL::compileShaderARB = (GL::GLCompileShaderARBProc) getProcAddress ("glCompileShaderARB");874 GL::compileShaderARB = (GL::GLCompileShaderARBProc) getProcAddress ("glCompileShaderARB");
842 GL::createProgram = (GL::GLCreateProgramProc) GL::createProgramARBWrapper;875 GL::createProgram = (GL::GLCreateProgramProc) GL::createProgramARBWrapper;
843 GL::createProgramObjectARB = (GL::GLCreateProgramObjectARBProc) getProcAddress ("glCreateProgramObjectARB");876 GL::createProgramObjectARB = (GL::GLCreateProgramObjectARBProc) getProcAddress ("glCreateProgramObjectARB");
844 GL::attachShader = GL::attachShaderARBWrapper;877 GL::attachShader = GL::attachShaderARBWrapper;
845 GL::attachObjectARB = (GL::GLAttachObjectARBProc) getProcAddress ("glAttachObjectARB");878 GL::attachObjectARB = (GL::GLAttachObjectARBProc) getProcAddress ("glAttachObjectARB");
846 GL::linkProgram = GL::linkProgramARBWrapper;879 GL::linkProgram = GL::linkProgramARBWrapper;
847 GL::linkProgramARB = (GL::GLLinkProgramARBProc) getProcAddress ("glLinkProgramARB");880 GL::linkProgramARB = (GL::GLLinkProgramARBProc) getProcAddress ("glLinkProgramARB");
848 GL::validateProgram = GL::validateProgramARBWrapper;881 GL::validateProgram = GL::validateProgramARBWrapper;
849 GL::validateProgramARB = (GL::GLValidateProgramARBProc) getProcAddress ("glValidateProgramARB");882 GL::validateProgramARB = (GL::GLValidateProgramARBProc) getProcAddress ("glValidateProgramARB");
850 GL::deleteShader = GL::deleteShaderARBWrapper;883 GL::deleteShader = GL::deleteShaderARBWrapper;
851 GL::deleteProgram = GL::deleteProgramARBWrapper;884 GL::deleteProgram = GL::deleteProgramARBWrapper;
852 GL::deleteObjectARB = (GL::GLDeleteObjectARBProc) getProcAddress ("glDeleteObjectARB");885 GL::deleteObjectARB = (GL::GLDeleteObjectARBProc) getProcAddress ("glDeleteObjectARB");
853 GL::useProgram = GL::useProgramARBWrapper;886 GL::useProgram = GL::useProgramARBWrapper;
854 GL::useProgramObjectARB = (GL::GLUseProgramObjectARBProc) getProcAddress ("glUseProgramObjectARB");887 GL::useProgramObjectARB = (GL::GLUseProgramObjectARBProc) getProcAddress ("glUseProgramObjectARB");
855 GL::getUniformLocation = GL::getUniformLocationARBWrapper;888 GL::getUniformLocation = GL::getUniformLocationARBWrapper;
856 GL::getUniformLocationARB = (GL::GLGetUniformLocationARBProc) getProcAddress ("glGetUniformLocationARB");889 GL::getUniformLocationARB = (GL::GLGetUniformLocationARBProc) getProcAddress ("glGetUniformLocationARB");
857 GL::uniform1f = (GL::GLUniform1fProc) getProcAddress ("glUniform1fARB");890 GL::uniform1f = (GL::GLUniform1fProc) getProcAddress ("glUniform1fARB");
858 GL::uniform1i = (GL::GLUniform1iProc) getProcAddress ("glUniform1iARB");891 GL::uniform1i = (GL::GLUniform1iProc) getProcAddress ("glUniform1iARB");
859 GL::uniform2f = (GL::GLUniform2fProc) getProcAddress ("glUniform2fARB");892 GL::uniform2f = (GL::GLUniform2fProc) getProcAddress ("glUniform2fARB");
860 GL::uniform2i = (GL::GLUniform2iProc) getProcAddress ("glUniform2iARB");893 GL::uniform2i = (GL::GLUniform2iProc) getProcAddress ("glUniform2iARB");
861 GL::uniform3f = (GL::GLUniform3fProc) getProcAddress ("glUniform3fARB");894 GL::uniform3f = (GL::GLUniform3fProc) getProcAddress ("glUniform3fARB");
862 GL::uniform3i = (GL::GLUniform3iProc) getProcAddress ("glUniform3iARB");895 GL::uniform3i = (GL::GLUniform3iProc) getProcAddress ("glUniform3iARB");
863 GL::uniform4f = (GL::GLUniform4fProc) getProcAddress ("glUniform4fARB");896 GL::uniform4f = (GL::GLUniform4fProc) getProcAddress ("glUniform4fARB");
864 GL::uniform4i = (GL::GLUniform4iProc) getProcAddress ("glUniform4iARB");897 GL::uniform4i = (GL::GLUniform4iProc) getProcAddress ("glUniform4iARB");
865 GL::uniformMatrix4fv = (GL::GLUniformMatrix4fvProc) getProcAddress ("glUniformMatrix4fvARB");898 GL::uniformMatrix4fv = (GL::GLUniformMatrix4fvProc) getProcAddress ("glUniformMatrix4fvARB");
866 GL::getAttribLocation = (GL::GLGetAttribLocationProc) GL::getAttribLocationARBWrapper;899 GL::getAttribLocation = (GL::GLGetAttribLocationProc) GL::getAttribLocationARBWrapper;
867 GL::getAttribLocationARB = (GL::GLGetAttribLocationARBProc) getProcAddress ("glGetAttribLocationARB");900 GL::getAttribLocationARB = (GL::GLGetAttribLocationARBProc) getProcAddress ("glGetAttribLocationARB");
868901
869 GL::enableVertexAttribArray = (GL::GLEnableVertexAttribArrayProc) getProcAddress ("glEnableVertexAttribArrayARB");902 GL::enableVertexAttribArray = (GL::GLEnableVertexAttribArrayProc) getProcAddress ("glEnableVertexAttribArrayARB");
870 GL::disableVertexAttribArray = (GL::GLDisableVertexAttribArrayProc) getProcAddress ("glDisableVertexAttribArrayARB");903 GL::disableVertexAttribArray = (GL::GLDisableVertexAttribArrayProc) getProcAddress ("glDisableVertexAttribArrayARB");
871 GL::vertexAttribPointer = (GL::GLVertexAttribPointerProc) getProcAddress ("glVertexAttribPointerARB");904 GL::vertexAttribPointer = (GL::GLVertexAttribPointerProc) getProcAddress ("glVertexAttribPointerARB");
872905
873 GL::shaders = true;906 GL::shaders = true;
874 }907 }
@@ -886,6 +919,7 @@
886 if (GL::textureEnvCombine && GL::maxTextureUnits >= 2)919 if (GL::textureEnvCombine && GL::maxTextureUnits >= 2)
887 {920 {
888 GL::canDoSaturated = true;921 GL::canDoSaturated = true;
922
889 if (GL::textureEnvCrossbar && GL::maxTextureUnits >= 4)923 if (GL::textureEnvCrossbar && GL::maxTextureUnits >= 4)
890 GL::canDoSlightlySaturated = true;924 GL::canDoSlightlySaturated = true;
891 }925 }
@@ -905,7 +939,6 @@
905939
906 priv->lighting = false;940 priv->lighting = false;
907941
908
909 priv->filter[NOTHING_TRANS_FILTER] = GLTexture::Fast;942 priv->filter[NOTHING_TRANS_FILTER] = GLTexture::Fast;
910 priv->filter[SCREEN_TRANS_FILTER] = GLTexture::Good;943 priv->filter[SCREEN_TRANS_FILTER] = GLTexture::Good;
911 priv->filter[WINDOW_TRANS_FILTER] = GLTexture::Good;944 priv->filter[WINDOW_TRANS_FILTER] = GLTexture::Good;
@@ -936,13 +969,13 @@
936 DetectionWorkaround workaround;969 DetectionWorkaround workaround;
937#endif970#endif
938971
939 XVisualInfo *visinfo = NULL;972 XVisualInfo *visinfo = NULL;
940#ifndef USE_GLES973#ifndef USE_GLES
941 Display *dpy = s->dpy ();974 Display *dpy = s->dpy ();
942 XVisualInfo templ;975 XVisualInfo templ;
943 GLXFBConfig *fbConfigs;976 GLXFBConfig *fbConfigs;
944 int defaultDepth, nvisinfo, nElements, value, i;977 int defaultDepth, nvisinfo, nElements, value;
945 const char *glxExtensions;978 const char *glxExtensions;
946 XWindowAttributes attr;979 XWindowAttributes attr;
947 CompOption::Vector o (0);980 CompOption::Vector o (0);
948981
@@ -956,6 +989,7 @@
956 templ.visualid = XVisualIDFromVisual (attr.visual);989 templ.visualid = XVisualIDFromVisual (attr.visual);
957990
958 visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);991 visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
992
959 if (!nvisinfo)993 if (!nvisinfo)
960 {994 {
961 compLogMessage ("opengl", CompLogLevelFatal,995 compLogMessage ("opengl", CompLogLevelFatal,
@@ -968,6 +1002,7 @@
968 defaultDepth = visinfo->depth;1002 defaultDepth = visinfo->depth;
9691003
970 glXGetConfig (dpy, visinfo, GLX_USE_GL, &value);1004 glXGetConfig (dpy, visinfo, GLX_USE_GL, &value);
1005
971 if (!value)1006 if (!value)
972 {1007 {
973 compLogMessage ("opengl", CompLogLevelFatal,1008 compLogMessage ("opengl", CompLogLevelFatal,
@@ -979,6 +1014,7 @@
979 }1014 }
9801015
981 glXGetConfig (dpy, visinfo, GLX_DOUBLEBUFFER, &value);1016 glXGetConfig (dpy, visinfo, GLX_DOUBLEBUFFER, &value);
1017
982 if (!value)1018 if (!value)
983 {1019 {
984 compLogMessage ("opengl", CompLogLevelFatal,1020 compLogMessage ("opengl", CompLogLevelFatal,
@@ -994,8 +1030,8 @@
994 if (glxExtensions == NULL)1030 if (glxExtensions == NULL)
995 {1031 {
996 compLogMessage ("opengl", CompLogLevelFatal,1032 compLogMessage ("opengl", CompLogLevelFatal,
997 "glXQueryExtensionsString is NULL for screen %d",1033 "glXQueryExtensionsString is NULL for screen %d",
998 s->screenNum ());1034 s->screenNum ());
999 screen->handleCompizEvent ("opengl", "fatal_fallback", o);1035 screen->handleCompizEvent ("opengl", "fatal_fallback", o);
1000 setFailed ();1036 setFailed ();
1001 return;1037 return;
@@ -1010,25 +1046,17 @@
1010 return;1046 return;
1011 }1047 }
10121048
1013 priv->getProcAddress = (GL::GLXGetProcAddressProc)1049 priv->getProcAddress = (GL::GLXGetProcAddressProc) getProcAddress ("glXGetProcAddressARB");
1014 getProcAddress ("glXGetProcAddressARB");1050 GL::bindTexImage = (GL::GLXBindTexImageProc) getProcAddress ("glXBindTexImageEXT");
1015 GL::bindTexImage = (GL::GLXBindTexImageProc)1051 GL::releaseTexImage = (GL::GLXReleaseTexImageProc) getProcAddress ("glXReleaseTexImageEXT");
1016 getProcAddress ("glXBindTexImageEXT");1052 GL::queryDrawable = (GL::GLXQueryDrawableProc) getProcAddress ("glXQueryDrawable");
1017 GL::releaseTexImage = (GL::GLXReleaseTexImageProc)1053 GL::getFBConfigs = (GL::GLXGetFBConfigsProc) getProcAddress ("glXGetFBConfigs");
1018 getProcAddress ("glXReleaseTexImageEXT");1054 GL::getFBConfigAttrib = (GL::GLXGetFBConfigAttribProc) getProcAddress ("glXGetFBConfigAttrib");
1019 GL::queryDrawable = (GL::GLXQueryDrawableProc)1055 GL::createPixmap = (GL::GLXCreatePixmapProc) getProcAddress ("glXCreatePixmap");
1020 getProcAddress ("glXQueryDrawable");1056 GL::destroyPixmap = (GL::GLXDestroyPixmapProc) getProcAddress ("glXDestroyPixmap");
1021 GL::getFBConfigs = (GL::GLXGetFBConfigsProc)
1022 getProcAddress ("glXGetFBConfigs");
1023 GL::getFBConfigAttrib = (GL::GLXGetFBConfigAttribProc)
1024 getProcAddress ("glXGetFBConfigAttrib");
1025 GL::createPixmap = (GL::GLXCreatePixmapProc)
1026 getProcAddress ("glXCreatePixmap");
1027 GL::destroyPixmap = (GL::GLXDestroyPixmapProc)
1028 getProcAddress ("glXDestroyPixmap");
10291057
1030 if (!strstr (glxExtensions, "GLX_EXT_texture_from_pixmap") ||1058 if (!strstr (glxExtensions, "GLX_EXT_texture_from_pixmap") ||
1031 !GL::bindTexImage || !GL::releaseTexImage)1059 !GL::bindTexImage || !GL::releaseTexImage)
1032 {1060 {
1033 compLogMessage ("opengl", CompLogLevelFatal,1061 compLogMessage ("opengl", CompLogLevelFatal,
1034 "GLX_EXT_texture_from_pixmap is missing");1062 "GLX_EXT_texture_from_pixmap is missing");
@@ -1051,52 +1079,46 @@
1051 }1079 }
10521080
1053 if (strstr (glxExtensions, "GLX_MESA_copy_sub_buffer"))1081 if (strstr (glxExtensions, "GLX_MESA_copy_sub_buffer"))
1054 GL::copySubBuffer = (GL::GLXCopySubBufferProc)1082 GL::copySubBuffer = (GL::GLXCopySubBufferProc) getProcAddress ("glXCopySubBufferMESA");
1055 getProcAddress ("glXCopySubBufferMESA");
10561083
1057 if (strstr (glxExtensions, "GLX_SGI_video_sync"))1084 if (strstr (glxExtensions, "GLX_SGI_video_sync"))
1058 {1085 {
1059 GL::getVideoSync = (GL::GLXGetVideoSyncProc)1086 GL::getVideoSync = (GL::GLXGetVideoSyncProc) getProcAddress ("glXGetVideoSyncSGI");
1060 getProcAddress ("glXGetVideoSyncSGI");1087 GL::waitVideoSync = (GL::GLXWaitVideoSyncProc) getProcAddress ("glXWaitVideoSyncSGI");
1061
1062 GL::waitVideoSync = (GL::GLXWaitVideoSyncProc)
1063 getProcAddress ("glXWaitVideoSyncSGI");
1064 }1088 }
10651089
1066 if (strstr (glxExtensions, "GLX_SGI_swap_control"))1090 if (strstr (glxExtensions, "GLX_SGI_swap_control"))
1067 {1091 {
1068 GL::swapInterval = (GL::GLXSwapIntervalProc)1092 GL::swapInterval = (GL::GLXSwapIntervalProc) getProcAddress ("glXSwapIntervalSGI");
1069 getProcAddress ("glXSwapIntervalSGI");
1070 }1093 }
10711094
1072 fbConfigs = (*GL::getFBConfigs) (dpy, s->screenNum (), &nElements);1095 fbConfigs = (*GL::getFBConfigs) (dpy, s->screenNum (), &nElements);
10731096
1074 GL::stencilBuffer = false;1097 GL::stencilBuffer = false;
10751098
1076 for (i = 0; i <= MAX_DEPTH; i++)1099 int alpha;
1100 int db = MAXSHORT;
1101 int stencil = MAXSHORT;
1102 int depth = MAXSHORT;
1103 int msaaBuffers = MAXSHORT;
1104 int msaaSamples = MAXSHORT;
1105 int mipmap = 0;
1106 int rgba = 0;
1107 int visualDepth;
1108 XVisualInfo *vi;
1109
1110 for (int i = 0; i <= MAX_DEPTH; ++i)
1077 {1111 {
1078 int j, db, stencil, depth, alpha, mipmap, msaaBuffers, msaaSamples, rgba;
1079
1080 priv->glxPixmapFBConfigs[i].fbConfig = NULL;1112 priv->glxPixmapFBConfigs[i].fbConfig = NULL;
1081 priv->glxPixmapFBConfigs[i].mipmap = 0;1113 priv->glxPixmapFBConfigs[i].mipmap = 0;
1082 priv->glxPixmapFBConfigs[i].yInverted = 0;1114 priv->glxPixmapFBConfigs[i].yInverted = 0;
1083 priv->glxPixmapFBConfigs[i].textureFormat = 0;1115 priv->glxPixmapFBConfigs[i].textureFormat = 0;
1084 priv->glxPixmapFBConfigs[i].textureTargets = 0;1116 priv->glxPixmapFBConfigs[i].textureTargets = 0;
10851117
1086 db = MAXSHORT;1118 for (int j = 0; j < nElements; ++j)
1087 stencil = MAXSHORT;
1088 depth = MAXSHORT;
1089 msaaBuffers = MAXSHORT;
1090 msaaSamples = MAXSHORT;
1091 mipmap = 0;
1092 rgba = 0;
1093
1094 for (j = 0; j < nElements; j++)
1095 {1119 {
1096 XVisualInfo *vi;
1097 int visualDepth;
1098
1099 vi = glXGetVisualFromFBConfig (dpy, fbConfigs[j]);1120 vi = glXGetVisualFromFBConfig (dpy, fbConfigs[j]);
1121
1100 if (vi == NULL)1122 if (vi == NULL)
1101 continue;1123 continue;
11021124
@@ -1107,14 +1129,14 @@
1107 if (visualDepth != i)1129 if (visualDepth != i)
1108 continue;1130 continue;
11091131
1110 (*GL::getFBConfigAttrib) (dpy, fbConfigs[j],1132 (*GL::getFBConfigAttrib) (dpy, fbConfigs[j], GLX_ALPHA_SIZE, &alpha);
1111 GLX_ALPHA_SIZE, &alpha);1133 (*GL::getFBConfigAttrib) (dpy, fbConfigs[j], GLX_BUFFER_SIZE, &value);
1112 (*GL::getFBConfigAttrib) (dpy, fbConfigs[j],1134
1113 GLX_BUFFER_SIZE, &value);
1114 if (value != i && (value - alpha) != i)1135 if (value != i && (value - alpha) != i)
1115 continue;1136 continue;
11161137
1117 value = 0;1138 value = 0;
1139
1118 if (i == 32)1140 if (i == 32)
1119 {1141 {
1120 (*GL::getFBConfigAttrib) (dpy, fbConfigs[j],1142 (*GL::getFBConfigAttrib) (dpy, fbConfigs[j],
@@ -1167,14 +1189,14 @@
1167 (*GL::getFBConfigAttrib) (dpy, fbConfigs[j],1189 (*GL::getFBConfigAttrib) (dpy, fbConfigs[j],
1168 GLX_SAMPLE_BUFFERS, &value);1190 GLX_SAMPLE_BUFFERS, &value);
1169 if (value > msaaBuffers)1191 if (value > msaaBuffers)
1170 continue;1192 continue;
11711193
1172 msaaBuffers = value;1194 msaaBuffers = value;
11731195
1174 (*GL::getFBConfigAttrib) (dpy, fbConfigs[j],1196 (*GL::getFBConfigAttrib) (dpy, fbConfigs[j],
1175 GLX_SAMPLES, &value);1197 GLX_SAMPLES, &value);
1176 if (value > msaaSamples)1198 if (value > msaaSamples)
1177 continue;1199 continue;
11781200
1179 msaaSamples = value;1201 msaaSamples = value;
11801202
@@ -1194,14 +1216,12 @@
1194 GLX_BIND_TO_TEXTURE_TARGETS_EXT, &value);1216 GLX_BIND_TO_TEXTURE_TARGETS_EXT, &value);
11951217
1196 priv->glxPixmapFBConfigs[i].textureTargets = value;1218 priv->glxPixmapFBConfigs[i].textureTargets = value;
11971219 priv->glxPixmapFBConfigs[i].fbConfig = fbConfigs[j];
1198 priv->glxPixmapFBConfigs[i].fbConfig = fbConfigs[j];1220 priv->glxPixmapFBConfigs[i].mipmap = mipmap;
1199 priv->glxPixmapFBConfigs[i].mipmap = mipmap;
1200 }1221 }
12011222
1202 if (i == defaultDepth)1223 if (i == defaultDepth && stencil != MAXSHORT)
1203 if (stencil != MAXSHORT)1224 GL::stencilBuffer = true;
1204 GL::stencilBuffer = true;
1205 }1225 }
12061226
1207 if (nElements)1227 if (nElements)
@@ -1227,12 +1247,14 @@
1227 CompositeScreen::get (screen)->unregisterPaintHandler ();1247 CompositeScreen::get (screen)->unregisterPaintHandler ();
12281248
1229 #ifdef USE_GLES1249 #ifdef USE_GLES
1230 Display *xdpy = screen->dpy ();1250 Display *xdpy = screen->dpy ();
1231 EGLDisplay dpy = eglGetDisplay (xdpy);1251 EGLDisplay dpy = eglGetDisplay (xdpy);
12321252
1233 eglMakeCurrent (dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);1253 eglMakeCurrent (dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
1254
1234 if (priv->ctx != EGL_NO_CONTEXT)1255 if (priv->ctx != EGL_NO_CONTEXT)
1235 eglDestroyContext (dpy, priv->ctx);1256 eglDestroyContext (dpy, priv->ctx);
1257
1236 eglDestroySurface (dpy, priv->surface);1258 eglDestroySurface (dpy, priv->surface);
1237 eglTerminate (dpy);1259 eglTerminate (dpy);
1238 eglReleaseThread ();1260 eglReleaseThread ();
@@ -1248,12 +1270,14 @@
1248 delete priv;1270 delete priv;
1249}1271}
12501272
1251PrivateGLScreen::PrivateGLScreen (GLScreen *gs) :1273PrivateGLScreen::PrivateGLScreen (GLScreen *gs) :
1252 gScreen (gs),1274 gScreen (gs),
1253 cScreen (CompositeScreen::get (screen)),1275 cScreen (CompositeScreen::get (screen)),
1254 textureFilter (GL_LINEAR),1276 textureFilter (GL_LINEAR),
1277 glxPixmapFBConfigs (),
1255 backgroundTextures (),1278 backgroundTextures (),
1256 backgroundLoaded (false),1279 backgroundLoaded (false),
1280 filter (),
1257 rasterPos (0, 0),1281 rasterPos (0, 0),
1258 projection (NULL),1282 projection (NULL),
1259 clearBuffers (true),1283 clearBuffers (true),
@@ -1268,15 +1292,17 @@
1268 #endif1292 #endif
1269 scratchFbo (NULL),1293 scratchFbo (NULL),
1270 outputRegion (),1294 outputRegion (),
1295 lastViewport (),
1271 refreshSubBuffer (false),1296 refreshSubBuffer (false),
1272 lastMask (0),1297 lastMask (0),
1273 bindPixmap (),1298 bindPixmap (),
1274 hasCompositing (false),1299 hasCompositing (false),
1275 commonFrontbuffer (true),1300 commonFrontbuffer (true),
1276 incorrectRefreshRate (false),1301 incorrectRefreshRate (false),
1302 saveWindow (),
1277 programCache (new GLProgramCache (30)),1303 programCache (new GLProgramCache (30)),
1278 shaderCache (),1304 shaderCache (),
1279 autoProgram (new GLScreenAutoProgram(gs)),1305 autoProgram (new GLScreenAutoProgram (gs)),
1280 rootPixmapCopy (None),1306 rootPixmapCopy (None),
1281 rootPixmapSize (),1307 rootPixmapSize (),
1282 glVendor (NULL),1308 glVendor (NULL),
@@ -1293,15 +1319,13 @@
1293 delete projection;1319 delete projection;
1294 delete programCache;1320 delete programCache;
1295 delete autoProgram;1321 delete autoProgram;
1322
1296 if (rootPixmapCopy)1323 if (rootPixmapCopy)
1297 XFreePixmap (screen->dpy (), rootPixmapCopy);1324 XFreePixmap (screen->dpy (), rootPixmapCopy);
1298
1299}1325}
13001326
1301GLushort defaultColor[4] = { 0xffff, 0xffff, 0xffff, 0xffff };1327GLushort defaultColor[4] = { 0xffff, 0xffff, 0xffff, 0xffff };
13021328
1303
1304
1305GLenum1329GLenum
1306GLScreen::textureFilter ()1330GLScreen::textureFilter ()
1307{1331{
@@ -1321,11 +1345,14 @@
13211345
1322 screen->handleEvent (event);1346 screen->handleEvent (event);
13231347
1324 switch (event->type) {1348 switch (event->type)
1349 {
1325 case ConfigureNotify:1350 case ConfigureNotify:
1326 if (event->xconfigure.window == screen->root ())1351 if (event->xconfigure.window == screen->root ())
1327 updateScreenBackground ();1352 updateScreenBackground ();
1353
1328 break;1354 break;
1355
1329 case PropertyNotify:1356 case PropertyNotify:
1330 if (event->xproperty.atom == Atoms::xBackground[0] ||1357 if (event->xproperty.atom == Atoms::xBackground[0] ||
1331 event->xproperty.atom == Atoms::xBackground[1])1358 event->xproperty.atom == Atoms::xBackground[1])
@@ -1338,15 +1365,18 @@
1338 event->xproperty.atom == Atoms::winSaturation)1365 event->xproperty.atom == Atoms::winSaturation)
1339 {1366 {
1340 w = screen->findWindow (event->xproperty.window);1367 w = screen->findWindow (event->xproperty.window);
1368
1341 if (w)1369 if (w)
1342 GLWindow::get (w)->updatePaintAttribs ();1370 GLWindow::get (w)->updatePaintAttribs ();
1343 }1371 }
1344 else if (event->xproperty.atom == Atoms::wmIcon)1372 else if (event->xproperty.atom == Atoms::wmIcon)
1345 {1373 {
1346 w = screen->findWindow (event->xproperty.window);1374 w = screen->findWindow (event->xproperty.window);
1375
1347 if (w)1376 if (w)
1348 GLWindow::get (w)->priv->icons.clear ();1377 GLWindow::get (w)->priv->icons.clear ();
1349 }1378 }
1379
1350 break;1380 break;
13511381
1352 default:1382 default:
@@ -1362,9 +1392,7 @@
1362 boundPixmapTex.find (de->damage);1392 boundPixmapTex.find (de->damage);
1363 #endif1393 #endif
1364 if (it != boundPixmapTex.end ())1394 if (it != boundPixmapTex.end ())
1365 {
1366 it->second->damaged = true;1395 it->second->damaged = true;
1367 }
13681396
1369 /* XXX: It would be nice if we could also update1397 /* XXX: It would be nice if we could also update
1370 * the background of the root window when the root1398 * the background of the root window when the root
@@ -1374,6 +1402,7 @@
1374 * be recopying the root window pixmap all the time1402 * be recopying the root window pixmap all the time
1375 * which is no good, so don't do that */1403 * which is no good, so don't do that */
1376 }1404 }
1405
1377 break;1406 break;
1378 }1407 }
1379}1408}
@@ -1384,7 +1413,6 @@
1384 clearOutput (targetOutput, mask);1413 clearOutput (targetOutput, mask);
1385}1414}
13861415
1387
1388static void1416static void
1389frustum (GLfloat *m,1417frustum (GLfloat *m,
1390 GLfloat left,1418 GLfloat left,
@@ -1394,14 +1422,12 @@
1394 GLfloat nearval,1422 GLfloat nearval,
1395 GLfloat farval)1423 GLfloat farval)
1396{1424{
1397 GLfloat x, y, a, b, c, d;1425 GLfloat x = (2.0 * nearval) / (right - left);
13981426 GLfloat y = (2.0 * nearval) / (top - bottom);
1399 x = (2.0 * nearval) / (right - left);1427 GLfloat a = (right + left) / (right - left);
1400 y = (2.0 * nearval) / (top - bottom);1428 GLfloat b = (top + bottom) / (top - bottom);
1401 a = (right + left) / (right - left);1429 GLfloat c = -(farval + nearval) / (farval - nearval);
1402 b = (top + bottom) / (top - bottom);1430 GLfloat d = -(2.0 * farval * nearval) / (farval - nearval);
1403 c = -(farval + nearval) / ( farval - nearval);
1404 d = -(2.0 * farval * nearval) / (farval - nearval);
14051431
1406#define M(row,col) m[col * 4 + row]1432#define M(row,col) m[col * 4 + row]
1407 M(0,0) = x; M(0,1) = 0.0f; M(0,2) = a; M(0,3) = 0.0f;1433 M(0,0) = x; M(0,1) = 0.0f; M(0,2) = a; M(0,3) = 0.0f;
@@ -1419,12 +1445,10 @@
1419 GLfloat zNear,1445 GLfloat zNear,
1420 GLfloat zFar)1446 GLfloat zFar)
1421{1447{
1422 GLfloat xmin, xmax, ymin, ymax;1448 GLfloat ymax = zNear * tan (fovy * M_PI / 360.0);
14231449 GLfloat ymin = -ymax;
1424 ymax = zNear * tan (fovy * M_PI / 360.0);1450 GLfloat xmin = ymin * aspect;
1425 ymin = -ymax;1451 GLfloat xmax = ymax * aspect;
1426 xmin = ymin * aspect;
1427 xmax = ymax * aspect;
14281452
1429 frustum (m, xmin, xmax, ymin, ymax, zNear, zFar);1453 frustum (m, xmin, xmax, ymin, ymax, zNear, zFar);
1430}1454}
@@ -1450,6 +1474,7 @@
14501474
1451 if (projection != NULL)1475 if (projection != NULL)
1452 delete projection;1476 delete projection;
1477
1453 projection = new GLMatrix (projection_array);1478 projection = new GLMatrix (projection_array);
14541479
1455 #ifndef USE_GLES1480 #ifndef USE_GLES
@@ -1478,6 +1503,7 @@
14781503
1479 if (scratchFbo)1504 if (scratchFbo)
1480 scratchFbo->allocate (*screen, NULL, GL_BGRA);1505 scratchFbo->allocate (*screen, NULL, GL_BGRA);
1506
1481 updateView ();1507 updateView ();
1482}1508}
14831509
@@ -1500,6 +1526,7 @@
1500 {1526 {
1501 dlerror ();1527 dlerror ();
1502 funcPtr = (GL::FuncPtr) dlsym (dlhand, name);1528 funcPtr = (GL::FuncPtr) dlsym (dlhand, name);
1529
1503 if (dlerror () != NULL)1530 if (dlerror () != NULL)
1504 funcPtr = NULL;1531 funcPtr = NULL;
1505 }1532 }
@@ -1512,18 +1539,18 @@
1512void1539void
1513PrivateGLScreen::updateScreenBackground ()1540PrivateGLScreen::updateScreenBackground ()
1514{1541{
1515 Display *dpy = screen->dpy ();1542 Display *dpy = screen->dpy ();
1516 Atom pixmapAtom, actualType;1543 Atom actualType;
1517 int actualFormat, i, status;1544 int actualFormat, status;
1518 unsigned int width = 1, height = 1, depth = 0;1545 unsigned int width = 1, height = 1, depth = 0;
1519 unsigned long nItems;1546 unsigned long nItems;
1520 unsigned long bytesAfter;1547 unsigned long bytesAfter;
1521 unsigned char *prop;1548 unsigned char *prop;
1522 Pixmap pixmap = None;1549 Pixmap pixmap = None;
15231550
1524 pixmapAtom = XInternAtom (dpy, "PIXMAP", false);1551 Atom pixmapAtom = XInternAtom (dpy, "PIXMAP", false);
15251552
1526 for (i = 0; pixmap == 0 && i < 2; i++)1553 for (int i = 0; pixmap == 0 && i < 2; ++i)
1527 {1554 {
1528 status = XGetWindowProperty (dpy, screen->root (),1555 status = XGetWindowProperty (dpy, screen->root (),
1529 Atoms::xBackground[i],1556 Atoms::xBackground[i],
@@ -1544,15 +1571,13 @@
1544 if (p)1571 if (p)
1545 {1572 {
1546 unsigned int ui;1573 unsigned int ui;
1547 int i;1574 int i;
1548 Window w;1575 Window w;
15491576
1550 if (XGetGeometry (dpy, p, &w, &i, &i,1577 if (XGetGeometry (dpy, p, &w, &i, &i,
1551 &width, &height, &ui, &depth))1578 &width, &height, &ui, &depth) &&
1552 {1579 (int) depth == screen->attrib ().depth)
1553 if ((int) depth == screen->attrib ().depth)1580 pixmap = p;
1554 pixmap = p;
1555 }
1556 }1581 }
1557 }1582 }
15581583
@@ -1564,17 +1589,14 @@
1564 {1589 {
1565 backgroundTextures =1590 backgroundTextures =
1566 GLTexture::bindPixmapToTexture (pixmap, width, height, depth);1591 GLTexture::bindPixmapToTexture (pixmap, width, height, depth);
1592
1567 if (backgroundTextures.empty ())1593 if (backgroundTextures.empty ())
1568 {
1569 compLogMessage ("core", CompLogLevelWarn,1594 compLogMessage ("core", CompLogLevelWarn,
1570 "Couldn't bind background pixmap 0x%x to "1595 "Couldn't bind background pixmap 0x%x to "
1571 "texture", (int) pixmap);1596 "texture", (int) pixmap);
1572 }
1573 }1597 }
1574 else1598 else
1575 {
1576 backgroundTextures.clear ();1599 backgroundTextures.clear ();
1577 }
15781600
1579 if (backgroundTextures.empty ())1601 if (backgroundTextures.empty ())
1580 {1602 {
@@ -1584,7 +1606,7 @@
1584 GC gc;1606 GC gc;
15851607
1586 gcv.graphics_exposures = false;1608 gcv.graphics_exposures = false;
1587 gcv.subwindow_mode = IncludeInferiors;1609 gcv.subwindow_mode = IncludeInferiors;
1588 gc = XCreateGC (screen->dpy (), screen->root (),1610 gc = XCreateGC (screen->dpy (), screen->root (),
1589 GCGraphicsExposures | GCSubwindowMode, &gcv);1611 GCGraphicsExposures | GCSubwindowMode, &gcv);
15901612
@@ -1605,11 +1627,9 @@
1605 DefaultDepth (screen->dpy (), DefaultScreen (screen->dpy ())));1627 DefaultDepth (screen->dpy (), DefaultScreen (screen->dpy ())));
16061628
1607 if (backgroundTextures.empty ())1629 if (backgroundTextures.empty ())
1608 {
1609 compLogMessage ("core", CompLogLevelWarn,1630 compLogMessage ("core", CompLogLevelWarn,
1610 "Couldn't bind background pixmap 0x%x to "1631 "Couldn't bind background pixmap 0x%x to "
1611 "texture", (int) screen->width ());1632 "texture", (int) screen->width ());
1612 }
1613 }1633 }
16141634
1615 if (rootPixmapCopy)1635 if (rootPixmapCopy)
@@ -1619,9 +1639,7 @@
1619 XSync (screen->dpy (), false);1639 XSync (screen->dpy (), false);
1620 }1640 }
1621 else1641 else
1622 {
1623 backgroundTextures.clear ();1642 backgroundTextures.clear ();
1624 }
16251643
1626 XFreeGC(dpy, gc);1644 XFreeGC(dpy, gc);
1627 }1645 }
@@ -1711,7 +1729,7 @@
1711void1729void
1712GLScreenInterface::glBufferStencil(const GLMatrix &matrix,1730GLScreenInterface::glBufferStencil(const GLMatrix &matrix,
1713 GLVertexBuffer &vertexBuffer,1731 GLVertexBuffer &vertexBuffer,
1714 CompOutput *output)1732 CompOutput *output)
1715 WRAPABLE_DEF (glBufferStencil, matrix, vertexBuffer, output)1733 WRAPABLE_DEF (glBufferStencil, matrix, vertexBuffer, output)
17161734
1717GLMatrix *1735GLMatrix *
@@ -1747,7 +1765,8 @@
1747}1765}
17481766
1749void1767void
1750GLScreen::setFilter (int num, GLTexture::Filter filter)1768GLScreen::setFilter (int num,
1769 GLTexture::Filter filter)
1751{1770{
1752 priv->filter[num] = filter;1771 priv->filter[num] = filter;
1753}1772}
@@ -1766,9 +1785,9 @@
1766{1785{
1767 BoxPtr pBox = &output->region ()->extents;1786 BoxPtr pBox = &output->region ()->extents;
17681787
1769 if (pBox->x1 != 0 ||1788 if (pBox->x1 != 0 ||
1770 pBox->y1 != 0 ||1789 pBox->y1 != 0 ||
1771 pBox->x2 != (int) screen->width () ||1790 pBox->x2 != (int) screen->width () ||
1772 pBox->y2 != (int) screen->height ())1791 pBox->y2 != (int) screen->height ())
1773 {1792 {
1774 glEnable (GL_SCISSOR_TEST);1793 glEnable (GL_SCISSOR_TEST);
@@ -1780,9 +1799,7 @@
1780 glDisable (GL_SCISSOR_TEST);1799 glDisable (GL_SCISSOR_TEST);
1781 }1800 }
1782 else1801 else
1783 {
1784 glClear (mask);1802 glClear (mask);
1785 }
1786}1803}
17871804
1788void1805void
@@ -1825,7 +1842,7 @@
1825 const compiz::opengl::impl::GLXSwapIntervalEXTFunc &swapIntervalFunc,1842 const compiz::opengl::impl::GLXSwapIntervalEXTFunc &swapIntervalFunc,
1826 const compiz::opengl::impl::GLXWaitVideoSyncSGIFunc &waitVideoSyncFunc) :1843 const compiz::opengl::impl::GLXWaitVideoSyncSGIFunc &waitVideoSyncFunc) :
1827 compiz::opengl::DoubleBuffer (swapIntervalFunc, waitVideoSyncFunc),1844 compiz::opengl::DoubleBuffer (swapIntervalFunc, waitVideoSyncFunc),
1828 mDpy (d),1845 mDpy (d),
1829 mSize (s)1846 mSize (s)
1830{1847{
1831}1848}
@@ -1914,6 +1931,7 @@
1914 glLoadIdentity ();1931 glLoadIdentity ();
19151932
1916 glDrawBuffer (GL_FRONT);1933 glDrawBuffer (GL_FRONT);
1934
1917 foreach (const CompRect &r, blitRects)1935 foreach (const CompRect &r, blitRects)
1918 {1936 {
1919 int x = r.x1 ();1937 int x = r.x1 ();
@@ -1921,6 +1939,7 @@
1921 glRasterPos2i (x, y);1939 glRasterPos2i (x, y);
1922 glCopyPixels (x, y, w, h, GL_COLOR);1940 glCopyPixels (x, y, w, h, GL_COLOR);
1923 }1941 }
1942
1924 glDrawBuffer (GL_BACK);1943 glDrawBuffer (GL_BACK);
19251944
1926 glPopMatrix ();1945 glPopMatrix ();
@@ -1929,7 +1948,6 @@
1929 glMatrixMode (GL_MODELVIEW);1948 glMatrixMode (GL_MODELVIEW);
19301949
1931 glFlush ();1950 glFlush ();
1932
1933}1951}
19341952
1935#else1953#else
@@ -1960,7 +1978,7 @@
1960EGLDoubleBuffer::blit (const CompRegion &region) const1978EGLDoubleBuffer::blit (const CompRegion &region) const
1961{1979{
1962 CompRect::vector blitRects (region.rects ());1980 CompRect::vector blitRects (region.rects ());
1963 int y = 0;1981 int y = 0;
19641982
1965 foreach (const CompRect &r, blitRects)1983 foreach (const CompRect &r, blitRects)
1966 {1984 {
@@ -1997,35 +2015,45 @@
1997 unsigned int mask,2015 unsigned int mask,
1998 const CompRegion &region)2016 const CompRegion &region)
1999{2017{
2000 if (clearBuffers)2018 if (clearBuffers &&
2001 {2019 mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
2002 if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)2020 glClear (GL_COLOR_BUFFER_BIT);
2003 glClear (GL_COLOR_BUFFER_BIT);
2004 }
20052021
2006 // Disable everything that we don't usually need and could slow us down2022 // Disable everything that we don't usually need and could slow us down
2007 glDisable (GL_BLEND);2023 GLboolean glBlendEnabled = glIsEnabled (GL_BLEND);
2008 glDisable (GL_STENCIL_TEST);2024 GLboolean glStencilEnabled = glIsEnabled (GL_STENCIL_TEST);
2009 glDisable (GL_DEPTH_TEST);2025 GLboolean glDepthEnabled = glIsEnabled (GL_DEPTH_TEST);
2026
2027 // just disable global states if they are enabled
2028 if (glBlendEnabled)
2029 glDisable (GL_BLEND);
2030
2031 if (glStencilEnabled)
2032 glDisable (GL_STENCIL_TEST);
2033
2034 if (glDepthEnabled)
2035 glDisable (GL_DEPTH_TEST);
2036
2010 glDepthMask (GL_FALSE);2037 glDepthMask (GL_FALSE);
2011 glStencilMask (0);2038 glStencilMask (0);
20122039
2013 GLFramebufferObject *oldFbo = NULL;2040 GLFramebufferObject *oldFbo = NULL;
2014 bool useFbo = false;2041 bool useFbo = false;
20152042
2016 /* Clear the color buffer where appropriate */2043 /* Clear the color buffer where appropriate */
2017 if (GL::fboEnabled && scratchFbo)2044 if (GL::fboEnabled && scratchFbo)
2018 {2045 {
2019 oldFbo = scratchFbo->bind ();2046 oldFbo = scratchFbo->bind ();
2020 useFbo = scratchFbo->checkStatus () && scratchFbo->tex ();2047 useFbo = scratchFbo->checkStatus () && scratchFbo->tex ();
2048
2021 if (!useFbo)2049 if (!useFbo)
2022 GLFramebufferObject::rebind (oldFbo);2050 GLFramebufferObject::rebind (oldFbo);
2023 }2051 }
20242052
2025#ifdef UNSAFE_ARM_SGX_FIXME2053#ifdef UNSAFE_ARM_SGX_FIXME
2026 refreshSubBuffer = ((lastMask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&2054 refreshSubBuffer = ((lastMask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&
2027 !(mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&2055 !(mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&
2028 (mask & COMPOSITE_SCREEN_DAMAGE_REGION_MASK));2056 (mask & COMPOSITE_SCREEN_DAMAGE_REGION_MASK));
20292057
2030 if (refreshSubBuffer)2058 if (refreshSubBuffer)
2031 {2059 {
@@ -2035,16 +2063,18 @@
2035 // Posting a fullscreen damage region to the SGX seems to reset the2063 // Posting a fullscreen damage region to the SGX seems to reset the
2036 // framebuffer, causing the screen to blackout.2064 // framebuffer, causing the screen to blackout.
2037 cScreen->damageRegion (CompRegion (screen->fullscreenOutput ()) -2065 cScreen->damageRegion (CompRegion (screen->fullscreenOutput ()) -
2038 CompRegion (CompRect(0, 0, 1, 1)));2066 CompRegion (CompRect(0, 0, 1, 1)));
2039 }2067 }
2040#endif2068#endif
20412069
2042 CompRegion tmpRegion = (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) ?2070 CompRegion tmpRegion = (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) ?
2043 screen->region () : region;2071 screen->region () : region;
2072
2073 XRectangle r;
2074 GLMatrix identity;
20442075
2045 foreach (CompOutput *output, outputs)2076 foreach (CompOutput *output, outputs)
2046 {2077 {
2047 XRectangle r;
2048 targetOutput = output;2078 targetOutput = output;
20492079
2050 r.x = output->x1 ();2080 r.x = output->x1 ();
@@ -2063,8 +2093,6 @@
20632093
2064 if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)2094 if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
2065 {2095 {
2066 GLMatrix identity;
2067
2068 gScreen->glPaintOutput (defaultScreenPaintAttrib,2096 gScreen->glPaintOutput (defaultScreenPaintAttrib,
2069 identity,2097 identity,
2070 CompRegion (*output), output,2098 CompRegion (*output), output,
@@ -2073,8 +2101,6 @@
2073 }2101 }
2074 else if (mask & COMPOSITE_SCREEN_DAMAGE_REGION_MASK)2102 else if (mask & COMPOSITE_SCREEN_DAMAGE_REGION_MASK)
2075 {2103 {
2076 GLMatrix identity;
2077
2078#ifdef UNSAFE_ARM_SGX_FIXME2104#ifdef UNSAFE_ARM_SGX_FIXME
2079 /*2105 /*
2080 * FIXME:2106 * FIXME:
@@ -2134,10 +2160,10 @@
2134 }2160 }
21352161
2136 bool alwaysSwap = optionGetAlwaysSwapBuffers ();2162 bool alwaysSwap = optionGetAlwaysSwapBuffers ();
2137 bool fullscreen = useFbo ||2163 bool fullscreen = useFbo ||
2138 alwaysSwap ||2164 alwaysSwap ||
2139 ((mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&2165 ((mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&
2140 commonFrontbuffer);2166 commonFrontbuffer);
21412167
2142 doubleBuffer.set (DoubleBuffer::VSYNC, optionGetSyncToVblank ());2168 doubleBuffer.set (DoubleBuffer::VSYNC, optionGetSyncToVblank ());
2143 doubleBuffer.set (DoubleBuffer::HAVE_PERSISTENT_BACK_BUFFER, useFbo);2169 doubleBuffer.set (DoubleBuffer::HAVE_PERSISTENT_BACK_BUFFER, useFbo);
@@ -2184,6 +2210,7 @@
2184{2210{
2185 bool wasFboEnabled = GL::fboEnabled;2211 bool wasFboEnabled = GL::fboEnabled;
2186 updateRenderMode ();2212 updateRenderMode ();
2213
2187 if (wasFboEnabled != GL::fboEnabled)2214 if (wasFboEnabled != GL::fboEnabled)
2188 CompositeScreen::get (screen)->damageScreen ();2215 CompositeScreen::get (screen)->damageScreen ();
2189}2216}
@@ -2198,8 +2225,9 @@
2198 if (prevRegex != regex)2225 if (prevRegex != regex)
2199 {2226 {
2200 prevBlacklisted = blacklisted (regex, glVendor, glRenderer, glVersion);2227 prevBlacklisted = blacklisted (regex, glVendor, glRenderer, glVersion);
2201 prevRegex = regex;2228 prevRegex = regex;
2202 }2229 }
2230
2203 return prevBlacklisted;2231 return prevBlacklisted;
2204}2232}
22052233
@@ -2207,9 +2235,11 @@
2207GLScreen::registerBindPixmap (GLTexture::BindPixmapProc proc)2235GLScreen::registerBindPixmap (GLTexture::BindPixmapProc proc)
2208{2236{
2209 priv->bindPixmap.push_back (proc);2237 priv->bindPixmap.push_back (proc);
2238
2210 if (!priv->hasCompositing &&2239 if (!priv->hasCompositing &&
2211 CompositeScreen::get (screen)->registerPaintHandler (priv))2240 CompositeScreen::get (screen)->registerPaintHandler (priv))
2212 priv->hasCompositing = true;2241 priv->hasCompositing = true;
2242
2213 return priv->bindPixmap.size () - 1;2243 return priv->bindPixmap.size () - 1;
2214}2244}
22152245
@@ -2217,10 +2247,13 @@
2217GLScreen::unregisterBindPixmap (GLTexture::BindPixmapHandle hnd)2247GLScreen::unregisterBindPixmap (GLTexture::BindPixmapHandle hnd)
2218{2248{
2219 bool hasBP = false;2249 bool hasBP = false;
2250
2220 priv->bindPixmap[hnd].clear ();2251 priv->bindPixmap[hnd].clear ();
2221 for (unsigned int i = 0; i < priv->bindPixmap.size (); i++)2252
2253 for (unsigned int i = 0; i < priv->bindPixmap.size (); ++i)
2222 if (!priv->bindPixmap[i].empty ())2254 if (!priv->bindPixmap[i].empty ())
2223 hasBP = true;2255 hasBP = true;
2256
2224 if (!hasBP && priv->hasCompositing)2257 if (!hasBP && priv->hasCompositing)
2225 {2258 {
2226 CompositeScreen::get (screen)->unregisterPaintHandler ();2259 CompositeScreen::get (screen)->unregisterPaintHandler ();
@@ -2240,10 +2273,9 @@
2240 CompIcon *i = screen->defaultIcon ();2273 CompIcon *i = screen->defaultIcon ();
2241 CompSize size;2274 CompSize size;
22422275
2243 if (!i)2276 if (!i ||
2244 return NULL;2277 !i->width () ||
22452278 !i->height ())
2246 if (!i->width () || !i->height ())
2247 return NULL;2279 return NULL;
22482280
2249 if (priv->defaultIcon.icon == i)2281 if (priv->defaultIcon.icon == i)
@@ -2272,4 +2304,3 @@
2272 priv->rasterPos.setX (0);2304 priv->rasterPos.setX (0);
2273 priv->rasterPos.setY (0);2305 priv->rasterPos.setY (0);
2274}2306}
2275
22762307
=== modified file 'plugins/opengl/src/shadercache.cpp'
--- plugins/opengl/src/shadercache.cpp 2013-01-09 10:45:16 +0000
+++ plugins/opengl/src/shadercache.cpp 2013-07-24 16:05:45 +0000
@@ -33,9 +33,10 @@
33class GLShaderParametersComparer33class GLShaderParametersComparer
34{34{
35public:35public:
36
36 bool operator()(const GLShaderParameters &left, const GLShaderParameters &right) const37 bool operator()(const GLShaderParameters &left, const GLShaderParameters &right) const
37 {38 {
38 return left.hash() < right.hash();39 return left.hash() < right.hash();
39 }40 }
4041
41};42};
@@ -48,6 +49,7 @@
48class PrivateShaderCache49class PrivateShaderCache
49{50{
50public:51public:
52
51 PrivateShaderCache() {}53 PrivateShaderCache() {}
5254
53 ShaderMapType::const_iterator addShaderData(const GLShaderParameters &params);55 ShaderMapType::const_iterator addShaderData(const GLShaderParameters &params);
@@ -65,12 +67,12 @@
65int67int
66GLShaderParameters::hash() const68GLShaderParameters::hash() const
67{69{
68 return static_cast<int>(opacity) |70 return static_cast<int>(opacity) |
69 (static_cast<int>(brightness) << 1) |71 (static_cast<int>(brightness) << 1) |
70 (static_cast<int>(saturation) << 2) |72 (static_cast<int>(saturation) << 2) |
71 (static_cast<int>(color) << 3) |73 (static_cast<int>(color) << 3) |
72 (static_cast<int>(normal) << 5) |74 (static_cast<int>(normal) << 5) |
73 (static_cast<int>(numTextures) << 8);75 (static_cast<int>(numTextures) << 8);
74}76}
7577
76std::string78std::string
@@ -78,14 +80,15 @@
78{80{
79 std::stringstream ss;81 std::stringstream ss;
8082
81 ss << (opacity ? "t" : "f");83 ss << (opacity ? "t" : "f");
82 ss << (brightness ? "t" : "f");84 ss << (brightness ? "t" : "f");
83 ss << (saturation ? "t" : "f");85 ss << (saturation ? "t" : "f");
84 ss << (color == GLShaderVariableNone ? "n" :86 ss << (color == GLShaderVariableNone ?
85 color == GLShaderVariableUniform ? "u" : "v");87 "n" : color == GLShaderVariableUniform ? "u" : "v");
8688
87 ss << (normal == GLShaderVariableNone ? "n" :89 ss << (normal == GLShaderVariableNone ?
88 normal == GLShaderVariableUniform ? "u" : "v");90 "n" : normal == GLShaderVariableUniform ? "u" : "v");
91
89 ss << numTextures;92 ss << numTextures;
9093
91 return ss.str();94 return ss.str();
@@ -113,7 +116,7 @@
113 // Try to find a cached shader pair that matches the parameters.116 // Try to find a cached shader pair that matches the parameters.
114 // If we don't have it cached, create it.117 // If we don't have it cached, create it.
115 if ((iter = priv->shaderMap.find (params)) == priv->shaderMap.end ())118 if ((iter = priv->shaderMap.find (params)) == priv->shaderMap.end ())
116 iter = priv->addShaderData (params);119 iter = priv->addShaderData (params);
117120
118 return iter->second;121 return iter->second;
119}122}
@@ -127,12 +130,13 @@
127{130{
128 GLShaderData shaderData;131 GLShaderData shaderData;
129132
130 shaderData.name = params.id ();133 shaderData.name = params.id ();
131 shaderData.fragmentShader = createFragmentShader (params);134 shaderData.fragmentShader = createFragmentShader (params);
132 shaderData.vertexShader = createVertexShader (params);135 shaderData.vertexShader = createVertexShader (params);
133136
134 std::pair<ShaderMapType::iterator, bool> ret =137 std::pair<ShaderMapType::iterator, bool> ret =
135 shaderMap.insert(std::pair<GLShaderParameters, GLShaderData>(params,shaderData));138 shaderMap.insert(std::pair<GLShaderParameters,
139 GLShaderData>(params,shaderData));
136140
137 return ret.first;141 return ret.first;
138}142}
@@ -150,35 +154,35 @@
150 std::stringstream ss;154 std::stringstream ss;
151155
152 ss << "#ifdef GL_ES\n" <<156 ss << "#ifdef GL_ES\n" <<
153 "precision mediump float;\n" <<157 "precision mediump float;\n" <<
154 "#endif\n";158 "#endif\n";
155159
156 ss << "uniform mat4 modelview;\n" <<160 ss << "uniform mat4 modelview;\n" <<
157 "uniform mat4 projection;\n";161 "uniform mat4 projection;\n";
158162
159 ss << "attribute vec3 position;\n" <<163 ss << "attribute vec3 position;\n" <<
160 "attribute vec3 normal;\n" <<164 "attribute vec3 normal;\n" <<
161 "attribute vec4 color;\n" <<165 "attribute vec4 color;\n" <<
162 "attribute vec2 texCoord0;\n" <<166 "attribute vec2 texCoord0;\n" <<
163 "attribute vec2 texCoord1;\n" <<167 "attribute vec2 texCoord1;\n" <<
164 "attribute vec2 texCoord2;\n" <<168 "attribute vec2 texCoord2;\n" <<
165 "attribute vec2 texCoord3;\n";169 "attribute vec2 texCoord3;\n";
166170
167 ss << "@VERTEX_FUNCTIONS@\n";171 ss << "@VERTEX_FUNCTIONS@\n";
168172
169 if (params.color == GLShaderVariableVarying)173 if (params.color == GLShaderVariableVarying)
170 ss << "varying vec4 vColor;\n";174 ss << "varying vec4 vColor;\n";
171175
172 for (int i = 0; i < params.numTextures; i++)176 for (int i = 0; i < params.numTextures; ++i)
173 ss << "varying vec2 vTexCoord" << i << ";\n";177 ss << "varying vec2 vTexCoord" << i << ";\n";
174178
175 ss << "void main() {\n";179 ss << "void main() {\n";
176180
177 for (int i = 0; i < params.numTextures; i++)181 for (int i = 0; i < params.numTextures; ++i)
178 ss << "vTexCoord" << i << " = texCoord" << i <<";\n";182 ss << "vTexCoord" << i << " = texCoord" << i <<";\n";
179183
180 if (params.color == GLShaderVariableVarying)184 if (params.color == GLShaderVariableVarying)
181 ss << "vColor = color;\n";185 ss << "vColor = color;\n";
182186
183 ss << "gl_Position = projection * modelview * vec4(position, 1.0);\n";187 ss << "gl_Position = projection * modelview * vec4(position, 1.0);\n";
184188
@@ -199,50 +203,52 @@
199{203{
200 std::stringstream ss;204 std::stringstream ss;
201 ss << "#ifdef GL_ES\n" <<205 ss << "#ifdef GL_ES\n" <<
202 "precision mediump float;\n" <<206 "precision mediump float;\n" <<
203 "#endif\n";207 "#endif\n";
204208
205 ss << "uniform vec3 paintAttrib;\n";209 ss << "uniform vec3 paintAttrib;\n";
206210
207 for (int i = 0; i < params.numTextures; i++) {211 for (int i = 0; i < params.numTextures; ++i)
208 ss << "uniform sampler2D texture" << i << ";\n";212 {
209 ss << "varying vec2 vTexCoord" << i << ";\n";213 ss << "uniform sampler2D texture" << i << ";\n";
214 ss << "varying vec2 vTexCoord" << i << ";\n";
210 }215 }
211216
212 if (params.color == GLShaderVariableUniform)217 if (params.color == GLShaderVariableUniform)
213 ss << "uniform vec4 singleColor;\n";218 ss << "uniform vec4 singleColor;\n";
214 else if (params.color == GLShaderVariableVarying)219 else if (params.color == GLShaderVariableVarying)
215 ss << "varying vec4 vColor;\n";220 ss << "varying vec4 vColor;\n";
216221
217 ss << "@FRAGMENT_FUNCTIONS@\n";222 ss << "@FRAGMENT_FUNCTIONS@\n";
218223
219 ss << "void main() {\n vec4 color = ";224 ss << "void main() {\n vec4 color = ";
220225
221 if (params.color == GLShaderVariableUniform)226 if (params.color == GLShaderVariableUniform)
222 ss << "singleColor *";227 ss << "singleColor *";
223 else if (params.color == GLShaderVariableVarying)228 else if (params.color == GLShaderVariableVarying)
224 ss << "vColor *";229 ss << "vColor *";
225230
226 for (int i = 0; i < params.numTextures; i++)231 for (int i = 0; i < params.numTextures; ++i)
227 ss << " texture2D(texture" << i << ", vTexCoord" << i << ") *";232 ss << " texture2D(texture" << i << ", vTexCoord" << i << ") *";
228233
229 ss << " 1.0;\n";234 ss << " 1.0;\n";
230235
231 if (params.saturation) {236 if (params.saturation)
237 {
232 ss << "vec3 desaturated = color.rgb * vec3 (0.30, 0.59, 0.11);\n" <<238 ss << "vec3 desaturated = color.rgb * vec3 (0.30, 0.59, 0.11);\n" <<
233 "desaturated = vec3 (dot (desaturated, color.rgb));\n" <<239 "desaturated = vec3 (dot (desaturated, color.rgb));\n" <<
234 "color.rgb = color.rgb * vec3 (paintAttrib.z) + desaturated *\n" <<240 "color.rgb = color.rgb * vec3 (paintAttrib.z) + desaturated *\n" <<
235 " vec3 (1.0 - paintAttrib.z);\n";241 " vec3 (1.0 - paintAttrib.z);\n";
236 }242 }
237243
238 if (params.brightness) {244 if (params.brightness)
245 {
239 ss << "color.rgb = color.rgb * paintAttrib.y" <<246 ss << "color.rgb = color.rgb * paintAttrib.y" <<
240 (params.opacity ? " * paintAttrib.x;\n" : ";\n") <<247 (params.opacity ? " * paintAttrib.x;\n" : ";\n") <<
241 (params.opacity ? "color.a = color.a * paintAttrib.x;\n" : "");248 (params.opacity ? "color.a = color.a * paintAttrib.x;\n" : "");
242 }249 }
243 else if (params.opacity) {250 else if (params.opacity)
244 ss << "color = color * paintAttrib.x;\n";251 ss << "color = color * paintAttrib.x;\n";
245 }
246252
247 ss << "gl_FragColor = color;\n";253 ss << "gl_FragColor = color;\n";
248 ss << "@FRAGMENT_FUNCTION_CALLS@\n}";254 ss << "@FRAGMENT_FUNCTION_CALLS@\n}";
249255
=== modified file 'plugins/opengl/src/texture.cpp'
--- plugins/opengl/src/texture.cpp 2012-09-19 12:18:34 +0000
+++ plugins/opengl/src/texture.cpp 2013-07-24 16:05:45 +0000
@@ -48,7 +48,8 @@
48std::map<Damage, TfpTexture*> boundPixmapTex;48std::map<Damage, TfpTexture*> boundPixmapTex;
49#endif49#endif
5050
51static GLTexture::Matrix _identity_matrix = {51static GLTexture::Matrix _identity_matrix =
52{
52 1.0f, 0.0f,53 1.0f, 0.0f,
53 0.0f, 1.0f,54 0.0f, 1.0f,
54 0.0f, 0.0f55 0.0f, 0.0f
@@ -62,14 +63,14 @@
62GLTexture::List::List (unsigned int size) :63GLTexture::List::List (unsigned int size) :
63 std::vector<GLTexture *> (size)64 std::vector<GLTexture *> (size)
64{65{
65 for (unsigned int i = 0; i < size; i++)66 for (unsigned int i = 0; i < size; ++i)
66 at (i) = NULL;67 at (i) = NULL;
67}68}
6869
69GLTexture::List::List (const GLTexture::List &c) :70GLTexture::List::List (const GLTexture::List &c) :
70 std::vector<GLTexture *> (c.size ())71 std::vector<GLTexture *> (c.size ())
71{72{
72 for (unsigned int i = 0; i < c.size (); i++)73 for (unsigned int i = 0; i < c.size (); ++i)
73 {74 {
74 at (i) = c[i];75 at (i) = c[i];
75 GLTexture::incRef (c[i]);76 GLTexture::incRef (c[i]);
@@ -88,11 +89,13 @@
88{89{
89 this->clear ();90 this->clear ();
90 resize (c.size ());91 resize (c.size ());
91 for (unsigned int i = 0; i < c.size (); i++)92
93 for (unsigned int i = 0; i < c.size (); ++i)
92 {94 {
93 at (i) = c[i];95 at (i) = c[i];
94 GLTexture::incRef (c[i]);96 GLTexture::incRef (c[i]);
95 }97 }
98
96 return *this;99 return *this;
97}100}
98101
@@ -102,6 +105,7 @@
102 foreach (GLTexture *t, *this)105 foreach (GLTexture *t, *this)
103 if (t)106 if (t)
104 GLTexture::decRef (t);107 GLTexture::decRef (t);
108
105 std::vector <GLTexture *>::clear ();109 std::vector <GLTexture *>::clear ();
106}110}
107111
@@ -119,15 +123,15 @@
119123
120PrivateTexture::PrivateTexture (GLTexture *texture) :124PrivateTexture::PrivateTexture (GLTexture *texture) :
121 texture (texture),125 texture (texture),
122 name (0),126 name (0),
123 target (GL_TEXTURE_2D),127 target (GL_TEXTURE_2D),
124 filter (GL_NEAREST),128 filter (GL_NEAREST),
125 wrap (GL_CLAMP_TO_EDGE),129 wrap (GL_CLAMP_TO_EDGE),
126 matrix (_identity_matrix),130 matrix (_identity_matrix),
127 mipmap (true),131 mipmap (true),
128 mipmapSupport (false),132 mipmapSupport (false),
129 initial (true),133 initial (true),
130 refCount (1)134 refCount (1)
131{135{
132 glGenTextures (1, &name);136 glGenTextures (1, &name);
133}137}
@@ -135,9 +139,7 @@
135PrivateTexture::~PrivateTexture ()139PrivateTexture::~PrivateTexture ()
136{140{
137 if (name)141 if (name)
138 {
139 glDeleteTextures (1, &name);142 glDeleteTextures (1, &name);
140 }
141}143}
142144
143GLuint145GLuint
@@ -235,13 +237,11 @@
235 }237 }
236 }238 }
237239
238 if (priv->filter == GL_LINEAR_MIPMAP_LINEAR)240 if (priv->filter == GL_LINEAR_MIPMAP_LINEAR &&
241 priv->initial)
239 {242 {
240 if (priv->initial)243 GL::generateMipmap (priv->target);
241 {244 priv->initial = false;
242 GL::generateMipmap (priv->target);
243 priv->initial = false;
244 }
245 }245 }
246}246}
247247
@@ -255,10 +255,12 @@
255}255}
256256
257void257void
258GLTexture::setData (GLenum target, Matrix &m, bool mipmap)258GLTexture::setData (GLenum target,
259 Matrix &m,
260 bool mipmap)
259{261{
260 priv->target = target;262 priv->target = target;
261 priv->matrix = m;263 priv->matrix = m;
262 priv->mipmapSupport = mipmap;264 priv->mipmapSupport = mipmap;
263}265}
264266
@@ -307,37 +309,36 @@
307309
308 GLTexture::List rv (1);310 GLTexture::List rv (1);
309 GLTexture *t = new GLTexture ();311 GLTexture *t = new GLTexture ();
310 rv[0] = t;312 rv[0] = t;
311313
312 GLTexture::Matrix matrix = _identity_matrix;314 GLTexture::Matrix matrix = _identity_matrix;
313 GLint internalFormat;
314 GLenum target;315 GLenum target;
315 bool mipmap;316 bool mipmap;
316 bool pot = POWER_OF_TWO (width) && POWER_OF_TWO (height);317 bool pot = POWER_OF_TWO (width) && POWER_OF_TWO (height);
317318
318 #ifdef USE_GLES319 #ifdef USE_GLES
319 target = GL_TEXTURE_2D;320 target = GL_TEXTURE_2D;
320 matrix.xx = 1.0f / width;321 matrix.xx = 1.0f / width;
321 matrix.yy = 1.0f / height;322 matrix.yy = 1.0f / height;
322 matrix.y0 = 0.0f;323 matrix.y0 = 0.0f;
323 mipmap = GL::textureNonPowerOfTwoMipmap || pot;324 mipmap = GL::textureNonPowerOfTwoMipmap || pot;
324 #else325 #else
325326
326 if (GL::textureNonPowerOfTwo || pot)327 if (GL::textureNonPowerOfTwo || pot)
327 {328 {
328 target = GL_TEXTURE_2D;329 target = GL_TEXTURE_2D;
329 matrix.xx = 1.0f / width;330 matrix.xx = 1.0f / width;
330 matrix.yy = 1.0f / height;331 matrix.yy = 1.0f / height;
331 matrix.y0 = 0.0f;332 matrix.y0 = 0.0f;
332 mipmap = GL::generateMipmap && (GL::textureNonPowerOfTwoMipmap || pot);333 mipmap = GL::generateMipmap && (GL::textureNonPowerOfTwoMipmap || pot);
333 }334 }
334 else335 else
335 {336 {
336 target = GL_TEXTURE_RECTANGLE_NV;337 target = GL_TEXTURE_RECTANGLE_NV;
337 matrix.xx = 1.0f;338 matrix.xx = 1.0f;
338 matrix.yy = 1.0f;339 matrix.yy = 1.0f;
339 matrix.y0 = 0.0f;340 matrix.y0 = 0.0f;
340 mipmap = false;341 mipmap = false;
341 }342 }
342 #endif343 #endif
343344
@@ -348,22 +349,21 @@
348349
349 #ifdef USE_GLES350 #ifdef USE_GLES
350 // For GLES2 no format conversion is allowed, i.e., format must equal internalFormat351 // For GLES2 no format conversion is allowed, i.e., format must equal internalFormat
351 internalFormat = format;352 GLint internalFormat = format;
352 #else353 #else
353 internalFormat = GL_RGBA;354 GLint internalFormat = GL_RGBA;
354 #endif355 #endif
355356
356 #ifndef USE_GLES357 #ifndef USE_GLES
357 CompOption *opt;358 CompOption *opt = GLScreen::get (screen)->getOption ("texture_compression");
358 opt = GLScreen::get (screen)->getOption ("texture_compression");359
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: