本文整理汇总了C++中MemoryBuffer::getRect方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBuffer::getRect方法的具体用法?C++ MemoryBuffer::getRect怎么用?C++ MemoryBuffer::getRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBuffer
的用法示例。
在下文中一共展示了MemoryBuffer::getRect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executePixel
void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, void *data)
{
const bool do_invert = this->m_do_subtract;
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = inputBuffer->getRect()->ymin;
int miny = y - this->m_rad;
int maxy = y + this->m_rad;
int minx = x;
int maxx = x;
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
maxy = min(maxy, inputBuffer->getRect()->ymax);
maxx = min(maxx, inputBuffer->getRect()->xmax);
/* *** this is the main part which is different to 'GaussianYBlurOperation' *** */
int step = getStep();
/* gauss */
float alpha_accum = 0.0f;
float multiplier_accum = 0.0f;
/* dilate */
float value_max = finv_test(buffer[(x * 4) + (y * 4 * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */
float distfacinv_max = 1.0f; /* 0 to 1 */
for (int ny = miny; ny < maxy; ny += step) {
int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
const int index = (ny - y) + this->m_rad;
float value = finv_test(buffer[bufferindex], do_invert);
float multiplier;
/* gauss */
{
multiplier = this->m_gausstab[index];
alpha_accum += value * multiplier;
multiplier_accum += multiplier;
}
/* dilate - find most extreme color */
if (value > value_max) {
multiplier = this->m_distbuf_inv[index];
value *= multiplier;
if (value > value_max) {
value_max = value;
distfacinv_max = multiplier;
}
}
}
/* blend between the max value and gauss blue - gives nice feather */
const float value_blur = alpha_accum / multiplier_accum;
const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max));
color[0] = finv_test(value_final, do_invert);
}
示例2: executePixel
void GaussianXBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float multiplier_accum = 0.0f;
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = inputBuffer->getRect()->ymin;
int miny = y;
int minx = x - this->m_rad;
int maxx = x + this->m_rad;
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
maxx = min(maxx, inputBuffer->getRect()->xmax - 1);
int step = getStep();
int offsetadd = getOffsetAdd();
int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth);
for (int nx = minx, index = (minx - x) + this->m_rad; nx <= maxx; nx += step, index += step) {
const float multiplier = this->m_gausstab[index];
madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier);
multiplier_accum += multiplier;
bufferindex += offsetadd;
}
mul_v4_v4fl(output, color_accum, 1.0f / multiplier_accum);
}
示例3: executePixel
void GaussianYBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float multiplier_accum = 0.0f;
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = inputBuffer->getRect()->ymin;
rcti &rect = *inputBuffer->getRect();
int xmin = max_ii(x, rect.xmin);
int ymin = max_ii(y - m_filtersize, rect.ymin);
int ymax = min_ii(y + m_filtersize + 1, rect.ymax);
int index;
int step = getStep();
const int bufferIndexx = ((xmin - bufferstartx) * 4);
for (int ny = ymin; ny < ymax; ny += step) {
index = (ny - y) + this->m_filtersize;
int bufferindex = bufferIndexx + ((ny - bufferstarty) * 4 * bufferwidth);
const float multiplier = this->m_gausstab[index];
madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier);
multiplier_accum += multiplier;
}
mul_v4_v4fl(output, color_accum, 1.0f / multiplier_accum);
}
示例4: executePixel
void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
float color_accum[4];
float tempBoundingBox[4];
float bokeh[4];
this->m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, COM_PS_NEAREST);
if (tempBoundingBox[0] > 0.0f) {
float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = inputBuffer->getRect()->ymin;
const float max_dim = max(this->getWidth(), this->getHeight());
int pixelSize = this->m_size * max_dim / 100.0f;
zero_v4(color_accum);
if (pixelSize < 2) {
this->m_inputProgram->readSampled(color_accum, x, y, COM_PS_NEAREST);
multiplier_accum[0] = 1.0f;
multiplier_accum[1] = 1.0f;
multiplier_accum[2] = 1.0f;
multiplier_accum[3] = 1.0f;
}
int miny = y - pixelSize;
int maxy = y + pixelSize;
int minx = x - pixelSize;
int maxx = x + pixelSize;
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
maxy = min(maxy, inputBuffer->getRect()->ymax);
maxx = min(maxx, inputBuffer->getRect()->xmax);
int step = getStep();
int offsetadd = getOffsetAdd() * COM_NUM_CHANNELS_COLOR;
float m = this->m_bokehDimension / pixelSize;
for (int ny = miny; ny < maxy; ny += step) {
int bufferindex = ((minx - bufferstartx) * COM_NUM_CHANNELS_COLOR) +
((ny - bufferstarty) * COM_NUM_CHANNELS_COLOR * bufferwidth);
for (int nx = minx; nx < maxx; nx += step) {
float u = this->m_bokehMidX - (nx - x) * m;
float v = this->m_bokehMidY - (ny - y) * m;
this->m_inputBokehProgram->readSampled(bokeh, u, v, COM_PS_NEAREST);
madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]);
add_v4_v4(multiplier_accum, bokeh);
bufferindex += offsetadd;
}
}
output[0] = color_accum[0] * (1.0f / multiplier_accum[0]);
output[1] = color_accum[1] * (1.0f / multiplier_accum[1]);
output[2] = color_accum[2] * (1.0f / multiplier_accum[2]);
output[3] = color_accum[3] * (1.0f / multiplier_accum[3]);
}
else {
this->m_inputProgram->readSampled(output, x, y, COM_PS_NEAREST);
}
}
示例5: executePixel
void GaussianAlphaXBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
const bool do_invert = this->m_do_subtract;
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = inputBuffer->getRect()->ymin;
rcti &rect = *inputBuffer->getRect();
int xmin = max_ii(x - m_filtersize, rect.xmin);
int xmax = min_ii(x + m_filtersize + 1, rect.xmax);
int ymin = max_ii(y, rect.ymin);
/* *** this is the main part which is different to 'GaussianXBlurOperation' *** */
int step = getStep();
int offsetadd = getOffsetAdd();
int bufferindex = ((xmin - bufferstartx) * 4) + ((ymin - bufferstarty) * 4 * bufferwidth);
/* gauss */
float alpha_accum = 0.0f;
float multiplier_accum = 0.0f;
/* dilate */
float value_max = finv_test(buffer[(x * 4) + (y * 4 * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */
float distfacinv_max = 1.0f; /* 0 to 1 */
for (int nx = xmin; nx < xmax; nx += step) {
const int index = (nx - x) + this->m_filtersize;
float value = finv_test(buffer[bufferindex], do_invert);
float multiplier;
/* gauss */
{
multiplier = this->m_gausstab[index];
alpha_accum += value * multiplier;
multiplier_accum += multiplier;
}
/* dilate - find most extreme color */
if (value > value_max) {
multiplier = this->m_distbuf_inv[index];
value *= multiplier;
if (value > value_max) {
value_max = value;
distfacinv_max = multiplier;
}
}
bufferindex += offsetadd;
}
/* blend between the max value and gauss blue - gives nice feather */
const float value_blur = alpha_accum / multiplier_accum;
const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max));
output[0] = finv_test(value_final, do_invert);
}
示例6: executePixel
void ErodeDistanceOperation::executePixel(float *color, int x, int y, void *data)
{
const float distance = this->m_distance;
const float mindist = distance * distance;
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
rcti *rect = inputBuffer->getRect();
const int minx = max(x - this->m_scope, rect->xmin);
const int miny = max(y - this->m_scope, rect->ymin);
const int maxx = min(x + this->m_scope, rect->xmax);
const int maxy = min(y + this->m_scope, rect->ymax);
const int bufferWidth = rect->xmax - rect->xmin;
int offset;
float value = 1.0f;
for (int yi = miny; yi < maxy; yi++) {
const float dy = yi - y;
offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin)) * 4;
for (int xi = minx; xi < maxx; xi++) {
const float dx = xi - x;
const float dis = dx * dx + dy * dy;
if (dis <= mindist) {
value = min(buffer[offset], value);
}
offset += 4;
}
}
color[0] = value;
}
示例7: executePixel
void GaussianXBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float multiplier_accum = 0.0f;
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = inputBuffer->getRect()->ymin;
rcti &rect = *inputBuffer->getRect();
int xmin = max_ii(x - m_filtersize, rect.xmin);
int xmax = min_ii(x + m_filtersize + 1, rect.xmax);
int ymin = max_ii(y, rect.ymin);
int step = getStep();
int offsetadd = getOffsetAdd();
int bufferindex = ((xmin - bufferstartx) * 4) + ((ymin - bufferstarty) * 4 * bufferwidth);
#ifdef __SSE2__
__m128 accum_r = _mm_load_ps(color_accum);
for (int nx = xmin, index = (xmin - x) + this->m_filtersize; nx < xmax; nx += step, index += step) {
__m128 reg_a = _mm_load_ps(&buffer[bufferindex]);
reg_a = _mm_mul_ps(reg_a, this->m_gausstab_sse[index]);
accum_r = _mm_add_ps(accum_r, reg_a);
multiplier_accum += this->m_gausstab[index];
bufferindex += offsetadd;
}
_mm_store_ps(color_accum, accum_r);
#else
for (int nx = xmin, index = (xmin - x) + this->m_filtersize; nx < xmax; nx += step, index += step) {
const float multiplier = this->m_gausstab[index];
madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier);
multiplier_accum += multiplier;
bufferindex += offsetadd;
}
#endif
mul_v4_v4fl(output, color_accum, 1.0f / multiplier_accum);
}
示例8: getDAI
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
}