Update wayland_sha
authorJørgen Lind <jorgen.lind@nokia.com>
Thu, 23 Jun 2011 08:40:45 +0000 (10:40 +0200)
committerJørgen Lind <jorgen.lind@nokia.com>
Thu, 23 Jun 2011 09:05:46 +0000 (11:05 +0200)
also, make the surfaceMapped signal give a size and not rect
and use the new visual api

12 files changed:
examples/qml-compositor/main.cpp
examples/qwidget-compositor/main.cpp
src/qt-compositor/compositor_api/waylandsurface.h
src/qt-compositor/compositor_api/waylandsurfaceitem.cpp
src/qt-compositor/compositor_api/waylandsurfaceitem.h
src/qt-compositor/hardware_integration/xcomposite_share/xcompositebuffer.cpp
src/qt-compositor/wayland_wrapper/wlcompositor.cpp
src/qt-compositor/wayland_wrapper/wloutput.cpp
src/qt-compositor/wayland_wrapper/wlshmbuffer.cpp
src/qt-compositor/wayland_wrapper/wlsurface.cpp
src/qt-compositor/wayland_wrapper/wlsurface.h
wayland_sha1.txt

index d92daea..ede41b4 100644 (file)
@@ -78,14 +78,14 @@ public slots:
     }
 
 private slots:
-    void surfaceMapped(const QRect &rect) {
+    void surfaceMapped(const QSize &size) {
         WaylandSurface *surface = qobject_cast<WaylandSurface *>(sender());
-        surface->setGeometry(rect);
+        surface->setGeometry(QRect(surface->geometry().topLeft(),size));
 
         if (m_windowMap.contains(surface)) {
             WaylandSurfaceItem *item = m_windowMap.value(surface);
-            item->setWidth(rect.width());
-            item->setHeight(rect.height());
+            item->setWidth(size.width());
+            item->setHeight(size.height());
             emit windowResized(QVariant::fromValue(static_cast<QSGItem *>(item)));
         } else {
             WaylandSurfaceItem *item = new WaylandSurfaceItem(surface, rootObject());
@@ -104,7 +104,7 @@ private slots:
 
 protected:
     void surfaceCreated(WaylandSurface *surface) {
-        connect(surface, SIGNAL(mapped(const QRect &)), this, SLOT(surfaceMapped(const QRect &)));
+        connect(surface, SIGNAL(mapped(const QSize &)), this, SLOT(surfaceMapped(const QSize &)));
     }
 
     void paintEvent(QPaintEvent *event) {
index 0f825c5..99efa02 100644 (file)
@@ -84,17 +84,17 @@ private slots:
         update();
     }
 
-    void surfaceMapped(const QRect &rect) {
+    void surfaceMapped(const QSize &size) {
         WaylandSurface *surface = qobject_cast<WaylandSurface *>(sender());
         QPoint pos;
         if (!m_surfaces.contains(surface)) {
-            uint px = 1 + (qrand() % (width() - rect.width() - 2));
-            uint py = 1 + (qrand() % (height() - rect.height() - 2));
+            uint px = 1 + (qrand() % (width() - size.width() - 2));
+            uint py = 1 + (qrand() % (height() - size.height() - 2));
             pos = QPoint(px, py);
-            surface->setGeometry(QRect(pos, rect.size()));
+            surface->setGeometry(QRect(pos, size));
             m_surfaces.append(surface);
         } else {
-            surface->setGeometry(rect);
+            surface->setGeometry(QRect(geometry().topLeft(),size));
         }
         setInputFocus(surface);
         update();
@@ -119,7 +119,7 @@ protected:
 
     void surfaceCreated(WaylandSurface *surface) {
         connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *)));
-        connect(surface, SIGNAL(mapped(const QRect &)), this, SLOT(surfaceMapped(const QRect &)));
+        connect(surface, SIGNAL(mapped(const QSize &)), this, SLOT(surfaceMapped(const QSize &)));
         connect(surface, SIGNAL(damaged(const QRect &)), this, SLOT(surfaceDamaged(const QRect &)));
         update();
     }
index 899bcae..288c3dc 100644 (file)
@@ -52,6 +52,7 @@ class WaylandSurfacePrivate;
 
 namespace Wayland {
 class Surface;
+class SurfacePrivate;
 }
 
 class WaylandSurface : public QObject
@@ -95,10 +96,11 @@ public:
     qint64 processId() const;
 
 signals:
-    void mapped(const QRect &rect);
+    void mapped(const QSize &size);
     void damaged(const QRect &rect);
 
     friend class Wayland::Surface;
+    friend class Wayland::SurfacePrivate;
 };
 
 #endif // WAYLANDSURFACE_H
index 89fdda2..9ce0dc1 100644 (file)
@@ -98,7 +98,7 @@ void WaylandSurfaceItem::init(WaylandSurface *surface)
     setSmooth(true);
     setFlag(ItemHasContents);
     setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton);
-    connect(surface, SIGNAL(mapped(const QRect &)), this, SLOT(surfaceMapped(const QRect &)));
+    connect(surface, SIGNAL(mapped(const QSize &)), this, SLOT(surfaceMapped(const QSize &)));
     connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *)));
     connect(this, SIGNAL(textureChanged()), this, SLOT(update()));
     connect(surface, SIGNAL(damaged(const QRect &)), this, SLOT(surfaceDamaged(const QRect &)));
@@ -169,10 +169,10 @@ QPoint WaylandSurfaceItem::toSurface(const QPointF &pos) const
     return pos.toPoint();
 }
 
-void WaylandSurfaceItem::surfaceMapped(const QRect &rect)
+void WaylandSurfaceItem::surfaceMapped(const QSize &size)
 {
-    setWidth(rect.width());
-    setHeight(rect.height());
+    setWidth(size.width());
+    setHeight(size.height());
 }
 
 void WaylandSurfaceItem::surfaceDestroyed(QObject *)
index f2a9e23..948d047 100644 (file)
@@ -91,7 +91,7 @@ public slots:
     void setPaintEnabled(bool paintEnabled);
 
 private slots:
-    void surfaceMapped(const QRect &rect);
+    void surfaceMapped(const QSize &size);
     void surfaceDestroyed(QObject *object);
     void surfaceDamaged(const QRect &);
 
index ad0203a..d6acc81 100644 (file)
@@ -4,7 +4,6 @@ XCompositeBuffer::XCompositeBuffer(Wayland::Compositor *compositor, Window windo
     : mWindow(window)
     , mInvertedY(false)
 {
-    base()->compositor = compositor->base();
     base()->height = size.height();
     base()->width = size.width();
     base()->visual = visual;
index 49003ea..96d9dd6 100644 (file)
@@ -157,11 +157,36 @@ void shell_selection(struct wl_client *client,
     Selection::instance()->create(client, id);
 }
 
+void set_toplevel(struct wl_client *client,
+                     struct wl_shell *wl_shell,
+                     struct wl_surface *surface)
+{
+
+}
+
+void set_transient(struct wl_client *client,
+                      struct wl_shell *wl_shell,
+                      struct wl_surface *surface,
+                      struct wl_surface *parent,
+                      int x,
+                      int y,
+                      uint32_t flags)
+{
+}
+void set_fullscreen(struct wl_client *client,
+                       struct wl_shell *wl_shell,
+                       struct wl_surface *surface)
+{
+}
+
 const static struct wl_shell_interface shell_interface = {
     shell_move,
     shell_resize,
     shell_drag,
-    shell_selection
+    shell_selection,
+    set_toplevel,
+    set_transient,
+    set_fullscreen
 };
 
 static Compositor *compositor;
index aecc209..6e7ea2d 100644 (file)
@@ -51,7 +51,9 @@ void output_post_geometry(struct wl_client *client, struct wl_object *global, ui
     Output *output = wayland_cast<Output *>(global);
 
     wl_client_post_event(client, global, WL_OUTPUT_GEOMETRY, 0, 0,
-                         output->size().width(), output->size().height());
+                         output->size().width(), output->size().height(),0,"","");
+
+    wl_client_post_event(client,global,WL_OUTPUT_MODE, 0,output->size().width(),output->size().height());
 }
 
 
index 7889fc7..e3fb4bd 100644 (file)
@@ -41,6 +41,7 @@
 #include "wlshmbuffer.h"
 
 #include "wldisplay.h"
+#include "wlcompositor.h"
 
 #include <QtCore/QDebug>
 
@@ -52,7 +53,6 @@ ShmBuffer::ShmBuffer(struct wl_buffer *buffer)
     : m_buffer(buffer)
 {
     m_buffer->user_data = this;
-    m_buffer->compositor = NULL;
     m_data = wl_shm_buffer_get_data(m_buffer);
     m_stride = wl_shm_buffer_get_stride(m_buffer);
 
@@ -77,22 +77,20 @@ void ShmBuffer::damage()
 {
     QImage::Format imageFormat = QImage::Format_Invalid;
 
-    //jl: need to do depth check as well.
-
-    if (!m_buffer->compositor)
-      return ;
-
-    if (m_buffer->visual == &m_buffer->compositor->premultiplied_argb_visual) {
+    wl_compositor *compositor = Wayland::Compositor::instance()->base();
+    if (m_buffer->visual == &compositor->premultiplied_argb_visual) {
         imageFormat = QImage::Format_ARGB32_Premultiplied;
-    } else if (m_buffer->visual == &m_buffer->compositor->rgb_visual) {
+    } else if (m_buffer->visual == &compositor->rgb_visual) {
         imageFormat = QImage::Format_RGB32;
-    } else if (m_buffer->visual == &m_buffer->compositor->argb_visual) {
+    } else if (m_buffer->visual == &compositor->argb_visual) {
         imageFormat = QImage::Format_ARGB32;
     } else {
+        qWarning("Failed to match ShmBuffer visual");
         imageFormat = QImage::Format_ARGB32_Premultiplied;
     }
 
     m_image = QImage(static_cast<uchar *>(m_data),m_buffer->width, m_buffer->height,m_stride,imageFormat);
+
 }
 
 ShmHandler::ShmHandler(Display *display)
@@ -127,6 +125,10 @@ void ShmHandler::buffer_damaged_callback(struct wl_buffer *buffer,
     Q_UNUSED(y);
     Q_UNUSED(width);
     Q_UNUSED(height);
+    //damage has the responsibillity to update the QImage
+    //for now we just recrate the entire QImage as we need a new
+    //hash key for texture uploads
+    static_cast<ShmBuffer *>(buffer->user_data)->damage();
 }
 
 void ShmHandler::buffer_destroyed_callback(struct wl_buffer *buffer)
index 76346a0..225b7ab 100644 (file)
@@ -64,7 +64,6 @@ public:
     SurfacePrivate(struct wl_client *client, Compositor *compositor)
         : client(client)
         , compositor(compositor)
-        , needsMap(false)
         , textureCreatedForBuffer(false)
         , directRenderBuffer(0)
         , processId(0)
@@ -91,10 +90,13 @@ public:
     }
 
     void attach(struct wl_buffer *buffer) {
-        this->surfaceBuffer = buffer;
+        bool emitMap = !surfaceBuffer;
+        surfaceBuffer = buffer;
         surfaceType = WaylandSurface::Invalid;
         textureCreatedForBuffer = false;
-        buffer->compositor = compositor->base();
+        if (emitMap) {
+            qtSurface->mapped(QSize(surfaceBuffer->width,surfaceBuffer->height));
+        }
     }
 
     inline struct wl_buffer *buffer() const { return surfaceBuffer; }
@@ -106,7 +108,6 @@ public:
 #ifdef QT_COMPOSITOR_WAYLAND_GL
     GLuint texture_id;
 #endif
-    bool needsMap;
     bool textureCreatedForBuffer;
     wl_buffer *directRenderBuffer;
     qint64 processId;
@@ -132,39 +133,6 @@ void surface_attach(struct wl_client *client, struct wl_surface *surface,
     wayland_cast<Surface *>(surface)->attach(buffer);
 }
 
-void surface_map_toplevel(struct wl_client *client,
-                          struct wl_surface *surface)
-{
-    Q_UNUSED(client);
-    printf("surface_map_toplevel: %p, %p\n", client, surface);
-
-    wayland_cast<Surface *>(surface)->mapTopLevel();
-}
-
-void surface_map_transient(struct wl_client *client,
-                      struct wl_surface *surface,
-                      struct wl_surface *parent,
-                      int x,
-                      int y,
-                      uint32_t flags)
-{
-    Q_UNUSED(client);
-    Q_UNUSED(surface);
-    Q_UNUSED(parent);
-    Q_UNUSED(x);
-    Q_UNUSED(y);
-    Q_UNUSED(flags);
-    printf("surface_map_transient: %p, %p\n", client, surface);
-}
-
-void surface_map_fullscreen(struct wl_client *client,
-                       struct wl_surface *surface)
-{
-    Q_UNUSED(client);
-    Q_UNUSED(surface);
-    printf("surface_map_fullscreen: %p, %p\n", client, surface);
-}
-
 void surface_damage(struct wl_client *client, struct wl_surface *surface,
                     int32_t x, int32_t y, int32_t width, int32_t height)
 {
@@ -233,18 +201,8 @@ void Surface::damage(const QRect &rect)
     }
 #endif
 
-    if (d->needsMap) {
-        QRect rect(0,0,d->buffer()->width,d->buffer()->height);
-        emit d->qtSurface->mapped(rect);
-        d->needsMap = false;
-    }
-
     d->compositor->markSurfaceAsDirty(this);
 
-    if (d->type() == WaylandSurface::Shm) {
-        static_cast<ShmBuffer *>(d->buffer()->user_data)->damage();
-    }
-
     emit d->qtSurface->damaged(rect);
 }
 
@@ -280,16 +238,6 @@ void Surface::attach(struct wl_buffer *buffer)
     d->attach(buffer);
 }
 
-
-void Surface::mapTopLevel()
-{
-    Q_D(Surface);
-    if (!d->buffer())
-        d->needsMap = true;
-    else
-        emit d->qtSurface->mapped(QRect(0,0,d->buffer()->width, d->buffer()->height));
-}
-
 WaylandSurface * Surface::handle() const
 {
     Q_D(const Surface);
index 73f19fd..cc5dad7 100644 (file)
@@ -76,8 +76,6 @@ public:
     uint id() const { return base()->resource.object.id; }
     void attach(struct wl_buffer *buffer);
 
-    void mapTopLevel();
-
     void damage(const QRect &rect);
 
     QImage image() const;
@@ -114,25 +112,12 @@ private:
 void surface_destroy(struct wl_client *client, struct wl_surface *_surface);
 void surface_attach(struct wl_client *client, struct wl_surface *surface,
                     struct wl_buffer *buffer, int x, int y);
-void surface_map_toplevel(struct wl_client *client,
-                          struct wl_surface *surface);
-void surface_map_transient(struct wl_client *client,
-                      struct wl_surface *surface,
-                      struct wl_surface *parent,
-                      int x,
-                      int y,
-                      uint32_t flags);
-void surface_map_fullscreen(struct wl_client *client,
-                       struct wl_surface *surface);
 void surface_damage(struct wl_client *client, struct wl_surface *_surface,
                int32_t x, int32_t y, int32_t width, int32_t height);
 
 const static struct wl_surface_interface surface_interface = {
     surface_destroy,
     surface_attach,
-    surface_map_toplevel,
-    surface_map_transient,
-    surface_map_fullscreen,
     surface_damage
 };
 }
index 3b3225d..5e559ec 100644 (file)
@@ -1,3 +1,3 @@
 This version of Qt-Compositor is checked against the following sha1 from the
 Wayland repository:
-2d27f3b6e9001d4fae4a4de7a19db76b5174f9d7
+b6fdded54bc86260f2b6126d34648c85f4f2d7b1