Implement invertedY in the glx backend
authorJørgen Lind <jorgen.lind@nokia.com>
Fri, 6 May 2011 11:26:51 +0000 (13:26 +0200)
committerJørgen Lind <jorgen.lind@nokia.com>
Fri, 6 May 2011 11:27:49 +0000 (13:27 +0200)
Also change flipped to be true as default for texture buffers

src/qt-compositor/hardware_integration/graphicshardwareintegration.h
src/qt-compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.cpp
src/qt-compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.h
src/qt-compositor/hardware_integration/xcomposite_share/xcompositebuffer.cpp
src/qt-compositor/hardware_integration/xcomposite_share/xcompositebuffer.h
src/qt-compositor/wayland_wrapper/wlsurface.cpp

index 9fa574e..339e20a 100644 (file)
@@ -58,7 +58,7 @@ public:
         so there is no need to do makeCurrent in this function.
      **/
     virtual GLuint createTextureFromBuffer(struct wl_buffer *buffer) = 0;
-    virtual bool isYInverted(struct wl_buffer *) const { return false; }
+    virtual bool isYInverted(struct wl_buffer *) const { return true; }
 
     virtual bool setDirectRenderSurface(WaylandSurface *) {return false;}
     virtual bool postBuffer(struct wl_buffer *) {return false;}
index 383fa65..b5f4928 100644 (file)
@@ -87,6 +87,11 @@ GLuint XCompositeGLXIntegration::createTextureFromBuffer(wl_buffer *buffer)
     attribList.append(GLX_TEXTURE_2D_EXT);
     attribList.append(0);
     GLXPixmap glxPixmap = glXCreatePixmap(mDisplay,*configs,pixmap,attribList.constData());
+
+    uint inverted;
+    glXQueryDrawable(mDisplay, glxPixmap, GLX_Y_INVERTED_EXT,&inverted);
+    compositorBuffer->setInvertedY(!inverted);
+
     XFree(configs);
 
     GLuint textureId;
@@ -98,3 +103,9 @@ GLuint XCompositeGLXIntegration::createTextureFromBuffer(wl_buffer *buffer)
 //    m_glxReleaseTexImageEXT(mDisplay,glxPixmap,GLX_FRONT_EXT);
     return textureId;
 }
+
+bool XCompositeGLXIntegration::isYInverted(wl_buffer *buffer) const
+{
+    XCompositeBuffer *compositorBuffer = Wayland::wayland_cast<XCompositeBuffer *>(buffer);
+    return compositorBuffer->isYInverted();
+}
index c11adb6..ace454e 100644 (file)
@@ -17,6 +17,7 @@ public:
     void initializeHardware(Wayland::Display *waylandDisplay);
 
     GLuint createTextureFromBuffer(struct wl_buffer *buffer);
+    bool isYInverted(wl_buffer *) const;
 
 private:
     PFNGLXBINDTEXIMAGEEXTPROC m_glxBindTexImageEXT;
index 380145a..ad0203a 100644 (file)
@@ -2,6 +2,7 @@
 
 XCompositeBuffer::XCompositeBuffer(Wayland::Compositor *compositor, Window window, const QSize &size, struct wl_visual *visual)
     : mWindow(window)
+    , mInvertedY(false)
 {
     base()->compositor = compositor->base();
     base()->height = size.height();
index 6247903..42b20ee 100644 (file)
@@ -25,8 +25,11 @@ public:
     static void delete_resource(struct wl_resource *resource,
                                         struct wl_client *client);
 
+    bool isYInverted() const { return mInvertedY; }
+    void setInvertedY(bool inverted) { mInvertedY = inverted; }
 private:
     Window mWindow;
+    bool mInvertedY;
 
     static void buffer_interface_destroy(struct wl_client *client,
                         struct wl_buffer *buffer);
index c0eeace..deec00e 100644 (file)
@@ -196,9 +196,12 @@ WaylandSurface::Type Surface::type() const
 bool Surface::isYInverted() const
 {
     Q_D(const Surface);
-    if (d->type() == WaylandSurface::Texture) {
-        return d->compositor->graphicsHWIntegration()->isYInverted(d->buffer());
+    if (d->type() == WaylandSurface::Texture || d->type() == WaylandSurface::Direct) {
+        if (textureId()) {
+            return d->compositor->graphicsHWIntegration()->isYInverted(d->buffer());
+        }
     }
+    //shm surfaces are not flipped (in our "world")
     return false;
 }