diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-21 19:14:29 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-21 19:14:29 +0400 |
commit | 3090ae35afe478435a77be6a9c1be913fe406242 (patch) | |
tree | 598e1d42ff89a6cc99355a1e34e0f053bb3d786e | |
parent | 857a3cd1120c402e22928e7d43612a9fee72a80d (diff) |
fix [#32374] Curve compositor UI drawing glitch
copy the curve for the compositor.
8 files changed, 33 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 79cd97ed25c..85d28f68034 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -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; } } diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp index 82c8deafd9d..00ca797bd9b 100644 --- a/source/blender/compositor/nodes/COM_TimeNode.cpp +++ b/source/blender/compositor/nodes/COM_TimeNode.cpp @@ -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(); diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp index 81205514040..2f13a90c072 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp @@ -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); } diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp index 48d2bcd0ef9..36c49859880 100644 --- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp @@ -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); +} diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.h b/source/blender/compositor/operations/COM_CurveBaseOperation.h index 1636c13a571..6bfce26f532 100644 --- a/source/blender/compositor/operations/COM_CurveBaseOperation.h +++ b/source/blender/compositor/operations/COM_CurveBaseOperation.h @@ -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 diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp index 57d43f67c9b..8f58942fbe2 100644 --- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp @@ -74,5 +74,6 @@ void HueSaturationValueCorrectOperation::executePixel(float output[4], float x, void HueSaturationValueCorrectOperation::deinitExecution() { + CurveBaseOperation::deinitExecution(); this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp index d0a077fed61..6450b0716a3 100644 --- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp @@ -56,5 +56,6 @@ void VectorCurveOperation::executePixel(float output[4], float x, float y, Pixel void VectorCurveOperation::deinitExecution() { + CurveBaseOperation::deinitExecution(); this->m_inputProgram = NULL; } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index c9a6ba0abe7..a8b50f5c76e 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -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]); |