diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-31 20:04:47 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-31 20:04:47 +0400 |
commit | 4c02549d5d90c698946c6beb9df344c05e453158 (patch) | |
tree | 12ad718582db598b16261832e38ff28c875aca0e | |
parent | 2e5181195057b8e8525f2f91c107d6d67e2bdf3a (diff) |
remove references to raskter from compositor and BKE mask.
-rw-r--r-- | source/blender/blenkernel/BKE_mask.h | 21 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 253 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mask_rasterize.c | 4 | ||||
-rw-r--r-- | source/blender/compositor/operations/COM_MaskOperation.cpp | 101 | ||||
-rw-r--r-- | source/blender/compositor/operations/COM_MaskOperation.h | 21 | ||||
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_mask.c | 19 |
6 files changed, 13 insertions, 406 deletions
diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 6c2e2b5d0f3..1148cffffb4 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -185,23 +185,8 @@ void BKE_mask_layer_shape_changed_add(struct MaskLayer *masklay, int index, void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, int count); -/* rasterization */ int BKE_mask_get_duration(struct Mask *mask); -void BKE_mask_rasterize_layers(struct ListBase *masklayers, int width, int height, float *buffer, - const short do_aspect_correct, const short do_mask_aa, - const short do_feather); - -void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer, - const short do_aspect_correct, const short do_mask_aa, - const short do_feather); - -/* initialization for tiling */ -#ifdef __PLX_RASKTER_MT__ -void BKE_mask_init_layers(Mask *mask, struct layer_init_data *mlayer_data, int width, int height, - const short do_aspect_correct); -#endif - #define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f2) & SELECT) #define MASKPOINT_ISSEL_KNOT(p) ( (p)->bezt.f2 & SELECT) #define MASKPOINT_ISSEL_HANDLE_ONLY(p) ( (((p)->bezt.f1 | (p)->bezt.f2) & SELECT) && (((p)->bezt.f2 & SELECT) == 0) ) @@ -216,11 +201,7 @@ void BKE_mask_init_layers(Mask *mask, struct layer_init_data *mlayer_data, int w #define MASK_RESOL_MAX 128 -/* disable to test alternate rasterizer */ -/* #define USE_RASKTER */ - /* mask_rasterize.c */ -#ifndef USE_RASKTER struct MaskRasterHandle; typedef struct MaskRasterHandle MaskRasterHandle; @@ -236,6 +217,4 @@ void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle, const unsigned int width, const unsigned int height, float *buffer); -#endif /* USE_RASKTER */ - #endif /* __BKE_MASK_H__ */ diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index a088a91000c..bb6e4d82bd2 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -56,8 +56,6 @@ #include "BKE_movieclip.h" #include "BKE_utildefines.h" -#include "raskter.h" - static MaskSplinePoint *mask_spline_point_next(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point) { if (point == &points_array[spline->tot_point - 1]) { @@ -2535,256 +2533,7 @@ void BKE_mask_layer_shape_changed_remove(MaskLayer *masklay, int index, int coun } } -/* local functions */ -static void invert_vn_vn(float *array, const int size) -{ - float *arr = array + (size - 1); - int i = size; - while (i--) { - *(arr) = 1.0f - *(arr); - arr--; - } -} - -static void m_invert_vn_vn(float *array, const float f, const int size) -{ - float *arr = array + (size - 1); - int i = size; - while (i--) { - *(arr) = 1.0f - (*(arr) * f); - arr--; - } -} - -static void clamp_vn_vn(float *array, const int size) -{ - float *arr = array + (size - 1); - - int i = size; - while (i--) { - if (*arr < 0.0f) *arr = 0.0f; - else if (*arr > 1.0f) *arr = 1.0f; - arr--; - } -} - int BKE_mask_get_duration(Mask *mask) { - return MAX2(1, mask->efra - mask->sfra); -} - -/* rasterization */ -void BKE_mask_rasterize_layers(ListBase *masklayers, int width, int height, float *buffer, - const short do_aspect_correct, const short do_mask_aa, - const short do_feather) -{ - MaskLayer *masklay; - - /* temp blending buffer */ - const int buffer_size = width * height; - float *buffer_tmp = MEM_mallocN(sizeof(float) * buffer_size, __func__); - - for (masklay = masklayers->first; masklay; masklay = masklay->next) { - MaskSpline *spline; - float alpha; - - if (masklay->restrictflag & MASK_RESTRICT_RENDER) { - continue; - } - - memset(buffer_tmp, 0, sizeof(float) * buffer_size); - - for (spline = masklay->splines.first; spline; spline = spline->next) { - float (*diff_points)[2]; - int tot_diff_point; - - float (*diff_feather_points)[2]; - int tot_diff_feather_points; - - diff_points = BKE_mask_spline_differentiate_with_resolution(spline, width, height, - &tot_diff_point); - - if (tot_diff_point) { - if (do_feather) { - diff_feather_points = - BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, - &tot_diff_feather_points); - } - else { - tot_diff_feather_points = 0; - diff_feather_points = NULL; - } - - if (do_aspect_correct) { - if (width != height) { - float *fp; - float *ffp; - int i; - float asp; - - if (width < height) { - fp = &diff_points[0][0]; - ffp = tot_diff_feather_points ? &diff_feather_points[0][0] : NULL; - asp = (float)width / (float)height; - } - else { - fp = &diff_points[0][1]; - ffp = tot_diff_feather_points ? &diff_feather_points[0][1] : NULL; - asp = (float)height / (float)width; - } - - for (i = 0; i < tot_diff_point; i++, fp += 2) { - (*fp) = (((*fp) - 0.5f) / asp) + 0.5f; - } - - if (tot_diff_feather_points) { - for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) { - (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f; - } - } - } - } - - if (tot_diff_point) { - PLX_raskterize(diff_points, tot_diff_point, - buffer_tmp, width, height,do_mask_aa); - - if (tot_diff_feather_points) { - PLX_raskterize_feather(diff_points, tot_diff_point, - diff_feather_points, tot_diff_feather_points, - buffer_tmp, width, height); - MEM_freeN(diff_feather_points); - } - - MEM_freeN(diff_points); - } - } - } - - /* blend with original */ - if (masklay->blend_flag & MASK_BLENDFLAG_INVERT) { - /* apply alpha multiply before inverting */ - if (masklay->alpha != 1.0f) { - m_invert_vn_vn(buffer_tmp, masklay->alpha, buffer_size); - } - else { - invert_vn_vn(buffer_tmp, buffer_size); - } - - alpha = 1.0f; - } - else { - alpha = masklay->alpha; - } - - switch (masklay->blend) { - case MASK_BLEND_SUBTRACT: - { - if (alpha == 1.0f) { - sub_vn_vn(buffer, buffer_tmp, buffer_size); - } - else { - msub_vn_vn(buffer, buffer_tmp, alpha, buffer_size); - } - break; - } - case MASK_BLEND_ADD: - default: - { - if (alpha == 1.0f) { - add_vn_vn(buffer, buffer_tmp, buffer_size); - } - else { - madd_vn_vn(buffer, buffer_tmp, alpha, buffer_size); - } - break; - } - } - - if (do_mask_aa) { - //PLX_antialias_buffer(buffer,width,height); - } - /* clamp at the end */ - clamp_vn_vn(buffer, buffer_size); - } - MEM_freeN(buffer_tmp); -} - -#ifdef __PLX_RASKTER_MT__ -void BKE_mask_init_layers(Mask *mask, struct layer_init_data *mlayer_data, int width, int height, const short do_aspect_correct) -{ - MaskLayer *masklay; - int numLayers=0; - int currLayer=0; - for (masklay = mask->masklayers->first; masklay; masklay = masklay->next) { - numLayers++; - } - mlayer_data = MEM_mallocN(sizeof(struct layer_init_data) * numLayers, __func__); //size correct? - - - for (masklay = mask->masklayers->first; masklay; masklay = masklay->next) { - MaskSpline *spline; - for (spline = masklay->splines.first; spline; spline = spline->next) { - float (*diff_points)[2]; - int tot_diff_point; - - float (*diff_feather_points)[2]; - int tot_diff_feather_points; - - diff_points = BKE_mask_spline_differentiate_with_resolution(spline, width, height, - &tot_diff_point); - - if (tot_diff_point) { - if (do_feather) { - diff_feather_points = - BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, - &tot_diff_feather_points); - } - else { - tot_diff_feather_points = 0; - diff_feather_points = NULL; - } - - if (do_aspect_correct) { - if (width != height) { - float *fp; - float *ffp; - int i; - float asp; - - if (width < height) { - fp = &diff_points[0][0]; - ffp = tot_diff_feather_points ? &diff_feather_points[0][0] : NULL; - asp = (float)width / (float)height; - } - else { - fp = &diff_points[0][1]; - ffp = tot_diff_feather_points ? &diff_feather_points[0][1] : NULL; - asp = (float)height / (float)width; - } - - for (i = 0; i < tot_diff_point; i++, fp += 2) { - (*fp) = (((*fp) - 0.5f) / asp) + 0.5f; - } - - if (tot_diff_feather_points) { - for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) { - (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f; - } - } - } - } - PLX_init_base_data(mlayer_data[currLayer], diff_points, tot_diff_points, width, height); - currLayer++; - } - } - } -} -#endif - -void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, - const short do_aspect_correct, const short do_mask_aa, - const short do_feather) -{ - BKE_mask_rasterize_layers(&mask->masklayers, width, height, buffer, do_aspect_correct, do_mask_aa, do_feather); + return maxi(1, mask->efra - mask->sfra); } diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index 6811a6fea18..ce04ad31a33 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -45,8 +45,6 @@ #include "BKE_mask.h" -#ifndef USE_RASKTER - /* this is rather and annoying hack, use define to isolate it. * problem is caused by scanfill removing edges on us. */ #define USE_SCANFILL_EDGE_WORKAROUND @@ -1317,5 +1315,3 @@ void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle, } } } - -#endif /* USE_RASKTER */ diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index a3326de0a30..32e79a794bf 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -30,10 +30,8 @@ #include "DNA_scene_types.h" -#ifdef USE_RASKTER - extern "C" { - #include "../../../../intern/raskter/raskter.h" + #include "BKE_mask.h" } MaskOperation::MaskOperation() : NodeOperation() @@ -42,101 +40,6 @@ MaskOperation::MaskOperation() : NodeOperation() this->m_mask = NULL; this->m_maskWidth = 0; this->m_maskHeight = 0; - this->m_framenumber = 0; - this->m_rasterizedMask = NULL; - setComplex(true); -} - -void MaskOperation::initExecution() -{ - initMutex(); - - this->m_rasterizedMask = NULL; - this->m_maskLayers.first = this->m_maskLayers.last = NULL; - - if (this->m_mask) { - BKE_mask_layer_copy_list(&this->m_maskLayers, &this->m_mask->masklayers); - } -} - -void MaskOperation::deinitExecution() -{ - BKE_mask_layer_free_list(&this->m_maskLayers); - - if (this->m_rasterizedMask) { - MEM_freeN(this->m_rasterizedMask); - this->m_rasterizedMask = NULL; - } -} - -void *MaskOperation::initializeTileData(rcti *rect) -{ - if (this->m_rasterizedMask) - return this->m_rasterizedMask; - - if (!this->m_mask) - return NULL; - - lockMutex(); - if (this->m_rasterizedMask == NULL) { - int width = this->getWidth(); - int height = this->getHeight(); - float *buffer; - - buffer = (float *)MEM_callocN(sizeof(float) * width * height, "rasterized mask"); - - BKE_mask_rasterize_layers(&this->m_maskLayers, width, height, buffer, TRUE, - this->m_do_smooth, this->m_do_feather); - - if (this->m_do_smooth) { - PLX_antialias_buffer(buffer, width, height); - } - - this->m_rasterizedMask = buffer; - } - unlockMutex(); - return this->m_rasterizedMask; -} - -void MaskOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) -{ - if (this->m_maskWidth == 0 || this->m_maskHeight == 0) { - NodeOperation::determineResolution(resolution, preferredResolution); - } - else { - unsigned int nr[2]; - - nr[0] = this->m_maskWidth; - nr[1] = this->m_maskHeight; - - NodeOperation::determineResolution(resolution, nr); - - resolution[0] = this->m_maskWidth; - resolution[1] = this->m_maskHeight; - } -} - -void MaskOperation::executePixel(float *color, int x, int y, void *data) -{ - if (!data) { - color[0] = 0.0f; - } - else { - float *buffer = (float *) data; - int index = (y * this->getWidth() + x); - - color[0] = buffer[index]; - } -} - -#else /* mask rasterizer by campbell wip */ - -MaskOperation::MaskOperation() : NodeOperation() -{ - this->addOutputSocket(COM_DT_VALUE); - this->m_mask = NULL; - this->m_maskWidth = 0; - this->m_maskHeight = 0; this->m_maskWidthInv = 0.0f; this->m_maskHeightInv = 0.0f; this->m_frame_shutter = 0.0f; @@ -252,5 +155,3 @@ void MaskOperation::executePixel(float *color, float x, float y, PixelSampler sa color[0] /= this->m_rasterMaskHandleTot; } } - -#endif /* USE_RASKTER */ diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index 77d8e1148c2..859420bd650 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -21,14 +21,9 @@ * Sergey Sharybin */ - #ifndef _COM_MaskOperation_h #define _COM_MaskOperation_h -/* XXX, remove when the USE_RASKTER option is also removed */ -extern "C" { - #include "BKE_mask.h" -} #include "COM_NodeOperation.h" #include "DNA_scene_types.h" @@ -36,10 +31,6 @@ extern "C" { #include "BLI_listbase.h" #include "IMB_imbuf_types.h" -#ifdef __PLX_RASKTER_MT__ -#include "../../../../intern/raskter/raskter.h" -#endif - /** * Class with implementation of mask rasterization */ @@ -60,15 +51,8 @@ protected: bool m_do_smooth; bool m_do_feather; -#ifdef USE_RASKTER - float *m_rasterizedMask; - - ListBase m_maskLayers; - -#else /* USE_RASKTER */ struct MaskRasterHandle *m_rasterMaskHandles[32]; unsigned int m_rasterMaskHandleTot; -#endif /* USE_RASKTER */ /** * Determine the output resolution. The resolution is retrieved from the Renderer @@ -100,12 +84,7 @@ public: void setMotionBlurSamples(int samples) { this->m_rasterMaskHandleTot = max(1, samples); } void setMotionBlurShutter(float shutter) { this->m_frame_shutter = shutter; } -#ifdef USE_RASKTER - void *initializeTileData(rcti *rect); - void executePixel(float *color, int x, int y, void *data); -#else /* USE_RASKTER */ void executePixel(float *color, float x, float y, PixelSampler sampler); -#endif /* USE_RASKTER */ }; #endif diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.c b/source/blender/nodes/composite/nodes/node_composite_mask.c index 5df8bdc0a85..f4cbd1b7f6f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.c +++ b/source/blender/nodes/composite/nodes/node_composite_mask.c @@ -38,8 +38,6 @@ #include "node_composite_util.h" -#include "../../../../intern/raskter/raskter.h" - /* **************** Translate ******************** */ static bNodeSocketTemplate cmp_node_mask_out[] = { @@ -51,6 +49,7 @@ static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack ** { if (node->id) { Mask *mask = (Mask *)node->id; + MaskRasterHandle *mr_handle; CompBuf *stackbuf; RenderData *rd = data; float *res; @@ -70,13 +69,17 @@ static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack ** stackbuf = alloc_compbuf(sx, sy, CB_VAL, TRUE); res = stackbuf->rect; - BKE_mask_rasterize(mask, sx, sy, res, TRUE, - (node->custom1 & CMP_NODEFLAG_MASK_AA) != 0, - (node->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); + /* mask raster begin */ + mr_handle = BKE_maskrasterize_handle_new(); + BKE_maskrasterize_handle_init(mr_handle, mask, + sx, sy, + TRUE, + (node->custom1 & CMP_NODEFLAG_MASK_AA) != 0, + (node->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); + BKE_maskrasterize_buffer(mr_handle, sx, sy, res); + BKE_maskrasterize_handle_free(mr_handle); + /* mask raster end */ - if (node->custom1) { - PLX_antialias_buffer(res,sx,sy); - } /* pass on output and free */ out[0]->data = stackbuf; } |