Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2017-11-26 21:06:26 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2017-11-26 21:06:26 +0300
commit06e64058dd687634b6bf873dbf21c6d3563ed6c9 (patch)
tree67c0da75d9929c59fed4bbaf4f5727919c85afc6 /source/blender/blenkernel/intern/mask_rasterize.c
parent440a49a24cb82fc78edfb6b2539d9ebd0f805a4c (diff)
Removing OMP: BKE's mask_rasterize.c
Once again nothing much to say here, except that whole mask rendering process from VSE is about 25% quicker now. ;)
Diffstat (limited to 'source/blender/blenkernel/intern/mask_rasterize.c')
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c70
1 files changed, 42 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index 13ec970c65c..4c0cc131440 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -80,6 +80,7 @@
#include "BLI_math.h"
#include "BLI_rect.h"
+#include "BLI_task.h"
#include "BLI_listbase.h"
#include "BLI_linklist.h"
@@ -1423,6 +1424,37 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x
return value;
}
+
+typedef struct MaskRasterizeBufferData {
+ MaskRasterHandle *mr_handle;
+ float x_inv, y_inv;
+ float x_px_ofs, y_px_ofs;
+ uint width;
+
+ float *buffer;
+} MaskRasterizeBufferData;
+
+static void maskrasterize_buffer_cb(void *userdata, int y)
+{
+ MaskRasterizeBufferData *data = userdata;
+
+ MaskRasterHandle *mr_handle = data->mr_handle;
+ float *buffer = data->buffer;
+
+ const uint width = data->width;
+ const float x_inv = data->x_inv;
+ const float x_px_ofs = data->x_px_ofs;
+
+ uint i = (uint)y * width;
+ float xy[2];
+ xy[1] = ((float)y * data->y_inv) + data->y_px_ofs;
+ for (uint x = 0; x < width; x++, i++) {
+ xy[0] = ((float)x * x_inv) + x_px_ofs;
+
+ buffer[i] = BKE_maskrasterize_handle_sample(mr_handle, xy);
+ }
+}
+
/**
* \brief Rasterize a buffer from a single mask
*
@@ -1439,33 +1471,15 @@ void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle,
{
const float x_inv = 1.0f / (float)width;
const float y_inv = 1.0f / (float)height;
- const float x_px_ofs = x_inv * 0.5f;
- const float y_px_ofs = y_inv * 0.5f;
-#ifdef _MSC_VER
- int y; /* msvc requires signed for some reason */
-
- /* ignore sign mismatch */
-# pragma warning(push)
-# pragma warning(disable:4018)
-#else
- unsigned int y;
-#endif
-
-#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 * y_inv) + y_px_ofs;
- for (x = 0; x < width; x++, i++) {
- xy[0] = ((float)x * x_inv) + x_px_ofs;
-
- buffer[i] = BKE_maskrasterize_handle_sample(mr_handle, xy);
- }
- }
-
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
+ MaskRasterizeBufferData data = {
+ .mr_handle = mr_handle,
+ .x_inv = x_inv,
+ .y_inv = y_inv,
+ .x_px_ofs = x_inv * 0.5f,
+ .y_px_ofs = y_inv * 0.5f,
+ .width = width,
+ .buffer = buffer
+ };
+ BLI_task_parallel_range(0, (int)height, &data, maskrasterize_buffer_cb, height * width > 10000);
}