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:
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp31
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.h5
2 files changed, 31 insertions, 5 deletions
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
index 23a3abe61ee..08f6f8ada4a 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cpp
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -25,7 +25,7 @@
#include "BLI_listbase.h"
#include "BKE_image.h"
-TextureBaseOperation::TextureBaseOperation() : NodeOperation()
+TextureBaseOperation::TextureBaseOperation() : SingleThreadedNodeOperation()
{
this->addInputSocket(COM_DT_VECTOR); //offset
this->addInputSocket(COM_DT_VECTOR); //size
@@ -48,6 +48,7 @@ void TextureBaseOperation::initExecution()
this->m_inputOffset = getInputSocketReader(0);
this->m_inputSize = getInputSocketReader(1);
this->m_pool = BKE_image_pool_new();
+ SingleThreadedNodeOperation::initExecution();
}
void TextureBaseOperation::deinitExecution()
{
@@ -55,6 +56,7 @@ void TextureBaseOperation::deinitExecution()
this->m_inputOffset = NULL;
BKE_image_pool_free(this->m_pool);
this->m_pool = NULL;
+ SingleThreadedNodeOperation::deinitExecution();
}
void TextureBaseOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
@@ -89,8 +91,8 @@ void TextureBaseOperation::executePixel(float output[4], float x, float y, Pixel
int retval;
const float cx = this->getWidth() / 2;
const float cy = this->getHeight() / 2;
- const float u = (cx - x) / this->getWidth() * 2;
- const float v = (cy - y) / this->getHeight() * 2;
+ const float u = (x - cx) / this->getWidth() * 2;
+ const float v = (y - cy) / this->getHeight() * 2;
this->m_inputSize->read(textureSize, x, y, sampler);
this->m_inputOffset->read(textureOffset, x, y, sampler);
@@ -115,3 +117,26 @@ void TextureBaseOperation::executePixel(float output[4], float x, float y, Pixel
output[0] = output[1] = output[2] = output[3];
}
}
+
+MemoryBuffer *TextureBaseOperation::createMemoryBuffer(rcti *rect2)
+{
+ int height = getHeight();
+ int width = getWidth();
+
+ rcti rect;
+ rect.xmin = 0;
+ rect.ymin = 0;
+ rect.xmax = width;
+ rect.ymax = height;
+ MemoryBuffer *result = new MemoryBuffer(NULL, &rect);
+
+ float *data = result->getBuffer();
+
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++, data += 4) {
+ this->executePixel(data, x, y, COM_PS_NEAREST);
+ }
+ }
+
+ return result;
+}
diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h
index 227ad37579a..fc9369099a6 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.h
+++ b/source/blender/compositor/operations/COM_TextureOperation.h
@@ -24,7 +24,7 @@
#ifndef _COM_TextureOperation_h
#define _COM_TextureOperation_h
-#include "COM_NodeOperation.h"
+#include "COM_SingleThreadedNodeOperation.h"
#include "DNA_texture_types.h"
#include "BLI_listbase.h"
extern "C" {
@@ -39,7 +39,7 @@ extern "C" {
*
* @todo: rename to operation.
*/
-class TextureBaseOperation : public NodeOperation {
+class TextureBaseOperation : public SingleThreadedNodeOperation {
private:
Tex *m_texture;
const RenderData *m_rd;
@@ -59,6 +59,7 @@ protected:
*/
TextureBaseOperation();
+ MemoryBuffer *createMemoryBuffer(rcti *rect2);
public:
void executePixel(float output[4], float x, float y, PixelSampler sampler);