From 23a014049d105baa8e91ec29f4dc3e02ca950cdf Mon Sep 17 00:00:00 2001 From: Nobuhiko Tanibata Date: Fri, 21 Dec 2012 13:25:09 +0900 Subject: [PATCH] WaylandDrmWindowSystem: Modify for multi screen WaylandBaseWindowSystem Add virtual definition because of overriding. WaylandDrmWindowSystem Add controlling multiple screens Signed-off-by: Nobuhiko Tanibata --- .../WindowSystems/WaylandBaseWindowSystem.h | 4 +- .../include/WindowSystems/WaylandDrmWindowSystem.h | 2 + .../src/WindowSystems/WaylandDrmWindowSystem.cpp | 96 +++++++++++++++++++++- 3 files changed, 99 insertions(+), 3 deletions(-) diff --git a/LayerManagerPlugins/Renderers/Graphic/include/WindowSystems/WaylandBaseWindowSystem.h b/LayerManagerPlugins/Renderers/Graphic/include/WindowSystems/WaylandBaseWindowSystem.h index 6e4f084..db7efb8 100644 --- a/LayerManagerPlugins/Renderers/Graphic/include/WindowSystems/WaylandBaseWindowSystem.h +++ b/LayerManagerPlugins/Renderers/Graphic/include/WindowSystems/WaylandBaseWindowSystem.h @@ -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(); diff --git a/LayerManagerPlugins/Renderers/Graphic/include/WindowSystems/WaylandDrmWindowSystem.h b/LayerManagerPlugins/Renderers/Graphic/include/WindowSystems/WaylandDrmWindowSystem.h index 629ffef..8f99c81 100644 --- a/LayerManagerPlugins/Renderers/Graphic/include/WindowSystems/WaylandDrmWindowSystem.h +++ b/LayerManagerPlugins/Renderers/Graphic/include/WindowSystems/WaylandDrmWindowSystem.h @@ -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; diff --git a/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandDrmWindowSystem.cpp b/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandDrmWindowSystem.cpp index 9c756ed..e87f0f3 100644 --- a/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandDrmWindowSystem.cpp +++ b/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandDrmWindowSystem.cpp @@ -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::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; + } + } +} -- 2.7.4