示例#1
0
MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *rect)
{
	MemoryBuffer *imageBuffer = memoryProxy->getBuffer();
	MemoryBuffer *result = new MemoryBuffer(memoryProxy, rect);
	result->copyContentFrom(imageBuffer);
	return result;
}
示例#2
0
float MemoryBuffer::getMaximumValue(rcti *rect)
{
	rcti rect_clamp;

	/* first clamp the rect by the bounds or we get un-initialized values */
	BLI_rcti_isect(rect, &this->m_rect, &rect_clamp);

	if (!BLI_rcti_is_empty(&rect_clamp)) {
		MemoryBuffer *temp = new MemoryBuffer(NULL, &rect_clamp);
		temp->copyContentFrom(this);
		float result = temp->getMaximumValue();
		delete temp;
		return result;
	}
	else {
		BLI_assert(0);
		return 0.0f;
	}
}
void *FastGaussianBlurOperation::initializeTileData(rcti *rect)
{
#if 0
	lockMutex();
	if (!this->m_iirgaus) {
		MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect);
		MemoryBuffer *copy = newBuf->duplicate();
		updateSize();

		int c;
		this->m_sx = this->m_data->sizex * this->m_size / 2.0f;
		this->m_sy = this->m_data->sizey * this->m_size / 2.0f;
		
		if ((this->m_sx == this->m_sy) && (this->m_sx > 0.f)) {
			for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
				IIR_gauss(copy, this->m_sx, c, 3);
		}
		else {
			if (this->m_sx > 0.0f) {
				for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
					IIR_gauss(copy, this->m_sx, c, 1);
			}
			if (this->m_sy > 0.0f) {
				for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
					IIR_gauss(copy, this->m_sy, c, 2);
			}
		}
		this->m_iirgaus = copy;
	}
	unlockMutex();
	return this->m_iirgaus;
#else

	lockMutex();
	if (this->m_iirgaus) {
		// if this->m_iirgaus is set, we don't do tile rendering, so
		// we can return the already calculated cache
		unlockMutex();
		return this->m_iirgaus;
	}
	updateSize();
	rcti dai;
	bool use_tiles = getDAI(rect, &dai);
	if (use_tiles) {
		unlockMutex();
	}

	MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL);
	rcti *buf_rect = buffer->getRect();

	dai.xmin = max(dai.xmin, buf_rect->xmin);
	dai.xmax = min(dai.xmax, buf_rect->xmax);
	dai.ymin = max(dai.ymin, buf_rect->ymin);
	dai.ymax = min(dai.ymax, buf_rect->ymax);

	MemoryBuffer *tile = new MemoryBuffer(NULL, &dai);
	tile->copyContentFrom(buffer);

	int c;
	float sx = this->m_data->sizex * this->m_size / 2.0f;
	float sy = this->m_data->sizey * this->m_size / 2.0f;

	if ((sx == sy) && (sx > 0.f)) {
		for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
			IIR_gauss(tile, sx, c, 3);
	}
	else {
		if (sx > 0.0f) {
			for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
				IIR_gauss(tile, sx, c, 1);
		}
		if (sy > 0.0f) {
			for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
				IIR_gauss(tile, sy, c, 2);
		}
	}
	if (!use_tiles) {
		this->m_iirgaus = tile;
		unlockMutex();
	}
	return tile;
#endif
}