fix [#32374] Curve compositor UI drawing glitch
authorCampbell Barton <ideasman42@gmail.com>
Tue, 21 Aug 2012 15:14:29 +0000 (15:14 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 21 Aug 2012 15:14:29 +0000 (15:14 +0000)
copy the curve for the compositor.

source/blender/blenkernel/intern/colortools.c
source/blender/compositor/nodes/COM_TimeNode.cpp
source/blender/compositor/operations/COM_ColorCurveOperation.cpp
source/blender/compositor/operations/COM_CurveBaseOperation.cpp
source/blender/compositor/operations/COM_CurveBaseOperation.h
source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
source/blender/compositor/operations/COM_VectorCurveOperation.cpp
source/blender/editors/interface/interface_draw.c

index 79cd97ed25c18608c5ab2ce3362977d2fded498a..85d28f680347ae871431126aca61624e3c5ad430 100644 (file)
@@ -150,7 +150,7 @@ void curvemapping_set_black_white_ex(const float black[3], const float white[3],
        int a;
 
        for (a = 0; a < 3; a++) {
-               const float delta = MAX2(white[a] - black[a], 1e-5f);
+               const float delta = maxf(white[a] - black[a], 1e-5f);
                r_bwmul[a] = 1.0f / delta;
        }
 }
index 82c8deafd9de03adf535a2ae037962f1b5539638..00ca797bd9bfb9b8821cf195131f6002d1592f05 100644 (file)
@@ -33,8 +33,6 @@ TimeNode::TimeNode(bNode *editorNode) : Node(editorNode)
        /* pass */
 }
 
-////curvemapping_initialize(&hcmd->curve_mapping);
-
 void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
 {
        SetValueOperation *operation = new SetValueOperation();
index 81205514040853869e585150121ace85760e69da..2f13a90c07248c0fe2a53f1cba5c35d617cc0ba8 100644 (file)
@@ -98,11 +98,11 @@ void ColorCurveOperation::executePixel(float output[4], float x, float y, PixelS
 
 void ColorCurveOperation::deinitExecution()
 {
+       CurveBaseOperation::deinitExecution();
        this->m_inputFacProgram = NULL;
        this->m_inputImageProgram = NULL;
        this->m_inputBlackProgram = NULL;
        this->m_inputWhiteProgram = NULL;
-       curvemapping_premultiply(this->m_curveMapping, 1);
 }
 
 
@@ -154,7 +154,7 @@ void ConstantLevelColorCurveOperation::executePixel(float output[4], float x, fl
 
 void ConstantLevelColorCurveOperation::deinitExecution()
 {
+       CurveBaseOperation::deinitExecution();
        this->m_inputFacProgram = NULL;
        this->m_inputImageProgram = NULL;
-       curvemapping_premultiply(this->m_curveMapping, 1);
 }
index 48d2bcd0ef9211d56da76c5ff35f273e20323672..36c4985988011ded103f47ecca8e53169f5aafcc 100644 (file)
@@ -38,3 +38,17 @@ void CurveBaseOperation::initExecution()
 {
        curvemapping_initialize(this->m_curveMapping);
 }
+void CurveBaseOperation::deinitExecution()
+{
+       curvemapping_free(this->m_curveMapping);
+       this->m_curveMapping = NULL;
+}
+
+void CurveBaseOperation::setCurveMapping(CurveMapping *mapping)
+{
+       /* duplicate the curve to avoid glitches while drawing, see bug [#32374] */
+       if (this->m_curveMapping) {
+               curvemapping_free(this->m_curveMapping);
+       }
+       this->m_curveMapping = curvemapping_copy(mapping);
+}
index 1636c13a571a52b5773bb1a3aea30a29e6352472..6bfce26f532f4107882a7f6bc8bd8608c8890dc5 100644 (file)
@@ -38,7 +38,8 @@ public:
         * Initialize the execution
         */
        void initExecution();
+       void deinitExecution();
        
-       void setCurveMapping(CurveMapping *mapping) { this->m_curveMapping = mapping; }
+       void setCurveMapping(CurveMapping *mapping);
 };
 #endif
index 57d43f67c9b13cfb7a43f3f20abb4173b781825d..8f58942fbe2c0f3b3307ee307366fdb78b588d8a 100644 (file)
@@ -74,5 +74,6 @@ void HueSaturationValueCorrectOperation::executePixel(float output[4], float x,
 
 void HueSaturationValueCorrectOperation::deinitExecution()
 {
+       CurveBaseOperation::deinitExecution();
        this->m_inputProgram = NULL;
 }
index d0a077fed61faacbae523540de0d9b710f80e9b3..6450b0716a38f0e12248824132b1bef66a4f5431 100644 (file)
@@ -56,5 +56,6 @@ void VectorCurveOperation::executePixel(float output[4], float x, float y, Pixel
 
 void VectorCurveOperation::deinitExecution()
 {
+       CurveBaseOperation::deinitExecution();
        this->m_inputProgram = NULL;
 }
index c9a6ba0abe7c12c4c12722731b783071e5fe2072..a8b50f5c76e7d4c0b58e6f8d5277e20128b05e06 100644 (file)
@@ -1355,8 +1355,14 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
        rcti scissor_new;
        int a;
 
-       cumap = (CurveMapping *)(but->editcumap ? but->editcumap : but->poin);
-       cuma = cumap->cm + cumap->cur;
+       if (but->editcumap) {
+               cumap = but->editcumap;
+       }
+       else {
+               cumap = (CurveMapping *)but->poin;
+       }
+
+       cuma = &cumap->cm[cumap->cur];
 
        /* need scissor test, curve can draw outside of boundary */
        glGetIntegerv(GL_VIEWPORT, scissor);
@@ -1485,8 +1491,9 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
        cmp = cuma->table;
        
        /* first point */
-       if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0)
+       if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
                glVertex2f(rect->xmin, rect->ymin + zoomy * (cmp[0].y - offsy));
+       }
        else {
                fx = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]);
                fy = rect->ymin + zoomy * (cmp[0].y - offsy + cuma->ext_in[1]);
@@ -1498,8 +1505,9 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
                glVertex2f(fx, fy);
        }
        /* last point */
-       if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0)
+       if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
                glVertex2f(rect->xmax, rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy));
+       }
        else {
                fx = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]);
                fy = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]);