Merge lp:~compiz-team/compiz/compiz.fix_1040478.1 into lp:compiz/0.9.10

Proposed by Sam Spilsbury
Status: Work in progress
Proposed branch: lp:~compiz-team/compiz/compiz.fix_1040478.1
Merge into: lp:compiz/0.9.10
Diff against target: 2316 lines (+1368/-324)
17 files modified
.bzrignore (+1/-0)
debian/patches/100_workaround_virtualbox_hang.patch (+31/-23)
plugins/opengl/CMakeLists.txt (+6/-0)
plugins/opengl/include/opengl/framebufferobject.h (+182/-41)
plugins/opengl/include/opengl/opengl-api.h (+42/-0)
plugins/opengl/include/opengl/opengl.h (+82/-22)
plugins/opengl/src/fbdirectdraw/CMakeLists.txt (+32/-0)
plugins/opengl/src/fbdirectdraw/include/framebuffer-direct-draw.h (+111/-0)
plugins/opengl/src/fbdirectdraw/src/framebuffer-direct-draw.cpp (+177/-0)
plugins/opengl/src/fbdirectdraw/tests/CMakeLists.txt (+24/-0)
plugins/opengl/src/fbdirectdraw/tests/test-opengl-framebuffer-direct-draw.cpp (+237/-0)
plugins/opengl/src/framebufferobject.cpp (+112/-104)
plugins/opengl/src/paint.cpp (+10/-80)
plugins/opengl/src/privates.h (+49/-7)
plugins/opengl/src/screen.cpp (+251/-34)
plugins/water/src/water.cpp (+17/-9)
plugins/water/src/water.h (+4/-4)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.fix_1040478.1
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
MC Return Pending
Sam Spilsbury Pending
Daniel van Vugt Pending
jenkins continuous-integration Pending
Review via email: mp+165770@code.launchpad.net

This proposal supersedes a proposal from 2013-05-26.

Commit message

Implement support for glBlitFramebuffer. On some platforms this may speed up the final composite operation as we skip the fragment processor entirely.

The logic around this code is basically that if glBlitFramebuffer fails, then we don't use it again (the failure case is it not being available), and use the fallback textured draw code.

Tests added for the new module FramebufferDirectDraw.

(LP: #1040478) (LP: #1051287)

Description of the change

Rebased.

Implement support for glBlitFramebuffer. On some platforms this may speed up the final composite operation as we skip the fragment processor entirely.

The logic around this code is basically that if glBlitFramebuffer fails, then we don't use it again (the failure case is it not being available), and use the fallback textured draw code.

Tests added for the new module FramebufferDirectDraw.

The API and ABI of GLFramebufferObject were broken too so that we could specify which buffer we actually wanted to bind.

Also added new concepts of framebuffer binding points. These are now responsible for binding framebuffers to the GL_DRAW_FRAMEBUFFER or GL_READ_FRAMEBUFFER rather than the object itself. This effectively means that we can optimize out multiple binds of the same object, or leave objects bound until they /actually/ need to change.

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
jenkins (martin-mrazik+qa) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I have not seen any improvement yet myself. It would have to be quite significant to risk large changes to the 0.9.8 tree right now.

As far as I can tell, this is not required for quantal. So please repropose it after we've branched for 0.9.9.

review: Needs Resubmitting
Revision history for this message
jenkins (martin-mrazik+qa) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
jenkins (martin-mrazik+qa) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Don't we want to fix bug 1051287 before merging this?

review: Needs Information
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Probably a good idea. Lets do that.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Though, I'm not entirely certain. In order to fix it properly I'll need to add a concept of framebuffer bindings points to opengl, that could inflate this change a little more (or at least introduce a dependency)

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

OK, then. Bug 1051287 needs fixing here.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Lets look into this again post 0.9.9.0

review: Needs Resubmitting
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

165 + * This since this code only draws a rectangular region from one
should probably be:
165 + * Since this code only draws a rectangular region from one

The copyright in plugins/opengl/include/opengl/opengl-api.h seems to be incorrect.

Is the fallthrough in plugins/opengl/src/framebufferobject.cpp intentional ?
1323 switch (status)
1324 {
1325 - case GL::FRAMEBUFFER_COMPLETE:
1326 + case GL::FRAMEBUFFER_COMPLETE:
1327 return "GL::FRAMEBUFFER_COMPLETE";
1328 - case GL::FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
1329 + case GL::FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
1330 return "GL::FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
1331 - case GL::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
1332 + case GL::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
1333 return "GL::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
1334 - case GL::FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
1335 + case GL::FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
1336 return "GL::FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
1337 - case GL::FRAMEBUFFER_UNSUPPORTED:
1338 + case GL::FRAMEBUFFER_UNSUPPORTED:
1339 return "GL::FRAMEBUFFER_UNSUPPORTED";
1340 default:
1341 return "unexpected status";
1342 }

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Sun, Feb 10, 2013 at 8:28 PM, MC Return <email address hidden> wrote:
> 165 + * This since this code only draws a rectangular region from one
> should probably be:
> 165 + * Since this code only draws a rectangular region from one
>
> The copyright in plugins/opengl/include/opengl/opengl-api.h seems to be incorrect.

Thanks, I'll update it.

>
> Is the fallthrough in plugins/opengl/src/framebufferobject.cpp intentional ?
> 1323 switch (status)
> 1324 {
> 1325 - case GL::FRAMEBUFFER_COMPLETE:
> 1326 + case GL::FRAMEBUFFER_COMPLETE:
> 1327 return "GL::FRAMEBUFFER_COMPLETE";
> 1328 - case GL::FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
> 1329 + case GL::FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
> 1330 return "GL::FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
> 1331 - case GL::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
> 1332 + case GL::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
> 1333 return "GL::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
> 1334 - case GL::FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
> 1335 + case GL::FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
> 1336 return "GL::FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
> 1337 - case GL::FRAMEBUFFER_UNSUPPORTED:
> 1338 + case GL::FRAMEBUFFER_UNSUPPORTED:
> 1339 return "GL::FRAMEBUFFER_UNSUPPORTED";
> 1340 default:
> 1341 return "unexpected status";
> 1342 }
>

No fall-through is possible, since we return directly.

> --
> https://code.launchpad.net/~compiz-team/compiz/compiz.performance_1040478/+merge/147541
> You proposed lp:~compiz-team/compiz/compiz.performance_1040478 for merging.

--
Sam Spilsbury

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

>
> No fall-through is possible, since we return directly.
>
Ah, yeah - you are right ofc. - sorry 'bout that.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Checking the copyright again on opengl-api.h, I don't think there is any problem there. All I did for that code was cut-and-paste part of private.h, no actual modification on my part.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

The change to debian/changelog seems to be unintended and should probably be removed here as well.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Thanks. I fixed that yesterday but seemed to forget to push it here.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Works for me (on ATI fglrx).

Btw, ATI fglrx supports GL_EXT_framebuffer_blit as well, reference: http://www.geeks3d.com/opengl-extensions/

review: Approve
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote : Posted in a previous version of this proposal

Since the 13.04 is happening, we are now past Feature Freeze with 0.9.9 :( The bug report would need be changed to a FFe if this would be wanted to be gotten in. The performance benefits should probably also need benchmarking to double-check there won't be any regressions? Especially Intel I'd guess, its OpenGL 3.0 support is quite new.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

My understanding is that these branches will not be taken in
lp:compiz/raring. lp:compiz is now a separate project.

On Mon, Mar 11, 2013 at 1:17 PM, Timo Jyrinki
<email address hidden> wrote:
> Since the 13.04 is happening, we are now past Feature Freeze with 0.9.9 :( The bug report would need be changed to a FFe if this would be wanted to be gotten in. The performance benefits should probably also need benchmarking to double-check there won't be any regressions? Especially Intel I'd guess, its OpenGL 3.0 support is quite new.
> --
> https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1040478/+merge/150949
> You proposed lp:~compiz-team/compiz/compiz.fix_1040478 for merging.

--
Sam Spilsbury

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote : Posted in a previous version of this proposal

Yeah, you're correct.

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> Since the 13.04 is happening, we are now past Feature Freeze with 0.9.9 :( The
> bug report would need be changed to a FFe if this would be wanted to be gotten
> in. The performance benefits should probably also need benchmarking to double-
> check there won't be any regressions? Especially Intel I'd guess, its OpenGL
> 3.0 support is quite new.

Intel should support GL_EXT_framebuffer_blit as well AFAIK.
We should land this in trunk and set up a Compiz-trunk-PPA, so more users could
test changes that are landed in trunk.

review: Approve
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> My understanding is that these branches will not be taken in
> lp:compiz/raring. lp:compiz is now a separate project.
>

Sam, could you set up a PPA auto-building lp:compiz ?
It would be very useful to be able to have a solid user testing
base for changes landing in trunk==lp:compiz...

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

 This is easy enough to do yourself, see "create packaging recipe"
here https://code.launchpad.net/~compiz-team/compiz/0.9.9 . The
default will work fine.

On Sun, Mar 24, 2013 at 6:11 PM, MC Return <email address hidden> wrote:
>> My understanding is that these branches will not be taken in
>> lp:compiz/raring. lp:compiz is now a separate project.
>>
>
> Sam, could you set up a PPA auto-building lp:compiz ?
> It would be very useful to be able to have a solid user testing
> base for changes landing in trunk==lp:compiz...
>
> --
> https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1040478/+merge/150949
> You proposed lp:~compiz-team/compiz/compiz.fix_1040478 for merging.

--
Sam Spilsbury

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Please re-target this for lp:compiz/0.9.10

review: Needs Resubmitting
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote :

Sam, I've linked this MP with the related bug reports.

Unmerged revisions

3726. By Sam Spilsbury

Merge lp:~compiz-team/compiz/compiz.fix_1040478

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file '.bzrignore'
--- .bzrignore 1970-01-01 00:00:00 +0000
+++ .bzrignore 2013-05-26 06:45:17 +0000
@@ -0,0 +1,1 @@
1.bzr-repo
02
=== modified file 'debian/patches/100_workaround_virtualbox_hang.patch'
--- debian/patches/100_workaround_virtualbox_hang.patch 2013-05-10 16:10:55 +0000
+++ debian/patches/100_workaround_virtualbox_hang.patch 2013-05-26 06:45:17 +0000
@@ -1,6 +1,8 @@
1--- a/plugins/opengl/include/opengl/opengl.h1Index: compiz/plugins/opengl/include/opengl/opengl.h
2+++ b/plugins/opengl/include/opengl/opengl.h2===================================================================
3@@ -582,6 +582,17 @@3--- compiz.orig/plugins/opengl/include/opengl/opengl.h 2013-05-26 14:31:59.814835940 +0800
4+++ compiz/plugins/opengl/include/opengl/opengl.h 2013-05-26 14:31:59.810835918 +0800
5@@ -614,6 +614,17 @@
4 6
5 extern GLScreenPaintAttrib defaultScreenPaintAttrib;7 extern GLScreenPaintAttrib defaultScreenPaintAttrib;
6 8
@@ -16,9 +18,9 @@
16+}18+}
17+19+
18 class GLScreen;20 class GLScreen;
19 class GLFramebufferObject;
20 class GLScreenInterface;21 class GLScreenInterface;
21@@ -774,6 +785,13 @@22 extern template class WrapableInterface<GLScreen, GLScreenInterface>;
23@@ -834,6 +845,13 @@
22 24
23 bool glInitContext (XVisualInfo *);25 bool glInitContext (XVisualInfo *);
24 26
@@ -32,9 +34,11 @@
32 WRAPABLE_HND (0, GLScreenInterface, bool, glPaintOutput,34 WRAPABLE_HND (0, GLScreenInterface, bool, glPaintOutput,
33 const GLScreenPaintAttrib &, const GLMatrix &,35 const GLScreenPaintAttrib &, const GLMatrix &,
34 const CompRegion &, CompOutput *, unsigned int);36 const CompRegion &, CompOutput *, unsigned int);
35--- a/plugins/opengl/src/privates.h37Index: compiz/plugins/opengl/src/privates.h
36+++ b/plugins/opengl/src/privates.h38===================================================================
37@@ -47,6 +47,24 @@39--- compiz.orig/plugins/opengl/src/privates.h 2013-05-26 14:31:59.814835940 +0800
40+++ compiz/plugins/opengl/src/privates.h 2013-05-26 14:31:59.810835918 +0800
41@@ -53,6 +53,24 @@
38 42
39 extern CompOutput *targetOutput;43 extern CompOutput *targetOutput;
40 44
@@ -59,7 +63,7 @@
59 class GLDoubleBuffer :63 class GLDoubleBuffer :
60 public compiz::opengl::DoubleBuffer64 public compiz::opengl::DoubleBuffer
61 {65 {
62@@ -123,6 +141,7 @@66@@ -161,6 +179,7 @@
63 class PrivateGLScreen :67 class PrivateGLScreen :
64 public ScreenInterface,68 public ScreenInterface,
65 public compiz::composite::PaintHandler,69 public compiz::composite::PaintHandler,
@@ -67,7 +71,7 @@
67 public OpenglOptions71 public OpenglOptions
68 {72 {
69 public:73 public:
70@@ -207,6 +226,7 @@74@@ -246,6 +265,7 @@
71 std::vector<GLTexture::BindPixmapProc> bindPixmap;75 std::vector<GLTexture::BindPixmapProc> bindPixmap;
72 bool hasCompositing;76 bool hasCompositing;
73 bool commonFrontbuffer;77 bool commonFrontbuffer;
@@ -75,7 +79,7 @@
75 bool incorrectRefreshRate; // hack for NVIDIA specifying an incorrect79 bool incorrectRefreshRate; // hack for NVIDIA specifying an incorrect
76 // refresh rate, causing us to miss vblanks80 // refresh rate, causing us to miss vblanks
77 81
78@@ -226,6 +246,10 @@82@@ -268,6 +288,10 @@
79 83
80 mutable CompString prevRegex;84 mutable CompString prevRegex;
81 mutable bool prevBlacklisted;85 mutable bool prevBlacklisted;
@@ -86,17 +90,19 @@
86 };90 };
87 91
88 class PrivateGLWindow :92 class PrivateGLWindow :
89--- a/plugins/opengl/src/screen.cpp93Index: compiz/plugins/opengl/src/screen.cpp
90+++ b/plugins/opengl/src/screen.cpp94===================================================================
91@@ -67,6 +67,7 @@95--- compiz.orig/plugins/opengl/src/screen.cpp 2013-05-26 14:31:59.814835940 +0800
92 96+++ compiz/plugins/opengl/src/screen.cpp 2013-05-26 14:32:31.938995233 +0800
93 97@@ -70,6 +70,7 @@
94 using namespace compiz::opengl;98 using namespace compiz::opengl;
99 namespace cglfb = compiz::opengl;
100 namespace cgli = compiz::opengl::impl;
95+namespace cglint = compiz::opengl::internal;101+namespace cglint = compiz::opengl::internal;
96 102
97 namespace GL {103 namespace compiz
98 #ifdef USE_GLES104 {
99@@ -359,6 +360,18 @@105@@ -490,6 +491,18 @@
100 #endif106 #endif
101 107
102 bool108 bool
@@ -115,7 +121,7 @@
115 GLScreen::glInitContext (XVisualInfo *visinfo)121 GLScreen::glInitContext (XVisualInfo *visinfo)
116 {122 {
117 #ifndef USE_GLES123 #ifndef USE_GLES
118@@ -660,6 +673,7 @@124@@ -809,6 +822,7 @@
119 125
120 priv->commonFrontbuffer = true;126 priv->commonFrontbuffer = true;
121 priv->incorrectRefreshRate = false;127 priv->incorrectRefreshRate = false;
@@ -123,7 +129,7 @@
123 if (glRenderer != NULL && strstr (glRenderer, "on llvmpipe"))129 if (glRenderer != NULL && strstr (glRenderer, "on llvmpipe"))
124 {130 {
125 /*131 /*
126@@ -680,6 +694,18 @@132@@ -829,6 +843,18 @@
127 priv->incorrectRefreshRate = true;133 priv->incorrectRefreshRate = true;
128 }134 }
129 135
@@ -142,8 +148,10 @@
142 if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))148 if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))
143 GL::textureNonPowerOfTwo = true;149 GL::textureNonPowerOfTwo = true;
144 GL::textureNonPowerOfTwoMipmap = GL::textureNonPowerOfTwo;150 GL::textureNonPowerOfTwoMipmap = GL::textureNonPowerOfTwo;
145--- a/plugins/opengl/src/texture.cpp151Index: compiz/plugins/opengl/src/texture.cpp
146+++ b/plugins/opengl/src/texture.cpp152===================================================================
153--- compiz.orig/plugins/opengl/src/texture.cpp 2013-05-26 14:31:59.814835940 +0800
154+++ compiz/plugins/opengl/src/texture.cpp 2013-05-26 14:31:59.814835940 +0800
147@@ -41,6 +41,7 @@155@@ -41,6 +41,7 @@
148 #include "glx-tfp-bind.h"156 #include "glx-tfp-bind.h"
149 157
150158
=== modified file 'plugins/opengl/CMakeLists.txt'
--- plugins/opengl/CMakeLists.txt 2012-12-12 07:33:12 +0000
+++ plugins/opengl/CMakeLists.txt 2013-05-26 06:45:17 +0000
@@ -5,15 +5,21 @@
5set (INTERNAL_LIBRARIES5set (INTERNAL_LIBRARIES
6 compiz_opengl_double_buffer6 compiz_opengl_double_buffer
7 compiz_opengl_fsregion7 compiz_opengl_fsregion
8 compiz_opengl_framebuffer_direct_draw
8 compiz_opengl_blacklist9 compiz_opengl_blacklist
9 compiz_opengl_glx_tfp_bind10 compiz_opengl_glx_tfp_bind
10)11)
1112
13set (COMPIZ_OPENGL_PLUGIN_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
14set (COMPIZ_OPENGL_PLUGIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
15
12add_subdirectory (src/doublebuffer)16add_subdirectory (src/doublebuffer)
13add_subdirectory (src/fsregion)17add_subdirectory (src/fsregion)
18add_subdirectory (src/fbdirectdraw)
14add_subdirectory (src/blacklist)19add_subdirectory (src/blacklist)
15add_subdirectory (src/glxtfpbind)20add_subdirectory (src/glxtfpbind)
1621
22include_directories (src/fbdirectdraw/include)
17include_directories (src/glxtfpbind/include)23include_directories (src/glxtfpbind/include)
1824
19if (USE_GLES)25if (USE_GLES)
2026
=== modified file 'plugins/opengl/include/opengl/framebufferobject.h'
--- plugins/opengl/include/opengl/framebufferobject.h 2012-08-09 02:19:26 +0000
+++ plugins/opengl/include/opengl/framebufferobject.h 2013-05-26 06:45:17 +0000
@@ -26,29 +26,177 @@
26#ifndef _COMPIZ_GLFRAMEBUFFEROBJECT_H26#ifndef _COMPIZ_GLFRAMEBUFFEROBJECT_H
27#define _COMPIZ_GLFRAMEBUFFEROBJECT_H27#define _COMPIZ_GLFRAMEBUFFEROBJECT_H
2828
29#include <opengl/opengl.h>29#include <list>
30#include <boost/function.hpp>
31#include <opengl/opengl-api.h>
32#include <core/size.h>
33#include <core/rect.h>
34
35class GLVertexBuffer;
36class GLTexture;
37
38namespace compiz
39{
40namespace opengl
41{
42typedef enum _BlitMask
43{
44 ColorData = (1 << 0),
45 StencilData = (1 << 1)
46} BlitMask;
47
48typedef enum _Filter
49{
50 Fast = 0,
51 Good = 1,
52} Filter;
53
54typedef enum _BindPoint
55{
56 Read = 0,
57 Draw = 1
58} BindPoint;
59
60class BindableFramebuffer
61{
62 public:
63
64 virtual ~BindableFramebuffer () {}
65
66 virtual GLuint getResourceId () const = 0;
67 virtual bool setBindStatus (GLenum) = 0;
68 virtual void updateAllocation (GLenum) = 0;
69};
70
71class BindLocation
72{
73 public:
74
75 virtual ~BindLocation () {}
76
77 /**
78 * Bind the specified BindableFramebuffer to this bind location
79 * usually either as the read target or the draw target
80 *
81 * The previous FBO is no longer bound. If it was bound to the
82 * draw target, it will be safe to use its texture.
83 *
84 * This returns the last-bound BindableFramebuffer object on
85 * success and NULL on failure (no change). Call this again
86 * in order to restore that framebuffer
87 */
88 virtual BindableFramebuffer * bind (BindableFramebuffer *) = 0;
89 virtual BindableFramebuffer * getCurrentlyBound () = 0;
90};
91
92typedef boost::function <bool (const CompRect &src,
93 const CompRect &dst,
94 GLbitfield mask,
95 GLenum filter)> RectangularDraw;
96typedef std::list <RectangularDraw> RectangularDrawList;
97
98class DirectDrawStrategies
99{
100 public:
101
102 typedef boost::shared_ptr <DirectDrawStrategies> Ptr;
103
104 virtual ~DirectDrawStrategies () {}
105 virtual void draw (const CompRect &src,
106 const CompRect &dst,
107 BlitMask mask,
108 Filter filter) = 0;
109};
110
111class FramebufferObject
112{
113 public:
114
115 virtual ~FramebufferObject () {}
116
117 /**
118 * Ensure the texture is of the given size, recreating it if needed,
119 * and replace the FBO color attachment with it. The texture contents
120 * become undefined, unless specified in the 'image' argument.
121 * When specifying 'image', it's also possible to pass-in the
122 * desired image's 'format' and 'type'.
123 *
124 * Returns true on success, and false on texture allocation failure.
125 */
126 virtual bool allocate (const CompSize &size,
127 const char *image = NULL,
128 GLenum format = GL_RGBA,
129 GLenum type = GL_UNSIGNED_BYTE) = 0;
130
131 /**
132 * Check the FBO completeness. Returns true on complete.
133 * Otherwise returns false and reports the error to log.
134 */
135 virtual bool checkStatus () = 0;
136
137 /**
138 * Return a pointer to the texture that is the color attachment.
139 * This will return NULL, if allocate () has not been called, or
140 * the last allocate () call failed.
141 */
142 virtual GLTexture * tex () = 0;
143};
144
145class DirectDrawObject :
146 virtual public compiz::opengl::FramebufferObject,
147 virtual public compiz::opengl::BindableFramebuffer
148{
149 public:
150
151 virtual ~DirectDrawObject () {};
152
153 /**
154 * Draws a region of the framebuffer object as specified in
155 * framebuffer-specified co-ordinates as @src co-ordinates in
156 * the buffer currently bound co-ordinates @dst . @mask indicates
157 * what kind of data should be propogated downwards. @filter indicates
158 * what kind of filter should be used when drawing this buffer
159 *
160 * This since this code only draws a rectangular region from one
161 * framebuffer to another, it will try and use the fastest codepath
162 * possible, falling back to a simple textured draw if
163 * glBlitFramebuffer is not available
164 *
165 */
166 virtual void directDraw (const CompRect &src,
167 const CompRect &dst,
168 compiz::opengl::BlitMask mask,
169 compiz::opengl::Filter filter) = 0;
170};
171
172namespace impl
173{
174namespace cgl = compiz::opengl;
30175
31struct PrivateGLFramebufferObject;176struct PrivateGLFramebufferObject;
32177
33/**178class FBOBindLocation :
34 * Class representing a framebuffer object in GL, supporting only one179 public cgl::BindLocation
35 * color attachment as per GLES 2 spec. The color attachment is referred180{
36 * to as the texture (of the FBO).181 public:
37 *182
38 * Usage:183 FBOBindLocation (GLenum binding, BindableFramebuffer *back);
39 * 1. create a GLFramebufferObject (requires a GL context)184 BindableFramebuffer * bind (BindableFramebuffer *);
40 * 2. call allocate (size), and check status ()185 BindableFramebuffer * getCurrentlyBound ();
41 * 3. old = bind ()186
42 * 4. do your rendering187 private:
43 * 5. rebind (old)188
44 * 6. use the rendered texture via tex ()189 class Private;
45 * 7. go to 2 or 3, or delete to quit (requires a GL context)190 std::auto_ptr <Private> priv;
46 */191};
47class GLFramebufferObject192
48{193class FramebufferObject :
49 public:194 public cgl::FramebufferObject,
50 GLFramebufferObject ();195 public cgl::BindableFramebuffer
51 ~GLFramebufferObject ();196{
197 public:
198 FramebufferObject ();
199 ~FramebufferObject ();
52200
53 /**201 /**
54 * Ensure the texture is of the given size, recreating it if needed,202 * Ensure the texture is of the given size, recreating it if needed,
@@ -65,26 +213,6 @@
65 GLenum type = GL_UNSIGNED_BYTE);213 GLenum type = GL_UNSIGNED_BYTE);
66214
67 /**215 /**
68 * Bind this as the current FBO, previous binding in GL context is
69 * undone. GL rendering is now targeted to this FBO.
70 * Returns a pointer to the previously bound FBO, or NULL if
71 * the previous binding was zero (the window system provided
72 * framebuffer).
73 *
74 * The previous FBO is no longer bound, so you can use its
75 * texture. To restore the previous FBO, call rebind (FBO) with
76 * the returned pointer as the argument.
77 */
78 GLFramebufferObject *bind ();
79
80 /**
81 * Bind the given FBO as the current FBO, without looking up the
82 * previous binding. The argument can be NULL, in which case the
83 * window system provided framebuffer gets bound (FBO is unbound).
84 */
85 static void rebind (GLFramebufferObject *fbo);
86
87 /**
88 * Check the FBO completeness. Returns true on complete.216 * Check the FBO completeness. Returns true on complete.
89 * Otherwise returns false and reports the error to log.217 * Otherwise returns false and reports the error to log.
90 */218 */
@@ -95,10 +223,23 @@
95 * This will return NULL, if allocate () has not been called, or223 * This will return NULL, if allocate () has not been called, or
96 * the last allocate () call failed.224 * the last allocate () call failed.
97 */225 */
98 GLTexture *tex ();226 GLTexture * tex ();
99227
100 private:228 private:
229
230 /**
231 * Returns the framebuffer identifier
232 */
233 GLuint getResourceId () const;
234 bool setBindStatus (GLenum);
235 void updateAllocation (GLenum bindingLocation);
236
101 PrivateGLFramebufferObject *priv;237 PrivateGLFramebufferObject *priv;
102};238};
239}
240}
241}
242
243typedef compiz::opengl::impl::FramebufferObject GLFramebufferObject;
103244
104#endif // _COMPIZ_GLFRAMEBUFFEROBJECT_H245#endif // _COMPIZ_GLFRAMEBUFFEROBJECT_H
105246
=== added file 'plugins/opengl/include/opengl/opengl-api.h'
--- plugins/opengl/include/opengl/opengl-api.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/opengl-api.h 2013-05-26 06:45:17 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright © 2008 Dennis Kasprzyk
3 * Copyright © 2007 Novell, Inc.
4 *
5 * Permission to use, copy, modify, distribute, and sell this software
6 * and its documentation for any purpose is hereby granted without
7 * fee, provided that the above copyright notice appear in all copies
8 * and that both that copyright notice and this permission notice
9 * appear in supporting documentation, and that the name of
10 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior permission.
12 * Dennis Kasprzyk makes no representations about the suitability of this
13 * software for any purpose. It is provided "as is" without express or
14 * implied warranty.
15 *
16 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
18 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
22 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 *
24 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
25 * David Reveman <davidr@novell.com>
26 */
27
28#ifndef _COMPIZ_OPENGL_API_H
29#define _COMPIZ_OPENGL_API_H
30
31#ifdef USE_GLES
32#define SUPPORT_X11
33#include <GLES2/gl2.h>
34#include <GLES2/gl2ext.h>
35#include <EGL/egl.h>
36#include <EGL/eglext.h>
37#else
38#include <GL/gl.h>
39#include <GL/glx.h>
40#endif
41
42#endif
043
=== 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-05-26 06:45:17 +0000
@@ -28,29 +28,19 @@
28#ifndef _COMPIZ_OPENGL_H28#ifndef _COMPIZ_OPENGL_H
29#define _COMPIZ_OPENGL_H29#define _COMPIZ_OPENGL_H
3030
31#ifdef USE_GLES31#include <opengl/opengl-api.h>
32#define SUPPORT_X11
33#include <GLES2/gl2.h>
34#include <GLES2/gl2ext.h>
35#include <EGL/egl.h>
36#include <EGL/eglext.h>
37#else
38#include <GL/gl.h>
39#include <GL/glx.h>
40#endif
4132
42#include <core/size.h>33#include <core/size.h>
43#include <core/pluginclasshandler.h>34#include <core/pluginclasshandler.h>
4435
45#include <opengl/matrix.h>36#include <opengl/matrix.h>
46#include <opengl/texture.h>37#include <opengl/texture.h>
47#include <opengl/framebufferobject.h>
48#include <opengl/vertexbuffer.h>38#include <opengl/vertexbuffer.h>
49#include <opengl/program.h>39#include <opengl/program.h>
50#include <opengl/programcache.h>40#include <opengl/programcache.h>
51#include <opengl/shadercache.h>41#include <opengl/shadercache.h>
5242
53#define COMPIZ_OPENGL_ABI 643#define COMPIZ_OPENGL_ABI 7
5444
55/*45/*
56 * Some plugins check for #ifdef USE_MODERN_COMPIZ_GL. Support it for now, but46 * Some plugins check for #ifdef USE_MODERN_COMPIZ_GL. Support it for now, but
@@ -84,9 +74,38 @@
84extern const float GREEN_SATURATION_WEIGHT;74extern const float GREEN_SATURATION_WEIGHT;
85extern const float BLUE_SATURATION_WEIGHT;75extern const float BLUE_SATURATION_WEIGHT;
8676
77class GLScreen;
87class PrivateGLScreen;78class PrivateGLScreen;
88class PrivateGLWindow;79class PrivateGLWindow;
8980
81namespace compiz
82{
83namespace opengl
84{
85typedef boost::function <bool (const CompRect &src,
86 const CompRect &dst,
87 GLbitfield mask,
88 GLenum filter)> BlitFramebufferFunc;
89
90class DirectDrawObject;
91class FramebufferObject;
92class BindableFramebuffer;
93
94/**
95 * Convenience method to construct a framebuffer object that
96 * supports GLX_EXT_blit_framebuffer and a fallback path
97 */
98DirectDrawObject *createBlittableFramebufferObjectWithFallback(const CompSize &sz, GLScreen *gScreen);
99
100namespace impl
101{
102class FramebufferObject;
103}
104}
105}
106
107typedef compiz::opengl::impl::FramebufferObject GLFramebufferObject;
108
90extern GLushort defaultColor[4];109extern GLushort defaultColor[4];
91110
92#ifndef GLX_EXT_texture_from_pixmap111#ifndef GLX_EXT_texture_from_pixmap
@@ -313,6 +332,18 @@
313 GLsizei width,332 GLsizei width,
314 GLsizei height);333 GLsizei height);
315334
335 /* GLX_EXT_blit_framebuffer */
336 typedef void (*GLBlitFramebufferProc) (GLint srcX0,
337 GLint srcY0,
338 GLint srcX1,
339 GLint srcY1,
340 GLint dstX0,
341 GLint dstY0,
342 GLint dstX1,
343 GLint dstY1,
344 GLbitfield mask,
345 GLenum filter);
346
316347
317 /* GL_ARB_shader_objects */348 /* GL_ARB_shader_objects */
318 #ifndef USE_GLES349 #ifndef USE_GLES
@@ -413,11 +444,12 @@
413 extern GLDisableVertexAttribArrayProc disableVertexAttribArray;444 extern GLDisableVertexAttribArrayProc disableVertexAttribArray;
414 extern GLVertexAttribPointerProc vertexAttribPointer;445 extern GLVertexAttribPointerProc vertexAttribPointer;
415446
416 extern GLGenRenderbuffersProc genRenderbuffers;447 extern GLGenRenderbuffersProc genRenderbuffers;
417 extern GLDeleteRenderbuffersProc deleteRenderbuffers;448 extern GLDeleteRenderbuffersProc deleteRenderbuffers;
418 extern GLBindRenderbufferProc bindRenderbuffer;449 extern GLBindRenderbufferProc bindRenderbuffer;
419 extern GLFramebufferRenderbufferProc framebufferRenderbuffer;450 extern GLFramebufferRenderbufferProc framebufferRenderbuffer;
420 extern GLRenderbufferStorageProc renderbufferStorage;451 extern GLRenderbufferStorageProc renderbufferStorage;
452 extern GLBlitFramebufferProc blitFramebuffer;
421453
422 #ifndef USE_GLES454 #ifndef USE_GLES
423 extern GLCreateShaderObjectARBProc createShaderObjectARB;455 extern GLCreateShaderObjectARBProc createShaderObjectARB;
@@ -583,7 +615,6 @@
583extern GLScreenPaintAttrib defaultScreenPaintAttrib;615extern GLScreenPaintAttrib defaultScreenPaintAttrib;
584616
585class GLScreen;617class GLScreen;
586class GLFramebufferObject;
587class GLScreenInterface;618class GLScreenInterface;
588extern template class WrapableInterface<GLScreen, GLScreenInterface>;619extern template class WrapableInterface<GLScreen, GLScreenInterface>;
589620
@@ -662,9 +693,9 @@
662 * @param scratchFbo Describes the final composited FBO that is693 * @param scratchFbo Describes the final composited FBO that is
663 * to be rendered.694 * to be rendered.
664 */695 */
665 virtual void glPaintCompositedOutput (const CompRegion &region,696 virtual void glPaintCompositedOutput (const CompRegion &region,
666 GLFramebufferObject *fbo,697 compiz::opengl::DirectDrawObject *fbo,
667 unsigned int mask);698 unsigned int mask);
668699
669 /**700 /**
670 * Hookable function used by plugins to determine stenciling mask701 * Hookable function used by plugins to determine stenciling mask
@@ -763,13 +794,42 @@
763 /**794 /**
764 * Returns the FBO compiz is using for the screen795 * Returns the FBO compiz is using for the screen
765 */796 */
766 GLFramebufferObject *fbo ();797 compiz::opengl::FramebufferObject * fbo ();
798
799 /**
800 * Binds a framebuffer for drawing, returns the old bindable
801 */
802 compiz::opengl::BindableFramebuffer *
803 bindFramebufferForDrawing (compiz::opengl::BindableFramebuffer *);
804
805 /**
806 * Binds a framebuffer for reading, returns the old reading
807 */
808 compiz::opengl::BindableFramebuffer *
809 bindFramebufferForReading (compiz::opengl::BindableFramebuffer *);
810
811 /**
812 * Gets the currently bound draw framebuffer
813 */
814 compiz::opengl::BindableFramebuffer *
815 drawFramebuffer ();
816
817 /**
818 * Gets the backbuffer as a BindableFramebuffer
819 */
820 compiz::opengl::BindableFramebuffer *
821 backbuffer ();
767822
768 /**823 /**
769 * Returns a default icon texture824 * Returns a default icon texture
770 */825 */
771 GLTexture *defaultIcon ();826 GLTexture *defaultIcon ();
772827
828 /**
829 * Returns the current framebuffer function for blitting the framebuffer
830 */
831 const compiz::opengl::BlitFramebufferFunc & blitFramebufferFunc ();
832
773 void resetRasterPos ();833 void resetRasterPos ();
774834
775 bool glInitContext (XVisualInfo *);835 bool glInitContext (XVisualInfo *);
@@ -790,7 +850,7 @@
790850
791 WRAPABLE_HND (5, GLScreenInterface, GLMatrix *, projectionMatrix);851 WRAPABLE_HND (5, GLScreenInterface, GLMatrix *, projectionMatrix);
792 WRAPABLE_HND (6, GLScreenInterface, void, glPaintCompositedOutput,852 WRAPABLE_HND (6, GLScreenInterface, void, glPaintCompositedOutput,
793 const CompRegion &, GLFramebufferObject *, unsigned int);853 const CompRegion &, compiz::opengl::DirectDrawObject *, unsigned int);
794854
795 WRAPABLE_HND (7, GLScreenInterface, void, glBufferStencil, const GLMatrix &,855 WRAPABLE_HND (7, GLScreenInterface, void, glBufferStencil, const GLMatrix &,
796 GLVertexBuffer &,856 GLVertexBuffer &,
797857
=== added directory 'plugins/opengl/src/fbdirectdraw'
=== added file 'plugins/opengl/src/fbdirectdraw/CMakeLists.txt'
--- plugins/opengl/src/fbdirectdraw/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/fbdirectdraw/CMakeLists.txt 2013-05-26 06:45:17 +0000
@@ -0,0 +1,32 @@
1INCLUDE_DIRECTORIES (
2 ${COMPIZ_OPENGL_PLUGIN_SOURCE_DIR}
3 ${COMPIZ_OPENGL_PLUGIN_INCLUDE_DIR}
4 ${CMAKE_CURRENT_SOURCE_DIR}/include
5 ${CMAKE_CURRENT_SOURCE_DIR}/src
6
7 ${Boost_INCLUDE_DIRS}
8)
9
10LINK_DIRECTORIES (${COMPIZ_LIBRARY_DIRS})
11
12SET(
13 SRCS
14 ${CMAKE_CURRENT_SOURCE_DIR}/src/framebuffer-direct-draw.cpp
15)
16
17ADD_LIBRARY(
18 compiz_opengl_framebuffer_direct_draw STATIC
19
20 ${SRCS}
21)
22
23if (COMPIZ_BUILD_TESTING)
24ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
25endif (COMPIZ_BUILD_TESTING)
26
27TARGET_LINK_LIBRARIES(
28 compiz_opengl_framebuffer_direct_draw
29
30 compiz_region
31 compiz_logmessage
32)
033
=== added directory 'plugins/opengl/src/fbdirectdraw/include'
=== added file 'plugins/opengl/src/fbdirectdraw/include/framebuffer-direct-draw.h'
--- plugins/opengl/src/fbdirectdraw/include/framebuffer-direct-draw.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/fbdirectdraw/include/framebuffer-direct-draw.h 2013-05-26 06:45:17 +0000
@@ -0,0 +1,111 @@
1/*
2 * Compiz, opengl plugin, FramebufferDirectDraw class
3 *
4 * Copyright (c) 2012 Canonical Ltd.
5 * Authors: Sam Spilsbury <sam.spilsbury@canonical.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25#ifndef _COMPIZ_OPENGL_FRAMEBUFFER_DIRECT_DRAW_H
26#define _COMPIZ_OPENGL_FRAMEBUFFER_DIRECT_DRAW_H
27
28#include <memory>
29#include <boost/shared_ptr.hpp>
30#include <core/rect.h>
31#include <opengl/framebufferobject.h>
32
33class GLVertexBuffer;
34
35namespace compiz
36{
37namespace opengl
38{
39namespace impl
40{
41namespace cglfb = compiz::opengl;
42
43class PrivateDirectDrawStrategies;
44
45class DirectDrawStrategies :
46 public cglfb::DirectDrawStrategies
47{
48 public:
49
50 typedef boost::shared_ptr <DirectDrawStrategies> Ptr;
51
52 DirectDrawStrategies (const RectangularDrawList &strategies);
53
54 void draw (const CompRect &src,
55 const CompRect &dst,
56 BlitMask mask,
57 Filter filter);
58
59 private:
60
61 std::auto_ptr <PrivateDirectDrawStrategies> priv;
62};
63
64class PrivateDirectDrawObject;
65
66class DirectDrawObject :
67 virtual public cglfb::FramebufferObject,
68 public cglfb::DirectDrawObject
69{
70 public:
71
72 DirectDrawObject (const boost::shared_ptr <cglfb::DirectDrawStrategies> &,
73 const boost::shared_ptr <cglfb::FramebufferObject> &,
74 const boost::shared_ptr <cglfb::BindableFramebuffer> &);
75
76 bool allocate (const CompSize &size,
77 const char *image = NULL,
78 GLenum format = GL_RGBA,
79 GLenum type = GL_UNSIGNED_BYTE);
80 bool checkStatus ();
81 GLTexture * tex ();
82
83 void directDraw (const CompRect &src,
84 const CompRect &dst,
85 cglfb::BlitMask mask,
86 cglfb::Filter filter);
87
88 private:
89
90 GLuint getResourceId () const;
91 bool setBindStatus (GLenum);
92 void updateAllocation (GLenum);
93
94 PrivateDirectDrawObject *priv;
95};
96
97typedef boost::function <cglfb::BindableFramebuffer * (cglfb::BindableFramebuffer *)>
98 BindReadBufferFunc;
99
100bool rectangleDrawFromReadBuffer (const CompRect &src,
101 const CompRect &dst,
102 GLbitfield mask,
103 GLenum filter,
104 cglfb::BindableFramebuffer *bindable,
105 const BindReadBufferFunc &func,
106 cglfb::RectangularDraw strategy);
107}
108}
109}
110
111#endif
0112
=== added directory 'plugins/opengl/src/fbdirectdraw/src'
=== added file 'plugins/opengl/src/fbdirectdraw/src/framebuffer-direct-draw.cpp'
--- plugins/opengl/src/fbdirectdraw/src/framebuffer-direct-draw.cpp 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/fbdirectdraw/src/framebuffer-direct-draw.cpp 2013-05-26 06:45:17 +0000
@@ -0,0 +1,177 @@
1/*
2 * Compiz, opengl plugin, DirectDrawFramebufferStrategies class
3 *
4 * Copyright (c) 2012 Canonical Ltd.
5 * Authors: Sam Spilsbury <sam.spilsbury@canonical.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25#include "framebuffer-direct-draw.h"
26
27namespace cglfb = compiz::opengl;
28namespace cglfbi = compiz::opengl::impl;
29
30class GLTexture;
31class GLVertexBuffer;
32
33namespace compiz
34{
35namespace opengl
36{
37namespace impl
38{
39class PrivateDirectDrawStrategies
40{
41 public:
42
43 PrivateDirectDrawStrategies (const cglfb::RectangularDrawList &strategies) :
44 rectDrawList (strategies)
45 {
46 }
47
48 cglfb::RectangularDrawList rectDrawList;
49};
50
51class PrivateDirectDrawObject
52{
53 public:
54
55 PrivateDirectDrawObject (const boost::shared_ptr <cglfb::DirectDrawStrategies> &strategies,
56 const boost::shared_ptr <cglfb::FramebufferObject> &object,
57 const boost::shared_ptr <cglfb::BindableFramebuffer> &bindable) :
58 directDrawStrategies (strategies),
59 framebufferObject (object),
60 bindableFramebuffer (bindable)
61 {
62 };
63
64 boost::shared_ptr <cglfb::DirectDrawStrategies> directDrawStrategies;
65 boost::shared_ptr <cglfb::FramebufferObject> framebufferObject;
66 boost::shared_ptr <cglfb::BindableFramebuffer> bindableFramebuffer;
67};
68}
69}
70}
71
72cglfbi::DirectDrawObject::DirectDrawObject (const boost::shared_ptr <cglfb::DirectDrawStrategies> &strategies,
73 const boost::shared_ptr <cglfb::FramebufferObject> &object,
74 const boost::shared_ptr <cglfb::BindableFramebuffer> &bindable) :
75 priv (new cglfbi::PrivateDirectDrawObject (strategies, object, bindable))
76{
77}
78
79bool
80cglfbi::DirectDrawObject::allocate (const CompSize &size, const char *image,
81 GLenum format, GLenum type)
82{
83 return priv->framebufferObject->allocate (size, image, format, type);
84}
85
86bool
87cglfbi::DirectDrawObject::checkStatus ()
88{
89 return priv->framebufferObject->checkStatus ();
90}
91
92GLTexture *
93cglfbi::DirectDrawObject::tex ()
94{
95 return priv->framebufferObject->tex ();
96}
97
98GLuint
99cglfbi::DirectDrawObject::getResourceId () const
100{
101 return priv->bindableFramebuffer->getResourceId ();
102}
103
104bool
105cglfbi::DirectDrawObject::setBindStatus (GLenum status)
106{
107 return priv->bindableFramebuffer->setBindStatus (status);
108}
109
110void
111cglfbi::DirectDrawObject::updateAllocation (GLenum bindPoint)
112{
113 return priv->bindableFramebuffer->updateAllocation (bindPoint);
114}
115
116void
117cglfbi::DirectDrawObject::directDraw (const CompRect &src,
118 const CompRect &dst,
119 cglfb::BlitMask mask,
120 cglfb::Filter filter)
121{
122 if (!checkStatus ())
123 return;
124
125 priv->directDrawStrategies->draw (src, dst, mask, filter);
126}
127
128bool
129cglfbi::rectangleDrawFromReadBuffer (const CompRect &src,
130 const CompRect &dst,
131 GLbitfield mask,
132 GLenum filter,
133 cglfb::BindableFramebuffer *bindable,
134 const cglfbi::BindReadBufferFunc &bindReadBuffer,
135 cglfb::RectangularDraw strategy)
136{
137 bool status = false;
138 /* Bind to the read framebuffer first */
139 cglfb::BindableFramebuffer *old = bindReadBuffer (bindable);
140
141 if (old)
142 status = strategy (src, dst, mask, filter);
143
144 /* Intentionally not rebinding the old one */
145
146 return status;
147}
148
149cglfbi::DirectDrawStrategies::DirectDrawStrategies (const cglfb::RectangularDrawList &strategies) :
150 priv (new cglfbi::PrivateDirectDrawStrategies (strategies))
151{
152}
153
154void
155cglfbi::DirectDrawStrategies::draw (const CompRect &src,
156 const CompRect &dst,
157 cglfb::BlitMask mask,
158 cglfb::Filter filter)
159{
160 if (!mask)
161 return;
162
163 const GLbitfield glMask = (mask & cglfb::ColorData ? GL_COLOR_BUFFER_BIT : 0) |
164 (mask & cglfb::StencilData ? GL_STENCIL_BUFFER_BIT : 0);
165 const GLenum glFilter = (filter == cglfb::Fast ? GL_NEAREST : GL_LINEAR);
166
167 while (!priv->rectDrawList.empty ())
168 {
169 const cglfb::RectangularDraw &strategy = priv->rectDrawList.back ();
170
171 /* If one method fails, try the next */
172 if (!strategy (src, dst, glMask, glFilter))
173 priv->rectDrawList.pop_back ();
174 else
175 break;
176 }
177}
0178
=== added directory 'plugins/opengl/src/fbdirectdraw/tests'
=== added file 'plugins/opengl/src/fbdirectdraw/tests/CMakeLists.txt'
--- plugins/opengl/src/fbdirectdraw/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/fbdirectdraw/tests/CMakeLists.txt 2013-05-26 06:45:17 +0000
@@ -0,0 +1,24 @@
1find_library (GMOCK_LIBRARY gmock)
2find_library (GMOCK_MAIN_LIBRARY gmock_main)
3
4if (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
5 message ("Google Mock and Google Test not found - cannot build tests!")
6 set (COMPIZ_BUILD_TESTING OFF)
7endif (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
8
9include_directories (${GTEST_INCLUDE_DIRS})
10
11link_directories (${COMPIZ_LIBRARY_DIRS})
12
13add_executable (compiz_test_opengl_framebuffer_direct_draw
14 ${CMAKE_CURRENT_SOURCE_DIR}/test-opengl-framebuffer-direct-draw.cpp)
15
16target_link_libraries (compiz_test_opengl_framebuffer_direct_draw
17 compiz_opengl_framebuffer_direct_draw
18 ${GTEST_BOTH_LIBRARIES}
19 ${GMOCK_LIBRARY}
20 ${GMOCK_MAIN_LIBRARY}
21 ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
22 )
23
24compiz_discover_tests (compiz_test_opengl_framebuffer_direct_draw COVERAGE compiz_opengl_framebuffer_direct_draw)
025
=== added file 'plugins/opengl/src/fbdirectdraw/tests/test-opengl-framebuffer-direct-draw.cpp'
--- plugins/opengl/src/fbdirectdraw/tests/test-opengl-framebuffer-direct-draw.cpp 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/fbdirectdraw/tests/test-opengl-framebuffer-direct-draw.cpp 2013-05-26 06:45:17 +0000
@@ -0,0 +1,237 @@
1/*
2 * Compiz, opengl plugin, DirectDrawFramebufferStrategies class
3 *
4 * Copyright (c) 2012 Canonical Ltd.
5 * Authors: Sam Spilsbury <sam.spilsbury@canonical.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25#include <memory>
26#include <boost/function.hpp>
27#include <boost/bind.hpp>
28#include <gtest/gtest.h>
29#include <gmock/gmock.h>
30#include <opengl/opengl-api.h>
31#include <opengl/framebufferobject.h>
32#include "framebuffer-direct-draw.h"
33
34using ::testing::Return;
35using ::testing::_;
36using ::testing::Expectation;
37using ::testing::StrictMock;
38using ::testing::NiceMock;
39using ::testing::ReturnNull;
40
41namespace cglfb = compiz::opengl;
42namespace cglfbi = compiz::opengl::impl;
43
44namespace
45{
46class MockDrawStrategy
47{
48 public:
49
50 MOCK_METHOD4 (draw, bool (const CompRect &,
51 const CompRect &,
52 GLbitfield,
53 GLenum));
54};
55
56class MockBindLocation :
57 public cglfb::BindLocation
58{
59 public:
60
61 MOCK_METHOD1 (bind, cglfb::BindableFramebuffer * (cglfb::BindableFramebuffer *));
62 MOCK_METHOD0 (getCurrentlyBound, cglfb::BindableFramebuffer * ());
63};
64
65class MockBindable :
66 public cglfb::BindableFramebuffer
67{
68 public:
69
70 MOCK_METHOD1 (updateAllocation, void (GLenum));
71 MOCK_METHOD1 (setBindStatus, bool (GLenum));
72 MOCK_CONST_METHOD0 (getResourceId, GLuint ());
73};
74
75}
76
77class FBDirectDrawStrategies :
78 public ::testing::Test
79{
80 public:
81
82 FBDirectDrawStrategies () :
83 blitFramebuffer (boost::bind (&MockDrawStrategy::draw, &mpfb, _1, _2, _3, _4)),
84 rtdraw (boost::bind (&MockDrawStrategy::draw, &mdr,
85 _1, _2, _3, _4))
86 {
87 }
88
89 void SetUpStrategyList (const cglfb::RectangularDraw &blit,
90 const cglfb::RectangularDraw &draw)
91 {
92 strategyList.clear ();
93 strategyList.push_back (draw);
94 strategyList.push_back (blit);
95 }
96
97 virtual void SetUp ()
98 {
99 boost::function <cglfb::BindableFramebuffer * (cglfb::BindableFramebuffer *)> readBind
100 (boost::bind (&MockBindLocation::bind, &mockBindLocation, _1));
101 blitFramebufferWithReadPushed = boost::bind (&cglfbi::rectangleDrawFromReadBuffer,
102 _1, _2, _3, _4,
103 &mockBindable,
104 readBind,
105 blitFramebuffer);
106
107 SetUpStrategyList (blitFramebuffer, rtdraw);
108 directDraw.reset (new cglfbi::DirectDrawStrategies (strategyList));
109 }
110
111 std::auto_ptr <cglfbi::DirectDrawStrategies> directDraw;
112 MockDrawStrategy mpfb;
113 cglfb::RectangularDraw blitFramebuffer;
114 cglfb::RectangularDraw blitFramebufferWithReadPushed;
115 MockDrawStrategy mdr;
116 StrictMock <MockBindable> mockBindable;
117 StrictMock <MockBindLocation> mockBindLocation;
118 cglfb::RectangularDraw rtdraw;
119 cglfb::RectangularDrawList strategyList;
120
121};
122
123TEST_F (FBDirectDrawStrategies, BufferBitsSet)
124{
125 CompRect srcAndDst (0, 0, 0, 0);
126
127 EXPECT_CALL (mpfb, draw (srcAndDst, srcAndDst, GL_COLOR_BUFFER_BIT |
128 GL_STENCIL_BUFFER_BIT,
129 _)).WillOnce (Return (true));
130
131 directDraw->draw (srcAndDst,
132 srcAndDst,
133 static_cast <cglfb::BlitMask> (cglfb::ColorData |
134 cglfb::StencilData),
135 cglfb::Good);
136}
137
138TEST_F (FBDirectDrawStrategies, BufferNoBitsSet)
139{
140 CompRect srcAndDst (0, 0, 0, 0);
141
142 EXPECT_CALL (mpfb, draw (srcAndDst, srcAndDst, 0,
143 _)).Times (0);
144
145 directDraw->draw (srcAndDst,
146 srcAndDst,
147 static_cast <cglfb::BlitMask> (0),
148 cglfb::Good);
149}
150
151TEST_F (FBDirectDrawStrategies, GoodToLinear)
152{
153 CompRect srcAndDst (0, 0, 0, 0);
154
155 EXPECT_CALL (mpfb, draw (srcAndDst, srcAndDst, _,
156 GL_LINEAR)).WillOnce (Return (true));
157
158 directDraw->draw (srcAndDst,
159 srcAndDst,
160 cglfb::ColorData,
161 cglfb::Good);
162}
163
164TEST_F (FBDirectDrawStrategies, FastToNearest)
165{
166 CompRect srcAndDst (0, 0, 0, 0);
167
168 EXPECT_CALL (mpfb, draw (srcAndDst, srcAndDst, _,
169 GL_NEAREST)).WillOnce (Return (true));
170
171 directDraw->draw (srcAndDst,
172 srcAndDst,
173 cglfb::ColorData,
174 cglfb::Fast);
175}
176
177TEST_F (FBDirectDrawStrategies, RevertToPaintWhenBlitUnavailable)
178{
179 CompRect srcAndDst (0, 0, 0, 0);
180
181 EXPECT_CALL (mpfb, draw (srcAndDst, srcAndDst, _,
182 _)).WillOnce (Return (false));
183 EXPECT_CALL (mdr, draw (srcAndDst, srcAndDst, _, _));
184
185 directDraw->draw (srcAndDst,
186 srcAndDst,
187 cglfb::ColorData,
188 cglfb::Fast);
189}
190
191TEST_F (FBDirectDrawStrategies, RevertOnBlitUnavailablePermanent)
192{
193 StrictMock <MockDrawStrategy> strictMdr;
194 CompRect srcAndDst (0, 0, 0, 0);
195
196 rtdraw = boost::bind (&MockDrawStrategy::draw, &strictMdr, _1, _2, _3, _4);
197
198 SetUpStrategyList (blitFramebuffer, rtdraw);
199 directDraw.reset (new cglfbi::DirectDrawStrategies (strategyList));
200
201 EXPECT_CALL (mpfb, draw (srcAndDst, srcAndDst, _, _)).WillOnce (Return (false));
202 ON_CALL (strictMdr, draw (_, _, _, _)).WillByDefault (Return (true));
203 EXPECT_CALL (strictMdr, draw (srcAndDst, srcAndDst, _, _)).Times (2);
204
205 directDraw->draw (srcAndDst,
206 srcAndDst,
207 cglfb::ColorData,
208 cglfb::Fast);
209 directDraw->draw (srcAndDst,
210 srcAndDst,
211 cglfb::ColorData,
212 cglfb::Fast);
213}
214
215TEST_F (FBDirectDrawStrategies, BindReadFramebufferOnBlit)
216{
217 CompRect srcAndDst (0, 0, 0, 0);
218
219 SetUpStrategyList (blitFramebufferWithReadPushed, rtdraw);
220 directDraw.reset (new cglfbi::DirectDrawStrategies (strategyList));
221
222 MockBindable backBuffer;
223
224 EXPECT_CALL (mockBindLocation, bind (&mockBindable)).WillOnce (Return (&backBuffer));
225 EXPECT_CALL (mpfb, draw (srcAndDst, srcAndDst, _, _)).WillOnce (Return (false));
226 ON_CALL (mdr, draw (_, _, _, _)).WillByDefault (Return (true));
227 EXPECT_CALL (mdr, draw (srcAndDst, srcAndDst, _, _)).Times (2);
228
229 directDraw->draw (srcAndDst,
230 srcAndDst,
231 cglfb::ColorData,
232 cglfb::Fast);
233 directDraw->draw (srcAndDst,
234 srcAndDst,
235 cglfb::ColorData,
236 cglfb::Fast);
237}
0238
=== 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-05-26 06:45:17 +0000
@@ -22,88 +22,96 @@
22 *22 *
23 * Authors: Pekka Paalanen <ppaalanen@gmail.com>23 * Authors: Pekka Paalanen <ppaalanen@gmail.com>
24 */24 */
2525#include <memory>
26#include <map>26#include <map>
27#include <opengl/opengl.h>
27#include <opengl/framebufferobject.h>28#include <opengl/framebufferobject.h>
28#include <opengl/texture.h>29#include <opengl/texture.h>
2930
31#include "framebuffer-direct-draw.h"
32
33namespace cglfb = compiz::opengl;
34namespace cglfbi = compiz::opengl::impl;
35
36namespace compiz
37{
38namespace opengl
39{
40namespace impl
41{
30struct PrivateGLFramebufferObject42struct PrivateGLFramebufferObject
31{43{
32 PrivateGLFramebufferObject () :44 PrivateGLFramebufferObject () :
33 fboId (0),45 fboId (0),
34 pushedId (0),
35 glTex (NULL),46 glTex (NULL),
36 status (-1)47 status (-1)
37 {48 {
38 }49 }
3950
40 void pushFBO ();
41 void popFBO ();
42
43 GLuint fboId;51 GLuint fboId;
44 GLuint pushedId;
45 GLuint rbStencilId;52 GLuint rbStencilId;
46 GLTexture *glTex;53 GLTexture *glTex;
4754
48 GLint status;55 GLint status;
4956
50 static GLuint boundId;57 std::auto_ptr <cglfb::DirectDrawStrategies> mDirectDraw;
51 static std::map<GLuint, GLFramebufferObject *> idMap;58 GLVertexBuffer *vertexBuffer;
52};59};
5360
54GLuint PrivateGLFramebufferObject::boundId = 0;61}
55std::map<GLuint, GLFramebufferObject *> PrivateGLFramebufferObject::idMap;62}
5663}
57void64
58PrivateGLFramebufferObject::pushFBO ()65GLuint
59{66cglfbi::FramebufferObject::getResourceId () const
60 pushedId = boundId;67{
61 if (boundId != fboId)68 return priv->fboId;
62 {69}
63 (*GL::bindFramebuffer) (GL::FRAMEBUFFER, fboId);70
64 boundId = fboId;71bool
65 }72cglfbi::FramebufferObject::setBindStatus (GLenum status)
66}73{
6774 priv->status = status;
68void75 return checkStatus ();
69PrivateGLFramebufferObject::popFBO ()76}
70{77
71 if (boundId != pushedId)78void
72 {79cglfbi::FramebufferObject::updateAllocation (GLenum bindingLocation)
73 (*GL::bindFramebuffer) (GL::FRAMEBUFFER, pushedId);80{
74 boundId = pushedId;81 if (priv->status == -1)
75 }82 {
76}83 (*GL::framebufferTexture2D) (bindingLocation, GL::COLOR_ATTACHMENT0,
7784 priv->glTex->target (),
78GLFramebufferObject::GLFramebufferObject () :85 priv->glTex->name (), 0);
79 priv (new PrivateGLFramebufferObject)86 (*GL::framebufferRenderbuffer) (bindingLocation, GL::DEPTH_ATTACHMENT, GL::RENDERBUFFER, priv->rbStencilId);
87 (*GL::framebufferRenderbuffer) (bindingLocation, GL::STENCIL_ATTACHMENT, GL::RENDERBUFFER, priv->rbStencilId);
88 }
89
90}
91
92cglfbi::FramebufferObject::FramebufferObject () :
93 priv (new cglfbi::PrivateGLFramebufferObject ())
80{94{
81 (*GL::genFramebuffers) (1, &priv->fboId);95 (*GL::genFramebuffers) (1, &priv->fboId);
82 (*GL::genRenderbuffers) (1, &priv->rbStencilId);96 (*GL::genRenderbuffers) (1, &priv->rbStencilId);
83
84 if (priv->fboId != 0)
85 PrivateGLFramebufferObject::idMap[priv->fboId] = this;
86}97}
8798
88GLFramebufferObject::~GLFramebufferObject ()99cglfbi::FramebufferObject::~FramebufferObject ()
89{100{
90 if (priv->glTex)101 if (priv->glTex)
91 GLTexture::decRef (priv->glTex);102 GLTexture::decRef (priv->glTex);
92103
93 PrivateGLFramebufferObject::idMap.erase (priv->fboId);
94 (*GL::deleteFramebuffers) (1, &priv->fboId);104 (*GL::deleteFramebuffers) (1, &priv->fboId);
95 (*GL::deleteRenderbuffers) (1, &priv->rbStencilId);105 (*GL::deleteRenderbuffers) (1, &priv->rbStencilId);
96106
97
98 delete priv;107 delete priv;
99}108}
100109
101bool110bool
102GLFramebufferObject::allocate (const CompSize &size, const char *image,111cglfbi::FramebufferObject::allocate (const CompSize &size,
103 GLenum format, GLenum type)112 const char *image,
113 GLenum format, GLenum type)
104{114{
105 priv->status = -1;
106
107 if (!priv->glTex ||115 if (!priv->glTex ||
108 size.width () != priv->glTex->width () ||116 size.width () != priv->glTex->width () ||
109 size.height () != priv->glTex->height ())117 size.height () != priv->glTex->height ())
@@ -125,86 +133,39 @@
125 (*GL::bindRenderbuffer) (GL::RENDERBUFFER, priv->rbStencilId);133 (*GL::bindRenderbuffer) (GL::RENDERBUFFER, priv->rbStencilId);
126 (*GL::renderbufferStorage) (GL::RENDERBUFFER, GL::DEPTH24_STENCIL8, size.width (), size.height ());134 (*GL::renderbufferStorage) (GL::RENDERBUFFER, GL::DEPTH24_STENCIL8, size.width (), size.height ());
127 }135 }
136
137 priv->status = -1;
128 }138 }
129139
130 priv->pushFBO ();
131
132 (*GL::framebufferTexture2D) (GL::FRAMEBUFFER, GL::COLOR_ATTACHMENT0,
133 priv->glTex->target (),
134 priv->glTex->name (), 0);
135
136 priv->status = (*GL::checkFramebufferStatus) (GL::DRAW_FRAMEBUFFER);
137
138 priv->popFBO ();
139 return true;140 return true;
140}141}
141142
142GLFramebufferObject *143namespace
143GLFramebufferObject::bind ()144{
144{145const char *
145 GLFramebufferObject *old = NULL;
146
147 if (priv->boundId != 0)
148 {
149 std::map<GLuint, GLFramebufferObject *>::iterator it;
150 it = PrivateGLFramebufferObject::idMap.find (priv->boundId);
151
152 if (it != PrivateGLFramebufferObject::idMap.end ())
153 old = it->second;
154 else
155 compLogMessage ("opengl", CompLogLevelError,
156 "An FBO without GLFramebufferObject cannot be restored");
157 }
158
159 (*GL::bindFramebuffer) (GL::FRAMEBUFFER, priv->fboId);
160 priv->boundId = priv->fboId;
161
162 (*GL::framebufferRenderbuffer) (GL::FRAMEBUFFER, GL::DEPTH_ATTACHMENT, GL::RENDERBUFFER, priv->rbStencilId);
163 (*GL::framebufferRenderbuffer) (GL::FRAMEBUFFER, GL::STENCIL_ATTACHMENT, GL::RENDERBUFFER, priv->rbStencilId);
164
165 return old;
166}
167
168// static
169void
170GLFramebufferObject::rebind (GLFramebufferObject *fbo)
171{
172 GLuint id = fbo ? fbo->priv->fboId : 0;
173
174 if (id != fbo->priv->boundId)
175 {
176 (*GL::bindFramebuffer) (GL::FRAMEBUFFER, id);
177 fbo->priv->boundId = id;
178 }
179}
180
181static const char *
182getFboErrorString (GLint status)146getFboErrorString (GLint status)
183{147{
184 switch (status)148 switch (status)
185 {149 {
186 case GL::FRAMEBUFFER_COMPLETE:150 case GL::FRAMEBUFFER_COMPLETE:
187 return "GL::FRAMEBUFFER_COMPLETE";151 return "GL::FRAMEBUFFER_COMPLETE";
188 case GL::FRAMEBUFFER_INCOMPLETE_ATTACHMENT:152 case GL::FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
189 return "GL::FRAMEBUFFER_INCOMPLETE_ATTACHMENT";153 return "GL::FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
190 case GL::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:154 case GL::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
191 return "GL::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";155 return "GL::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
192 case GL::FRAMEBUFFER_INCOMPLETE_DIMENSIONS:156 case GL::FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
193 return "GL::FRAMEBUFFER_INCOMPLETE_DIMENSIONS";157 return "GL::FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
194 case GL::FRAMEBUFFER_UNSUPPORTED:158 case GL::FRAMEBUFFER_UNSUPPORTED:
195 return "GL::FRAMEBUFFER_UNSUPPORTED";159 return "GL::FRAMEBUFFER_UNSUPPORTED";
196 default:160 default:
197 return "unexpected status";161 return "unexpected status";
198 }162 }
199}163}
164}
200165
201bool166bool
202GLFramebufferObject::checkStatus ()167cglfbi::FramebufferObject::checkStatus ()
203{168{
204 priv->pushFBO ();
205 priv-> status = (*GL::checkFramebufferStatus) (GL_FRAMEBUFFER);
206 priv->popFBO ();
207
208 if (priv->status == static_cast <GLint> (GL::FRAMEBUFFER_COMPLETE))169 if (priv->status == static_cast <GLint> (GL::FRAMEBUFFER_COMPLETE))
209 return true;170 return true;
210171
@@ -215,7 +176,54 @@
215}176}
216177
217GLTexture *178GLTexture *
218GLFramebufferObject::tex ()179cglfbi::FramebufferObject::tex ()
219{180{
220 return priv->glTex;181 return priv->glTex;
221}182}
183
184class cglfbi::FBOBindLocation::Private
185{
186 public:
187
188 Private (GLenum binding,
189 cglfb::BindableFramebuffer *back) :
190 mCurrentlyBound (back),
191 mBindPoint (binding)
192 {
193 }
194
195 cglfb::BindableFramebuffer *mCurrentlyBound;
196 GLenum mBindPoint;
197};
198
199cglfbi::FBOBindLocation::FBOBindLocation (GLenum binding,
200 cglfb::BindableFramebuffer *back) :
201 priv (new cglfbi::FBOBindLocation::Private (binding, back))
202{
203}
204
205cglfb::BindableFramebuffer *
206cglfbi::FBOBindLocation::bind (cglfb::BindableFramebuffer *next)
207{
208 if (priv->mCurrentlyBound == next)
209 return next;
210
211 (*GL::bindFramebuffer) (priv->mBindPoint, next->getResourceId ());
212 next->updateAllocation (priv->mBindPoint);
213 if (!next->setBindStatus ((*GL::checkFramebufferStatus) (priv->mBindPoint)))
214 {
215 (*GL::bindFramebuffer) (priv->mBindPoint, priv->mCurrentlyBound->getResourceId ());
216 return NULL;
217 }
218
219 cglfb::BindableFramebuffer *last = priv->mCurrentlyBound;
220 priv->mCurrentlyBound = next;
221 return last;
222}
223
224cglfb::BindableFramebuffer *
225cglfbi::FBOBindLocation::getCurrentlyBound ()
226{
227 return priv->mCurrentlyBound;
228}
229
222230
=== modified file 'plugins/opengl/src/paint.cpp'
--- plugins/opengl/src/paint.cpp 2013-05-08 15:13:28 +0000
+++ plugins/opengl/src/paint.cpp 2013-05-26 06:45:17 +0000
@@ -44,6 +44,7 @@
44#define DEG2RAD (M_PI / 180.0f)44#define DEG2RAD (M_PI / 180.0f)
4545
46using namespace compiz::opengl;46using namespace compiz::opengl;
47namespace cglfb = compiz::opengl;
4748
48GLScreenPaintAttrib defaultScreenPaintAttrib = {49GLScreenPaintAttrib defaultScreenPaintAttrib = {
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
@@ -437,6 +438,8 @@
437 continue;438 continue;
438 }439 }
439440
441 gw = GLWindow::get (w);
442
440 const CompRegion &clip =443 const CompRegion &clip =
441 (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK)) ?444 (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK)) ?
442 gw->clip () : region;445 gw->clip () : region;
@@ -677,89 +680,16 @@
677}680}
678681
679void682void
680GLScreen::glPaintCompositedOutput (const CompRegion &region,683GLScreen::glPaintCompositedOutput (const CompRegion &region,
681 GLFramebufferObject *fbo,684 compiz::opengl::DirectDrawObject *fbo,
682 unsigned int mask)685 unsigned int mask)
683{686{
684 WRAPABLE_HND_FUNCTN (glPaintCompositedOutput, region, fbo, mask)687 WRAPABLE_HND_FUNCTN (glPaintCompositedOutput, region, fbo, mask)
685688
686 GLMatrix sTransform;689 /* Draw every rect individually, this could be a little slow
687 const GLTexture::Matrix & texmatrix = fbo->tex ()->matrix ();690 * for lots of rects, but the general usecase isn't that */
688 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();691 foreach (const CompRect &r, region.rects ())
689692 fbo->directDraw (r, r, cglfb::ColorData, cglfb::Fast);
690 streamingBuffer->begin (GL_TRIANGLES);
691
692 if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
693 {
694 GLfloat tx1 = COMP_TEX_COORD_X (texmatrix, 0.0f);
695 GLfloat tx2 = COMP_TEX_COORD_X (texmatrix, screen->width ());
696 GLfloat ty1 = 1.0 - COMP_TEX_COORD_Y (texmatrix, 0.0f);
697 GLfloat ty2 = 1.0 - COMP_TEX_COORD_Y (texmatrix, screen->height ());
698
699 const GLfloat vertexData[] = {
700 0.0f, 0.0f, 0.0f,
701 0.0f, (float)screen->height (), 0.0f,
702 (float)screen->width (), 0.0f, 0.0f,
703
704 0.0f, (float)screen->height (), 0.0f,
705 (float)screen->width (), (float)screen->height (), 0.0f,
706 (float)screen->width (), 0.0f, 0.0f,
707 };
708
709 const GLfloat textureData[] = {
710 tx1, ty1,
711 tx1, ty2,
712 tx2, ty1,
713 tx1, ty2,
714 tx2, ty2,
715 tx2, ty1,
716 };
717
718 streamingBuffer->addVertices (6, &vertexData[0]);
719 streamingBuffer->addTexCoords (0, 6, &textureData[0]);
720 }
721 else
722 {
723 BoxPtr pBox = const_cast <Region> (region.handle ())->rects;
724 int nBox = const_cast <Region> (region.handle ())->numRects;
725
726 while (nBox--)
727 {
728 GLfloat tx1 = COMP_TEX_COORD_X (texmatrix, pBox->x1);
729 GLfloat tx2 = COMP_TEX_COORD_X (texmatrix, pBox->x2);
730 GLfloat ty1 = 1.0 - COMP_TEX_COORD_Y (texmatrix, pBox->y1);
731 GLfloat ty2 = 1.0 - COMP_TEX_COORD_Y (texmatrix, pBox->y2);
732
733 const GLfloat vertexData[] = {
734 (float)pBox->x1, (float)pBox->y1, 0.0f,
735 (float)pBox->x1, (float)pBox->y2, 0.0f,
736 (float)pBox->x2, (float)pBox->y1, 0.0f,
737
738 (float)pBox->x1, (float)pBox->y2, 0.0f,
739 (float)pBox->x2, (float)pBox->y2, 0.0f,
740 (float)pBox->x2, (float)pBox->y1, 0.0f,
741 };
742
743 const GLfloat textureData[] = {
744 tx1, ty1,
745 tx1, ty2,
746 tx2, ty1,
747 tx1, ty2,
748 tx2, ty2,
749 tx2, ty1,
750 };
751
752 streamingBuffer->addVertices (6, &vertexData[0]);
753 streamingBuffer->addTexCoords (0, 6, &textureData[0]);
754 pBox++;
755 }
756 }
757
758 streamingBuffer->end ();
759 fbo->tex ()->enable (GLTexture::Fast);
760 sTransform.toScreenSpace (&screen->fullscreenOutput (), -DEFAULT_Z_CAMERA);
761 streamingBuffer->render (sTransform);
762 fbo->tex ()->disable ();
763}693}
764694
765static void695static void
766696
=== 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-05-26 06:45:17 +0000
@@ -29,22 +29,28 @@
29#define _OPENGL_PRIVATES_H29#define _OPENGL_PRIVATES_H
3030
31#include <memory>31#include <memory>
32
33#include <composite/composite.h>32#include <composite/composite.h>
34#include <opengl/opengl.h>33#include <opengl/opengl.h>
35#include <core/atoms.h>34#include <core/atoms.h>
36#include <core/configurerequestbuffer.h>35#include <core/configurerequestbuffer.h>
37
38#ifdef USE_GLES
39#include <opengl/framebufferobject.h>36#include <opengl/framebufferobject.h>
40#endif
41
42#include <opengl/doublebuffer.h>37#include <opengl/doublebuffer.h>
4338
44#include "privatetexture.h"39#include "privatetexture.h"
45#include "privatevertexbuffer.h"40#include "privatevertexbuffer.h"
46#include "opengl_options.h"41#include "opengl_options.h"
4742
43namespace compiz
44{
45 namespace opengl
46 {
47 namespace impl
48 {
49 class DirectDrawObject;
50 }
51 }
52}
53
48extern CompOutput *targetOutput;54extern CompOutput *targetOutput;
4955
50class GLDoubleBuffer :56class GLDoubleBuffer :
@@ -86,6 +92,17 @@
86 Window mOutput;92 Window mOutput;
87};93};
8894
95namespace compiz
96{
97 namespace opengl
98 {
99 bool blitFramebufferGLX (const CompRect &src,
100 const CompRect &dst,
101 GLbitfield mask,
102 GLenum filter);
103 }
104}
105
89#else106#else
90107
91class EGLDoubleBuffer :108class EGLDoubleBuffer :
@@ -109,6 +126,17 @@
109 EGLSurface const & mSurface;126 EGLSurface const & mSurface;
110};127};
111128
129namespace compiz
130{
131 namespace opengl
132 {
133 bool blitFramebufferEGL (const CompRect &src,
134 const CompRect &dst,
135 GLbitfield mask,
136 GLenum filter);
137 }
138}
139
112#endif140#endif
113141
114class GLIcon142class GLIcon
@@ -120,6 +148,16 @@
120 GLTexture::List textures;148 GLTexture::List textures;
121};149};
122150
151class BindableBackbuffer :
152 public compiz::opengl::BindableFramebuffer
153{
154 public:
155
156 GLuint getResourceId () const;
157 bool setBindStatus (GLenum);
158 void updateAllocation (GLenum);
159};
160
123class PrivateGLScreen :161class PrivateGLScreen :
124 public ScreenInterface,162 public ScreenInterface,
125 public compiz::composite::PaintHandler,163 public compiz::composite::PaintHandler,
@@ -197,8 +235,9 @@
197 GLXDoubleBuffer doubleBuffer;235 GLXDoubleBuffer doubleBuffer;
198 #endif236 #endif
199237
200 GLFramebufferObject *scratchFbo;238 std::auto_ptr <compiz::opengl::DirectDrawObject> scratchFbo;
201 CompRegion outputRegion;239 compiz::opengl::BlitFramebufferFunc blitFramebuffer;
240 CompRegion outputRegion;
202241
203 XRectangle lastViewport;242 XRectangle lastViewport;
204 bool refreshSubBuffer;243 bool refreshSubBuffer;
@@ -222,6 +261,9 @@
222 Pixmap rootPixmapCopy;261 Pixmap rootPixmapCopy;
223 CompSize rootPixmapSize;262 CompSize rootPixmapSize;
224263
264 BindableBackbuffer backbuffer;
265 compiz::opengl::impl::FBOBindLocation drawFramebufferBinding;
266 compiz::opengl::impl::FBOBindLocation readFramebufferBinding;
225 const char *glVendor, *glRenderer, *glVersion;267 const char *glVendor, *glRenderer, *glVersion;
226268
227 mutable CompString prevRegex;269 mutable CompString prevRegex;
228270
=== 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-05-26 06:45:17 +0000
@@ -36,6 +36,7 @@
36#include <boost/make_shared.hpp>36#include <boost/make_shared.hpp>
3737
38#include "privates.h"38#include "privates.h"
39#include "framebuffer-direct-draw.h"
39#include "blacklist/blacklist.h"40#include "blacklist/blacklist.h"
4041
41#include <dlfcn.h>42#include <dlfcn.h>
@@ -67,6 +68,26 @@
6768
6869
69using namespace compiz::opengl;70using namespace compiz::opengl;
71namespace cglfb = compiz::opengl;
72namespace cgli = compiz::opengl::impl;
73
74namespace compiz
75{
76 namespace opengl
77 {
78#ifndef USE_GLES
79 bool blitFramebufferGLX (const CompRect &src,
80 const CompRect &dst,
81 GLbitfield mask,
82 GLenum filter);
83#else
84 bool blitFramebufferEGL (const CompRect &src,
85 const CompRect &dst,
86 GLbitfield mask,
87 GLenum filter);
88#endif
89 }
90}
7091
71namespace GL {92namespace GL {
72 #ifdef USE_GLES93 #ifdef USE_GLES
@@ -164,11 +185,12 @@
164 GLDisableVertexAttribArrayProc disableVertexAttribArray = NULL;185 GLDisableVertexAttribArrayProc disableVertexAttribArray = NULL;
165 GLVertexAttribPointerProc vertexAttribPointer = NULL;186 GLVertexAttribPointerProc vertexAttribPointer = NULL;
166187
167 GLGenRenderbuffersProc genRenderbuffers = NULL;188 GLGenRenderbuffersProc genRenderbuffers = NULL;
168 GLDeleteRenderbuffersProc deleteRenderbuffers = NULL;189 GLDeleteRenderbuffersProc deleteRenderbuffers = NULL;
169 GLFramebufferRenderbufferProc framebufferRenderbuffer = NULL;190 GLFramebufferRenderbufferProc framebufferRenderbuffer = NULL;
170 GLBindRenderbufferProc bindRenderbuffer = NULL;191 GLBindRenderbufferProc bindRenderbuffer = NULL;
171 GLRenderbufferStorageProc renderbufferStorage = NULL;192 GLRenderbufferStorageProc renderbufferStorage = NULL;
193 GLBlitFramebufferProc blitFramebuffer = NULL;
172194
173 bool textureFromPixmap = true;195 bool textureFromPixmap = true;
174 bool textureRectangle = false;196 bool textureRectangle = false;
@@ -299,6 +321,115 @@
299 GLScreen *gScreen;321 GLScreen *gScreen;
300};322};
301323
324namespace
325{
326bool defaultRectangularFramebufferDraw (GLVertexBuffer *vertexBuffer,
327 GLFramebufferObject *fbo,
328 const CompRect &src,
329 const CompRect &dst,
330 GLbitfield mask,
331 GLenum filter)
332{
333 GLTexture *texture = fbo->tex ();
334 GLMatrix sTransform;
335 const GLTexture::Matrix & texmatrix = texture->matrix ();
336 const GLfloat tx1 = COMP_TEX_COORD_X (texmatrix, src.x1 ());
337 const GLfloat tx2 = COMP_TEX_COORD_X (texmatrix, src.x2 ());
338 const GLfloat ty1 = 1.0 - COMP_TEX_COORD_Y (texmatrix, src.y1 ());
339 const GLfloat ty2 = 1.0 - COMP_TEX_COORD_Y (texmatrix, src.y2 ());
340
341 const GLfloat vx1 = src.x1 ();
342 const GLfloat vx2 = src.x2 ();
343 const GLfloat vy1 = src.y1 ();
344 const GLfloat vy2 = src.y2 ();
345
346 const GLTexture::Filter texFilter =
347 (filter == GL_LINEAR) ? GLTexture::Good :
348 GLTexture::Fast;
349
350 GLfloat vertexData[] = {
351 vx1, vy1, 0.0f,
352 vx1, vy2, 0.0f,
353 vx2, vy1, 0.0f,
354
355 vx1, vy2, 0.0f,
356 vx2, vy2, 0.0f,
357 vx2, vy1, 0.0f,
358 };
359
360 GLfloat textureData[] = {
361 tx1, ty1,
362 tx1, ty2,
363 tx2, ty1,
364 tx1, ty2,
365 tx2, ty2,
366 tx2, ty1,
367 };
368
369 vertexBuffer->begin (GL_TRIANGLES);
370 vertexBuffer->addVertices (6, vertexData);
371 vertexBuffer->addTexCoords (0, 6, textureData);
372
373 if (vertexBuffer->end ())
374 {
375 texture->enable (texFilter);
376 sTransform.toScreenSpace (&screen->fullscreenOutput (), -DEFAULT_Z_CAMERA);
377 vertexBuffer->render (sTransform);
378 texture->disable ();
379 }
380
381 return true;
382}
383
384void initDirectDraw (cgli::DirectDrawStrategies::Ptr &directDraw,
385 const compiz::opengl::RectangularDraw &blitFramebuffer,
386 const compiz::opengl::RectangularDraw &rectangularTextureDraw,
387 const cgli::BindReadBufferFunc &func,
388 compiz::opengl::BindableFramebuffer *bindable)
389{
390 cglfb::RectangularDraw blitFramebufferBound (
391 boost::bind (
392 cgli::rectangleDrawFromReadBuffer,
393 _1, _2, _3, _4,
394 bindable,
395 func,
396 blitFramebuffer));
397
398 /* Tries each of these from back to front */
399 cglfb::RectangularDrawList strategies;
400
401 strategies.push_back (rectangularTextureDraw);
402 strategies.push_back (blitFramebufferBound);
403 directDraw.reset (new cgli::DirectDrawStrategies (strategies));
404}
405}
406
407namespace compiz
408{
409namespace opengl
410{
411DirectDrawObject *
412createBlittableFramebufferObjectWithFallback (const CompSize &sz,
413 GLScreen *gScreen)
414{
415 boost::shared_ptr <cgli::DirectDrawStrategies> directDraw;
416 boost::shared_ptr <cgli::FramebufferObject> fbo (boost::make_shared <cgli::FramebufferObject> ());
417 cglfb::RectangularDraw rectangularTextureDraw (boost::bind (defaultRectangularFramebufferDraw,
418 GLVertexBuffer::streamingBuffer (),
419 fbo.get (),
420 _1, _2, _3, _4));
421 initDirectDraw (directDraw,
422 gScreen->blitFramebufferFunc (),
423 rectangularTextureDraw,
424 boost::bind (&GLScreen::bindFramebufferForReading, gScreen, _1),
425 fbo.get ());
426 DirectDrawObject *dd (new cgli::DirectDrawObject (directDraw, fbo, fbo));
427 dd->allocate (*screen, NULL, GL_BGRA);
428 return dd;
429}
430}
431}
432
302#ifndef USE_GLES433#ifndef USE_GLES
303434
304namespace compiz435namespace compiz
@@ -608,6 +739,7 @@
608 if (GL::textureFromPixmap)739 if (GL::textureFromPixmap)
609 registerBindPixmap (EglTexture::bindPixmapToTexture);740 registerBindPixmap (EglTexture::bindPixmapToTexture);
610741
742 priv->blitFramebuffer = boost::bind (compiz::opengl::blitFramebufferEGL, _1, _2, _3, _4);
611 priv->incorrectRefreshRate = false;743 priv->incorrectRefreshRate = false;
612744
613 #else745 #else
@@ -796,6 +928,10 @@
796 GL::fboSupported = true;928 GL::fboSupported = true;
797 }929 }
798930
931 if (GL::fboSupported &&
932 strstr (glExtensions, "GL_EXT_framebuffer_blit"))
933 GL::blitFramebuffer = (GL::GLBlitFramebufferProc) getProcAddress ("glBlitFramebufferEXT");
934
799 GL::fboStencilSupported = GL::fboSupported &&935 GL::fboStencilSupported = GL::fboSupported &&
800 strstr (glExtensions, "GL_EXT_packed_depth_stencil");936 strstr (glExtensions, "GL_EXT_packed_depth_stencil");
801937
@@ -912,13 +1048,13 @@
9121048
913 if (GL::textureFromPixmap)1049 if (GL::textureFromPixmap)
914 registerBindPixmap (TfpTexture::bindPixmapToTexture);1050 registerBindPixmap (TfpTexture::bindPixmapToTexture);
1051
1052 priv->blitFramebuffer = boost::bind (compiz::opengl::blitFramebufferGLX, _1, _2, _3, _4);
915#endif1053#endif
9161054
917 if (GL::fboSupported)1055 if (GL::fboSupported)
918 {1056 priv->scratchFbo.reset (compiz::opengl::createBlittableFramebufferObjectWithFallback (*screen,
919 priv->scratchFbo = new GLFramebufferObject;1057 this));
920 priv->scratchFbo->allocate (*screen, NULL, GL_BGRA);
921 }
9221058
923 GLVertexBuffer::streamingBuffer ()->setAutoProgram (priv->autoProgram);1059 GLVertexBuffer::streamingBuffer ()->setAutoProgram (priv->autoProgram);
9241060
@@ -1242,9 +1378,6 @@
1242 glXDestroyContext (screen->dpy (), priv->ctx);1378 glXDestroyContext (screen->dpy (), priv->ctx);
1243 #endif1379 #endif
12441380
1245 if (priv->scratchFbo)
1246 delete priv->scratchFbo;
1247
1248 delete priv;1381 delete priv;
1249}1382}
12501383
@@ -1267,6 +1400,7 @@
1267 doubleBuffer (screen->dpy (), *screen, surface),1400 doubleBuffer (screen->dpy (), *screen, surface),
1268 #endif1401 #endif
1269 scratchFbo (NULL),1402 scratchFbo (NULL),
1403 blitFramebuffer (),
1270 outputRegion (),1404 outputRegion (),
1271 refreshSubBuffer (false),1405 refreshSubBuffer (false),
1272 lastMask (0),1406 lastMask (0),
@@ -1279,6 +1413,10 @@
1279 autoProgram (new GLScreenAutoProgram(gs)),1413 autoProgram (new GLScreenAutoProgram(gs)),
1280 rootPixmapCopy (None),1414 rootPixmapCopy (None),
1281 rootPixmapSize (),1415 rootPixmapSize (),
1416 drawFramebufferBinding (GL::DRAW_FRAMEBUFFER,
1417 &backbuffer),
1418 readFramebufferBinding (GL::READ_FRAMEBUFFER,
1419 &backbuffer),
1282 glVendor (NULL),1420 glVendor (NULL),
1283 glRenderer (NULL),1421 glRenderer (NULL),
1284 glVersion (NULL),1422 glVersion (NULL),
@@ -1474,11 +1612,19 @@
1474void1612void
1475PrivateGLScreen::outputChangeNotify ()1613PrivateGLScreen::outputChangeNotify ()
1476{1614{
1615 compiz::opengl::BindableFramebuffer *previousReadBuffer =
1616 readFramebufferBinding.bind (&backbuffer);
1617 compiz::opengl::BindableFramebuffer *previousDrawBuffer =
1618 drawFramebufferBinding.bind (&backbuffer);
1619
1477 screen->outputChangeNotify ();1620 screen->outputChangeNotify ();
14781621
1479 if (scratchFbo)1622 if (scratchFbo.get ())
1480 scratchFbo->allocate (*screen, NULL, GL_BGRA);1623 scratchFbo->allocate (*screen, NULL, GL_BGRA);
1481 updateView ();1624 updateView ();
1625
1626 readFramebufferBinding.bind (previousReadBuffer);
1627 drawFramebufferBinding.bind (previousDrawBuffer);
1482}1628}
14831629
1484#ifndef USE_GLES1630#ifndef USE_GLES
@@ -1703,9 +1849,9 @@
1703 WRAPABLE_DEF (projectionMatrix)1849 WRAPABLE_DEF (projectionMatrix)
17041850
1705void1851void
1706GLScreenInterface::glPaintCompositedOutput (const CompRegion &region,1852GLScreenInterface::glPaintCompositedOutput (const CompRegion &region,
1707 GLFramebufferObject *fbo,1853 compiz::opengl::DirectDrawObject *fbo,
1708 unsigned int mask)1854 unsigned int mask)
1709 WRAPABLE_DEF (glPaintCompositedOutput, region, fbo, mask)1855 WRAPABLE_DEF (glPaintCompositedOutput, region, fbo, mask)
17101856
1711void1857void
@@ -1932,6 +2078,30 @@
19322078
1933}2079}
19342080
2081bool
2082cglfb::blitFramebufferGLX (const CompRect &src,
2083 const CompRect &dst,
2084 GLbitfield mask,
2085 GLenum filter)
2086{
2087 /* Must have GL_EXT_blit_framebuffer */
2088 if (!GL::blitFramebuffer)
2089 return false;
2090
2091 /* Be sure to invert y-coords too */
2092 (*GL::blitFramebuffer) (src.x1 (), // sx0
2093 screen->height () - src.y2 (), // sy0
2094 src.x2 (), // sx1
2095 screen->height () - src.y1 (), // sy1
2096 dst.x1 (), // dx0
2097 screen->height () - dst.y2 (), // dy0
2098 dst.x2 (), // dx1,
2099 screen->height () - dst.y1 (), // dy1
2100 GL_COLOR_BUFFER_BIT,
2101 GL_LINEAR);
2102 return true;
2103}
2104
1935#else2105#else
19362106
1937EGLDoubleBuffer::EGLDoubleBuffer (Display *d,2107EGLDoubleBuffer::EGLDoubleBuffer (Display *d,
@@ -1990,6 +2160,16 @@
1990{2160{
1991}2161}
19922162
2163bool
2164cglfb::blitFramebufferEGL (const CompRect &src,
2165 const CompRect &dst,
2166 GLbitfield mask,
2167 GLenum filter)
2168{
2169 /* Not supported on OpenGL|ES2 */
2170 return false;
2171}
2172
1993#endif2173#endif
19942174
1995void2175void
@@ -2010,17 +2190,11 @@
2010 glDepthMask (GL_FALSE);2190 glDepthMask (GL_FALSE);
2011 glStencilMask (0);2191 glStencilMask (0);
20122192
2013 GLFramebufferObject *oldFbo = NULL;2193 compiz::opengl::BindableFramebuffer *oldFbo = NULL;
2014 bool useFbo = false;
20152194
2016 /* Clear the color buffer where appropriate */2195 /* Clear the color buffer where appropriate */
2017 if (GL::fboEnabled && scratchFbo)2196 if (GL::fboEnabled && scratchFbo.get ())
2018 {2197 oldFbo = drawFramebufferBinding.bind (scratchFbo.get ());
2019 oldFbo = scratchFbo->bind ();
2020 useFbo = scratchFbo->checkStatus () && scratchFbo->tex ();
2021 if (!useFbo)
2022 GLFramebufferObject::rebind (oldFbo);
2023 }
20242198
2025#ifdef UNSAFE_ARM_SGX_FIXME2199#ifdef UNSAFE_ARM_SGX_FIXME
2026 refreshSubBuffer = ((lastMask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&2200 refreshSubBuffer = ((lastMask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&
@@ -2113,13 +2287,10 @@
21132287
2114 glViewport (0, 0, screen->width (), screen->height ());2288 glViewport (0, 0, screen->width (), screen->height ());
21152289
2116 if (useFbo)2290 if (oldFbo)
2117 {2291 {
2118 GLFramebufferObject::rebind (oldFbo);2292 drawFramebufferBinding.bind (oldFbo);
21192293 gScreen->glPaintCompositedOutput (screen->region (), scratchFbo.get (), mask);
2120 // FIXME: does not work if screen dimensions exceed max texture size
2121 // We should try to use glBlitFramebuffer instead.
2122 gScreen->glPaintCompositedOutput (screen->region (), scratchFbo, mask);
2123 }2294 }
21242295
2125 if (cScreen->outputWindowChanged ())2296 if (cScreen->outputWindowChanged ())
@@ -2134,13 +2305,13 @@
2134 }2305 }
21352306
2136 bool alwaysSwap = optionGetAlwaysSwapBuffers ();2307 bool alwaysSwap = optionGetAlwaysSwapBuffers ();
2137 bool fullscreen = useFbo ||2308 bool fullscreen = oldFbo ||
2138 alwaysSwap ||2309 alwaysSwap ||
2139 ((mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&2310 ((mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&
2140 commonFrontbuffer);2311 commonFrontbuffer);
21412312
2142 doubleBuffer.set (DoubleBuffer::VSYNC, optionGetSyncToVblank ());2313 doubleBuffer.set (DoubleBuffer::VSYNC, optionGetSyncToVblank ());
2143 doubleBuffer.set (DoubleBuffer::HAVE_PERSISTENT_BACK_BUFFER, useFbo);2314 doubleBuffer.set (DoubleBuffer::HAVE_PERSISTENT_BACK_BUFFER, oldFbo ? true : false);
2144 doubleBuffer.set (DoubleBuffer::NEED_PERSISTENT_BACK_BUFFER, alwaysSwap);2315 doubleBuffer.set (DoubleBuffer::NEED_PERSISTENT_BACK_BUFFER, alwaysSwap);
2145 doubleBuffer.render (tmpRegion, fullscreen);2316 doubleBuffer.render (tmpRegion, fullscreen);
21462317
@@ -2228,10 +2399,40 @@
2228 }2399 }
2229}2400}
22302401
2231GLFramebufferObject *2402compiz::opengl::FramebufferObject *
2232GLScreen::fbo ()2403GLScreen::fbo ()
2233{2404{
2234 return priv->scratchFbo;2405 return priv->scratchFbo.get ();
2406}
2407
2408compiz::opengl::BindableFramebuffer *
2409GLScreen::backbuffer ()
2410{
2411 return &priv->backbuffer;
2412}
2413
2414compiz::opengl::BindableFramebuffer *
2415GLScreen::drawFramebuffer ()
2416{
2417 return priv->drawFramebufferBinding.getCurrentlyBound ();
2418}
2419
2420compiz::opengl::BindableFramebuffer *
2421GLScreen::bindFramebufferForDrawing (compiz::opengl::BindableFramebuffer *next)
2422{
2423 return priv->drawFramebufferBinding.bind (next);
2424}
2425
2426compiz::opengl::BindableFramebuffer *
2427GLScreen::bindFramebufferForReading (compiz::opengl::BindableFramebuffer *next)
2428{
2429 return priv->readFramebufferBinding.bind (next);
2430}
2431
2432const cglfb::BlitFramebufferFunc &
2433GLScreen::blitFramebufferFunc ()
2434{
2435 return priv->blitFramebuffer;
2235}2436}
22362437
2237GLTexture *2438GLTexture *
@@ -2273,3 +2474,19 @@
2273 priv->rasterPos.setY (0);2474 priv->rasterPos.setY (0);
2274}2475}
22752476
2477GLuint
2478BindableBackbuffer::getResourceId () const
2479{
2480 return 0;
2481}
2482
2483bool
2484BindableBackbuffer::setBindStatus (GLenum)
2485{
2486 return true;
2487}
2488
2489void
2490BindableBackbuffer::updateAllocation (GLenum)
2491{
2492}
22762493
=== modified file 'plugins/water/src/water.cpp'
--- plugins/water/src/water.cpp 2013-05-09 14:02:10 +0000
+++ plugins/water/src/water.cpp 2013-05-26 06:45:17 +0000
@@ -62,7 +62,11 @@
62 if (!useFbo)62 if (!useFbo)
63 return false;63 return false;
6464
65 oldFbo = waterFbo[fIndex]->bind ();65 oldFbo = gScreen->bindFramebufferForDrawing (waterFbo[fIndex]);
66
67 if (!oldFbo)
68 return false;
69
66 glGetIntegerv(GL_VIEWPORT, &oldViewport[0]);70 glGetIntegerv(GL_VIEWPORT, &oldViewport[0]);
67 glViewport (0, 0, texWidth, texHeight);71 glViewport (0, 0, texWidth, texHeight);
6872
@@ -72,7 +76,7 @@
72void76void
73WaterScreen::fboEpilogue ()77WaterScreen::fboEpilogue ()
74{78{
75 GLFramebufferObject::rebind (oldFbo);79 gScreen->bindFramebufferForDrawing (oldFbo);
76 glViewport (oldViewport[0], oldViewport[1], oldViewport[2], oldViewport[3]);80 glViewport (oldViewport[0], oldViewport[1], oldViewport[2], oldViewport[3]);
77}81}
7882
@@ -305,28 +309,32 @@
305 waterFbo[i]->allocate (size, (char *) t0,309 waterFbo[i]->allocate (size, (char *) t0,
306 GL_BGRA, GL_UNSIGNED_BYTE);310 GL_BGRA, GL_UNSIGNED_BYTE);
307 // check if FBOs are working. If not, fallback to software textures311 // check if FBOs are working. If not, fallback to software textures
308 oldFbo = waterFbo[i]->bind ();312 oldFbo = gScreen->bindFramebufferForDrawing (waterFbo[i]);
309 waterFbo[i]->rebind (oldFbo);313 if (!oldFbo)
310 if (!waterFbo[i]->checkStatus ())
311 {314 {
312 useFbo = false;315 useFbo = false;
313 delete waterFbo[i];316 delete waterFbo[i];
314 break;317 break;
315 }318 }
319 gScreen->bindFramebufferForDrawing (oldFbo);
316 }320 }
317 }321 }
318}322}
319323
320void324void
321WaterScreen::glPaintCompositedOutput (const CompRegion &region,325WaterScreen::glPaintCompositedOutput (const CompRegion &region,
322 GLFramebufferObject *fbo,326 compiz::opengl::DirectDrawObject *fbo,
323 unsigned int mask)327 unsigned int mask)
324{328{
325 if (count)329 if (count)
326 {330 {
327 if (GL::vboEnabled && GL::shaders)331 if (GL::vboEnabled && GL::shaders)
328 {332 {
329 GLFramebufferObject::rebind (oldFbo);333 /* This seems redundant to me */
334 gScreen->bindFramebufferForDrawing (oldFbo);
335
336 oldFbo = NULL;
337
330 glViewport (oldViewport[0], oldViewport[1],338 glViewport (oldViewport[0], oldViewport[1],
331 oldViewport[2], oldViewport[3]);339 oldViewport[2], oldViewport[3]);
332340
333341
=== modified file 'plugins/water/src/water.h'
--- plugins/water/src/water.h 2012-09-07 23:56:21 +0000
+++ plugins/water/src/water.h 2013-05-26 06:45:17 +0000
@@ -64,9 +64,9 @@
6464
65 void handleEvent (XEvent *);65 void handleEvent (XEvent *);
6666
67 void glPaintCompositedOutput (const CompRegion &region,67 void glPaintCompositedOutput (const CompRegion &region,
68 GLFramebufferObject *fbo,68 compiz::opengl::DirectDrawObject *fbo,
69 unsigned int mask);69 unsigned int mask);
70 void preparePaint (int);70 void preparePaint (int);
71 void donePaint ();71 void donePaint ();
7272
@@ -100,7 +100,7 @@
100100
101 GLFramebufferObject *waterFbo[TEXTURE_NUM];101 GLFramebufferObject *waterFbo[TEXTURE_NUM];
102102
103 GLFramebufferObject *oldFbo;103 compiz::opengl::BindableFramebuffer *oldFbo;
104 GLint oldViewport[4];104 GLint oldViewport[4];
105 int fboIndex;105 int fboIndex;
106 bool useFbo;106 bool useFbo;

Subscribers

People subscribed via source and target branches

to all changes: