Пример #1
0
static int
map_process(struct sol_flow_node *node, void *data, uint16_t port, uint16_t conn_id, const struct sol_flow_packet *packet)
{
    struct drange_map_data *mdata = data;
    struct sol_drange in_value;
    double out_value;
    int r;

    r = sol_flow_packet_get_drange(packet, &in_value);
    SOL_INT_CHECK(r, < 0, r);

    if (mdata->use_input_range) {
        if (isgreaterequal(in_value.min, in_value.max)) {
            SOL_WRN("Invalid range: input max must to be bigger than min");
            return -EINVAL;
        }
        r = _map(in_value.val, in_value.min, in_value.max, mdata->output.min,
            mdata->output.max, mdata->output_value.step, &out_value);
    } else
        r = _map(in_value.val, mdata->input.min, mdata->input.max,
            mdata->output.min, mdata->output.max, mdata->output_value.step,
            &out_value);

    SOL_INT_CHECK(r, < 0, r);

    mdata->output_value.val = out_value;

    return sol_flow_send_drange_packet(node,
        SOL_FLOW_NODE_TYPE_FLOAT_MAP__OUT__OUT,
        &mdata->output_value);
}
Пример #2
0
 /// Serialize to stream
 void Tracker::toStream(QDataStream& _os) const
 {
   PropertyMap _map;
   _map("center",center_);
   _map("direction",direction_);
   _os << _map;
 }
//-----------------------------------------------------------------------------
void D3D11HardwarePixelBuffer::unlockImpl(void)
{
    if(mUsage == HBU_STATIC)
        _unmapstagingbuffer();
    else if(mUsage & HBU_DYNAMIC)
    {
        if(mCurrentLockOptions == HBL_READ_ONLY || mCurrentLockOptions == HBL_NORMAL || mCurrentLockOptions == HBL_WRITE_ONLY)
        {
            size_t sizeinbytes = D3D11Mappings::_getSizeInBytes(mParentTexture->getFormat(), mParentTexture->getWidth(), mParentTexture->getHeight());
            PixelBox box;
            _map(mParentTexture->getTextureResource(), D3D11_MAP_WRITE_DISCARD, box);
            void *data = box.data;

            memcpy(data, mCurrentLock.data, sizeinbytes);

            // unmap the texture and the staging buffer
            _unmap(mParentTexture->getTextureResource());

            _unmapstagingbuffer(false);
        }
        else
            _unmap(mParentTexture->getTextureResource());
    }
    else
        _unmapstaticbuffer();

    _genMipmaps();
}
//-----------------------------------------------------------------------------
void *D3D11HardwarePixelBuffer::_mapstagingbuffer(D3D11_MAP flags)
{
    if(!mStagingBuffer)
        createStagingBuffer();

    if(flags == D3D11_MAP_READ_WRITE || flags == D3D11_MAP_READ || flags == D3D11_MAP_WRITE)
    {
        if(mLockBox.getHeight() == mParentTexture->getHeight() && mLockBox.getWidth() == mParentTexture->getWidth())
            mDevice.GetImmediateContext()->CopyResource(mStagingBuffer, mParentTexture->getTextureResource());
        else
        {
            D3D11_BOX dstBoxDx11 = OgreImageBoxToDx11Box(mLockBox);
            dstBoxDx11.front = 0;
            dstBoxDx11.back = mLockBox.getDepth();

            unsigned int subresource = D3D11CalcSubresource(mSubresourceIndex, mLockBox.front, mParentTexture->getNumMipmaps()+1);
            mDevice.GetImmediateContext()->CopySubresourceRegion(mStagingBuffer, subresource, mLockBox.left, mLockBox.top, mSubresourceIndex, mParentTexture->getTextureResource(), subresource, &dstBoxDx11);
        }
    }
    else if(flags == D3D11_MAP_WRITE_DISCARD)
        flags = D3D11_MAP_WRITE; // stagingbuffer doesn't support discarding

    PixelBox box;
    _map(mStagingBuffer, flags, box);
    return box.data;
}
Пример #5
0
void Water::_updatePaths()
{
  auto reservoir = _d->overlay.selected.as<Reservoir>();
  if( reservoir.isValid() )
  {
    _d->ways.clear();
    PathwayCondition wayCondition;
    auto fountains = reservoir->aquifer().overlays<Fountain>();

    for( auto fountain : fountains )
    {
      Pathway pathway = PathwayHelper::create( reservoir->pos(), fountain->pos(),
                                               wayCondition.bySomething(), Pathway::fourDirection  );
      if( pathway.isValid() )
        _d->ways.push_back( { pathway.allTiles(), ColorList::red } );
    }
  }

  auto fountain = _d->overlay.underMouse.as<Fountain>();
  if( fountain.isValid() )
  {
    _d->ways.clear();

    PathwayCondition wayCondition;
    auto reservoirs = _map().rect( 10, fountain->pos() ).overlays<Reservoir>();

    for( auto reservoir : reservoirs )
    {
      Pathway pathway = PathwayHelper::create( reservoir->pos(), fountain->pos(), wayCondition.bySomething() );
      if( pathway.isValid() )
        _d->ways.push_back( { pathway.allTiles(), ColorList::blue } );
    }
  }
}
Пример #6
0
void Game::askGodToDo(Map & map, int & wait)
	{
		unsigned int x, y;
		int tBdstr = _god.makeStep((*this),x,y);	//Ile zostanie zniszczonych
		if(tBdstr>0)
		{
			_printer.printMessage(GOD_DECIDE_TO_DO,cout);
			int result = putBlock(x,y,_map,PS_GOD_BLOCK);
			prepareWeights(_map);
			list<ElementData *> * path = testWeight(_map);
			if(path->size() > 0)
			{
				if(_map(x,y,DIM_WHO_TAB) != path->back()->operator [](DIM_WHO_TAB))
				{
					_destroyedBlocks += destroyElements(path);
					_printer.printMessage(GOD_SAY_OMG,cout);
					_printer.makeBoomConsole();
				}
				else
					_printer.printMessage(GOD_BLESS_YOU, cout);
				wait++;	
			}
			delete path;
		}
	}
Пример #7
0
        /// Write tuning to stream
        void Tuning::toStream(QDataStream& _os) const {
            PropertyMap _map;
            _map("color",color_)
                ("projector",projector_)
                ("warpGrid",warpGrid_)
                ("blendMask",blendMask_)
                ("outputDisabled",outputDisabled_)
                ("overlapOpacity",overlapOpacity_)
                ("colorCorrection",colorCorrection_)
                ("patches",patches_)
                ;

            _map("screenGeometry", screenGeometry());
            _map("contentGeometry", contentGeometry());
            _map("subScreenIndex", subScreenIndex_);
            _os << _map;
        }
Пример #8
0
 vector<int> spiralOrder(vector<vector<int>>& matrix) {
     
     vector<int> result;
     int m = matrix.size();
     int n = m > 0 ? matrix[0].size() : 0;
     if(m == 0 || n == 0)
         return result;
     
     vector<vector<int>> _map(matrix);
     for(int i = 0;i < m;++i)
         for(int j = 0;j < n;++j)
             _map[i][j] = 0;
     
     int x = 0;
     int y = 0;
     while(result.size() < m * n)
     {
         if(!_map[y][x])
         {
             result.push_back(matrix[y][x]);
             _map[y][x] = 1;
         }
         
         
         // can right
         while(x < n - 1 && !_map[y][x + 1])
         {
             x++;
             result.push_back(matrix[y][x]);
             _map[y][x] = 1;
             
         }
         // can down
         while(y < m - 1 && !_map[y + 1][x])
         {
             y++;
             result.push_back(matrix[y][x]);
             _map[y][x] = 1;
             
         }
         // can left
         while(x > 0 && !_map[y][x - 1])
         {
             x--;
             result.push_back(matrix[y][x]);
             _map[y][x] = 1;
         }
         // can up
         while(y > 0 && !_map[y - 1][x])
         {
             y--;
             result.push_back(matrix[y][x]);
             _map[y][x] = 1;
         }
         
     }
     return result;
 }
Пример #9
0
void io::MMapInputStream::open(const std::string& fname, char* flags)
{
    mLength = mOs.getSize(fname);
    //    std::cout << mLength << std::endl;
    mFile = fopen(fname.c_str(), "r");
    if (!mFile)
        throw sys::SystemException(FmtX("Failure while opening file: %s", fname.c_str()));

    _map();

}
Пример #10
0
 /// Write transformation to stream
 void AffineTransform::toStream(QDataStream& _os) const {
     PropertyMap _map;
     _map("rotationEnabled",rotationEnabled_)
         ("rotation",rotation_)
         ("scaleEnabled",scaleEnabled_)
         ("scale",scale_)
         ("uniformScale",uniformScale_)
         ("uniformScaleEnabled",uniformScaleEnabled_)
         ("translationEnabled",translationEnabled_)
         ("translation",translation_);
     _os << _map;
 }
Пример #11
0
#include "clock.h"
#include "driver.h"
#include "events.h"
#include "syslog.h"
#include "cmdline.h"

typedef struct generic_string_map_s {
	const char *item;
	int value;
} generic_string_map_t;

#define _map(x)  { #x, LOG_ ## x }
static generic_string_map_t options_table[] =
{
	// Available Options
	_map( CONS ), _map( NDELAY ), _map( PERROR ), _map( PID ),
	//
	// Available Facilities
	_map( AUTH ), _map( AUTHPRIV ), _map( CRON ), _map( DAEMON ), _map( FTP ), _map( KERN ),
	_map( LOCAL0 ), _map( LOCAL1 ), _map( LOCAL2 ), _map( LOCAL3 ), _map( LOCAL4 ), _map( LOCAL5 ), _map( LOCAL6 ), _map( LOCAL7 ),
	_map( LPR ), _map( MAIL ), _map( NEWS ), _map( SYSLOG ), _map( USER ), _map( UUCP ),
	//
	// Available Levels
	_map( EMERG ), _map( ALERT ), _map( CRIT ), _map( ERR ), _map( WARNING ), _map( NOTICE ), _map( INFO ), _map( DEBUG ),
	{ 0L, 0 }
};

static int syslog_lookup_ident( const char *str )
{
	generic_string_map_t *ptr = options_table;
//-----------------------------------------------------------------------------
PixelBox D3D11HardwarePixelBuffer::lockImpl(const Image::Box lockBox,  LockOptions options)
{
    // Check for misuse
    if(mUsage & TU_RENDERTARGET)
        OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "DirectX does not allow locking of or directly writing to RenderTargets. Use blitFromMemory if you need the contents.",
                    "D3D11HardwarePixelBuffer::lockImpl");

    mLockBox = lockBox;

    // Set extents and format
    // Note that we do not carry over the left/top/front here, since the returned
    // PixelBox will be re-based from the locking point onwards
    PixelBox rval(lockBox.getWidth(), lockBox.getHeight(), lockBox.getDepth(), mFormat);
    // Set locking flags according to options
    D3D11_MAP  flags = D3D11_MAP_WRITE_DISCARD ;
    switch(options)
    {
    case HBL_NO_OVERWRITE:
        flags = D3D11_MAP_WRITE_NO_OVERWRITE;
        break;
    case HBL_NORMAL:
        flags = D3D11_MAP_READ_WRITE;
        break;
    case HBL_DISCARD:
        flags = D3D11_MAP_WRITE_DISCARD;
        break;
    case HBL_READ_ONLY:
        flags = D3D11_MAP_READ;
        break;
    case HBL_WRITE_ONLY:
        flags = D3D11_MAP_WRITE;
        break;
    default:
        break;
    };

    size_t offset = 0;

    if(mUsage == HBU_STATIC || mUsage & HBU_DYNAMIC)
    {
        if(mUsage == HBU_STATIC || options == HBL_READ_ONLY || options == HBL_NORMAL || options == HBL_WRITE_ONLY)
            rval.data = _mapstagingbuffer(flags);
        else
            _map(mParentTexture->getTextureResource(), flags, rval);

        // calculate the offset in bytes
        offset = D3D11Mappings::_getSizeInBytes(rval.format, rval.left, rval.front);
        // add the offset, so the right memory will be changed
        //rval.data = static_cast<int*>(rval.data) + offset;
    }
    else
    {
        size_t sizeOfImage = rval.getConsecutiveSize();
        mDataForStaticUsageLock = new int8[sizeOfImage];
        rval.data = mDataForStaticUsageLock;
    }
    // save without offset
    mCurrentLock = rval;
    mCurrentLockOptions = options;

    // add the offset, so the right memory will be changed
    rval.data = static_cast<int*>(rval.data) + offset;

    return rval;
}
Пример #13
0
result_t LruCache::put(v8::Local<v8::Object> map)
{
    return _map(this, map, &LruCache::put);
}
Пример #14
0
 template <typename F, typename G> gf<block_index, std14::result_of_t<F(G)>> map(F &&f, gf_const_view<block_index, G> g) {
  return make_block_gf(get_block_names(g), _map(f, g.data()));
 }
Пример #15
0
result_t Map::put(v8::Local<v8::Object> map)
{
    return _map(this, map, &Map::put);
}
Пример #16
0
 template <typename F, typename T> auto _map(F &&f, std::vector<std::vector<T>> &V) {
   std::vector<std::vector<std::result_of_t<F(T)>>> res;
   res.reserve(V.size());
   for (auto &x : V) res.push_back(_map(f, x));
   return res;
 }
Пример #17
0
result_t Redis::unpsub(v8::Local<v8::Object> map)
{
    return _map(map, PUNSUBSCRIBE);
}
Пример #18
0
 static auto invoke(F &&f, G &&g) { return _map(std::forward<F>(f), std::forward<G>(g).data()); }
Пример #19
0
result_t HttpUploadCollection::set(v8::Local<v8::Object> map)
{
    return _map(this, map, &HttpUploadCollection::set);
}