Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #5 from headupinclouds/pr.fix.flow.destruction
Browse files Browse the repository at this point in the history
Pr.fix.flow.destruction
  • Loading branch information
headupinclouds authored Dec 18, 2016
2 parents 8d75fd1 + 6ae6fc4 commit 7f0d180
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
5 changes: 4 additions & 1 deletion ogles_gpgpu/common/proc/flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,10 @@ Flow2Pipeline::Flow2Pipeline(float tau, float strength, bool doGray)
procPasses.push_back(&m_pImpl->nmsProc);
};

Flow2Pipeline::~Flow2Pipeline() {}
Flow2Pipeline::~Flow2Pipeline()
{
procPasses.clear();
}
ProcInterface * Flow2Pipeline::getInputFilter() const { return &m_pImpl->grayProc; }

#if USE_MEDIAN
Expand Down
2 changes: 1 addition & 1 deletion ogles_gpgpu/common/proc/flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class Flow2Pipeline : public MultiPassProc
public:

Flow2Pipeline(float tau = 0.004f, float strength = 1.0f, bool doGray=false);
virtual ~Flow2Pipeline();
~Flow2Pipeline();

virtual float getStrength() const;
virtual ProcInterface * corners(); // corner output
Expand Down
21 changes: 13 additions & 8 deletions ogles_gpgpu/common/proc/grayscale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const GLfloat GrayscaleProc::grayscaleConvVecBGR[3] = {
0.114, 0.587, 0.299
};

const GLfloat GrayscaleProc::grayscaleConvVecNone[3] = {
1.0, 1.0, 1.0
};

const char *GrayscaleProc::fshaderGrayscaleSrc = OG_TO_STR(

#if defined(OGLES_GPGPU_OPENGLES)
Expand Down Expand Up @@ -86,15 +90,16 @@ void GrayscaleProc::setGrayscaleConvType(GrayscaleInputConversionType type) {

const GLfloat *v = NULL;

if (type == GRAYSCALE_INPUT_CONVERSION_RGB) {
v = &grayscaleConvVecRGB[0];
} else if (type == GRAYSCALE_INPUT_CONVERSION_BGR) {
v = &grayscaleConvVecBGR[0];
} else {
OG_LOGERR(getProcName(), "unknown grayscale input conversion type %d", type);
v = &grayscaleConvVecRGB[0]; // set default
switch(type)
{
case GRAYSCALE_INPUT_CONVERSION_RGB: v = &grayscaleConvVecRGB[0]; break;
case GRAYSCALE_INPUT_CONVERSION_BGR: v = &grayscaleConvVecBGR[0]; break;
case GRAYSCALE_INPUT_CONVERSION_NONE: v = &grayscaleConvVecNone[0]; break;
default:
v = &grayscaleConvVecNone[0];
OG_LOGERR(getProcName(), "unknown grayscale input conversion type %d", type);
}

memcpy(grayscaleConvVec, v, sizeof(GLfloat) * 3);

inputConvType = type;
Expand Down
3 changes: 2 additions & 1 deletion ogles_gpgpu/common/proc/grayscale.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef enum {
GRAYSCALE_INPUT_CONVERSION_NONE = -2,
GRAYSCALE_INPUT_CONVERSION_CUSTOM = -1,
GRAYSCALE_INPUT_CONVERSION_RGB = 0,
GRAYSCALE_INPUT_CONVERSION_BGR,
GRAYSCALE_INPUT_CONVERSION_BGR = 1,
} GrayscaleInputConversionType;

/**
Expand Down Expand Up @@ -99,6 +99,7 @@ class GrayscaleProc : public FilterProcBase {
static const char *fshaderGrayscaleSrc; // fragment shader source
static const GLfloat grayscaleConvVecRGB[3]; // weighted channel grayscale conversion for RGB input (default)
static const GLfloat grayscaleConvVecBGR[3]; // weighted channel grayscale conversion for BGR input
static const GLfloat grayscaleConvVecNone[3]; // identity transformation for pass through shader behavior

GLint shParamUInputConvVec; // shader uniform weighted channel grayscale conversion vector

Expand Down

0 comments on commit 7f0d180

Please sign in to comment.