LCOV - code coverage report
Current view: top level - eq/fabric - pipe.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 13 14 92.9 %
Date: 2017-12-16 05:07:20 Functions: 22 39 56.4 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2015, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          Cedric Stalder <cedric.stalder@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #ifndef EQFABRIC_PIPE_H
      20             : #define EQFABRIC_PIPE_H
      21             : 
      22             : #include <eq/fabric/object.h>        // base class
      23             : #include <eq/fabric/pixelViewport.h> // property
      24             : #include <eq/fabric/types.h>
      25             : 
      26             : namespace eq
      27             : {
      28             : namespace fabric
      29             : {
      30             : /** Base data transport class for pipes. @sa eq::Pipe */
      31             : template <class N, class P, class W, class V>
      32             : class Pipe : public Object
      33             : {
      34             : public:
      35             :     /** A vector of pointers to windows. @version 1.0 */
      36             :     typedef std::vector<W*> Windows;
      37             : 
      38             :     /** @name Data Access */
      39             :     //@{
      40             :     /** @return the parent node of this pipe. @version 1.0 */
      41        3354 :     N* getNode() { return _node; }
      42             :     /** @return the parent node of this pipe. @version 1.0 */
      43           8 :     const N* getNode() const { return _node; }
      44             :     /** @return the vector of child windows. @version 1.0 */
      45       33962 :     const Windows& getWindows() const { return _windows; }
      46             :     /**
      47             :      * Returns the port number of this pipe.
      48             :      *
      49             :      * The port number identifies the X server for systems using the X11/GLX
      50             :      * window system, i.e., the :<strong>&lt;port&gt;</strong>.&lt;screen&gt; of
      51             :      * the DISPLAY name. It currently has no meaning on all other systems.
      52             :      *
      53             :      * @return the port number of this pipe, or LB_UNDEFINED_UINT32.
      54             :      * @version 1.0
      55             :      */
      56         592 :     uint32_t getPort() const { return _port; }
      57             :     EQFABRIC_INL void setPort(const uint32_t port); //!< @internal
      58             : 
      59             :     /**
      60             :      * Returns the device number of this pipe.
      61             :      *
      62             :      * The device number identifies the X screen for systems using the X11/GLX
      63             :      * window system, or the number of the virtual screen for the AGL window
      64             :      * system. On Windows systems it identifies the graphics adapter. Normally
      65             :      * the device identifies a GPU.
      66             :      *
      67             :      * @return the device number of this pipe, or LB_UNDEFINED_UINT32.
      68             :      * @version 1.0
      69             :      */
      70         654 :     uint32_t getDevice() const { return _device; }
      71             :     EQFABRIC_INL void setDevice(const uint32_t device); //!< @internal
      72             : 
      73             :     /** @return the pixel viewport. @version 1.0 */
      74        3383 :     const PixelViewport& getPixelViewport() const { return _data.pvp; }
      75             :     /**
      76             :      * Set the pipe's pixel viewport.
      77             :      *
      78             :      * If invalid, the OSPipe has to set it to the device viewport during
      79             :      * configInit().
      80             :      *
      81             :      * @param pvp the viewport in pixels.
      82             :      * @version 1.0
      83             :      */
      84             :     EQFABRIC_INL void setPixelViewport(const PixelViewport& pvp);
      85             : 
      86             :     /** @internal Notify this pipe that the viewport has changed. */
      87             :     void notifyPixelViewportChanged();
      88             : 
      89             :     /** @internal @return the index path to this pipe. */
      90             :     EQFABRIC_INL PipePath getPath() const;
      91             : 
      92             :     /**
      93             :      * Perform a depth-first traversal of this pipe.
      94             :      *
      95             :      * @param visitor the visitor.
      96             :      * @return the result of the visitor traversal.
      97             :      * @version 1.0
      98             :      */
      99             :     EQFABRIC_INL VisitorResult accept(V& visitor);
     100             : 
     101             :     /** Const-version of accept(). @version 1.0 */
     102             :     EQFABRIC_INL VisitorResult accept(V& visitor) const;
     103             :     //@}
     104             : 
     105             :     /** @name Attributes */
     106             :     //@{
     107             :     /** Pipe attributes. @version 1.0 */
     108             :     enum IAttribute
     109             :     {
     110             :         // Note: also update string array initialization in pipe.cpp
     111             :         IATTR_HINT_THREAD,   //!< Execute tasks in separate thread (default)
     112             :         IATTR_HINT_AFFINITY, //!< Bind render thread to subset of cores
     113             :         IATTR_LAST,
     114             :         IATTR_ALL = IATTR_LAST + 5
     115             :     };
     116             : 
     117             :     /** @internal Set a pipe attribute. */
     118             :     EQFABRIC_INL void setIAttribute(const IAttribute attr, const int32_t value);
     119             : 
     120             :     /** @return the value of a pipe integer attribute. @version 1.0 */
     121        1176 :     int32_t getIAttribute(const IAttribute attr) const
     122             :     {
     123        1176 :         return _iAttributes[attr];
     124             :     }
     125             : 
     126             :     /** @internal @return true if tasks are executed in a separate thread.*/
     127          12 :     bool isThreaded() const { return (getIAttribute(IATTR_HINT_THREAD) == 1); }
     128             :     /** @internal @return the name of a pipe attribute. */
     129             :     EQFABRIC_INL static const std::string& getIAttributeString(
     130             :         const IAttribute attr);
     131             :     //@}
     132             : 
     133             :     /** @name internal */
     134             :     //@{
     135             :     EQFABRIC_INL virtual void backup();         //!< @internal
     136             :     EQFABRIC_INL virtual void restore();        //!< @internal
     137             :     void create(W** window);                    //!< @internal
     138             :     void release(W* window);                    //!< @internal
     139           0 :     virtual void output(std::ostream&) const {} //!< @internal
     140             :     /** @internal */
     141             :     EQFABRIC_INL virtual uint128_t commit(
     142             :         const uint32_t incarnation = CO_COMMIT_NEXT);
     143             :     //@}
     144             : 
     145             : protected:
     146             :     /** @internal Construct a new pipe. */
     147             :     explicit Pipe(N* parent);
     148             :     EQFABRIC_INL virtual ~Pipe(); //!< @internal
     149             : 
     150             :     virtual void attach(const uint128_t& id,
     151             :                         const uint32_t instanceID); //!< @internal
     152             :     /** @internal */
     153             :     EQFABRIC_INL virtual void serialize(co::DataOStream& os,
     154             :                                         const uint64_t dirtyBits);
     155             :     /** @internal */
     156             :     EQFABRIC_INL virtual void deserialize(co::DataIStream& is,
     157             :                                           const uint64_t dirtyBits);
     158             : 
     159             :     EQFABRIC_INL virtual void notifyDetach(); //!< @internal
     160             : 
     161             :     /** @internal @sa Serializable::setDirty() */
     162             :     EQFABRIC_INL virtual void setDirty(const uint64_t bits);
     163             : 
     164             :     /** @internal */
     165           8 :     virtual ChangeType getChangeType() const { return UNBUFFERED; }
     166             :     W* _findWindow(const uint128_t& id); //!< @internal
     167             : 
     168             :     enum DirtyBits
     169             :     {
     170             :         DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 0,
     171             :         DIRTY_WINDOWS = Object::DIRTY_CUSTOM << 1,
     172             :         DIRTY_PIXELVIEWPORT = Object::DIRTY_CUSTOM << 2,
     173             :         DIRTY_MEMBER = Object::DIRTY_CUSTOM << 3,
     174             :         DIRTY_PIPE_BITS = DIRTY_ATTRIBUTES | DIRTY_WINDOWS |
     175             :                           DIRTY_PIXELVIEWPORT | DIRTY_MEMBER | DIRTY_OBJECT_BITS
     176             :     };
     177             : 
     178             :     /** @internal @return the bits to be re-committed by the master. */
     179           8 :     virtual uint64_t getRedistributableBits() const { return DIRTY_PIPE_BITS; }
     180             : private:
     181             :     /** The parent node. */
     182             :     N* const _node;
     183             : 
     184             :     /** The list of windows. */
     185             :     Windows _windows;
     186             : 
     187             :     /** Integer attributes. */
     188             :     int32_t _iAttributes[IATTR_ALL];
     189             : 
     190             :     /** The display (GLX) or ignored (Win32, AGL). */
     191             :     uint32_t _port;
     192             : 
     193             :     /** The screen (GLX), GPU (Win32) or virtual screen (AGL). */
     194             :     uint32_t _device;
     195             : 
     196        2304 :     struct BackupData
     197             :     {
     198             :         /** The size (and location) of the pipe. */
     199             :         PixelViewport pvp;
     200             :     } _data, _backup;
     201             : 
     202             :     struct Private;
     203             :     Private* _private; // placeholder for binary-compatible changes
     204             : 
     205             :     void _addWindow(W* window);
     206             :     EQFABRIC_INL bool _removeWindow(W* window);
     207             :     template <class, class, class, class>
     208             :     friend class Window;
     209             : 
     210             :     /** @internal */
     211          38 :     bool _mapNodeObjects() { return _node->_mapNodeObjects(); }
     212             :     typedef co::CommandFunc<Pipe<N, P, W, V>> CmdFunc;
     213             :     bool _cmdNewWindow(co::ICommand& command);
     214             :     bool _cmdNewWindowReply(co::ICommand& command);
     215             : };
     216             : 
     217             : template <class N, class P, class W, class V>
     218             : EQFABRIC_INL std::ostream& operator<<(std::ostream&, const Pipe<N, P, W, V>&);
     219             : }
     220             : }
     221             : 
     222             : #endif // EQFABRIC_PIPE_H

Generated by: LCOV version 1.11