use the same rasterizer as the compositor for the sequencer.
This commit is contained in:
@@ -231,6 +231,11 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, str
|
||||
const short do_aspect_correct, const short do_mask_aa,
|
||||
const short do_feather);
|
||||
float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float xy[2]);
|
||||
|
||||
void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle,
|
||||
const unsigned int width, const unsigned int height,
|
||||
float *buffer);
|
||||
|
||||
#endif /* USE_RASKTER */
|
||||
|
||||
#endif /* __BKE_MASK_H__ */
|
||||
|
@@ -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 */
|
||||
|
@@ -2072,10 +2072,30 @@ static ImBuf *seq_render_mask_strip(
|
||||
if (!seq->mask) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
Mask *mask_temp;
|
||||
MaskRasterHandle *mr_handle;
|
||||
|
||||
BKE_mask_evaluate(seq->mask, seq->mask->sfra + nr, TRUE);
|
||||
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_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;
|
||||
|
Reference in New Issue
Block a user