WaylandDrmWindowSystem: Modify for multi screen
authorNobuhiko Tanibata <ntanibata@jp.adit-jv.com>
Fri, 21 Dec 2012 04:25:09 +0000 (13:25 +0900)
committerTimo Lotterbach <timo.lotterbach@bmw-carit.de>
Wed, 9 Jan 2013 13:04:29 +0000 (05:04 -0800)
WaylandBaseWindowSystem
  Add virtual definition because of overriding.

WaylandDrmWindowSystem
  Add controlling multiple screens

Signed-off-by: Nobuhiko Tanibata <ntanibata@jp.adit-jv.com>
LayerManagerPlugins/Renderers/Graphic/include/WindowSystems/WaylandBaseWindowSystem.h
LayerManagerPlugins/Renderers/Graphic/include/WindowSystems/WaylandDrmWindowSystem.h
LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandDrmWindowSystem.cpp

index 6e4f084..db7efb8 100644 (file)
@@ -129,7 +129,7 @@ protected:
     void createServerinfo(WaylandBaseWindowSystem* windowSystem);
     struct native_surface* createNativeSurface();
     void postReleaseBuffer(struct wl_buffer *buffer);
-    void attachBufferToNativeSurface(struct wl_buffer* buffer, struct wl_surface* surface); // ADIT TODO:reconfirm!!
+    virtual void attachBufferToNativeSurface(struct wl_buffer* buffer, struct wl_surface* surface);
     void repaint(int msecs);
     void cleanup();
     void Screenshot();
@@ -137,7 +137,7 @@ protected:
     void shutdownCompositor();
     Surface* getSurfaceFromNativeSurface(struct native_surface* nativeSurface);
     struct native_surface* getNativeSurfaceFromSurface(Surface* surface);
-    void checkForNewSurfaceNativeContent();
+    virtual void checkForNewSurfaceNativeContent();
     void calculateFps();
     void calculateSurfaceFps(Surface *currentSurface, float time) ;
     void printDebug();
index 629ffef..8f99c81 100644 (file)
@@ -43,6 +43,8 @@ protected:
     virtual bool createNativeContext();
     virtual bool initGraphicSystem();
     virtual bool createInputEvent();
+    virtual void checkForNewSurfaceNativeContent();
+    virtual void RedrawAllLayers(bool clear, bool swap);
 
 private:
     int m_fdDev;
index 9c756ed..e87f0f3 100644 (file)
@@ -59,7 +59,16 @@ WaylandDrmWindowSystem::~WaylandDrmWindowSystem()
 bool WaylandDrmWindowSystem::initGraphicSystem()
 {
        graphicSystem->setBaseWindowSystem(this);
-    return graphicSystem->init((void*)m_gbm, (void*)NULL);
+    bool ans = graphicSystem->init((void*)m_gbm, (void*)NULL);
+    if (true != ans)
+    {
+        LOG_ERROR("WaylandDrmWindowSystem", "Failed to init graphic system");
+        return false;
+    }
+
+    graphicSystem->updateScreenList(m_pScene->getScreenList());
+
+    return true;
 }
 
 bool WaylandDrmWindowSystem::createNativeContext()
@@ -136,3 +145,88 @@ bool WaylandDrmWindowSystem::createInputEvent()
     m_inputEvent->setupInputEvent();
     return true;
 }
+
+void WaylandDrmWindowSystem::checkForNewSurfaceNativeContent()
+{
+    m_pScene->lockScene();
+    LmScreenList screenList = m_pScene->getScreenList();
+    LmScreenListIterator iter = screenList.begin();
+    LmScreenListIterator iterEnd = screenList.end();
+    for (; iter != iterEnd; ++iter)
+    {
+        LayerList layers = m_pScene->getCurrentRenderOrder((*iter)->getID());
+        for(LayerListConstIterator current = layers.begin(); current != layers.end(); current++)
+        {
+            SurfaceList surfaces = (*current)->getAllSurfaces();
+            for(SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
+            {
+                if ((*currentS)->hasNativeContent())
+                {
+                    graphicSystem->switchScreen((*iter)->getID());
+                    allocatePlatformSurface(*currentS);
+                }
+                else // While we are at it, also cleanup any stale native content
+                {
+                    deallocatePlatformSurface(*currentS);
+                }
+            }
+        }
+    }
+    m_pScene->unlockScene();
+}
+
+void WaylandDrmWindowSystem::RedrawAllLayers(bool clear, bool swap)
+{
+    LmScreenList screenList = m_pScene->getScreenList();
+    LmScreenListIterator iter = screenList.begin();
+    LmScreenListIterator iterEnd = screenList.end();
+    for (; iter != iterEnd; ++iter)
+    {
+        LayerList layers = m_pScene->getCurrentRenderOrder((*iter)->getID());
+        LayerList swLayers;
+        // TODO: bRedraw is overly conservative if layers includes a hardware layer
+        bool bRedraw = m_forceComposition || graphicSystem->needsRedraw(layers) || (m_systemState == REDRAW_STATE);
+
+        if (bRedraw)
+        {
+            graphicSystem->switchScreen((*iter)->getID());
+            graphicSystem->activateGraphicContext();
+            if (clear)
+            {
+                graphicSystem->clearBackground();
+            }
+        }
+        for(std::list<Layer*>::const_iterator current = layers.begin(); current != layers.end(); current++)
+        {
+            if ((*current)->getLayerType() == Hardware)
+            {
+                if (m_forceComposition || graphicSystem->needsRedraw(*current))
+                {
+                    renderHWLayer(*current);
+                }
+            }
+            else if (bRedraw)
+            {
+                swLayers.push_back(*current);
+            }
+        }
+        if (bRedraw)
+        {
+            graphicSystem->renderSWLayers(swLayers, false); // Already cleared
+            if (swap)
+            {
+                graphicSystem->swapBuffers();
+            }
+            graphicSystem->releaseGraphicContext();
+
+            if (m_debugMode)
+            {
+                printDebug();
+            }
+
+            calculateFps();
+
+            m_systemState = IDLE_STATE;
+        }
+    }
+}