LCOV - code coverage report
Current view: top level - eq/qt - window.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 0 14 0.0 %
Date: 2017-12-16 05:07:20 Functions: 0 8 0.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2014-2016, Daniel Nachbaur <danielnachbaur@gmail.com>
       3             :  *                          Stefan.Eilemann@epfl.ch
       4             :  *                          Juan Hernando <jhernando@fi.upm.es>
       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_QT_WINDOW_H
      21             : #define EQ_QT_WINDOW_H
      22             : 
      23             : #include <QObject> // base class
      24             : #include <QScreen>
      25             : #include <eq/glWindow.h> // base class
      26             : #include <eq/qt/types.h>
      27             : 
      28             : namespace eq
      29             : {
      30             : namespace qt
      31             : {
      32             : namespace detail
      33             : {
      34             : class Window;
      35             : }
      36             : 
      37             : /** The interface defining the minimum functionality for a Qt window. */
      38             : class WindowIF : public GLWindow
      39             : {
      40             : public:
      41           0 :     WindowIF(NotifierInterface& parent, const WindowSettings& settings)
      42           0 :         : GLWindow(parent, settings)
      43             :     {
      44           0 :     }
      45           0 :     virtual ~WindowIF() {}
      46             :     /** Process a stateless event. @return true if the event was handled. */
      47           0 :     virtual bool processEvent(EventType type, QEvent*)
      48             :     {
      49           0 :         return GLWindow::processEvent(type);
      50             :     }
      51             : 
      52             :     /** Process a (re)size event. @return true if the event was handled. */
      53           0 :     virtual bool processEvent(EventType type, QEvent*, SizeEvent& event)
      54             :     {
      55           0 :         return GLWindow::processEvent(type, event);
      56             :     }
      57             : 
      58             :     /** Process a mouse event. @return true if the event was handled. */
      59           0 :     virtual bool processEvent(EventType type, QEvent*, PointerEvent& event)
      60             :     {
      61           0 :         return GLWindow::processEvent(type, event);
      62             :     }
      63             : 
      64             :     /** Process a keyboard event. @return true if the event was handled. */
      65           0 :     virtual bool processEvent(EventType type, QEvent*, KeyEvent& event)
      66             :     {
      67           0 :         return GLWindow::processEvent(type, event);
      68             :     }
      69             : 
      70             :     /** Process a stateless event. @return true if the event was handled. */
      71           0 :     virtual bool processEvent(EventType type)
      72             :     {
      73           0 :         return GLWindow::processEvent(type);
      74             :     }
      75             : };
      76             : 
      77             : /** Equalizer default implementation of a Qt window */
      78             : class Window : public QObject, public WindowIF
      79             : {
      80             :     Q_OBJECT
      81             : 
      82             : public:
      83             :     /**
      84             :      * Create a new window using Qt.
      85             :      *
      86             :      * The actual window will be a QWindow or a QOffscreenSurface depending on
      87             :      * the window settings. The window won't be realized until configInit is
      88             :      * called.
      89             :      *
      90             :      * @param parent The eq::Window parent window interface that uses this
      91             :      *        system window.
      92             :      * @param settings The window settings. The GL context format will be
      93             :      *        derived from these.
      94             :      * @param screen the Qt screen to create the window on.
      95             :      * @param thread the Qt thread running the window.
      96             :      *
      97             :      * @version 1.9
      98             :      */
      99             :     EQ_API Window(NotifierInterface& parent, const WindowSettings& settings,
     100             :                   QScreen* screen, QThread* thread);
     101             : 
     102             :     /** Destruct this Qt window. @version 1.7.3 */
     103             :     EQ_API ~Window() final;
     104             : 
     105             :     /** @name Qt initialization */
     106             :     //@{
     107             :     /**
     108             :      * Initialize this window for the Qt window system.
     109             :      *
     110             :      * The window will be only usable by the thread that invokes this
     111             :      * functions. Otherwise Qt thread affinity constraints will be violated.
     112             :      *
     113             :      * @return true if the initialization was successful, false otherwise.
     114             :      * @version 1.7.3
     115             :      */
     116             :     EQ_API bool configInit() override;
     117             : 
     118             :     /** @version 1.7.3 */
     119             :     EQ_API void configExit() override;
     120             : 
     121             :     //@}
     122             : 
     123             :     /**
     124             :      * The context won't be ready to be used until configInit is called.
     125             :      *
     126             :      * @return the Open GL context used by this window.
     127             :      * @version 1.9
     128             :      */
     129             :     EQ_API QOpenGLContext* getContext() const;
     130             : 
     131             :     /** @name Operations. */
     132             :     //@{
     133             :     /** @version 1.7.3 */
     134             :     EQ_API void makeCurrent(const bool cache = true) const override;
     135             : 
     136             :     /** @version 1.10 */
     137             :     EQ_API void doneCurrent() const override;
     138             : 
     139             :     /** @version 1.7.3 */
     140             :     EQ_API void swapBuffers() override;
     141             : 
     142             :     /** Implementation untested for Qt. @version 1.7.3 */
     143             :     EQ_API void joinNVSwapBarrier(const uint32_t group,
     144             :                                   const uint32_t barrier) override;
     145             : 
     146             :     /** Implementation untested for Qt. @version 1.7.3 */
     147             :     EQ_API void leaveNVSwapBarrier();
     148             : 
     149             :     /** @version 1.7.3 */
     150             :     EQ_API bool processEvent(EventType type, QEvent* qEvent,
     151             :                              SizeEvent& event) override;
     152             :     //@}
     153             : 
     154             :     /**
     155             :      * Use this object to make Qt events reach eq::Config when using this window
     156             :      * for offscreen rendering with shared context mode (e.g. to embed Equalizer
     157             :      * output into a Qt GUI).
     158             :      *
     159             :      * Don't send events directly to the object unless you know what you're
     160             :      * doing, use QApplication::postEvent instead.
     161             :      *
     162             :      * @return the object to which forward Qt events.
     163             :      * @version 1.9
     164             :      */
     165             :     EQ_API QObject* getEventProcessor();
     166             : 
     167             :     /** Move OpenGLContext object to given thread. @version 1.10 */
     168             :     void moveContextToThread(QThread* thread);
     169             : 
     170             : signals:
     171             :     void destroyImpl(detail::Window*);
     172             : 
     173             : private:
     174             :     detail::Window* const _impl;
     175             : 
     176             :     void _resize(const PixelViewport& pvp) override;
     177             : };
     178             : }
     179             : }
     180             : #endif // EQ_QT_WINDOW_H

Generated by: LCOV version 1.11