diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-31 20:37:47 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-31 20:37:47 +0400 |
commit | 4473b846fbaf9c92e76f653ec28a5255db446d1a (patch) | |
tree | 58913444ea3c204a261cdf50c7b31ad24bc41639 /source/blender/blenkernel/intern | |
parent | 4c02549d5d90c698946c6beb9df344c05e453158 (diff) |
multi-threaded sequencer buffer calculation for masks.
Diffstat (limited to 'source/blender/blenkernel/intern')
-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); } } } |