[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47966] trunk/blender/source/blender: minor optimizations for dilate
Campbell Barton
ideasman42 at gmail.com
Fri Jun 15 17:55:42 CEST 2012
Revision: 47966
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47966
Author: campbellbarton
Date: 2012-06-15 15:55:37 +0000 (Fri, 15 Jun 2012)
Log Message:
-----------
minor optimizations for dilate
Modified Paths:
--------------
trunk/blender/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_OpenCLKernels.cl
trunk/blender/source/blender/nodes/composite/nodes/node_composite_dilate.c
Modified: trunk/blender/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_DilateErodeOperation.cpp 2012-06-15 15:04:56 UTC (rev 47965)
+++ trunk/blender/source/blender/compositor/operations/COM_DilateErodeOperation.cpp 2012-06-15 15:55:37 UTC (rev 47966)
@@ -82,11 +82,11 @@
this->inputProgram->read(inputValue, x, y, inputBuffers, NULL);
if (inputValue[0] > sw) {
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++) {
if (buffer[offset] < sw) {
const float dx = xi - x;
- const float dy = yi - y;
const float dis = dx * dx + dy * dy;
mindist = min(mindist, dis);
}
@@ -97,11 +97,11 @@
}
else {
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++) {
if (buffer[offset] > sw) {
const float dx = xi - x;
- const float dy = yi - y;
const float dis = dx * dx + dy * dy;
mindist = min(mindist, dis);
}
@@ -187,7 +187,7 @@
void DilateDistanceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
const float distance = this->distance;
- float mindist = distance * distance;
+ const float mindist = distance * distance;
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
@@ -202,10 +202,10 @@
float value = 0.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 dy = yi - y;
const float dis = dx * dx + dy * dy;
if (dis <= mindist) {
value = max(buffer[offset], value);
@@ -262,7 +262,7 @@
void ErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
const float distance = this->distance;
- float mindist = distance * distance;
+ const float mindist = distance * distance;
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
@@ -277,10 +277,10 @@
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 dy = yi - y;
const float dis = dx * dx + dy * dy;
if (dis <= mindist) {
value = min(buffer[offset], value);
Modified: trunk/blender/source/blender/compositor/operations/COM_OpenCLKernels.cl
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_OpenCLKernels.cl 2012-06-15 15:04:56 UTC (rev 47965)
+++ trunk/blender/source/blender/compositor/operations/COM_OpenCLKernels.cl 2012-06-15 15:55:37 UTC (rev 47966)
@@ -68,9 +68,9 @@
int2 inputXy;
for (ny = minXY.y, inputXy.y = ny - offsetInput.y ; ny < maxXY.y ; ny ++, inputXy.y++) {
+ const float deltaY = (realCoordinate.y - ny);
for (nx = minXY.x, inputXy.x = nx - offsetInput.x; nx < maxXY.x ; nx ++, inputXy.x++) {
const float deltaX = (realCoordinate.x - nx);
- const float deltaY = (realCoordinate.y - ny);
const float measuredDistance = deltaX*deltaX+deltaY*deltaY;
if (measuredDistance <= distanceSquared) {
value = max(value, read_imagef(inputImage, SAMPLER_NEAREST, inputXy).s0);
Modified: trunk/blender/source/blender/nodes/composite/nodes/node_composite_dilate.c
===================================================================
--- trunk/blender/source/blender/nodes/composite/nodes/node_composite_dilate.c 2012-06-15 15:04:56 UTC (rev 47965)
+++ trunk/blender/source/blender/nodes/composite/nodes/node_composite_dilate.c 2012-06-15 15:55:37 UTC (rev 47966)
@@ -52,28 +52,28 @@
for (y = 0; y < cbuf->y; y++) {
for (x = 0; x < cbuf->x - 1; x++) {
p = rectf + cbuf->x * y + x;
- *p = MAX2(*p, *(p + 1));
+ *p = maxf(*p, *(p + 1));
}
}
for (y = 0; y < cbuf->y; y++) {
for (x = cbuf->x - 1; x >= 1; x--) {
p = rectf + cbuf->x * y + x;
- *p = MAX2(*p, *(p - 1));
+ *p = maxf(*p, *(p - 1));
}
}
for (x = 0; x < cbuf->x; x++) {
for (y = 0; y < cbuf->y - 1; y++) {
p = rectf + cbuf->x * y + x;
- *p = MAX2(*p, *(p + cbuf->x));
+ *p = maxf(*p, *(p + cbuf->x));
}
}
for (x = 0; x < cbuf->x; x++) {
for (y = cbuf->y - 1; y >= 1; y--) {
p = rectf + cbuf->x * y + x;
- *p = MAX2(*p, *(p - cbuf->x));
+ *p = maxf(*p, *(p - cbuf->x));
}
}
}
@@ -86,28 +86,28 @@
for (y = 0; y < cbuf->y; y++) {
for (x = 0; x < cbuf->x - 1; x++) {
p = rectf + cbuf->x * y + x;
- *p = MIN2(*p, *(p + 1));
+ *p = minf(*p, *(p + 1));
}
}
for (y = 0; y < cbuf->y; y++) {
for (x = cbuf->x - 1; x >= 1; x--) {
p = rectf + cbuf->x * y + x;
- *p = MIN2(*p, *(p - 1));
+ *p = minf(*p, *(p - 1));
}
}
for (x = 0; x < cbuf->x; x++) {
for (y = 0; y < cbuf->y - 1; y++) {
p = rectf + cbuf->x * y + x;
- *p = MIN2(*p, *(p + cbuf->x));
+ *p = minf(*p, *(p + cbuf->x));
}
}
for (x = 0; x < cbuf->x; x++) {
for (y = cbuf->y - 1; y >= 1; y--) {
p = rectf + cbuf->x * y + x;
- *p = MIN2(*p, *(p - cbuf->x));
+ *p = minf(*p, *(p - cbuf->x));
}
}
@@ -122,8 +122,7 @@
/* input no image? then only color operation */
if (in[0]->data == NULL) {
- out[0]->vec[0] = out[0]->vec[1] = out[0]->vec[2] = 0.0f;
- out[0]->vec[3] = 0.0f;
+ zero_v4(out[0]->vec);
}
else {
/* make output size of input image */
More information about the Bf-blender-cvs
mailing list