Esempio n. 1
0
 void resize(size_t newRows, size_t newColumns) {
 	if (rows != newRows || columns != newColumns) {
 		rows = newRows;
 		columns = newColumns;
 		assureSize();
 	}
 }
Esempio n. 2
0
/******************************************************************************
* SWBuf::setSize - Size this buffer to a specific length
*/
void SWBuf::setSize(unsigned long len) {
    assureSize(len+1);
    if ((unsigned)(end - buf) < len)
        memset(end, fillByte, len - (end-buf));
    end = buf + len;
    *end = 0;
}
Esempio n. 3
0
/******************************************************************************
* SWBuf::setFormatted - sets this buf to a formatted string
* WARNING: This function can only write at most
* JUNKBUFSIZE to the string per call.
*/
SWBuf &SWBuf::setFormatted(const char *format, ...) {
	va_list argptr;

	va_start(argptr, format);
#ifdef NO_VSNPRINTF
	int len = vsprintf(junkBuf, format, argptr)+1;
#else
	int len = vsnprintf(0, 0, format, argptr)+1;
#endif
	va_end(argptr);
	assureSize(len);
	va_start(argptr, format);
	end = vsprintf(buf, format, argptr) + buf;
	va_end(argptr);
	return *this;
}
void AUD_AnimateableProperty::write(const float* data, int position, int count)
{
	lock();

	m_isAnimated = true;

	int pos = getSize() / (sizeof(float) * m_count);

	assureSize((count + position) * m_count * sizeof(float), true);

	float* buf = getBuffer();

	memcpy(buf + position * m_count, data, count * m_count * sizeof(float));

	for(int i = pos; i < position; i++)
		memcpy(buf + i * m_count, buf + (pos - 1) * m_count, m_count * sizeof(float));

	unlock();
}
void AUD_AnimateableProperty::write(const float* data, int position, int count)
{
	AUD_MutexLock lock(*this);

	int pos = getSize() / (sizeof(float) * m_count);

	if(!m_isAnimated)
		pos = 0;

	m_isAnimated = true;

	assureSize((count + position) * m_count * sizeof(float), true);

	float* buf = getBuffer();

	memcpy(buf + position * m_count, data, count * m_count * sizeof(float));

	// have to fill up space between?
	if(pos < position)
	{
		m_unknown.push_back(Unknown(pos, position - 1));

		if(pos == 0)
		{
			memset(buf, 0, position * m_count * sizeof(float));
		}
		else
			updateUnknownCache(pos, position - 1);
	}
	// otherwise it's not at the end, let's check if some unknown part got filled
	else
	{
		bool erased = false;

		for(std::list<Unknown>::iterator it = m_unknown.begin(); it != m_unknown.end(); erased ? it : it++)
		{
			erased = false;

			// unknown area before position
			if(it->end < position)
				continue;

			// we're after the new area, let's stop
			if(it->start >= position + count)
				break;

			// we have an intersection, now 4 cases:
			// the start is included
			if(position <= it->start)
			{
				// the end is included
				if(position + count > it->end)
				{
					// simply delete
					it = m_unknown.erase(it);
					erased = true;
				}
				// the end is excluded, a second part remains
				else
				{
					// update second part
					it->start = position + count;
					updateUnknownCache(it->start, it->end);
					break;
				}
			}
			// start is excluded, a first part remains
			else
			{
				// the end is included
				if(position + count > it->end)
				{
					// update first part
					it->end = position - 1;
				}
				// the end is excluded, a second part remains
				else
				{
					// add another item and update both parts
					m_unknown.insert(it, Unknown(it->start, position - 1));
					it->start = position + count;
					updateUnknownCache(it->start, it->end);
				}
			}
		}
	}
}