diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-31 19:45:01 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-31 19:45:01 +0400 |
commit | 2e5181195057b8e8525f2f91c107d6d67e2bdf3a (patch) | |
tree | fd14d8d901247b542f6689bcc230f2111e299de6 /source/blender/blenkernel/intern | |
parent | 8dc3d4e3fdb4e33e52699d615af4a3a65a92c776 (diff) |
use the same rasterizer as the compositor for the sequencer.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/mask_rasterize.c | 29 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 40 |
2 files changed, 51 insertions, 18 deletions
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index da0070f0c09..6811a6fea18 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -1289,4 +1289,33 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x return value; } +/** + * \brief Rasterize a buffer from a single mask + * + * We could get some speedup by inlining #BKE_maskrasterize_handle_sample + * and calcilating each layer then blending buffers, but this function is only + * used by the sequencer - so better have the caller thread. + * + * If we wanted to this function could be threaded with OpenMP easily. + */ +void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle, + const unsigned int width, const unsigned int height, + float *buffer) +{ + unsigned int x; + unsigned int y; + float *fp = buffer; + + float xy[2]; + + for (y = 0; y < height; y++) { + xy[1] = (float)y / (float)height; + for (x = 0; x < width; x++) { + xy[0] = (float)x / (float)width; + + *fp++ = BKE_maskrasterize_handle_sample(mr_handle, xy); + } + } +} + #endif /* USE_RASKTER */ diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 545ec0812ee..2900cb55529 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2072,10 +2072,30 @@ static ImBuf *seq_render_mask_strip( if (!seq->mask) { return NULL; } + else { + Mask *mask_temp; + MaskRasterHandle *mr_handle; + + mask_temp = BKE_mask_copy_nolib(seq->mask); + + BKE_mask_evaluate(mask_temp, seq->mask->sfra + nr, TRUE); + + maskbuf = MEM_mallocN(sizeof(float) * context.rectx * context.recty, __func__); + + mr_handle = BKE_maskrasterize_handle_new(); + + BKE_maskrasterize_handle_init(mr_handle, mask_temp, + context.rectx, context.recty, + TRUE, TRUE, TRUE); - BKE_mask_evaluate(seq->mask, seq->mask->sfra + nr, TRUE); + BKE_mask_free(mask_temp); + MEM_freeN(mask_temp); + + BKE_maskrasterize_buffer(mr_handle, context.rectx, context.recty, maskbuf); + + BKE_maskrasterize_handle_free(mr_handle); + } - maskbuf = MEM_callocN(sizeof(float) * context.rectx * context.recty, __func__); if (seq->flag & SEQ_MAKE_FLOAT) { /* pixels */ @@ -2084,14 +2104,6 @@ static ImBuf *seq_render_mask_strip( ibuf = IMB_allocImBuf(context.rectx, context.recty, 32, IB_rectfloat); - BKE_mask_rasterize(seq->mask, - context.rectx, context.recty, - maskbuf, - TRUE, - FALSE, /*XXX- TODO: make on/off for anti-aliasing */ - TRUE /*XXX- TODO: make on/off for feather */ - ); - fp_src = maskbuf; fp_dst = ibuf->rect_float; i = context.rectx * context.recty; @@ -2110,14 +2122,6 @@ static ImBuf *seq_render_mask_strip( ibuf = IMB_allocImBuf(context.rectx, context.recty, 32, IB_rect); - BKE_mask_rasterize(seq->mask, - context.rectx, context.recty, - maskbuf, - TRUE, - FALSE, /*XXX- TODO: make on/off for anti-aliasing */ - TRUE /*XXX- TODO: make on/off for feather */ - ); - fp_src = maskbuf; ub_dst = (unsigned char *)ibuf->rect; i = context.rectx * context.recty; |