Cleanup: Use Enum Class For PixelSampler.

This commit is contained in:
Jeroen Bakker 2021-03-26 12:39:54 +01:00
parent 23b1872d6e
commit e5fb7eac85
26 changed files with 65 additions and 65 deletions

View File

@ -29,11 +29,11 @@
# include "MEM_guardedalloc.h"
#endif
typedef enum PixelSampler {
COM_PS_NEAREST = 0,
COM_PS_BILINEAR = 1,
COM_PS_BICUBIC = 2,
} PixelSampler;
enum class PixelSampler {
Nearest = 0,
Bilinear = 1,
Bicubic = 2,
};
class MemoryBuffer;
@ -81,7 +81,7 @@ class SocketReader {
*/
virtual void executePixel(float output[4], int x, int y, void * /*chunkData*/)
{
executePixelSampled(output, x, y, COM_PS_NEAREST);
executePixelSampled(output, x, y, PixelSampler::Nearest);
}
/**

View File

@ -167,7 +167,7 @@ void BlurBaseOperation::updateSize()
{
if (!this->m_sizeavailable) {
float result[4];
this->getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST);
this->getInputSocketReader(1)->readSampled(result, 0, 0, PixelSampler::Nearest);
this->m_size = result[0];
this->m_sizeavailable = true;
}

View File

@ -76,7 +76,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
float tempBoundingBox[4];
float bokeh[4];
this->m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, COM_PS_NEAREST);
this->m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, PixelSampler::Nearest);
if (tempBoundingBox[0] > 0.0f) {
float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
@ -90,7 +90,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
zero_v4(color_accum);
if (pixelSize < 2) {
this->m_inputProgram->readSampled(color_accum, x, y, COM_PS_NEAREST);
this->m_inputProgram->readSampled(color_accum, x, y, PixelSampler::Nearest);
multiplier_accum[0] = 1.0f;
multiplier_accum[1] = 1.0f;
multiplier_accum[2] = 1.0f;
@ -115,7 +115,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
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);
this->m_inputBokehProgram->readSampled(bokeh, u, v, PixelSampler::Nearest);
madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]);
add_v4_v4(multiplier_accum, bokeh);
bufferindex += offsetadd;
@ -127,7 +127,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
output[3] = color_accum[3] * (1.0f / multiplier_accum[3]);
}
else {
this->m_inputProgram->readSampled(output, x, y, COM_PS_NEAREST);
this->m_inputProgram->readSampled(output, x, y, PixelSampler::Nearest);
}
}
@ -224,7 +224,7 @@ void BokehBlurOperation::updateSize()
{
if (!this->m_sizeavailable) {
float result[4];
this->getInputSocketReader(3)->readSampled(result, 0, 0, COM_PS_NEAREST);
this->getInputSocketReader(3)->readSampled(result, 0, 0, PixelSampler::Nearest);
this->m_size = result[0];
CLAMP(this->m_size, 0.0f, 10.0f);
this->m_sizeavailable = true;

View File

@ -196,14 +196,14 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
for (x = x1; x < x2 && (!breaked); x++) {
int input_x = x + dx, input_y = y + dy;
this->m_imageInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
this->m_imageInput->readSampled(color, input_x, input_y, PixelSampler::Nearest);
if (this->m_useAlphaInput) {
this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, COM_PS_NEAREST);
this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, PixelSampler::Nearest);
}
copy_v4_v4(buffer + offset4, color);
this->m_depthInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
this->m_depthInput->readSampled(color, input_x, input_y, PixelSampler::Nearest);
zbuffer[offset] = color[0];
offset4 += COM_NUM_CHANNELS_COLOR;
offset++;

View File

@ -66,7 +66,7 @@ void DirectionalBlurOperation::executePixel(float output[4], int x, int y, void
const int iterations = pow(2.0f, this->m_data->iter);
float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float col2[4] = {0.0f, 0.0f, 0.0f, 0.0f};
this->m_inputProgram->readSampled(col2, x, y, COM_PS_BILINEAR);
this->m_inputProgram->readSampled(col2, x, y, PixelSampler::Bilinear);
float ltx = this->m_tx;
float lty = this->m_ty;
float lsc = this->m_sc;
@ -82,7 +82,7 @@ void DirectionalBlurOperation::executePixel(float output[4], int x, int y, void
this->m_inputProgram->readSampled(col,
cs * u + ss * v + this->m_center_x_pix,
cs * v - ss * u + this->m_center_y_pix,
COM_PS_BILINEAR);
PixelSampler::Bilinear);
add_v4_v4(col2, col);

View File

@ -56,7 +56,7 @@ void DisplaceOperation::executePixelSampled(float output[4],
pixelTransform(xy, uv, deriv);
if (is_zero_v2(deriv[0]) && is_zero_v2(deriv[1])) {
this->m_inputColorProgram->readSampled(output, uv[0], uv[1], COM_PS_BILINEAR);
this->m_inputColorProgram->readSampled(output, uv[0], uv[1], PixelSampler::Bilinear);
}
else {
/* EWA filtering (without nearest it gets blurry with NO distortion) */
@ -76,7 +76,7 @@ bool DisplaceOperation::read_displacement(
}
float col[4];
m_inputVectorProgram->readSampled(col, x, y, COM_PS_BILINEAR);
m_inputVectorProgram->readSampled(col, x, y, PixelSampler::Bilinear);
r_u = origin[0] - col[0] * xscale;
r_v = origin[1] - col[1] * yscale;
return true;
@ -88,9 +88,9 @@ void DisplaceOperation::pixelTransform(const float xy[2], float r_uv[2], float r
float uv[2]; /* temporary variables for derivative estimation */
int num;
m_inputScaleXProgram->readSampled(col, xy[0], xy[1], COM_PS_NEAREST);
m_inputScaleXProgram->readSampled(col, xy[0], xy[1], PixelSampler::Nearest);
float xs = col[0];
m_inputScaleYProgram->readSampled(col, xy[0], xy[1], COM_PS_NEAREST);
m_inputScaleYProgram->readSampled(col, xy[0], xy[1], PixelSampler::Nearest);
float ys = col[0];
/* clamp x and y displacement to triple image resolution -
* to prevent hangs from huge values mistakenly plugged in eg. z buffers */

View File

@ -123,13 +123,13 @@ static void sampleImageAtLocation(
{
if (ibuf->rect_float) {
switch (sampler) {
case COM_PS_NEAREST:
case PixelSampler::Nearest:
nearest_interpolation_color(ibuf, nullptr, color, x, y);
break;
case COM_PS_BILINEAR:
case PixelSampler::Bilinear:
bilinear_interpolation_color(ibuf, nullptr, color, x, y);
break;
case COM_PS_BICUBIC:
case PixelSampler::Bicubic:
bicubic_interpolation_color(ibuf, nullptr, color, x, y);
break;
}
@ -137,13 +137,13 @@ static void sampleImageAtLocation(
else {
unsigned char byte_color[4];
switch (sampler) {
case COM_PS_NEAREST:
case PixelSampler::Nearest:
nearest_interpolation_color(ibuf, byte_color, nullptr, x, y);
break;
case COM_PS_BILINEAR:
case PixelSampler::Bilinear:
bilinear_interpolation_color(ibuf, byte_color, nullptr, x, y);
break;
case COM_PS_BICUBIC:
case PixelSampler::Bicubic:
bicubic_interpolation_color(ibuf, byte_color, nullptr, x, y);
break;
}

View File

@ -89,7 +89,7 @@ bool MapUVOperation::read_uv(float x, float y, float &r_u, float &r_v, float &r_
}
float vector[3];
m_inputUVProgram->readSampled(vector, x, y, COM_PS_BILINEAR);
m_inputUVProgram->readSampled(vector, x, y, PixelSampler::Bilinear);
r_u = vector[0] * m_inputColorProgram->getWidth();
r_v = vector[1] * m_inputColorProgram->getHeight();
r_alpha = vector[2];

View File

@ -101,13 +101,13 @@ void MovieClipBaseOperation::executePixelSampled(float output[4],
}
else {
switch (sampler) {
case COM_PS_NEAREST:
case PixelSampler::Nearest:
nearest_interpolation_color(ibuf, nullptr, output, x, y);
break;
case COM_PS_BILINEAR:
case PixelSampler::Bilinear:
bilinear_interpolation_color(ibuf, nullptr, output, x, y);
break;
case COM_PS_BICUBIC:
case PixelSampler::Bicubic:
bicubic_interpolation_color(ibuf, nullptr, output, x, y);
break;
}

View File

@ -107,10 +107,10 @@ void MovieDistortionOperation::executePixelSampled(float output[4],
float u = out[0] * aspx /* + 0.5 * overscan * w */,
v = (out[1] * aspy /* + 0.5 * overscan * h */) * pixel_aspect;
this->m_inputOperation->readSampled(output, u, v, COM_PS_BILINEAR);
this->m_inputOperation->readSampled(output, u, v, PixelSampler::Bilinear);
}
else {
this->m_inputOperation->readSampled(output, x, y, COM_PS_BILINEAR);
this->m_inputOperation->readSampled(output, x, y, PixelSampler::Bilinear);
}
}

View File

@ -86,13 +86,13 @@ void MultilayerColorOperation::executePixelSampled(float output[4],
else {
if (this->m_numberOfChannels == 4) {
switch (sampler) {
case COM_PS_NEAREST:
case PixelSampler::Nearest:
nearest_interpolation_color(this->m_buffer, nullptr, output, x, y);
break;
case COM_PS_BILINEAR:
case PixelSampler::Bilinear:
bilinear_interpolation_color(this->m_buffer, nullptr, output, x, y);
break;
case COM_PS_BICUBIC:
case PixelSampler::Bicubic:
bicubic_interpolation_color(this->m_buffer, nullptr, output, x, y);
break;
}

View File

@ -191,7 +191,7 @@ static void write_buffer_rect(rcti *rect,
for (y = y1; y < y2 && (!breaked); y++) {
for (x = x1; x < x2 && (!breaked); x++) {
reader->readSampled(color, x, y, COM_PS_NEAREST);
reader->readSampled(color, x, y, PixelSampler::Nearest);
for (i = 0; i < size; i++) {
buffer[offset + i] = color[i];

View File

@ -60,7 +60,7 @@ static void readCornersFromSockets(rcti *rect, SocketReader *readers[4], float c
{
for (int i = 0; i < 4; i++) {
float result[4] = {0.0f, 0.0f, 0.0f, 0.0f};
readers[i]->readSampled(result, rect->xmin, rect->ymin, COM_PS_NEAREST);
readers[i]->readSampled(result, rect->xmin, rect->ymin, PixelSampler::Nearest);
corners[i][0] = result[0];
corners[i][1] = result[1];
}

View File

@ -104,7 +104,7 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
color[1] = 0.0f;
color[2] = 0.0f;
color[3] = 1.0f;
this->m_input->readSampled(color, rx, ry, COM_PS_NEAREST);
this->m_input->readSampled(color, rx, ry, PixelSampler::Nearest);
IMB_colormanagement_processor_apply_v4(cm_processor, color);
rgba_float_to_uchar(this->m_outputBuffer + offset, color);
offset += 4;

View File

@ -103,7 +103,7 @@ void ProjectorLensDistortionOperation::updateDispersion()
this->lockMutex();
if (!this->m_dispersionAvailable) {
float result[4];
this->getInputSocketReader(1)->readSampled(result, 1, 1, COM_PS_NEAREST);
this->getInputSocketReader(1)->readSampled(result, 1, 1, PixelSampler::Nearest);
this->m_dispersion = result[0];
this->m_kr = 0.25f * max_ff(min_ff(this->m_dispersion, 1.0f), 0.0f);
this->m_kr2 = this->m_kr * 20;

View File

@ -60,14 +60,14 @@ void ReadBufferOperation::executePixelSampled(float output[4],
}
else {
switch (sampler) {
case COM_PS_NEAREST:
case PixelSampler::Nearest:
m_buffer->read(output, x, y);
break;
case COM_PS_BILINEAR:
case PixelSampler::Bilinear:
default:
m_buffer->readBilinear(output, x, y);
break;
case COM_PS_BICUBIC:
case PixelSampler::Bicubic:
m_buffer->readBilinear(output, x, y);
break;
}
@ -85,7 +85,7 @@ void ReadBufferOperation::executePixelExtend(float output[4],
/* write buffer has a single value stored at (0,0) */
m_buffer->read(output, 0, 0);
}
else if (sampler == COM_PS_NEAREST) {
else if (sampler == PixelSampler::Nearest) {
m_buffer->read(output, x, y, extend_x, extend_y);
}
else {

View File

@ -92,7 +92,7 @@ void RenderLayersProg::doInterpolation(float output[4], float x, float y, PixelS
}
switch (sampler) {
case COM_PS_NEAREST: {
case PixelSampler::Nearest: {
offset = (iy * width + ix) * this->m_elementsize;
if (this->m_elementsize == 1) {
@ -107,12 +107,12 @@ void RenderLayersProg::doInterpolation(float output[4], float x, float y, PixelS
break;
}
case COM_PS_BILINEAR:
case PixelSampler::Bilinear:
BLI_bilinear_interpolation_fl(
this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
break;
case COM_PS_BICUBIC:
case PixelSampler::Bicubic:
BLI_bicubic_interpolation_fl(
this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
break;

View File

@ -48,7 +48,7 @@ inline void RotateOperation::ensureDegree()
{
if (!this->m_isDegreeSet) {
float degree[4];
this->m_degreeSocket->readSampled(degree, 0, 0, COM_PS_NEAREST);
this->m_degreeSocket->readSampled(degree, 0, 0, PixelSampler::Nearest);
double rad;
if (this->m_doDegree2RadConversion) {
rad = DEG2RAD((double)degree[0]);

View File

@ -28,7 +28,7 @@
BaseScaleOperation::BaseScaleOperation()
{
#ifdef USE_FORCE_BILINEAR
m_sampler = (int)COM_PS_BILINEAR;
m_sampler = (int)PixelSampler::Bilinear;
#else
m_sampler = -1;
#endif
@ -89,8 +89,8 @@ bool ScaleOperation::determineDependingAreaOfInterest(rcti *input,
float scaleX[4];
float scaleY[4];
this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST);
this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST);
this->m_inputXOperation->readSampled(scaleX, 0, 0, PixelSampler::Nearest);
this->m_inputYOperation->readSampled(scaleY, 0, 0, PixelSampler::Nearest);
const float scx = scaleX[0];
const float scy = scaleY[0];
@ -174,8 +174,8 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input,
float scaleX[4];
float scaleY[4];
this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST);
this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST);
this->m_inputXOperation->readSampled(scaleX, 0, 0, PixelSampler::Nearest);
this->m_inputYOperation->readSampled(scaleY, 0, 0, PixelSampler::Nearest);
const float scx = scaleX[0];
const float scy = scaleY[0];

View File

@ -83,12 +83,12 @@ void *ScreenLensDistortionOperation::initializeTileData(rcti * /*rect*/)
if (!m_distortion_const) {
float result[4];
getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST);
getInputSocketReader(1)->readSampled(result, 0, 0, PixelSampler::Nearest);
m_distortion = result[0];
}
if (!m_dispersion_const) {
float result[4];
getInputSocketReader(2)->readSampled(result, 0, 0, COM_PS_NEAREST);
getInputSocketReader(2)->readSampled(result, 0, 0, PixelSampler::Nearest);
m_dispersion = result[0];
}

View File

@ -58,10 +58,10 @@ void SplitOperation::executePixelSampled(float output[4],
this->m_splitPercentage * this->getHeight() / 100.0f;
bool image1 = this->m_xSplit ? x > perc : y > perc;
if (image1) {
this->m_image1Input->readSampled(output, x, y, COM_PS_NEAREST);
this->m_image1Input->readSampled(output, x, y, PixelSampler::Nearest);
}
else {
this->m_image2Input->readSampled(output, x, y, COM_PS_NEAREST);
this->m_image2Input->readSampled(output, x, y, PixelSampler::Nearest);
}
}

View File

@ -56,7 +56,7 @@ void TranslateOperation::executePixelSampled(float output[4],
float originalXPos = x - this->getDeltaX();
float originalYPos = y - this->getDeltaY();
this->m_inputOperation->readSampled(output, originalXPos, originalYPos, COM_PS_BILINEAR);
this->m_inputOperation->readSampled(output, originalXPos, originalYPos, PixelSampler::Bilinear);
}
bool TranslateOperation::determineDependingAreaOfInterest(rcti *input,

View File

@ -54,9 +54,9 @@ class TranslateOperation : public NodeOperation {
{
if (!this->m_isDeltaSet) {
float tempDelta[4];
this->m_inputXOperation->readSampled(tempDelta, 0, 0, COM_PS_NEAREST);
this->m_inputXOperation->readSampled(tempDelta, 0, 0, PixelSampler::Nearest);
this->m_deltaX = tempDelta[0];
this->m_inputYOperation->readSampled(tempDelta, 0, 0, COM_PS_NEAREST);
this->m_inputYOperation->readSampled(tempDelta, 0, 0, PixelSampler::Nearest);
this->m_deltaY = tempDelta[0];
this->m_isDeltaSet = true;
}

View File

@ -319,7 +319,7 @@ void *InverseSearchRadiusOperation::initializeTileData(rcti *rect)
// for (int x2 = 0 ; x2 < DIVIDER ; x2 ++) {
// for (int y2 = 0 ; y2 < DIVIDER ; y2 ++) {
// this->m_inputRadius->read(temp, rx+x2, ry+y2, COM_PS_NEAREST);
// this->m_inputRadius->read(temp, rx+x2, ry+y2, PixelSampler::Nearest);
// if (radius < temp[0]) {
// radius = temp[0];
// maxx = x2;

View File

@ -98,12 +98,12 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
for (y = y1; y < y2 && (!breaked); y++) {
for (x = x1; x < x2; x++) {
this->m_imageInput->readSampled(&(buffer[offset4]), x, y, COM_PS_NEAREST);
this->m_imageInput->readSampled(&(buffer[offset4]), x, y, PixelSampler::Nearest);
if (this->m_useAlphaInput) {
this->m_alphaInput->readSampled(alpha, x, y, COM_PS_NEAREST);
this->m_alphaInput->readSampled(alpha, x, y, PixelSampler::Nearest);
buffer[offset4 + 3] = alpha[0];
}
this->m_depthInput->readSampled(depth, x, y, COM_PS_NEAREST);
this->m_depthInput->readSampled(depth, x, y, PixelSampler::Nearest);
depthbuffer[offset] = depth[0];
offset++;

View File

@ -97,7 +97,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/
for (y = y1; y < y2 && (!breaked); y++) {
int offset4 = (y * memoryBuffer->getWidth() + x1) * num_channels;
for (x = x1; x < x2; x++) {
this->m_input->readSampled(&(buffer[offset4]), x, y, COM_PS_NEAREST);
this->m_input->readSampled(&(buffer[offset4]), x, y, PixelSampler::Nearest);
offset4 += num_channels;
}
if (isBraked()) {