Example #1
0
moDMatrix<Real>& moDMatrix<Real>::operator= (const moDMatrix& rkM)
{
    if (rkM.m_iQuantity > 0)
    {
        if (m_iRows != rkM.m_iRows || m_iCols != rkM.m_iCols)
        {
            Deallocate();
            m_iRows = rkM.m_iRows;
            m_iCols = rkM.m_iCols;
            m_iQuantity = rkM.m_iQuantity;
            Allocate(false);
        }
        for (int iRow = 0; iRow < m_iRows; iRow++)
        {
            for (int iCol = 0; iCol < m_iCols; iCol++)
            {
                m_aafEntry[iRow][iCol] = rkM.m_aafEntry[iRow][iCol];
            }
        }
    }
    else
    {
        Deallocate();
        m_iRows = 0;
        m_iCols = 0;
        m_iQuantity = 0;
        m_afData = 0;
        m_aafEntry = 0;
    }
    return *this;
}
Example #2
0
EditorFrame::~EditorFrame()
{
#ifdef EDITOR_OLD_UI
	Deallocate(documentManager);

	eventManager->disconnectPluginListeners();
#endif

	ArchiveDestroy(archive);

	pluginManager->disablePlugins();
	Deallocate(pluginManager);

	Deallocate(eventManager);
	Deallocate(input);

#ifdef EDITOR_OLD_UI
	if(notebookCtrl)
	{
		notebookCtrl->Destroy();
		paneCtrl->DetachPane(notebookCtrl);
	}
	
	if(paneCtrl)
	{
		paneCtrl->UnInit();
		delete paneCtrl;
	}
#endif

	Deallocate(engine);

	CoreDeinitialize();
}
Example #3
0
Resource* OGG_Loader::prepare(ResourceLoadOptions& options)
{
	ResourceLoadOption& option = options.option;
	bool streamed = option.key == SOUND_LOAD_STREAM && option.value;
	
	Sound* sound = AllocateThis(Sound);
	if( !streamed) return sound;
	
	sound->setStreamed(true);
	options.keepStreamOpen = true;
	options.resource = sound;

	OggVorbis_File* oggFile = AllocateThis(OggVorbis_File);

	if( !initOgg(oggFile, options) )
	{
		Deallocate(oggFile);
		Deallocate(sound);
		return nullptr;
	}

	OggStream* oggStream = AllocateThis(OggStream);
	oggStream->loader = this;
	oggStream->stream = options.stream;
	oggStream->ogg = oggFile;
	oggStream->begin = oggStream->ogg->offset;

	sound->stream = oggStream;

	return sound;
}
Example #4
0
BSplineBasis<Real>::~BSplineBasis ()
{
	delete1(mKnot);
	Deallocate(mBD0);
	Deallocate(mBD1);
	Deallocate(mBD2);
	Deallocate(mBD3);
}
Example #5
0
ResourceManager::~ResourceManager()
{
	destroyHandles();
	resourceLoaders.clear();

	Deallocate(resourceFinishLoad);
	Deallocate(resourceFinishLoadMutex);
}
Example #6
0
void DestroyLineSet( PLINESEGSET pls )
{
   if( pls )
   {
      if( pls->pLines )
         Deallocate( PLINESEG, pls->pLines );
      Deallocate( PLINESEGSET pls );
   }
}
Example #7
0
Adventure::ITexture* Adventure::Image::LoadTgaFromFile(File& file, IDisplay& display, Allocator* scratch)
{
	file.GetStream().seekg(2, std::ios::beg);
	
	File::UInt8 type;
	file.Read(type);
	
	if (type != 2) // Type 2 indicates a regular image
		return NULL;
	
	file.GetStream().seekg(12, std::ios::beg);
	
	File::UInt16 width, height;
	file.Read(width);
	file.Read(height);
	
	int pixels = width * height;
	
	file.GetStream().seekg(16, std::ios::beg);
	
	File::UInt8 bits;
	file.Read(bits);
	
	if (bits < 24)
		return NULL;
	
	file.GetStream().seekg(18, std::ios::beg);
	
	Color* pixelData = new(scratch) Color[pixels];
	
	for (int i = 0; i < pixels; i++)
	{
		// BGRA format
		file.Read(pixelData[i].Blue);
		file.Read(pixelData[i].Green);
		file.Read(pixelData[i].Red);
		
		if (bits == 32)
			file.Read(pixelData[i].Alpha);
		else
			pixelData[i].Alpha = Color::MaxChannelValue;
	}
	
	ITexture* texture = display.CreateTexture();
	
	if (texture == NULL)
	{
		Deallocate(pixelData, scratch);
		return NULL;
	}
	
	texture->SetData(pixelData, width, height, ITexture::Rgba8, ITexture::Point);
	
	Deallocate(pixelData, scratch);
		
	return texture;
}
Example #8
0
Body::~Body()
{
    Transform* transform = getEntity()->getTransform().get();

    if(transform)
        transform->onTransformed.Disconnect( this, &Body::onTransformed );

    removeWorld();

    Deallocate(motionState);
    Deallocate(body);
}
Example #9
0
static LOGICAL SetP( TEXTSTR *p, const XML_Char **atts )
{
	if( p[0] )
		Deallocate( TEXTSTR, p[0] );
	if( p[1] )
		Deallocate( TEXTSTR, p[1] );
	if( atts[0] )
	{
		p[0] = DupCStr( atts[0] );
		p[1] = DupCStr( atts[1] );
		return TRUE;
	}
	else
		return FALSE;
}
Example #10
0
template <class T> void Vector<T>::CopyToSelf(Vector const & source)
{
	UInt length;
	ConstElement *it, *source_it, *source_end;

	Deallocate();
	_ctorMode = source._ctorMode;

	if(!source.IsEmpty())
	{
		length = source.Length();
		Allocate(length);

		it = _origin;
		source_it = source.Begin();
		source_end = source.End();

		if(_ctorMode != CtorModeEnum::Always)
		{
			Memory::Move((VoidPtr)source_it, (VoidPtr)it, sizeof(Element) * length);
			_last += length;
		}
		else
			while(source_it != source_end)
			{
				Construct(it++, source_it++);
				++_last;
			}
	}
}
void
MediaEngineWebRTCVideoSource::Shutdown()
{
  LOG((__FUNCTION__));
  if (!mInitDone) {
    return;
  }
#ifdef MOZ_B2G_CAMERA
  ReentrantMonitorAutoEnter sync(mCallbackMonitor);
#endif
  if (mState == kStarted) {
    while (!mSources.IsEmpty()) {
      Stop(mSources[0], kVideoTrack); // XXX change to support multiple tracks
    }
    MOZ_ASSERT(mState == kStopped);
  }

  if (mState == kAllocated || mState == kStopped) {
    Deallocate();
  }
#ifndef MOZ_B2G_CAMERA
  mViECapture->Release();
  mViERender->Release();
  mViEBase->Release();
#endif
  mState = kReleased;
  mInitDone = false;
}
Example #12
0
	void EpsilonVor::ReadIt(std::ifstream & fin){
		Matrix co0,oc0;
		fin.read((char *) &nnx, sizeof nnx);
		fin.read((char *) &nny, sizeof nny);
		fin.read((char *) &nnz, sizeof nnz);
		fin.read((char *) &co0, sizeof co0);
		fin.read((char *) &oc0, sizeof oc0);
		fin.read((char *) &nresid, sizeof nresid);
		Deallocate();
		is_xRefset=true;
		is_COset=true;
		setMetric(co0);
		Allocate();
		int ntoken;
		fin.read((char *) &ntoken, sizeof ntoken);
		char * css=new char [ntoken];
		fin.read(css, (sizeof css[0])*ntoken);
		string token(css);
		ResLabel.clear();

		boost::split(ResLabel,token, boost::is_any_of("\t "));

		fin.read((char *) &TotalCount, sizeof TotalCount);
		fin.read((char *) &M_avg[0], (sizeof M_avg[0])*DIM);
		fin.read((char *) &VoroVol[0], (sizeof VoroVol[0])*nresid);
		fin.read((char *) &D[0][0][0], (sizeof D[0][0][0])*DIM*DIM*nresid);
		fin.read((char *) &G[0][0][0], (sizeof G[0][0][0])*DIM*DIM*nresid);
		fin.read((char *) &M[0][0], (sizeof M[0][0])*DIM*nresid);
		fin.read((char *) &E[0][0], (sizeof E[0][0])*DIM*nresid);
	}
Example #13
0
void Path :: Deallocate (Entry *  good){
    
    if (good != NULL){
        Deallocate (good -> next);
        delete good;
    }
}
void DoublyLinkedListPriorityQueue:: Deallocate (Entry * & list){
    
    if (list != NULL){
        Deallocate (list -> next);
        delete list;
    }
}
Example #15
0
void SelectionPlugin::onMouseButtonRelease( const MouseButtonEvent& event )
{
	if( event.button != MouseButton::Left )
		return;

	SceneDocument* sceneDocument = (SceneDocument*) editor->getDocument();
	sceneDocument->getRenderWindow()->setCursorCapture(false);

	editor->getDocument()->getWindow()->flagRedraw();

	SelectionOperation* selection = nullptr;

	if(selections->dragRectangle)
		selection = processDragSelection(event);
	else
		selection = processSelection(event);

	if( !selection ) return;

	const SelectionCollection& selected = selections->getSelections();

	// Prevent duplication of selection events.
	if( selected.isSame(selection->selections) ) 
	{
		LogDebug("Ignoring duplicated selection");
		Deallocate(selection);
		return;
	}

	selection->redo();

	UndoManager* undoManager = sceneDocument->getUndoManager();
	undoManager->registerOperation(selection);
}
Example #16
0
void TileGrid2D::Resize(Vector2i newSize)
{
	std::cout<<"\nTileGrid2D::Resize";
	Deallocate();
	size = newSize;
	/// Space in X between the columns, use for creating hexagonal grids, since the distance between each tile should always be 1.0 if possible.
	float spaceX = 0;
	/// Offset in Y, used for creating hexagonal grids.
	Vector2f eachOtherRowOffset;
	Vector2f rowSpacing(1,1);
	if (gridType == GridType::HEXAGONS)
	{
		eachOtherRowOffset = Vector2f(0.5f, 0);
		rowSpacing = Vector2f(1, 0.86602540378f);
	}

	for (int y = 0; y < size[1]; ++y)
	{
		List<Tile*> * list = new List<Tile*>();
		for (int x = 0; x < size[0]; ++x)
		{
			Tile * tile = new Tile();
			tile->position = rowSpacing.ElementMultiplication(Vector2f(x,y));
			if (y % 2 == 0)
				tile->position += eachOtherRowOffset;
			list->Add(tile);
		}
		tiles.Add(list);
	}
}
Example #17
0
void	CARingBuffer::Allocate(int nChannels, UInt32 bytesPerFrame, UInt32 capacityFrames)
{
	Deallocate();
	
	//capacityFrames = NextPowerOfTwo(capacityFrames);
	
	mNumberChannels = nChannels;
	mBytesPerFrame = bytesPerFrame;
	mCapacityFrames = capacityFrames;
	//mCapacityFramesMask = capacityFrames - 1;
	mCapacityBytes = bytesPerFrame * capacityFrames;

	// put everything in one memory allocation, first the pointers, then the deinterleaved channels
	UInt32 allocSize = (mCapacityBytes + sizeof(Byte *)) * nChannels;
	Byte *p = (Byte *)CA_malloc(allocSize);
	memset(p, 0, allocSize);
	mBuffers = (Byte **)p;
	p += nChannels * sizeof(Byte *);
	for (int i = 0; i < nChannels; ++i) {
		mBuffers[i] = p;
		p += mCapacityBytes;
	}
	
	for (UInt32 i = 0; i<kGeneralRingTimeBoundsQueueSize; ++i)
	{
		mTimeBoundsQueue[i].mStartTime = 0;
		mTimeBoundsQueue[i].mEndTime = 0;
		mTimeBoundsQueue[i].mUpdateCounter = 0;
	}
	mTimeBoundsQueuePtr = 0;
}
Example #18
0
void moDMatrix<Real>::SetMatrix (int iRows, int iCols, const Real** aafEntry)
{
    Deallocate();
    if (iRows > 0 && iCols > 0)
    {
        m_iRows = iRows;
        m_iCols = iCols;
        m_iQuantity = m_iRows*m_iCols;
        Allocate(false);
        for (int iRow = 0; iRow < m_iRows; iRow++)
        {
            for (int iCol = 0; iCol < m_iCols; iCol++)
            {
                m_aafEntry[iRow][iCol] = aafEntry[iRow][iCol];
            }
        }
    }
    else
    {
        m_iRows = 0;
        m_iCols = 0;
        m_iQuantity = 0;
        m_afData = 0;
        m_aafEntry = 0;
    }
}
Example #19
0
void CTexture::Allocate( int width, int height, int ctype )
{
if ( (m_width == width) && (m_height == height) && (m_type == ctype) )
	return;

Deallocate();

TextureGetSize( ctype, &m_compsize, &m_pixelsize, &m_nelements );

if ( m_compsize == 0 || m_pixelsize == 0 || m_nelements == 0)     // Sanity check 
	{
	printf ("CTexture::Allocate - Unknown format %08X\n", ctype );
  return;
	}

m_width  = width;
m_height = height;
m_area   = width * height;
m_type   = ctype;
m_size   = m_area * m_pixelsize;
m_pdata  = new TEXBYTE[m_size];

m_pitch  = m_pixelsize * m_width;

if ( ctype == TEX_PALETTE )
		m_pcolormap = new colmap4f[256];

}
void
MediaEngineWebRTCVideoSource::Shutdown()
{
  LOG((__FUNCTION__));
  if (!mInitDone) {
    return;
  }
  if (mState == kStarted) {
    SourceMediaStream *source;
    bool empty;

    while (1) {
      {
        MonitorAutoLock lock(mMonitor);
        empty = mSources.IsEmpty();
        if (empty) {
          break;
        }
        source = mSources[0];
      }
      Stop(source, kVideoTrack); // XXX change to support multiple tracks
    }
    MOZ_ASSERT(mState == kStopped);
  }

  if (mState == kAllocated || mState == kStopped) {
    Deallocate();
  }
  mViECapture = nullptr;
  mViERender = nullptr;
  mViEBase = nullptr;

  mState = kReleased;
  mInitDone = false;
}
void	FSTCARingBuffer::AllocateWithABL(const AudioBufferList *abl)								// Assumes floating-point data
{
	Deallocate();
	
	if(abl->mNumberBuffers == 0)
		return;
	
	UInt32 idx, byteSize = offsetof(AudioBufferList, mBuffers[0]) + (sizeof(AudioBuffer) * abl->mNumberBuffers);
	mBufferList = (AudioBufferList *)malloc(byteSize);
	memset(mBufferList, 0, byteSize);
	
	mBufferList->mNumberBuffers = abl->mNumberBuffers;
	for(idx=0; idx<mBufferList->mNumberBuffers; idx++)
	{
		mBufferList->mBuffers[idx].mNumberChannels = abl->mBuffers[idx].mNumberChannels;
		mBufferList->mBuffers[idx].mDataByteSize = abl->mBuffers[idx].mDataByteSize;
		mBufferList->mBuffers[idx].mData = malloc(mBufferList->mBuffers[idx].mDataByteSize);
	}
	
	mCapacityFrames = abl->mBuffers[0].mDataByteSize/abl->mBuffers[0].mNumberChannels/sizeof(float);
	
	for (UInt32 i = 0; i<kFSTGeneralRingTimeBoundsQueueSize; ++i)
	{
		mTimeBoundsQueue[i].mStartTime = 0;
		mTimeBoundsQueue[i].mEndTime = 0;
		mTimeBoundsQueue[i].mUpdateCounter = 0;
	}
	mTimeBoundsQueuePtr = 0;
}
Example #22
0
moDBandedMatrix<Real>& moDBandedMatrix<Real>::operator= (const moDBandedMatrix& rkM)
{
    Deallocate();
    m_iSize = rkM.m_iSize;
    m_iLBands = rkM.m_iLBands;
    m_iUBands = rkM.m_iUBands;
    Allocate();

    size_t uiSize = m_iSize*sizeof(Real);
    memcpy(m_afDBand,rkM.m_afDBand,uiSize);

    int i;
    for (i = 0; i < m_iLBands; i++)
    {
        uiSize = (m_iSize-1-i)*sizeof(Real);
        memcpy(m_aafLBand[i],rkM.m_aafLBand[i],uiSize);
    }

    for (i = 0; i < m_iUBands; i++)
    {
        uiSize = (m_iSize-1-i)*sizeof(Real);
        memcpy(m_aafUBand[i],rkM.m_aafUBand[i],uiSize);
    }

    return *this;
}
void
MediaEngineGonkVideoSource::Shutdown()
{
  LOG((__FUNCTION__));
  if (!mInitDone) {
    return;
  }

  ReentrantMonitorAutoEnter sync(mCallbackMonitor);

  if (mState == kStarted) {
    SourceMediaStream *source;
    bool empty;

    while (1) {
      {
        MonitorAutoLock lock(mMonitor);
        empty = mSources.IsEmpty();
        if (empty) {
          break;
        }
        source = mSources[0];
      }
      Stop(source, kVideoTrack); // XXX change to support multiple tracks
    }
    MOZ_ASSERT(mState == kStopped);
  }

  if (mState == kAllocated || mState == kStopped) {
    Deallocate();
  }

  mState = kReleased;
  mInitDone = false;
}
Example #24
0
bool tTexture::LoadImage(std::string filename) {
	//This function uses the surface to load an image, then create a texture out of it

	Deallocate();

	//Create a "Guinna Pig" texture
	SDL_Texture* thePig = NULL;

	//Load a BMP into theSurface. BMP Is the only file type that native SDL2 can import. W(e will have to add SDL2_image to import other formats)
	theSurface = SDL_LoadBMP(filename.c_str()); //SDL_LoadBMP expects a ( char[] )

	//Debug VV
	if(theSurface == NULL) {
		std::cout << "Could not Load image! : " << SDL_GetError() <<std::endl;
	} else {
		//theTexture = SDL_CreateTextureFromSurface(theRenderer, theSurface);
		thePig = SDL_CreateTextureFromSurface(theRenderer, theSurface);

		//Debug VV
		if(thePig == NULL) {
			std::cout << "Could not create texture! : " << SDL_GetError() <<std::endl;
		}
		//Set the height and width. -> ->(Remember that theSurface is a pointer)
		tWidth = theSurface->w;
		tHeight = theSurface->h;
		//We are going to recycle our global "Surface"
		SDL_FreeSurface(theSurface);
		theSurface = NULL;
	}


	//Here is where we copy thePig into sTexture: If anything went wrong, thePig would have been NULL
	sTexture = thePig;
	return sTexture != NULL;
}
void
MediaEngineRemoteVideoSource::Shutdown()
{
  LOG((__PRETTY_FUNCTION__));
  if (!mInitDone) {
    return;
  }
  if (mState == kStarted) {
    SourceMediaStream *source;
    bool empty;

    while (1) {
      {
        MonitorAutoLock lock(mMonitor);
        empty = mSources.IsEmpty();
        if (empty) {
          MOZ_ASSERT(mPrincipalHandles.IsEmpty());
          break;
        }
        source = mSources[0];
      }
      Stop(source, kVideoTrack); // XXX change to support multiple tracks
    }
    MOZ_ASSERT(mState == kStopped);
  }

  for (auto& registered : mRegisteredHandles) {
    MOZ_ASSERT(mState == kAllocated || mState == kStopped);
    Deallocate(registered.get());
  }

  MOZ_ASSERT(mState == kReleased);
  Super::Shutdown();
  mInitDone = false;
}
Example #26
0
void CMTDHistory::SetCoordinate(unsigned int id,
                                const CSmallString& name,
                                const CSmallString& type,
                                double min_value,double max_value,unsigned int nbins)
{
    if( Sizes == NULL ){
        RUNTIME_ERROR("Sizes is NULL");
    }
    if( id < 0 || id >= NCoords ){
        INVALID_ARGUMENT("id out-of-range");
    }

    if( nbins <= 0 ){
        INVALID_ARGUMENT("nbins <= 0");
    }
    if( max_value < min_value ){
        INVALID_ARGUMENT("max_value < min_value");
    }

    if(Buffers.NumOfMembers() > 0) {
        // it was already finalized - destroy data
        Deallocate();
    }

    Sizes[id].Type = type;
    Sizes[id].Name = name;

    Sizes[id].MinValue = min_value;
    Sizes[id].MaxValue = max_value;

    Sizes[id].NBins = nbins;
    Sizes[id].BinWidth = (Sizes[id].MaxValue - Sizes[id].MinValue)/Sizes[id].NBins;
    Sizes[id].Width = Sizes[id].MaxValue - Sizes[id].MinValue;
}
Example #27
0
void CTexture::Allocate( CTexture &texsrc )
{
if ( (texsrc.m_width  == m_width) &&
     (texsrc.m_height == m_height) &&
     (texsrc.m_type   == m_type) )
    return;

Deallocate();
TextureGetSize( texsrc.m_type, &m_compsize, &m_pixelsize, &m_nelements );

if ( (m_compsize == 0) || (m_pixelsize == 0) || (m_nelements == 0) )
    return;

m_width  = texsrc.m_width;
m_height = texsrc.m_height;
m_area   = m_width * m_height;
m_type   = texsrc.m_type;
m_size   = m_area * m_pixelsize;
m_pdata  = new TEXBYTE[m_size];

m_pitch  = m_pixelsize * m_width;

if ( m_type == TEX_PALETTE )
		m_pcolormap = new colmap4f[256];
}
Example #28
0
void CMTDHistory::SetPVector(const CSimpleVector<double>& pvector)
{
    unsigned int   curr_position = 0;
    CMTDBuffer*    p_buff = NULL;
    int            loc = 0;

    Deallocate();

    while(loc < pvector.GetLength()) {

        if((p_buff == NULL) || (curr_position >= MaxBufferSize)) {
            // allocate new buffer
            p_buff = GetNewBuffer(MaxBufferSize);
            curr_position = 0;
        }

        // now set height
        p_buff->SetHeight(curr_position,pvector[loc++]);

        for(unsigned int i=0; i < GetNumberOfCoords(); i++) {
            // set value and width
            p_buff->SetValue(curr_position,i,pvector[loc++]);
            p_buff->SetWidth(curr_position,i,pvector[loc++]);
        }
        p_buff->IncNumberOfHills();
        curr_position++;
    }
}
Example #29
0
char *GetKey( void )
{
	static char old_path[256];
	DWORD dwType;
	DWORD data = 0;
	HKEY hTemp;
	DWORD dwStatus;
	DWORD data_size = sizeof( old_path );
	TEXTSTR optional_wide;
#ifdef _UNICODE
	optional_wide = MyCharWConvert( MyKey );
#else
	optional_wide = MyKey;
#endif
	dwStatus = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
									 optional_wide, 0,
                            KEY_READ, &hTemp );
	if( dwStatus == ERROR_SUCCESS )
	{
		dwStatus = RegQueryValueEx( hTemp,
											WIDE("Install_Dir"),
											NULL,
											&dwType,
											(LPBYTE)old_path,
											&data_size );
      //printf( "Result was %d\n", dwStatus );
	}
#ifdef _UNICODE
	Deallocate( TEXTSTR, optional_wide );
#endif
   //printf( "Result is %s[%s]\n", MyKey, old_path );
	return old_path;
}
Vertex Centroid::Run(int width, int height, Vertices vertices) {
  int required_bytes = sizeof(float) * width * height;

  if (bytes_ < required_bytes) {
    bytes_ = required_bytes;

    for (int n = 0; n < 4; n++) {
      if (buffer_[n] != NULL)
        Deallocate((void*)buffer_[n]);

      Allocate((void**)&(buffer_[n]), bytes_);
    }
  }

  CentroidKernel(width, height, vertices, buffer_);

  // Compute Centroid
  Vertex center;
  int count;

  center.x = Reduce(width * height, buffer_[0]);
  center.y = Reduce(width * height, buffer_[1]);
  center.z = Reduce(width * height, buffer_[2]);
  count = Reduce(width * height, buffer_[3]);

  center.x /= count;
  center.y /= count;
  center.z /= count;

  return center;
}