summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdiel Janulgue <abdiel.janulgue@nokia.com>2010-11-17 17:06:04 +0200
committerKimmo Hämäläinen <kimmo.hamalainen@nokia.com>2010-11-29 13:20:17 +0200
commitdc8542bbb02b08a4312e56fbe36520ec0600993c (patch)
tree6de5ecc556f387370ae130f85cc6d421d2b6550d
parent33e079999e5c54c3fc7b75ec94f3e2edb9c79f8d (diff)
Changes: Add a depth buffer attachment to the framebuffer object so we can
take advantage of GPU depth test to properly render Z-order of off-screen items irrespective of item ordering. Fix naming conflict with MWindowPropertyCache::windowGroup().
-rw-r--r--src/mcompositescene.cpp2
-rw-r--r--src/mcompositewindow.cpp2
-rw-r--r--src/mcompositewindow.h2
-rw-r--r--src/mcompositewindowgroup.cpp21
4 files changed, 19 insertions, 8 deletions
diff --git a/src/mcompositescene.cpp b/src/mcompositescene.cpp
index 593e075..b0d6c23 100644
--- a/src/mcompositescene.cpp
+++ b/src/mcompositescene.cpp
@@ -127,7 +127,7 @@ void MCompositeScene::drawItems(QPainter *painter, int numItems, QGraphicsItem *
if (!cw->isWindowTransitioning()
&& !cw->propertyCache()->hasAlpha()
&& cw->opacity() == 1.0
- && !cw->windowGroup()) // window is renderered off-screen)
+ && !cw->group()) // window is not renderered off-screen)
visible -= r;
}
if (size > 0) {
diff --git a/src/mcompositewindow.cpp b/src/mcompositewindow.cpp
index 40af5de..3055f8c 100644
--- a/src/mcompositewindow.cpp
+++ b/src/mcompositewindow.cpp
@@ -794,7 +794,7 @@ bool MCompositeWindow::isMapped() const
return pc ? pc->isMapped() : false;
}
-MCompositeWindowGroup* MCompositeWindow::windowGroup() const
+MCompositeWindowGroup* MCompositeWindow::group() const
{
return renderer()->current_window_group;
}
diff --git a/src/mcompositewindow.h b/src/mcompositewindow.h
index a7b480c..f13fcce 100644
--- a/src/mcompositewindow.h
+++ b/src/mcompositewindow.h
@@ -309,7 +309,7 @@ public:
* Returns a pointer to this window's group if it belongs to a group and 0
* if 0 if not a member
*/
- MCompositeWindowGroup* windowGroup() const;
+ MCompositeWindowGroup* group() const;
/*! Disabled alpha-blending for a dim-effect instead */
void setDimmedEffect(bool dimmed) { dimmed_effect = dimmed; }
diff --git a/src/mcompositewindowgroup.cpp b/src/mcompositewindowgroup.cpp
index 27aa61f..93bad80 100644
--- a/src/mcompositewindowgroup.cpp
+++ b/src/mcompositewindowgroup.cpp
@@ -48,8 +48,10 @@
#ifdef GLES2_VERSION
#define FORMAT GL_RGBA
+#define DEPTH GL_DEPTH_COMPONENT16
#else
#define FORMAT GL_RGBA8
+#define DEPTH GL_DEPTH_COMPONENT
#endif
class MCompositeWindowGroupPrivate
@@ -59,14 +61,15 @@ public:
:main_window(mainWindow),
texture(0),
fbo(0),
+ depth_buffer(0),
valid(false),
renderer(new MTexturePixmapPrivate(0, mainWindow))
- {
-
+ {
}
MTexturePixmapItem* main_window;
GLuint texture;
GLuint fbo;
+ GLuint depth_buffer;
bool valid;
QList<MTexturePixmapItem*> item_groups;
@@ -88,7 +91,7 @@ MCompositeWindowGroup::MCompositeWindowGroup(MTexturePixmapItem* mainWindow)
connect(mainWindow, SIGNAL(destroyed()), SLOT(deleteLater()));
init();
updateWindowPixmap();
- setZValue(mainWindow->zValue() - 1);
+ setZValue(mainWindow->zValue());
stackBefore(mainWindow);
}
@@ -126,9 +129,9 @@ void MCompositeWindowGroup::init()
return;
}
d->renderer->current_window_group = this;
-
- // no renderbuffer because we dont need the stencil and depthbuffer attachment
+
glGenFramebuffers(1, &d->fbo);
+ glGenRenderbuffers(1, &d->depth_buffer);
glBindFramebuffer(GL_RENDERBUFFER, d->fbo);
glGenTextures(1, &d->texture);
@@ -139,9 +142,17 @@ void MCompositeWindowGroup::init()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glBindRenderbuffer(GL_RENDERBUFFER, d->depth_buffer);
+ glRenderbufferStorage(GL_RENDERBUFFER, DEPTH,
+ d->main_window->boundingRect().width(),
+ d->main_window->boundingRect().height());
+
glBindFramebuffer(GL_FRAMEBUFFER, d->fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, d->texture, 0);
+
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
+ GL_RENDERBUFFER, d->depth_buffer);
glBindTexture(GL_TEXTURE_2D, d->texture);
glTexImage2D(GL_TEXTURE_2D, 0, FORMAT,