Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-08-16 16:32:48 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-16 16:32:48 +0400
commit3bc16fd60dd573f8289552a0046b0735d1c7e02b (patch)
tree3936a357fd922e96b622f29f04804b20cb11f234 /source/blender/compositor/operations
parent883e9df1ccdaaa847c86e2d1457fd88333b87c84 (diff)
compositor: replace C++ new/delete with guardedalloc.
Diffstat (limited to 'source/blender/compositor/operations')
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp15
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.h13
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cpp9
13 files changed, 57 insertions, 45 deletions
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
index 12bf651992e..c37830a9d92 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
@@ -23,6 +23,10 @@
#include "COM_AntiAliasOperation.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BKE_utildefines.h"
+
+#include "MEM_guardedalloc.h"
+
extern "C" {
#include "RE_render_ext.h"
}
@@ -58,7 +62,7 @@ void AntiAliasOperation::deinitExecution()
{
this->m_valueReader = NULL;
if (this->m_buffer) {
- delete this->m_buffer;
+ MEM_freeN(this->m_buffer);
}
NodeOperation::deinitMutex();
}
@@ -90,12 +94,10 @@ void *AntiAliasOperation::initializeTileData(rcti *rect)
MemoryBuffer *tile = (MemoryBuffer *)this->m_valueReader->initializeTileData(rect);
int size = tile->getHeight() * tile->getWidth();
float *input = tile->getBuffer();
- char *valuebuffer = new char[size];
+ char *valuebuffer = (char *)MEM_mallocN(sizeof(char) * size, __func__);
for (int i = 0; i < size; i++) {
float in = input[i * COM_NUMBER_OF_CHANNELS];
- if (in < 0.0f) { in = 0.0f; }
- if (in > 1.0f) {in = 1.0f; }
- valuebuffer[i] = in * 255;
+ valuebuffer[i] = FTOCHAR(in);
}
antialias_tagbuf(tile->getWidth(), tile->getHeight(), valuebuffer);
this->m_buffer = valuebuffer;
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
index 98aeba41ecb..c527807f839 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -22,6 +22,7 @@
#include "COM_BlurBaseOperation.h"
#include "BLI_math.h"
+#include "MEM_guardedalloc.h"
extern "C" {
#include "RE_pipeline.h"
@@ -74,7 +75,7 @@ float *BlurBaseOperation::make_gausstab(int rad)
n = 2 * rad + 1;
- gausstab = new float[n];
+ gausstab = (float *)MEM_mallocN(sizeof(float) * n, __func__);
sum = 0.0f;
for (i = -rad; i <= rad; i++) {
@@ -99,7 +100,7 @@ float *BlurBaseOperation::make_dist_fac_inverse(int rad, int falloff)
n = 2 * rad + 1;
- dist_fac_invert = new float[n];
+ dist_fac_invert = (float *)MEM_mallocN(sizeof(float) * n, __func__);
for (i = -rad; i <= rad; i++) {
val = 1.0f - fabsf(((float)i / (float)rad));
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
index fd593b39dcd..553a9827ffa 100644
--- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
@@ -24,6 +24,8 @@
#include "BLI_utildefines.h"
+#include "MEM_guardedalloc.h"
+
ConvolutionFilterOperation::ConvolutionFilterOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
@@ -42,7 +44,7 @@ void ConvolutionFilterOperation::initExecution()
void ConvolutionFilterOperation::set3x3Filter(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9)
{
- this->m_filter = new float[9];
+ this->m_filter = (float *)MEM_mallocN(sizeof(float) * 9, __func__);
this->m_filter[0] = f1;
this->m_filter[1] = f2;
this->m_filter[2] = f3;
@@ -61,7 +63,7 @@ void ConvolutionFilterOperation::deinitExecution()
this->m_inputOperation = NULL;
this->m_inputValueOperation = NULL;
if (this->m_filter) {
- delete[] this->m_filter;
+ MEM_freeN(this->m_filter);
this->m_filter = NULL;
}
}
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
index 5e70187557b..2687fee28ce 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
@@ -24,6 +24,8 @@
#include "BLI_math.h"
#include "COM_OpenCLDevice.h"
+#include "MEM_guardedalloc.h"
+
// DilateErode Distance Threshold
DilateErodeThresholdOperation::DilateErodeThresholdOperation() : NodeOperation()
{
@@ -384,7 +386,7 @@ void DilateStepOperation::deinitExecution()
this->m_inputProgram = NULL;
this->deinitMutex();
if (this->m_cached_buffer) {
- delete [] this->m_cached_buffer;
+ MEM_freeN(this->m_cached_buffer);
this->m_cached_buffer = NULL;
}
}
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
index d5daace059d..39665b10f48 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
@@ -1269,12 +1269,12 @@ void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect)
if (this->m_cachedInstance == NULL) {
MemoryBuffer *innerMask = (MemoryBuffer *)this->m_inputInnerMask->initializeTileData(rect);
MemoryBuffer *outerMask = (MemoryBuffer *)this->m_inputOuterMask->initializeTileData(rect);
- float *data = new float[this->getWidth() * this->getHeight()];
+ float *data = (float *)MEM_mallocN(sizeof(float) * this->getWidth() * this->getHeight(), __func__);
float *imask = innerMask->convertToValueBuffer();
float *omask = outerMask->convertToValueBuffer();
doDoubleEdgeMask(imask, omask, data);
- delete [] imask;
- delete [] omask;
+ MEM_freeN(imask);
+ MEM_freeN(omask);
this->m_cachedInstance = data;
}
unlockMutex();
@@ -1293,7 +1293,7 @@ void DoubleEdgeMaskOperation::deinitExecution()
this->m_inputOuterMask = NULL;
deinitMutex();
if (this->m_cachedInstance) {
- delete this->m_cachedInstance;
+ MEM_freeN(this->m_cachedInstance);
this->m_cachedInstance = NULL;
}
}
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
index 935bfcac6c7..82f38556e82 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
@@ -23,6 +23,7 @@
#include "COM_GaussianAlphaXBlurOperation.h"
#include "BLI_math.h"
+#include "MEM_guardedalloc.h"
extern "C" {
#include "RE_pipeline.h"
@@ -154,9 +155,9 @@ void GaussianAlphaXBlurOperation::executePixel(float output[4], int x, int y, vo
void GaussianAlphaXBlurOperation::deinitExecution()
{
BlurBaseOperation::deinitExecution();
- delete [] this->m_gausstab;
+ MEM_freeN(this->m_gausstab);
this->m_gausstab = NULL;
- delete [] this->m_distbuf_inv;
+ MEM_freeN(this->m_distbuf_inv);
this->m_distbuf_inv = NULL;
deinitMutex();
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
index 375f1bcf07c..bfd9564817e 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
@@ -23,6 +23,7 @@
#include "COM_GaussianAlphaYBlurOperation.h"
#include "BLI_math.h"
+#include "MEM_guardedalloc.h"
extern "C" {
#include "RE_pipeline.h"
@@ -154,9 +155,9 @@ void GaussianAlphaYBlurOperation::executePixel(float output[4], int x, int y, vo
void GaussianAlphaYBlurOperation::deinitExecution()
{
BlurBaseOperation::deinitExecution();
- delete [] this->m_gausstab;
+ MEM_freeN(this->m_gausstab);
this->m_gausstab = NULL;
- delete [] this->m_distbuf_inv;
+ MEM_freeN(this->m_distbuf_inv);
this->m_distbuf_inv = NULL;
deinitMutex();
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
index d97d2f15ded..a9bcb2dd752 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
@@ -88,7 +88,7 @@ void GaussianBokehBlurOperation::updateGauss()
n = (2 * this->m_radx + 1) * (2 * this->m_rady + 1);
/* create a full filter image */
- ddgauss = new float[n];
+ ddgauss = (float *)MEM_mallocN(sizeof(float) * n, __func__);
dgauss = ddgauss;
val = 0.0f;
for (j = -this->m_rady; j <= this->m_rady; j++) {
@@ -103,8 +103,9 @@ void GaussianBokehBlurOperation::updateGauss()
}
if (val != 0.0f) {
val = 1.0f / val;
- for (j = n - 1; j >= 0; j--)
+ for (j = n - 1; j >= 0; j--) {
ddgauss[j] *= val;
+ }
}
else ddgauss[4] = 1.0f;
@@ -158,7 +159,7 @@ void GaussianBokehBlurOperation::executePixel(float output[4], int x, int y, voi
void GaussianBokehBlurOperation::deinitExecution()
{
BlurBaseOperation::deinitExecution();
- delete [] this->m_gausstab;
+ MEM_freeN(this->m_gausstab);
this->m_gausstab = NULL;
deinitMutex();
@@ -258,8 +259,9 @@ void GaussianBlurReferenceOperation::updateGauss()
int i;
int x = MAX2(m_radx, m_rady);
this->m_maintabs = (float **)MEM_mallocN(x * sizeof(float *), "gauss array");
- for (i = 0; i < x; i++)
+ for (i = 0; i < x; i++) {
m_maintabs[i] = make_gausstab(i + 1);
+ }
}
void GaussianBlurReferenceOperation::executePixel(float output[4], int x, int y, void *data)
@@ -326,8 +328,9 @@ void GaussianBlurReferenceOperation::deinitExecution()
{
int x, i;
x = MAX2(m_radx, m_rady);
- for (i = 0; i < x; i++)
- delete []m_maintabs[i];
+ for (i = 0; i < x; i++) {
+ MEM_freeN(m_maintabs[i]);
+ }
MEM_freeN(m_maintabs);
BlurBaseOperation::deinitExecution();
}
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
index 01c85738822..984119b926a 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
@@ -22,6 +22,7 @@
#include "COM_GaussianXBlurOperation.h"
#include "BLI_math.h"
+#include "MEM_guardedalloc.h"
extern "C" {
#include "RE_pipeline.h"
@@ -107,7 +108,7 @@ void GaussianXBlurOperation::executePixel(float output[4], int x, int y, void *d
void GaussianXBlurOperation::deinitExecution()
{
BlurBaseOperation::deinitExecution();
- delete [] this->m_gausstab;
+ MEM_freeN(this->m_gausstab);
this->m_gausstab = NULL;
deinitMutex();
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
index 298b4660c6a..192bc29e1ae 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
@@ -22,6 +22,7 @@
#include "COM_GaussianYBlurOperation.h"
#include "BLI_math.h"
+#include "MEM_guardedalloc.h"
extern "C" {
#include "RE_pipeline.h"
@@ -108,7 +109,7 @@ void GaussianYBlurOperation::executePixel(float output[4], int x, int y, void *d
void GaussianYBlurOperation::deinitExecution()
{
BlurBaseOperation::deinitExecution();
- delete [] this->m_gausstab;
+ MEM_freeN(this->m_gausstab);
this->m_gausstab = NULL;
deinitMutex();
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp
index 9ce682ffe49..bfc0ecd1c00 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.cpp
+++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp
@@ -121,7 +121,7 @@ void InpaintSimpleOperation::calc_manhatten_distance()
{
int width = this->getWidth();
int height = this->getHeight();
- short *m = this->m_manhatten_distance = new short[width * height];
+ short *m = this->m_manhatten_distance = (short *)MEM_mallocN(sizeof(short) * width * height, __func__);
int *offsets;
offsets = (int *)MEM_callocN(sizeof(int) * (width + height + 1), "InpaintSimpleOperation offsets");
@@ -163,7 +163,7 @@ void InpaintSimpleOperation::calc_manhatten_distance()
}
this->m_area_size = offsets[width + height];
- this->m_pixelorder = new int[this->m_area_size];
+ this->m_pixelorder = (int *)MEM_mallocN(sizeof(int) * this->m_area_size, __func__);
for (int i = 0; i < width * height; i++) {
if (m[i] > 0) {
@@ -224,9 +224,7 @@ void *InpaintSimpleOperation::initializeTileData(rcti *rect)
lockMutex();
if (!this->m_cached_buffer_ready) {
MemoryBuffer *buf = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect);
-
- this->m_cached_buffer = new float[this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS];
- memcpy(this->m_cached_buffer, buf->getBuffer(), this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float));
+ this->m_cached_buffer = (float *)MEM_dupallocN(buf->getBuffer());
this->calc_manhatten_distance();
@@ -255,17 +253,17 @@ void InpaintSimpleOperation::deinitExecution()
this->m_inputImageProgram = NULL;
this->deinitMutex();
if (this->m_cached_buffer) {
- delete [] this->m_cached_buffer;
+ MEM_freeN(this->m_cached_buffer);
this->m_cached_buffer = NULL;
}
if (this->m_pixelorder) {
- delete [] this->m_pixelorder;
+ MEM_freeN(this->m_pixelorder);
this->m_pixelorder = NULL;
}
if (this->m_manhatten_distance) {
- delete [] this->m_manhatten_distance;
+ MEM_freeN(this->m_manhatten_distance);
this->m_manhatten_distance = NULL;
}
this->m_cached_buffer_ready = false;
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
index 00723d92a84..7e62de7b9f1 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
@@ -25,6 +25,8 @@
#include "COM_NodeOperation.h"
#include "DNA_movieclip_types.h"
+#include "MEM_guardedalloc.h"
+
extern "C" {
#include "BKE_tracking.h"
#include "PIL_time.h"
@@ -62,22 +64,19 @@ public:
this->m_calibration_width = calibration_width;
this->m_calibration_height = calibration_height;
this->m_inverted = inverted;
- this->m_bufferCalculated = new int[this->m_width * this->m_height];
- this->m_buffer = new float[this->m_width * this->m_height * 2];
- for (int i = 0; i < this->m_width * this->m_height; i++) {
- this->m_bufferCalculated[i] = 0;
- }
+ this->m_bufferCalculated = (int *)MEM_callocN(sizeof(int) * this->m_width * this->m_height, __func__);
+ this->m_buffer = (float *)MEM_mallocN(sizeof(float) * this->m_width * this->m_height * 2, __func__);
this->updateLastUsage();
}
~DistortionCache() {
if (this->m_buffer) {
- delete[] this->m_buffer;
+ MEM_freeN(this->m_buffer);
this->m_buffer = NULL;
}
if (this->m_bufferCalculated) {
- delete[] this->m_bufferCalculated;
+ MEM_freeN(this->m_bufferCalculated);
this->m_bufferCalculated = NULL;
}
}
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
index ebf3b772b3b..08ef1249a6a 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -23,6 +23,8 @@
#include "COM_VectorBlurOperation.h"
#include "BLI_math.h"
+#include "MEM_guardedalloc.h"
+
// use the implementation of blender internal renderer to calculate the vector blur.
extern "C" {
#include "RE_pipeline.h"
@@ -66,7 +68,7 @@ void VectorBlurOperation::deinitExecution()
this->m_inputSpeedProgram = NULL;
this->m_inputZProgram = NULL;
if (this->m_cachedInstance) {
- delete [] this->m_cachedInstance;
+ MEM_freeN(this->m_cachedInstance);
this->m_cachedInstance = NULL;
}
}
@@ -81,8 +83,7 @@ void *VectorBlurOperation::initializeTileData(rcti *rect)
MemoryBuffer *tile = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect);
MemoryBuffer *speed = (MemoryBuffer *)this->m_inputSpeedProgram->initializeTileData(rect);
MemoryBuffer *z = (MemoryBuffer *)this->m_inputZProgram->initializeTileData(rect);
- float *data = new float[this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS];
- memcpy(data, tile->getBuffer(), this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float));
+ float *data = (float *)MEM_dupallocN(tile->getBuffer());
this->generateVectorBlur(data, tile, speed, z);
this->m_cachedInstance = data;
}
@@ -115,6 +116,6 @@ void VectorBlurOperation::generateVectorBlur(float *data, MemoryBuffer *inputIma
blurdata.curved = this->m_settings->curved;
blurdata.fac = this->m_settings->fac;
RE_zbuf_accumulate_vecblur(&blurdata, this->getWidth(), this->getHeight(), data, inputImage->getBuffer(), inputSpeed->getBuffer(), zbuf);
- delete [] zbuf;
+ MEM_freeN((void *)zbuf);
return;
}