diff options
-rw-r--r-- | source/blender/blenkernel/intern/mask_rasterize.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index ce04ad31a33..ba0d738409c 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -1291,27 +1291,28 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x * \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 + * and calculating 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. + * Since #BKE_maskrasterize_handle_sample is used threaded elsewhere, + * we can simply use openmp here for some speedup. */ 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]; +#pragma omp parallel for private(y) for (y = 0; y < height; y++) { + unsigned int i = y * width; + unsigned int x; + float xy[2]; xy[1] = (float)y / (float)height; - for (x = 0; x < width; x++) { + for (x = 0; x < width; x++, i++) { xy[0] = (float)x / (float)width; - *fp++ = BKE_maskrasterize_handle_sample(mr_handle, xy); + buffer[i] = BKE_maskrasterize_handle_sample(mr_handle, xy); } } } |