Revision: 49422
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49422
Author:   campbellbarton
Date:     2012-07-31 15:45:01 +0000 (Tue, 31 Jul 2012)
Log Message:
-----------
use the same rasterizer as the compositor for the sequencer.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_mask.h
    trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c
    trunk/blender/source/blender/blenkernel/intern/sequencer.c

Modified: trunk/blender/source/blender/blenkernel/BKE_mask.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_mask.h  2012-07-31 15:28:36 UTC 
(rev 49421)
+++ trunk/blender/source/blender/blenkernel/BKE_mask.h  2012-07-31 15:45:01 UTC 
(rev 49422)
@@ -231,6 +231,11 @@
                                                 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__ */

Modified: trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c     
2012-07-31 15:28:36 UTC (rev 49421)
+++ trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c     
2012-07-31 15:45:01 UTC (rev 49422)
@@ -1289,4 +1289,33 @@
        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 */

Modified: trunk/blender/source/blender/blenkernel/intern/sequencer.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sequencer.c  2012-07-31 
15:28:36 UTC (rev 49421)
+++ trunk/blender/source/blender/blenkernel/intern/sequencer.c  2012-07-31 
15:45:01 UTC (rev 49422)
@@ -2072,11 +2072,31 @@
        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);
 
-       maskbuf = MEM_callocN(sizeof(float) * context.rectx * context.recty, 
__func__);
+               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);
+       }
+
+
        if (seq->flag & SEQ_MAKE_FLOAT) {
                /* pixels */
                float *fp_src;
@@ -2084,14 +2104,6 @@
 
                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 @@
 
                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;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to