LCOV - code coverage report
Current view: top level - eq - windowSystem.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 6 6 100.0 %
Date: 2017-12-16 05:07:20 Functions: 8 9 88.9 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2006-2017, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          Daniel Pfeifer <daniel@pfeifer-mail.de>
       4             :  *                          Daniel Nachbaur <danielnachbaur@gmail.com>
       5             :  *
       6             :  * This library is free software; you can redistribute it and/or modify it under
       7             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       8             :  * by the Free Software Foundation.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      12             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      17             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             :  */
      19             : 
      20             : #ifndef EQ_WINDOWSYSTEM_H
      21             : #define EQ_WINDOWSYSTEM_H
      22             : 
      23             : #include <eq/api.h>
      24             : #include <eq/types.h>
      25             : 
      26             : namespace eq
      27             : {
      28             : /**
      29             :  * The interface for windowing toolkits.
      30             :  *
      31             :  * This class is intended to be overwritten by an (anonymous) class with exactly
      32             :  * one static instance. The constructor will register this factory instance for
      33             :  * use with the WindowSystem frontend. See glx/windowSystem.cpp for an example.
      34             :  *
      35             :  * The implementation provides access to operating system dependent
      36             :  * functionality needed by Equalizer, and hides these specifics behind
      37             :  * interfaces.
      38             :  */
      39             : class WindowSystemIF
      40             : {
      41             : public:
      42             :     /** Destroy the window system instance. @version 1.6 */
      43           3 :     virtual ~WindowSystemIF() {}
      44             : protected:
      45             :     /** Create a new window system instance. @version 1.6 */
      46           3 :     WindowSystemIF() {}
      47             :     /** @internal */
      48             :     static uint32_t _setupLists(util::ObjectManager& gl, const void* key,
      49             :                                 const int num);
      50             : 
      51             :     /** @return the unique name of the window system. @version 1.6 */
      52             :     virtual std::string getName() const = 0;
      53             : 
      54             :     /** @return a new system pipe. @version 1.6 */
      55             :     virtual SystemPipe* createPipe(Pipe* pipe) = 0;
      56             : 
      57             :     /** @return a new event message pump @version 1.6 */
      58             :     virtual MessagePump* createMessagePump() = 0;
      59             : 
      60             :     /** @return a new system window @version 1.7.2 */
      61             :     virtual SystemWindow* createWindow(Window* window,
      62             :                                        const WindowSettings& settings) = 0;
      63             : 
      64             :     /**
      65             :      * Create a set of display lists for the given font.
      66             :      *
      67             :      * The implementation is expected to set up one display list per ASCII
      68             :      * character, and store the name of the first list in the given object
      69             :      * manager using the given key.
      70             :      *
      71             :      * @param gl the object manager for display list allocation.
      72             :      * @param key the key for display list allocation.
      73             :      * @param name the name of the font, OS-specific.
      74             :      * @param size the font size in points.
      75             :      * @return true if the font was created, false otherwise.
      76             :      * @warning experimental, might not be supported in the future.
      77             :      */
      78             :     virtual bool setupFont(util::ObjectManager& gl, const void* key,
      79             :                            const std::string& name,
      80             :                            const uint32_t size) const = 0;
      81             : 
      82             :     /** Perform per-process initialization for a Config. @version 1.6 */
      83           1 :     virtual void configInit(Node* /*node*/) {}
      84             :     /** Perform per-process de-initialization for a Config. @version 1.6 */
      85           1 :     virtual void configExit(Node* /*node*/) {}
      86             :     /**
      87             :      * @return true if events have to be dispatched in the main thread.
      88             :      * @version 1.7.4
      89             :      */
      90           2 :     virtual bool hasMainThreadEvents() const { return false; }
      91             : private:
      92             :     friend class WindowSystem;
      93             : };
      94             : 
      95             : using WindowSystemImpl = std::shared_ptr<WindowSystemIF>;
      96             : 
      97             : /** @internal
      98             :  * Access to the instantiated window systems.
      99             :  * @sa Pipe::getWindowSystem()
     100             :  */
     101          16 : class WindowSystem
     102             : {
     103             : public:
     104             :     EQ_API explicit WindowSystem(const std::string& name);
     105             : 
     106             :     static bool supports(const std::string& type);
     107             : 
     108             :     static void configInit(Node* node);
     109             :     static void configExit(Node* node);
     110             : 
     111             :     EQ_API std::string getName() const;
     112             : 
     113             :     EQ_API SystemWindow* createWindow(Window* window,
     114             :                                       const WindowSettings& settings);
     115             :     EQ_API SystemPipe* createPipe(Pipe* pipe);
     116             :     EQ_API MessagePump* createMessagePump();
     117             :     EQ_API bool setupFont(util::ObjectManager& gl, const void* key,
     118             :                           const std::string& name, const uint32_t size) const;
     119             :     EQ_API bool hasMainThreadEvents() const;
     120             : 
     121             :     EQ_API bool operator==(const WindowSystem& other) const;
     122             :     EQ_API bool operator!=(const WindowSystem& other) const;
     123             : 
     124             :     /** Register a new supported window system */
     125             :     static void add(WindowSystemImpl impl);
     126             : 
     127             :     /** Clear all window system registrations */
     128             :     static void clear();
     129             : 
     130             : private:
     131             :     WindowSystem();
     132             :     WindowSystemImpl _impl;
     133             :     WindowSystemImpl _chooseImpl(const std::string& name);
     134             : };
     135             : 
     136             : /** Print the window system name to the given output stream. @version 1.0 */
     137             : EQ_API std::ostream& operator<<(std::ostream& os, const WindowSystem&);
     138             : 
     139             : /** co::Object serializer. @version 1.1.3 */
     140             : EQ_API co::DataOStream& operator<<(co::DataOStream& os, const WindowSystem&);
     141             : 
     142             : /** WindowSystem deserializer. @version 1.1.3 */
     143             : EQ_API co::DataIStream& operator>>(co::DataIStream& is, WindowSystem& ws);
     144             : 
     145             : } // namespace eq
     146             : 
     147             : #endif // EQ_WINDOWSYSTEM_H

Generated by: LCOV version 1.11