LCOV - code coverage report
Current view: top level - eq - roiFinder.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 5 9 55.6 %
Date: 2017-12-16 05:07:20 Functions: 2 4 50.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c)      2009, Maxim Makhinya
       3             :  *               2010-2014, Stefan Eilemann <eile@eyescale.ch>
       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 EQ_ROI_FINDER_H
      20             : #define EQ_ROI_FINDER_H
      21             : 
      22             : #include "roiEmptySpaceFinder.h"
      23             : #include "roiTracker.h"
      24             : 
      25             : #include "image.h"                 // member
      26             : #include <eq/util/objectManager.h> // member
      27             : 
      28             : namespace eq
      29             : {
      30             : /**
      31             :  * Processes current rendering target and selects areas for read back.
      32             :  * @internal
      33             :  */
      34             : class ROIFinder
      35             : {
      36             : public:
      37             :     ROIFinder();
      38           2 :     virtual ~ROIFinder() {}
      39             :     /**
      40             :      * Processes current rendering target and selects areas for read back.
      41             :      *
      42             :      * @param buffers   current buffers (BUFFER_COLOR / BUFFER_DEPTH).
      43             :      * @param pvp       viewport to analyse.
      44             :      * @param zoom      current zoom
      45             :      * @param stage     compositing stage (to track separate statistics).
      46             :      * @param frameID   ID of current frame (to track separate statistics).
      47             :      * @param glObjects object manager.
      48             :      *
      49             :      * @return Areas for readback
      50             :      */
      51             :     PixelViewports findRegions(const uint32_t buffers, const PixelViewport& pvp,
      52             :                                const Zoom& zoom, const uint32_t stage,
      53             :                                const uint128_t& frameID,
      54             :                                util::ObjectManager& glObjects);
      55             : 
      56             : private:
      57             :     ROIFinder(const ROIFinder&) = delete;
      58             :     ROIFinder& operator=(const ROIFinder&) = delete;
      59             : 
      60             :     struct Area;
      61             : 
      62             :     const void* _getInfoKey() const;
      63             : 
      64             :     /** Called from getReadbackInfo. Calculates per-block statistic before
      65             :         actuall read-back */
      66             :     void _readbackInfo(util::ObjectManager& glObjects);
      67             : 
      68             :     /** Clears masks, filles per-block occupancy _mask from _perBlockInfo,
      69             :         that was previously read-back from GPU in _readbackInfo */
      70             :     void _init();
      71             : 
      72             :     /** Updates dimensions and resizes arrays */
      73             :     void _resize(const PixelViewport& pvp);
      74             : 
      75             :     /** Histogram based based AABB calculation of a region. */
      76             :     PixelViewport _getObjectPVP(const PixelViewport& pvp, const uint8_t* src);
      77             : 
      78             :     /** Result is returned via _finalAreas array */
      79             :     uint8_t _splitArea(Area& area);
      80             : 
      81             :     /** Finds empty area in sub area. Used during optimal split search */
      82             :     void _updateSubArea(const uint8_t type);
      83             : 
      84             :     /** Find areas in current mask*/
      85             :     void _findAreas(PixelViewports& resultPVPs);
      86             : 
      87             :     /** Only used in debug build, to invalidate unused areas */
      88             :     void _invalidateAreas(Area* areas, uint8_t num);
      89             : 
      90             :     /** Dimensions of regions around currntly found hole. Used
      91             :         to estimate optimal split */
      92             :     struct Dims
      93             :     {
      94             :         uint8_t x1, x2, x3;
      95             :         uint8_t y1, y2, y3;
      96             :         uint8_t w1, w2, w3, w4, w5, w6, w7, w8;
      97             :         uint8_t h1, h2, h3, h4, h5, h6, h7, h8;
      98             :     } _dim;
      99             : 
     100             :     /** Describes region that is used to search holes withing */
     101             :     struct Area
     102             :     {
     103          42 :         Area()
     104          42 :             : emptySize(0)
     105          42 :             , valid(false)
     106             :         {
     107          42 :         }
     108           0 :         explicit Area(PixelViewport pvp_)
     109           0 :             : emptySize(0)
     110             :             , pvp(pvp_)
     111           0 :             , valid(false)
     112             :         {
     113           0 :         }
     114             : 
     115             :         int32_t emptySize;  //!< number of empty blocks
     116             :         PixelViewport pvp;  //!< PVP of area
     117             :         PixelViewport hole; //!< largest hole
     118             : 
     119             :         bool valid; //!< Used in debug build only
     120             :     };
     121             : 
     122             :     Area _tmpAreas[17];  //!< possible arreas
     123             :     Area _finalAreas[4]; //!< links to picked areas from _tmpAreas
     124             : 
     125             :     std::vector<Area> _areasToCheck; //!< Areas used to search for holes
     126             : 
     127             :     PixelViewport _pvp;         //<! current, alligned to grid, PVP
     128             :     PixelViewport _pvpOriginal; //<! original PVP
     129             : 
     130             :     ROIEmptySpaceFinder _emptyFinder; //!< class to search for holes
     131             : 
     132             :     int32_t _w;    //!< alligned to grid width
     133             :     int32_t _h;    //!< alligned to grid height
     134             :     int32_t _wh;   //!< _w * _h
     135             :     int32_t _wb;   //!< _w + 1 (only 1 block currently is used as border)
     136             :     int32_t _hb;   //!< _h + 1 (only 1 block currently is used as border)
     137             :     int32_t _wbhb; //!< _wb * _wh (total number of blocks in _mask)
     138             : 
     139             :     Vectorub _mask; //!< mask of occupied blocks (main data)
     140             : 
     141             :     std::vector<float> _perBlockInfo; //!< buffer for data from GPU
     142             : 
     143             :     uint8_t _histX[256]; //!< histogram to find BB along X axis
     144             :     uint8_t _histY[256]; //!< histogram to find BB along Y axis
     145             : 
     146             :     Image _tmpImg; //!< used for dumping debug info
     147             : 
     148             :     ROITracker _roiTracker; //!< disables ROI when ROI is inefficient
     149             : };
     150             : }
     151             : 
     152             : #endif // EQ_ROI_FINDER_H

Generated by: LCOV version 1.11